Chromium Code Reviews| Index: src/gpu/SkGr.cpp |
| diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp |
| index a86ee6031701cd1d6ec863251b271127eef775bd..26a14ec169a3e38757ac82b34d60730f8b33a039 100644 |
| --- a/src/gpu/SkGr.cpp |
| +++ b/src/gpu/SkGr.cpp |
| @@ -6,15 +6,18 @@ |
| */ |
| #include "SkGr.h" |
| + |
| +#include "GrDrawTargetCaps.h" |
| +#include "GrGpu.h" |
| +#include "GrXferProcessor.h" |
| #include "SkColorFilter.h" |
| #include "SkConfig8888.h" |
| #include "SkData.h" |
| #include "SkMessageBus.h" |
| #include "SkPixelRef.h" |
| #include "SkTextureCompressor.h" |
| -#include "GrGpu.h" |
| #include "effects/GrDitherEffect.h" |
| -#include "GrDrawTargetCaps.h" |
| +#include "effects/GrPorterDuffXferProcessor.h" |
| #include "effects/GrYUVtoRGBEffect.h" |
| #ifndef SK_IGNORE_ETC1_SUPPORT |
| @@ -467,21 +470,34 @@ void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor |
| SkXfermode::Coeff dm; |
| SkXfermode* mode = skPaint.getXfermode(); |
| - GrFragmentProcessor* xferProcessor = NULL; |
| - if (SkXfermode::asFragmentProcessorOrCoeff(mode, &xferProcessor, &sm, &dm)) { |
| - if (xferProcessor) { |
| - grPaint->addColorProcessor(xferProcessor)->unref(); |
| + GrFragmentProcessor* fragmentProcessor = NULL; |
| + GrXPFactory* xpFactory = NULL; |
| + if (SkXfermode::asFragmentProcessorOrXPFactoryOrCoeff(mode, &fragmentProcessor, &xpFactory, |
| + &sm, &dm)) { |
| + if (xpFactory) { |
| sm = SkXfermode::kOne_Coeff; |
| dm = SkXfermode::kZero_Coeff; |
| + } else if (fragmentProcessor) { |
| + grPaint->addColorProcessor(fragmentProcessor)->unref(); |
| + xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kOne_Coeff, |
| + SkXfermode::kZero_Coeff); |
| + sm = SkXfermode::kOne_Coeff; |
| + dm = SkXfermode::kZero_Coeff; |
| + } else { |
| + // Xfer mode can be implemented as porter-duff coeffs |
| + xpFactory = GrPorterDuffXPFactory::Create(sm, dm); |
|
bsalomon
2014/11/26 21:02:45
why not make the asThisThatOrTheOther function do
egdaniel
2014/12/01 18:18:24
Moved to awseomeOrGreatOrPerfectorAmazingFunctionN
|
| } |
| } else { |
| - //SkDEBUGCODE(SkDebugf("Unsupported xfer mode.\n");) |
| // Fall back to src-over |
| + xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kOne_Coeff, |
| + SkXfermode::kISA_Coeff); |
| sm = SkXfermode::kOne_Coeff; |
| dm = SkXfermode::kISA_Coeff; |
| } |
| + SkASSERT(xpFactory); |
| + grPaint->setXPFactory(xpFactory)->unref(); |
| grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm)); |
| - |
| + |
| //set the color of the paint to the one of the parameter |
| grPaint->setColor(paintColor); |