| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrConvexPolyEffect.h" | 8 #include "GrConvexPolyEffect.h" |
| 9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
| 10 #include "SkPath.h" | 10 #include "SkPath.h" |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 cpe.getEdgeCount(), | 223 cpe.getEdgeCount(), |
| 224 &edgeArrayName); | 224 &edgeArrayName); |
| 225 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 225 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
| 226 fsBuilder->codeAppend("\t\tfloat alpha = 1.0;\n"); | 226 fsBuilder->codeAppend("\t\tfloat alpha = 1.0;\n"); |
| 227 fsBuilder->codeAppend("\t\tfloat edge;\n"); | 227 fsBuilder->codeAppend("\t\tfloat edge;\n"); |
| 228 const char* fragmentPos = fsBuilder->fragmentPosition(); | 228 const char* fragmentPos = fsBuilder->fragmentPosition(); |
| 229 for (int i = 0; i < cpe.getEdgeCount(); ++i) { | 229 for (int i = 0; i < cpe.getEdgeCount(); ++i) { |
| 230 // Add a device space "nudge" of 0.05f, 0.05f to match raster's rounding
behavior for | 230 // Add a device space "nudge" of 0.05f, 0.05f to match raster's rounding
behavior for |
| 231 // BW clipping/drawing. Since we are "nudging" fragment positions we hav
e to go in | 231 // BW clipping/drawing. Since we are "nudging" fragment positions we hav
e to go in |
| 232 // the opposite direction. | 232 // the opposite direction. |
| 233 fsBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(%s.x - 0.05, %s.y -
0.05, 1));\n", | 233 fsBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(%s.x - 0.05f, %s.y -
0.05f, 1));\n", |
| 234 edgeArrayName, i, fragmentPos, fragmentPos); | 234 edgeArrayName, i, fragmentPos, fragmentPos); |
| 235 if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) { | 235 if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) { |
| 236 fsBuilder->codeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n"); | 236 fsBuilder->codeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n"); |
| 237 } else { | 237 } else { |
| 238 fsBuilder->codeAppend("\t\tedge = edge >= 0.5 ? 1.0 : 0.0;\n"); | 238 fsBuilder->codeAppend("\t\tedge = edge >= 0.5 ? 1.0 : 0.0;\n"); |
| 239 } | 239 } |
| 240 fsBuilder->codeAppend("\t\talpha *= edge;\n"); | 240 fsBuilder->codeAppend("\t\talpha *= edge;\n"); |
| 241 } | 241 } |
| 242 | 242 |
| 243 // Woe is me. See skbug.com/2149. | 243 // Woe is me. See skbug.com/2149. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 } | 381 } |
| 382 | 382 |
| 383 GrFragmentProcessor* fp; | 383 GrFragmentProcessor* fp; |
| 384 do { | 384 do { |
| 385 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 385 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
| 386 random->nextULessThan(kGrProcessorEdgeTy
peCnt)); | 386 random->nextULessThan(kGrProcessorEdgeTy
peCnt)); |
| 387 fp = GrConvexPolyEffect::Create(edgeType, count, edges); | 387 fp = GrConvexPolyEffect::Create(edgeType, count, edges); |
| 388 } while (NULL == fp); | 388 } while (NULL == fp); |
| 389 return fp; | 389 return fp; |
| 390 } | 390 } |
| OLD | NEW |