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

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: Plumb gamma to shader, fix window title 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 c223a602132743d9a7baffcdb98c94e6cd39cee2..b316f924a93c6e059269e1c4fee7ec39f1eb41b2 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -19,6 +19,7 @@
#include "SkGrPriv.h"
#include "batches/GrCopySurfaceBatch.h"
+#include "effects/GrColorSpaceEffect.h"
#include "effects/GrConfigConversionEffect.h"
#include "text/GrTextBlobCache.h"
@@ -528,6 +529,63 @@ bool GrContext::readSurfacePixels(GrSurface* src,
return true;
}
+bool GrContext::writeSurfacePixelsWithColorSpace(GrSurface* surface,
+ int left, int top, int width, int height,
+ GrPixelConfig srcConfig,
+ const SkColorSpace* srcColorSpace,
+ const SkColorSpace* dstColorSpace,
+ const void* buffer, size_t rowBytes,
+ uint32_t colorSpaceOpsFlags) {
+ ASSERT_SINGLE_OWNER
+ RETURN_FALSE_IF_ABANDONED
+ ASSERT_OWNED_RESOURCE(surface);
+ SkASSERT(surface);
+ GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::writeSurfacePixelsWithColorSpace");
+
+ if (surface->surfacePriv().hasPendingIO()) {
+ this->flush();
+ }
+
+ GrSurfaceDesc srcDesc;
+ srcDesc.fWidth = width;
+ srcDesc.fHeight = height;
+ srcDesc.fConfig = srcConfig;
+
+ SkAutoTUnref<GrTexture> tempTexture(
+ this->textureProvider()->createTexture(srcDesc, SkBudgeted::kYes, buffer, rowBytes));
+ if (!tempTexture) {
+ return false;
+ }
+
+ SkAutoTUnref<const GrFragmentProcessor> fp;
+ fp.reset(GrColorSpaceEffect::Create(tempTexture,
+ srcColorSpace, dstColorSpace, colorSpaceOpsFlags));
+
+ GrRenderTarget* renderTarget = surface->asRenderTarget();
+ SkASSERT(renderTarget);
+
+ SkMatrix matrix;
+ matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
+ SkSurfaceProps props(SkSurfaceProps::kGammaCorrect_Flag,
+ SkSurfaceProps::kLegacyFontHost_InitType);
+ SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(renderTarget, &props));
+ if (!drawContext) {
+ return false;
+ }
+
+ GrPaint paint;
+ paint.addColorFragmentProcessor(fp);
+ paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
+ paint.setGammaCorrect(true);
+
+ SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
+ drawContext->drawRect(GrClip::WideOpen(), paint, matrix, rect, nullptr);
+
+ this->flushSurfaceWrites(surface);
+
+ return true;
+}
+
void GrContext::prepareSurfaceForExternalIO(GrSurface* surface) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
« samplecode/SampleApp.cpp ('K') | « samplecode/SampleApp.cpp ('k') | src/gpu/GrSurface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698