aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkXfermode.h11
-rw-r--r--src/core/SkXfermode.cpp32
-rw-r--r--src/gpu/SkGr.cpp9
3 files changed, 19 insertions, 33 deletions
diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h
index 9d72cef745..fc9ae21ac4 100644
--- a/include/core/SkXfermode.h
+++ b/include/core/SkXfermode.h
@@ -207,14 +207,11 @@ public:
*/
virtual bool asXPFactory(GrXPFactory** xpf) const;
- /** Returns true if the xfermode can be expressed as an xfer processor factory (xpFactory),
- or a fragment processor. This helper calls the asCoeff(), asXPFactory(),
- and asFragmentProcessor() virtuals. If the xfermode is NULL, it is treated as kSrcOver_Mode.
- It is legal to call this with all params NULL to simply test the return value.
- fp and xpf must both be NULL or all non-NULL.
+ /** Returns true if the xfermode can be expressed as an xfer processor factory (xpFactory).
+ This helper calls the asXPFactory() virtual. If the xfermode is NULL, it is treated as
+ kSrcOver_Mode. It is legal to call this with xpf param NULL to simply test the return value.
*/
- static bool AsFragmentProcessorOrXPFactory(SkXfermode*, GrFragmentProcessor**,
- GrXPFactory**);
+ static bool AsXPFactory(SkXfermode*, GrXPFactory**);
SK_TO_STRING_PUREVIRT()
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp
index 37dbd0d1e2..ac1ebcccb0 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -687,30 +687,18 @@ bool SkXfermode::asXPFactory(GrXPFactory**) const {
#if SK_SUPPORT_GPU
#include "effects/GrPorterDuffXferProcessor.h"
-bool SkXfermode::AsFragmentProcessorOrXPFactory(SkXfermode* xfermode,
- GrFragmentProcessor** fp,
- GrXPFactory** xpf) {
- Coeff src, dst;
- Mode mode;
+bool SkXfermode::AsXPFactory(SkXfermode* xfermode, GrXPFactory** xpf) {
if (NULL == xfermode) {
- *xpf = GrPorterDuffXPFactory::Create(kSrcOver_Mode);
- return true;
- } else if (xfermode->asMode(&mode) && mode <= kLastCoeffMode) {
- *xpf = GrPorterDuffXPFactory::Create(mode);
- return true;
- } else if (xfermode->asCoeff(&src, &dst)) {
- *xpf = GrPorterDuffXPFactory::Create(src, dst);
- return true;
- } else if (xfermode->asXPFactory(xpf)) {
+ if (xpf) {
+ *xpf = GrPorterDuffXPFactory::Create(kSrcOver_Mode);
+ }
return true;
} else {
- return xfermode->asFragmentProcessor(fp, NULL);
+ return xfermode->asXPFactory(xpf);
}
}
#else
-bool SkXfermode::AsFragmentProcessorOrXPFactory(SkXfermode* xfermode,
- GrFragmentProcessor** fp,
- GrXPFactory** xpf) {
+bool SkXfermode::AsXPFactory(SkXfermode* xfermode, GrXPFactory** xpf) {
return false;
}
#endif
@@ -934,6 +922,14 @@ bool SkProcCoeffXfermode::asFragmentProcessor(GrFragmentProcessor** fp,
}
bool SkProcCoeffXfermode::asXPFactory(GrXPFactory** xp) const {
+ if (CANNOT_USE_COEFF != fSrcCoeff) {
+ if (xp) {
+ *xp = GrPorterDuffXPFactory::Create(fMode);
+ SkASSERT(*xp);
+ }
+ return true;
+ }
+
if (GrCustomXfermode::IsSupportedMode(fMode)) {
if (xp) {
*xp = GrCustomXfermode::CreateXPFactory(fMode);
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 64142fe07e..a3972806f7 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -514,15 +514,8 @@ void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor
grPaint->setAntiAlias(skPaint.isAntiAlias());
SkXfermode* mode = skPaint.getXfermode();
- GrFragmentProcessor* fragmentProcessor = NULL;
GrXPFactory* xpFactory = NULL;
- if (SkXfermode::AsFragmentProcessorOrXPFactory(mode, &fragmentProcessor, &xpFactory)) {
- if (fragmentProcessor) {
- SkASSERT(NULL == xpFactory);
- grPaint->addColorProcessor(fragmentProcessor)->unref();
- xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode);
- }
- } else {
+ if (!SkXfermode::AsXPFactory(mode, &xpFactory)) {
// Fall back to src-over
xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kSrcOver_Mode);
}