From adf4edc4d6ddf781b2910f457ba360d99072604a Mon Sep 17 00:00:00 2001 From: bsalomon Date: Thu, 18 Aug 2016 08:32:27 -0700 Subject: [PATCH] Don't emit dead code in circle shader when not using distance vectors. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2254103004 Review-Url: https://codereview.chromium.org/2254103004 --- src/gpu/GrOvalRenderer.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index 622df15..079c261 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 ("}"); } -- 2.7.4