aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-27 18:31:15 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-27 18:31:15 +0000
commitf51c01328dc52a87c07e056d6fc4eb7452ccac7a (patch)
treeab5902f078fe940005ae5b7bd767cd6d629de640 /src
parent31ec7985f2b52a0cab4aa714a613b918cf663c08 (diff)
Add interface to SkXfermode to return a GrEffect and blend coeffs.
Review URL: https://codereview.chromium.org/13097006 git-svn-id: http://skia.googlecode.com/svn/trunk@8412 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkXfermode.cpp20
-rw-r--r--src/gpu/SkGpuDevice.cpp12
2 files changed, 27 insertions, 5 deletions
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp
index de18c26fd1..09710a393d 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -680,6 +680,22 @@ bool SkXfermode::asMode(Mode* mode) const {
return false;
}
+bool SkXfermode::asNewEffect(GrContext*, GrEffectRef**, Coeff*, Coeff*) const {
+ return false;
+}
+
+bool SkXfermode::AsNewEffect(SkXfermode* xfermode,
+ GrContext* context,
+ GrEffectRef** effect,
+ Coeff* src,
+ Coeff* dst) {
+ if (NULL == xfermode) {
+ return ModeAsCoeff(kSrcOver_Mode, src, dst);
+ } else {
+ return xfermode->asNewEffect(context, effect, src, dst);
+ }
+}
+
SkPMColor SkXfermode::xferColor(SkPMColor src, SkPMColor dst) const{
// no-op. subclasses should override this
return dst;
@@ -958,6 +974,10 @@ public:
return true;
}
+ virtual bool asNewEffect(GrContext*, GrEffectRef**, Coeff* src, Coeff* dst) const SK_OVERRIDE {
+ return this->asCoeff(src, dst);
+ }
+
SK_DEVELOPER_TO_STRING()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode)
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 77c4bd1115..ad65d17214 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -484,13 +484,15 @@ inline bool skPaint2GrPaintNoShader(SkGpuDevice* dev,
SkXfermode::Coeff dm = SkXfermode::kISA_Coeff;
SkXfermode* mode = skPaint.getXfermode();
- if (mode) {
- if (!mode->asCoeff(&sm, &dm)) {
- //SkDEBUGCODE(SkDebugf("Unsupported xfer mode.\n");)
+ GrEffectRef* xferEffect;
+ if (SkXfermode::AsNewEffect(mode, dev->context(), &xferEffect, &sm, &dm)) {
+ // We're not ready for xfermode effects yet
+ GrAssert(NULL == xferEffect);
+ } else {
+ //SkDEBUGCODE(SkDebugf("Unsupported xfer mode.\n");)
#if 0
- return false;
+ return false;
#endif
- }
}
grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm));