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

Unified Diff: src/effects/SkRRectsGaussianEdgeShader.cpp

Issue 2383863002: Fix precision issues in SkRRectsGaussianEdgeShader.cpp (Closed)
Patch Set: Fix typo Created 4 years, 2 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 25c57cdcd9a93c7dcd19ce166870d9c8bf06b008..e7703f964aae649c118cad5a31f30a228a95c623 100644
--- a/src/effects/SkRRectsGaussianEdgeShader.cpp
+++ b/src/effects/SkRRectsGaussianEdgeShader.cpp
@@ -117,7 +117,11 @@ public:
switch (mode) {
case kCircle_Mode:
- fragBuilder->codeAppendf("%s = clamp((%s.%c - length(delta))/%s, 0.0, 1.0);",
+ // When a shadow circle gets large we can have some precision issues if
+ // we do "length(delta)/radius". The scaleDist temporary cuts the
+ // delta vector down a bit before invoking length.
+ fragBuilder->codeAppendf("float scaledDist = length(delta/%s);", radName);
+ fragBuilder->codeAppendf("%s = clamp((%s.%c/%s - scaledDist), 0.0, 1.0);",
outputName, sizesName, indices[0], radName);
break;
case kRect_Mode:
@@ -136,7 +140,7 @@ public:
// distance from the corner and then use the multiplier to mask
// between the two distances.
fragBuilder->codeAppendf("float xDist = clamp((%s.%c - abs(delta.x))/%s,"
- " 0.0, 1.0);",
+ "0.0, 1.0);",
sizesName, indices[0], radName);
fragBuilder->codeAppendf("float yDist = clamp((%s.%c - abs(delta.y))/%s,"
"0.0, 1.0);",
« 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