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

Unified Diff: src/gpu/SkGr.cpp

Issue 321253002: Simple GPU based dithering (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
Index: src/gpu/SkGr.cpp
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index fb2ebdd53fcbbf70c1ed93568f14ed3526b7bce8..c566d6ffaf7b48fd6d48eadda680d2e0c4050f3f 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
@@ -465,6 +466,28 @@ void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, bool ju
}
}
}
+
robertphillips 2014/06/11 17:20:24 Wrap this in SK_IGNORE_GPU_DITHER and add it to gy
krajcevski 2014/06/11 22:33:18 Done.
+ // 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) {
+ target = context->getGpu()->getDrawState().getRenderTarget();
+ }
+ SkASSERT(NULL != target);
+
+ if (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);
+ }
+ }
+ }
}
/**

Powered by Google App Engine
This is Rietveld 408576698