Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Unified Diff: src/gpu/SkGr.cpp

Issue 321253002: Simple GPU based dithering (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use ordered dithering Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/skia_for_chromium_defines.gypi ('k') | src/gpu/effects/GrDitherEffect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
}
/**
« no previous file with comments | « gyp/skia_for_chromium_defines.gypi ('k') | src/gpu/effects/GrDitherEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698