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

Unified Diff: src/gpu/GrOvalRenderer.cpp

Issue 2254103004: Don't emit dead code in circle shader when not using distance vectors. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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/gpu/GrOvalRenderer.cpp
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 622df15d4aa4ff413475414f47575b3d5ae52745..079c261a66e7a6692983b38c01ef91f9d7394525 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -145,19 +145,18 @@ private:
v.fsIn(), v.fsIn());
fragBuilder->codeAppend("float innerAlpha = clamp(distanceToInnerEdge, 0.0, 1.0);");
fragBuilder->codeAppend("edgeAlpha *= innerAlpha;");
- } else {
- fragBuilder->codeAppend("float distanceToInnerEdge = 0.0;");
}
if (args.fDistanceVectorName) {
+ const char* innerEdgeDistance = cgp.fStroke ? "distanceToInnerEdge" : "0.0";
fragBuilder->codeAppend ("if (d == 0.0) {"); // if on the center of the circle
fragBuilder->codeAppendf(" %s = vec4(1.0, 0.0, distanceToOuterEdge, "
- "distanceToInnerEdge);", // no normalize
- args.fDistanceVectorName);
+ "%s);", // no normalize
+ args.fDistanceVectorName, innerEdgeDistance);
fragBuilder->codeAppend ("} else {");
fragBuilder->codeAppendf(" %s = vec4(normalize(%s.xy), distanceToOuterEdge, "
- "distanceToInnerEdge);",
- args.fDistanceVectorName, v.fsIn());
+ "%s);",
+ args.fDistanceVectorName, v.fsIn(), innerEdgeDistance);
fragBuilder->codeAppend ("}");
}
« 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