aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-08-03 14:23:03 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-03 14:23:03 -0700
commitc41f4d60559b0891353f8028d521b52e7a36d5da (patch)
tree45952bd6e042d90b89b18a38c3e24e1d546d94a9 /src/gpu
parent799a3646f9e1331bbfd82c5a34d1b47e279420f9 (diff)
Fix elliptical rrect clip shaders for large radii on devices with mediump
BUG=chromium:426217 Review URL: https://codereview.chromium.org/1256353004
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/effects/GrOvalEffect.cpp3
-rw-r--r--src/gpu/effects/GrRRectEffect.cpp6
2 files changed, 6 insertions, 3 deletions
diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp
index 729e8a599c..3b373cbda7 100644
--- a/src/gpu/effects/GrOvalEffect.cpp
+++ b/src/gpu/effects/GrOvalEffect.cpp
@@ -285,8 +285,9 @@ void GLEllipseEffect::emitCode(EmitArgs& args) {
const EllipseEffect& ee = args.fFp.cast<EllipseEffect>();
const char *ellipseName;
// The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2)
+ // The last two terms can underflow on mediump, so we use highp.
fEllipseUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision,
+ kVec4f_GrSLType, kHigh_GrSLPrecision,
"ellipse",
&ellipseName);
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index c95690ff19..dcc8944a23 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -509,16 +509,18 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
// fragments near the other three edges will get the correct AA. Fragments in the interior of
// the rrect will have a (0,0) vector at all four corners. So long as the radii > 0.5 they will
// correctly produce an alpha value of 1 at all four corners. We take the min of all the alphas.
+ //
// The code below is a simplified version of the above that performs maxs on the vector
// components before computing distances and alpha values so that only one distance computation
// need be computed to determine the min alpha.
fsBuilder->codeAppendf("\t\tvec2 dxy0 = %s.xy - %s.xy;\n", rectName, fragmentPos);
fsBuilder->codeAppendf("\t\tvec2 dxy1 = %s.xy - %s.zw;\n", fragmentPos, rectName);
+ // The uniforms with the inv squared radii are highp to prevent underflow.
switch (erre.getRRect().getType()) {
case SkRRect::kSimple_Type: {
const char *invRadiiXYSqdName;
fInvRadiiSqdUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType, kDefault_GrSLPrecision,
+ kVec2f_GrSLType, kHigh_GrSLPrecision,
"invRadiiXY",
&invRadiiXYSqdName);
fsBuilder->codeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n");
@@ -529,7 +531,7 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
case SkRRect::kNinePatch_Type: {
const char *invRadiiLTRBSqdName;
fInvRadiiSqdUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision,
+ kVec4f_GrSLType, kHigh_GrSLPrecision,
"invRadiiLTRB",
&invRadiiLTRBSqdName);
fsBuilder->codeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n");