Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Unified Diff: src/effects/SkRRectsGaussianEdgeShader.cpp

Issue 2345203003: Improve join between the two RRects in SkRRectsGaussianEdgeShader (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkRRectsGaussianEdgeShader.cpp
diff --git a/src/effects/SkRRectsGaussianEdgeShader.cpp b/src/effects/SkRRectsGaussianEdgeShader.cpp
index 365a5afcc60fc7f955c4c01838074ef5e2e74e2b..25c57cdcd9a93c7dcd19ce166870d9c8bf06b008 100644
--- a/src/effects/SkRRectsGaussianEdgeShader.cpp
+++ b/src/effects/SkRRectsGaussianEdgeShader.cpp
@@ -126,7 +126,8 @@ public:
"1.0 - clamp((%s.%c - abs(delta.y))/%s, 0.0, 1.0));",
sizesName, indices[0], radName,
sizesName, indices[1], radName);
- fragBuilder->codeAppendf("%s = 1.0 - length(rectDist);", outputName);
+ fragBuilder->codeAppendf("%s = clamp(1.0 - length(rectDist), 0.0, 1.0);",
+ outputName);
break;
case kSimpleCircular_Mode:
// For the circular round rect we first compute the distance
@@ -202,11 +203,10 @@ public:
radUniName, "secondDist", "zw");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppendf("float dist = %s * firstDist * secondDist;", radUniName);
+ fragBuilder->codeAppend("vec2 distVec = vec2(1.0 - firstDist, 1.0 - secondDist);");
// Finally use the distance to apply the Gaussian edge
- // TODO: we undo the multiply by the radius here - we should just skip both
- fragBuilder->codeAppendf("float factor = 1.0 - clamp(dist/%s, 0.0, 1.0);", radUniName);
+ fragBuilder->codeAppend("float factor = clamp(length(distVec), 0.0, 1.0);");
fragBuilder->codeAppend("factor = exp(-factor * factor * 4.0) - 0.018;");
fragBuilder->codeAppendf("%s = factor*%s;",
args.fOutputColor, args.fInputColor);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698