aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/SkGpuDevice.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-29 19:22:36 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-29 19:22:36 +0000
commit26e18b593ab65e4d92dfbce92579d8bc180d4c2c (patch)
treeddc5eddf771019decfe6a3401ea9b2da79dbc68a /src/gpu/SkGpuDevice.cpp
parente36f3baa78cbf4a7bab6e5f14702d6a4d259abde (diff)
Add support for reading the dst pixel value in an effect. Use in a new effect for the kDarken xfer mode.
The current implementation is to always make a copy of the entire dst before the draw. It will only succeed if the RT is also a texture. Obviously, there is lots of room for improvement. Review URL: https://codereview.chromium.org/13314002 git-svn-id: http://skia.googlecode.com/svn/trunk@8449 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/SkGpuDevice.cpp')
-rw-r--r--src/gpu/SkGpuDevice.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 49d6562cea..45176cf8c9 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -493,17 +493,27 @@ inline bool skPaint2GrPaintNoShader(SkGpuDevice* dev,
grPaint->setDither(skPaint.isDither());
grPaint->setAntiAlias(skPaint.isAntiAlias());
- SkXfermode::Coeff sm = SkXfermode::kOne_Coeff;
- SkXfermode::Coeff dm = SkXfermode::kISA_Coeff;
+ SkXfermode::Coeff sm;
+ SkXfermode::Coeff dm;
SkXfermode* mode = skPaint.getXfermode();
GrEffectRef* xferEffect = NULL;
- if (SkXfermode::AsNewEffect(mode, dev->context(), &xferEffect, &sm, &dm)) {
- SkSafeUnref(grPaint->colorStage(kXfermodeEffectIdx)->setEffect(xferEffect));
+ if (SkXfermode::AsNewEffectOrCoeff(mode, dev->context(), &xferEffect, &sm, &dm)) {
+ if (NULL != xferEffect) {
+ grPaint->colorStage(kXfermodeEffectIdx)->setEffect(xferEffect)->unref();
+ // This may not be the right place to have this logic but we set the GPU blend to
+ // src-over so that fractional coverage will be accounted for correctly.
+ sm = SkXfermode::kOne_Coeff;
+ dm = SkXfermode::kISA_Coeff;
+ }
} else {
//SkDEBUGCODE(SkDebugf("Unsupported xfer mode.\n");)
#if 0
return false;
+#else
+ // Fall back to src-over
+ sm = SkXfermode::kOne_Coeff;
+ dm = SkXfermode::kISA_Coeff;
#endif
}
grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm));