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 "SkPathPriv.h" | 10 #include "SkPathPriv.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 fsBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(%s.x, %s.y, 1));\n", | 205 fsBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(%s.x, %s.y, 1));\n", |
206 edgeArrayName, i, fragmentPos, fragmentPos); | 206 edgeArrayName, i, fragmentPos, fragmentPos); |
207 if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) { | 207 if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) { |
208 fsBuilder->codeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n"); | 208 fsBuilder->codeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n"); |
209 } else { | 209 } else { |
210 fsBuilder->codeAppend("\t\tedge = edge >= 0.5 ? 1.0 : 0.0;\n"); | 210 fsBuilder->codeAppend("\t\tedge = edge >= 0.5 ? 1.0 : 0.0;\n"); |
211 } | 211 } |
212 fsBuilder->codeAppend("\t\talpha *= edge;\n"); | 212 fsBuilder->codeAppend("\t\talpha *= edge;\n"); |
213 } | 213 } |
214 | 214 |
215 // Woe is me. See https://bug.skia.org/2149 . | |
216 if (kTegra2_GrGLRenderer == args.fBuilder->ctxInfo().renderer()) { | |
217 fsBuilder->codeAppend("\t\tif (-1.0 == alpha) {\n\t\t\tdiscard;\n\t\t}\n
"); | |
218 } | |
219 | |
220 if (GrProcessorEdgeTypeIsInverseFill(cpe.getEdgeType())) { | 215 if (GrProcessorEdgeTypeIsInverseFill(cpe.getEdgeType())) { |
221 fsBuilder->codeAppend("\talpha = 1.0 - alpha;\n"); | 216 fsBuilder->codeAppend("\talpha = 1.0 - alpha;\n"); |
222 } | 217 } |
223 fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutputColor, | 218 fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutputColor, |
224 (GrGLSLExpr4(args.fInputColor) * GrGLSLExpr1("alpha")
).c_str()); | 219 (GrGLSLExpr4(args.fInputColor) * GrGLSLExpr1("alpha")
).c_str()); |
225 } | 220 } |
226 | 221 |
227 void GrGLConvexPolyEffect::onSetData(const GrGLSLProgramDataManager& pdman, | 222 void GrGLConvexPolyEffect::onSetData(const GrGLSLProgramDataManager& pdman, |
228 const GrProcessor& effect) { | 223 const GrProcessor& effect) { |
229 const GrConvexPolyEffect& cpe = effect.cast<GrConvexPolyEffect>(); | 224 const GrConvexPolyEffect& cpe = effect.cast<GrConvexPolyEffect>(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 } | 346 } |
352 | 347 |
353 GrFragmentProcessor* fp; | 348 GrFragmentProcessor* fp; |
354 do { | 349 do { |
355 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 350 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
356 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); | 351 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); |
357 fp = GrConvexPolyEffect::Create(edgeType, count, edges); | 352 fp = GrConvexPolyEffect::Create(edgeType, count, edges); |
358 } while (nullptr == fp); | 353 } while (nullptr == fp); |
359 return fp; | 354 return fp; |
360 } | 355 } |
OLD | NEW |