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

Unified Diff: src/gpu/GrContext.cpp

Issue 1919993002: Added --deepColor option to SampleApp, triggers creation of a ten-bit/channel buffer on Windows. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: More cleanup Created 4 years, 8 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/GrContext.cpp
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index a186bd87bc101f1cf9107ccc1903172adf354622..28b59d08044a4db6a8bd8b3b34f0c0ae199253f1 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -20,6 +20,7 @@
#include "batches/GrCopySurfaceBatch.h"
#include "effects/GrConfigConversionEffect.h"
+#include "effects/GrGammaEffect.h"
#include "text/GrTextBlobCache.h"
#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this)
@@ -529,6 +530,40 @@ bool GrContext::readSurfacePixels(GrSurface* src,
return true;
}
+bool GrContext::applyGamma(GrRenderTarget* dst, GrTexture* src, SkScalar gamma){
+ ASSERT_SINGLE_OWNER
+ RETURN_FALSE_IF_ABANDONED
+ ASSERT_OWNED_RESOURCE(dst);
+ ASSERT_OWNED_RESOURCE(src);
+ GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::applyGamma");
+
+ SkSurfaceProps props(SkSurfaceProps::kGammaCorrect_Flag,
+ SkSurfaceProps::kLegacyFontHost_InitType);
+ sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(dst), &props));
+ if (!drawContext) {
+ return false;
+ }
+
+ GrPaint paint;
+ if (SkScalarNearlyEqual(gamma, 1.0f)) {
bsalomon 2016/04/29 18:27:20 Maybe just call copySurface here? Should we also d
Brian Osman 2016/05/02 21:02:45 I tried falling back to copySurface, but that code
bsalomon 2016/05/02 21:17:40 Is that what we want copySurface to do? Maybe we s
+ paint.addColorTextureProcessor(src, GrCoordTransform::MakeDivByTextureWHMatrix(src));
+ } else {
+ SkAutoTUnref<const GrFragmentProcessor> fp;
+ fp.reset(GrGammaEffect::Create(src, gamma));
+ paint.addColorFragmentProcessor(fp);
+ }
+ paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
+ paint.setGammaCorrect(true);
+
+ SkRect rect;
+ src->getBoundsRect(&rect);
+ drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect, nullptr);
+
+ this->flushSurfaceWrites(dst);
+
+ return true;
+}
+
void GrContext::prepareSurfaceForExternalIO(GrSurface* surface) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED

Powered by Google App Engine
This is Rietveld 408576698