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

Side by Side Diff: src/gpu/GrOvalRenderer.cpp

Issue 2223053002: Split distance vector into direction and magnitude components (Closed) Base URL: https://skia.googlesource.com/skia@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 | « src/core/SkNormalBevelSource.cpp ('k') | src/gpu/glsl/GrGLSLProgramBuilder.cpp » ('j') | 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 fragBuilder->codeAppendf("float distanceToEdge = %s.z * (1.0 - d);", v.fsIn()); 132 fragBuilder->codeAppendf("float distanceToEdge = %s.z * (1.0 - d);", v.fsIn());
133 fragBuilder->codeAppendf("float edgeAlpha = clamp(distanceToEdge, 0. 0, 1.0);"); 133 fragBuilder->codeAppendf("float edgeAlpha = clamp(distanceToEdge, 0. 0, 1.0);");
134 if (cgp.fStroke) { 134 if (cgp.fStroke) {
135 fragBuilder->codeAppendf("float innerAlpha = clamp(%s.z * (d - % s.w), 0.0, 1.0);", 135 fragBuilder->codeAppendf("float innerAlpha = clamp(%s.z * (d - % s.w), 0.0, 1.0);",
136 v.fsIn(), v.fsIn()); 136 v.fsIn(), v.fsIn());
137 fragBuilder->codeAppend("edgeAlpha *= innerAlpha;"); 137 fragBuilder->codeAppend("edgeAlpha *= innerAlpha;");
138 } 138 }
139 139
140 if (args.fDistanceVectorName) { 140 if (args.fDistanceVectorName) {
141 fragBuilder->codeAppend ("if (d == 0.0) {"); // if on the center of the circle 141 fragBuilder->codeAppend ("if (d == 0.0) {"); // if on the center of the circle
142 fragBuilder->codeAppendf(" %s = vec2(distanceToEdge, 0.0);", // avoid normalizing 142 fragBuilder->codeAppendf(" %s = vec3(1.0, 0.0, distanceToEdge );", // no normalize
143 args.fDistanceVectorName); 143 args.fDistanceVectorName);
144 fragBuilder->codeAppend ("} else {"); 144 fragBuilder->codeAppend ("} else {");
145 fragBuilder->codeAppendf(" %s = normalize(%s.xy) * distanceTo Edge;", 145 fragBuilder->codeAppendf(" %s = vec3(normalize(%s.xy), distan ceToEdge);",
146 args.fDistanceVectorName, v.fsIn()); 146 args.fDistanceVectorName, v.fsIn());
147 fragBuilder->codeAppend ("}"); 147 fragBuilder->codeAppend ("}");
148 } 148 }
149 149
150 fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCovera ge); 150 fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCovera ge);
151 } 151 }
152 152
153 static void GenKey(const GrGeometryProcessor& gp, 153 static void GenKey(const GrGeometryProcessor& gp,
154 const GrGLSLCaps&, 154 const GrGLSLCaps&,
155 GrProcessorKeyBuilder* b) { 155 GrProcessorKeyBuilder* b) {
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 } 1706 }
1707 1707
1708 DRAW_BATCH_TEST_DEFINE(RRectBatch) { 1708 DRAW_BATCH_TEST_DEFINE(RRectBatch) {
1709 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); 1709 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random);
1710 GrColor color = GrRandomColor(random); 1710 GrColor color = GrRandomColor(random);
1711 const SkRRect& rrect = GrTest::TestRRectSimple(random); 1711 const SkRRect& rrect = GrTest::TestRRectSimple(random);
1712 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom)); 1712 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom));
1713 } 1713 }
1714 1714
1715 #endif 1715 #endif
OLDNEW
« no previous file with comments | « src/core/SkNormalBevelSource.cpp ('k') | src/gpu/glsl/GrGLSLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698