Chromium Code Reviews| Index: src/gpu/SkGr.cpp |
| diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp |
| index c4720b58c85ade590aa0ad252e8b0f1da999cba2..f2f04017f5e470609952f5d807cb4b40cd13f20c 100644 |
| --- a/src/gpu/SkGr.cpp |
| +++ b/src/gpu/SkGr.cpp |
| @@ -13,6 +13,7 @@ |
| #include "SkPixelRef.h" |
| #include "GrResourceCache.h" |
| #include "GrGpu.h" |
| +#include "effects/GrDitherEffect.h" |
| #include "GrDrawTargetCaps.h" |
| #ifndef SK_IGNORE_ETC1_SUPPORT |
| @@ -458,6 +459,30 @@ void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor |
| } |
| } |
| } |
| + |
| +#ifndef SK_IGNORE_GPU_DITHER |
| + // If the dither flag is set, then we need to see if the underlying context |
| + // supports it. If not, then install a dither effect. |
| + if (skPaint.isDither()) { |
| + // What are we rendering into? |
| + const GrRenderTarget *target = context->getRenderTarget(); |
| + if (NULL == target) { |
|
bsalomon
2014/06/12 16:24:11
I'd like to understand how this happens. Falling b
|
| + target = context->getGpu()->getDrawState().getRenderTarget(); |
| + } |
| + |
| + if (NULL != target && |
| + (target->config() == kRGBA_8888_GrPixelConfig || |
| + target->config() == kBGRA_8888_GrPixelConfig)) { |
| + // The dither flag is set and the target is likely |
| + // not going to be dithered by the GPU. |
| + SkAutoTUnref<GrEffectRef> effect(GrDitherEffect::Create()); |
| + if (NULL != effect.get()) { |
| + grPaint->addColorEffect(effect); |
| + grPaint->setDither(false); |
| + } |
| + } |
| + } |
| +#endif |
| } |
| /** |