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 "effects/GrPorterDuffXferProcessor.h" | 8 #include "effects/GrPorterDuffXferProcessor.h" |
9 | 9 |
10 #include "GrBlend.h" | 10 #include "GrBlend.h" |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 fSrcBlend = kOne_GrBlendCoeff; | 323 fSrcBlend = kOne_GrBlendCoeff; |
324 fDstBlend = kZero_GrBlendCoeff; | 324 fDstBlend = kZero_GrBlendCoeff; |
325 return GrXferProcessor::kIgnoreColor_OptFlag | | 325 return GrXferProcessor::kIgnoreColor_OptFlag | |
326 GrXferProcessor::kIgnoreCoverage_OptFlag; | 326 GrXferProcessor::kIgnoreCoverage_OptFlag; |
327 } | 327 } |
328 } | 328 } |
329 } else { | 329 } else { |
330 // check whether coverage can be safely rolled into alpha | 330 // check whether coverage can be safely rolled into alpha |
331 // of if we can skip color computation and just emit coverage | 331 // of if we can skip color computation and just emit coverage |
332 if (can_tweak_alpha_for_coverage(fDstBlend)) { | 332 if (can_tweak_alpha_for_coverage(fDstBlend)) { |
333 return GrXferProcessor::kSetCoverageDrawing_OptFlag; | 333 if (colorPOI.allStagesMultiplyInput()) { |
| 334 return GrXferProcessor::kSetCoverageDrawing_OptFlag | |
| 335 GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag; |
| 336 } else { |
| 337 return GrXferProcessor::kSetCoverageDrawing_OptFlag; |
| 338 |
| 339 } |
334 } | 340 } |
335 if (dstCoeffIsZero) { | 341 if (dstCoeffIsZero) { |
336 if (kZero_GrBlendCoeff == fSrcBlend) { | 342 if (kZero_GrBlendCoeff == fSrcBlend) { |
337 // the source color is not included in the blend | 343 // the source color is not included in the blend |
338 // the dst coeff is effectively zero so blend works out to: | 344 // the dst coeff is effectively zero so blend works out to: |
339 // (c)(0)D + (1-c)D = (1-c)D. | 345 // (c)(0)D + (1-c)D = (1-c)D. |
340 fDstBlend = kISA_GrBlendCoeff; | 346 fDstBlend = kISA_GrBlendCoeff; |
341 return GrXferProcessor::kIgnoreColor_OptFlag | | 347 return GrXferProcessor::kIgnoreColor_OptFlag | |
342 GrXferProcessor::kSetCoverageDrawing_OptFlag; | 348 GrXferProcessor::kSetCoverageDrawing_OptFlag; |
343 } else if (srcAIsOne) { | 349 } else if (srcAIsOne) { |
344 // the dst coeff is effectively zero so blend works out to: | 350 // the dst coeff is effectively zero so blend works out to: |
345 // cS + (c)(0)D + (1-c)D = cS + (1-c)D. | 351 // cS + (c)(0)D + (1-c)D = cS + (1-c)D. |
346 // If Sa is 1 then we can replace Sa with c | 352 // If Sa is 1 then we can replace Sa with c |
347 // and set dst coeff to 1-Sa. | 353 // and set dst coeff to 1-Sa. |
348 fDstBlend = kISA_GrBlendCoeff; | 354 fDstBlend = kISA_GrBlendCoeff; |
349 return GrXferProcessor::kSetCoverageDrawing_OptFlag; | 355 if (colorPOI.allStagesMultiplyInput()) { |
| 356 return GrXferProcessor::kSetCoverageDrawing_OptFlag | |
| 357 GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag; |
| 358 } else { |
| 359 return GrXferProcessor::kSetCoverageDrawing_OptFlag; |
| 360 |
| 361 } |
350 } | 362 } |
351 } else if (dstCoeffIsOne) { | 363 } else if (dstCoeffIsOne) { |
352 // the dst coeff is effectively one so blend works out to: | 364 // the dst coeff is effectively one so blend works out to: |
353 // cS + (c)(1)D + (1-c)D = cS + D. | 365 // cS + (c)(1)D + (1-c)D = cS + D. |
354 fDstBlend = kOne_GrBlendCoeff; | 366 fDstBlend = kOne_GrBlendCoeff; |
| 367 if (colorPOI.allStagesMultiplyInput()) { |
| 368 return GrXferProcessor::kSetCoverageDrawing_OptFlag | |
| 369 GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag; |
| 370 } else { |
| 371 return GrXferProcessor::kSetCoverageDrawing_OptFlag; |
| 372 |
| 373 } |
355 return GrXferProcessor::kSetCoverageDrawing_OptFlag; | 374 return GrXferProcessor::kSetCoverageDrawing_OptFlag; |
356 } | 375 } |
357 } | 376 } |
358 | 377 |
359 return GrXferProcessor::kNone_Opt; | 378 return GrXferProcessor::kNone_Opt; |
360 } | 379 } |
361 | 380 |
362 bool PorterDuffXferProcessor::hasSecondaryOutput() const { | 381 bool PorterDuffXferProcessor::hasSecondaryOutput() const { |
363 return kNone_SecondaryOutputType != fSecondaryOutputType; | 382 return kNone_SecondaryOutputType != fSecondaryOutputType; |
364 } | 383 } |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 } while (GrBlendCoeffRefsSrc(src)); | 623 } while (GrBlendCoeffRefsSrc(src)); |
605 | 624 |
606 GrBlendCoeff dst; | 625 GrBlendCoeff dst; |
607 do { | 626 do { |
608 dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub
licGrBlendCoeff)); | 627 dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub
licGrBlendCoeff)); |
609 } while (GrBlendCoeffRefsDst(dst)); | 628 } while (GrBlendCoeffRefsDst(dst)); |
610 | 629 |
611 return GrPorterDuffXPFactory::Create(src, dst); | 630 return GrPorterDuffXPFactory::Create(src, dst); |
612 } | 631 } |
613 | 632 |
OLD | NEW |