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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrOvalRenderer.h" 8 #include "GrOvalRenderer.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 args.fTransformsOut); 138 args.fTransformsOut);
139 139
140 fragBuilder->codeAppendf("float d = length(%s.xy);", v.fsIn()); 140 fragBuilder->codeAppendf("float d = length(%s.xy);", v.fsIn());
141 fragBuilder->codeAppendf("float distanceToOuterEdge = %s.z * (1.0 - d);", v.fsIn()); 141 fragBuilder->codeAppendf("float distanceToOuterEdge = %s.z * (1.0 - d);", v.fsIn());
142 fragBuilder->codeAppendf("float edgeAlpha = clamp(distanceToOuterEdg e, 0.0, 1.0);"); 142 fragBuilder->codeAppendf("float edgeAlpha = clamp(distanceToOuterEdg e, 0.0, 1.0);");
143 if (cgp.fStroke) { 143 if (cgp.fStroke) {
144 fragBuilder->codeAppendf("float distanceToInnerEdge = %s.z * (d - %s.w);", 144 fragBuilder->codeAppendf("float distanceToInnerEdge = %s.z * (d - %s.w);",
145 v.fsIn(), v.fsIn()); 145 v.fsIn(), v.fsIn());
146 fragBuilder->codeAppend("float innerAlpha = clamp(distanceToInne rEdge, 0.0, 1.0);"); 146 fragBuilder->codeAppend("float innerAlpha = clamp(distanceToInne rEdge, 0.0, 1.0);");
147 fragBuilder->codeAppend("edgeAlpha *= innerAlpha;"); 147 fragBuilder->codeAppend("edgeAlpha *= innerAlpha;");
148 } else {
149 fragBuilder->codeAppend("float distanceToInnerEdge = 0.0;");
150 } 148 }
151 149
152 if (args.fDistanceVectorName) { 150 if (args.fDistanceVectorName) {
151 const char* innerEdgeDistance = cgp.fStroke ? "distanceToInnerEd ge" : "0.0";
153 fragBuilder->codeAppend ("if (d == 0.0) {"); // if on the center of the circle 152 fragBuilder->codeAppend ("if (d == 0.0) {"); // if on the center of the circle
154 fragBuilder->codeAppendf(" %s = vec4(1.0, 0.0, distanceToOute rEdge, " 153 fragBuilder->codeAppendf(" %s = vec4(1.0, 0.0, distanceToOute rEdge, "
155 "distanceToInnerEdge);", // no normaliz e 154 "%s);", // no normalize
156 args.fDistanceVectorName); 155 args.fDistanceVectorName, innerEdgeDist ance);
157 fragBuilder->codeAppend ("} else {"); 156 fragBuilder->codeAppend ("} else {");
158 fragBuilder->codeAppendf(" %s = vec4(normalize(%s.xy), distan ceToOuterEdge, " 157 fragBuilder->codeAppendf(" %s = vec4(normalize(%s.xy), distan ceToOuterEdge, "
159 "distanceToInnerEdge);", 158 "%s);",
160 args.fDistanceVectorName, v.fsIn()); 159 args.fDistanceVectorName, v.fsIn(), inn erEdgeDistance);
161 fragBuilder->codeAppend ("}"); 160 fragBuilder->codeAppend ("}");
162 } 161 }
163 162
164 fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCovera ge); 163 fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCovera ge);
165 } 164 }
166 165
167 static void GenKey(const GrGeometryProcessor& gp, 166 static void GenKey(const GrGeometryProcessor& gp,
168 const GrGLSLCaps&, 167 const GrGLSLCaps&,
169 GrProcessorKeyBuilder* b) { 168 GrProcessorKeyBuilder* b) {
170 const CircleGeometryProcessor& cgp = gp.cast<CircleGeometryProcessor >(); 169 const CircleGeometryProcessor& cgp = gp.cast<CircleGeometryProcessor >();
(...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 } 1694 }
1696 1695
1697 DRAW_BATCH_TEST_DEFINE(RRectBatch) { 1696 DRAW_BATCH_TEST_DEFINE(RRectBatch) {
1698 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); 1697 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random);
1699 GrColor color = GrRandomColor(random); 1698 GrColor color = GrRandomColor(random);
1700 const SkRRect& rrect = GrTest::TestRRectSimple(random); 1699 const SkRRect& rrect = GrTest::TestRRectSimple(random);
1701 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom)); 1700 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom));
1702 } 1701 }
1703 1702
1704 #endif 1703 #endif
OLDNEW
« 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