| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |