diff options
author | Robert Phillips <robertphillips@google.com> | 2017-01-18 10:08:39 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-18 16:22:59 +0000 |
commit | 2c86249465c28a532c8be55b6ba497021e3110ec (patch) | |
tree | b33ecbfb9bfdb8e848e461ea67beeca1097d9cb6 /src/gpu/GrTextureContext.cpp | |
parent | dfff166db5d5226dc002a22ab3e3097ef971d615 (diff) |
Move read/write-Pixels up to GrSurfaceContext
This still needs to be propagated out in several ways:
replace more instances of GrSurface::read/write-Pixels
add colorSpace to more instances of the TextureContext
but it establishes a beach-head and is exciting enough as is.
Change-Id: If86035aa0245e70b54541e83722b3c75bc5ade13
Reviewed-on: https://skia-review.googlesource.com/7172
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrTextureContext.cpp')
-rw-r--r-- | src/gpu/GrTextureContext.cpp | 60 |
1 files changed, 54 insertions, 6 deletions
diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp index 9f61551270..7ca1e54bef 100644 --- a/src/gpu/GrTextureContext.cpp +++ b/src/gpu/GrTextureContext.cpp @@ -19,9 +19,10 @@ GrTextureContext::GrTextureContext(GrContext* context, GrDrawingManager* drawingMgr, sk_sp<GrTextureProxy> textureProxy, + sk_sp<SkColorSpace> colorSpace, GrAuditTrail* auditTrail, GrSingleOwner* singleOwner) - : GrSurfaceContext(context, auditTrail, singleOwner) + : GrSurfaceContext(context, std::move(colorSpace), auditTrail, singleOwner) , fDrawingManager(drawingMgr) , fTextureProxy(std::move(textureProxy)) , fOpList(SkSafeRef(fTextureProxy->getLastTextureOpList())) { @@ -75,11 +76,11 @@ bool GrTextureContext::onCopy(GrSurfaceProxy* srcProxy, if (!src) { return false; } -
-#ifndef ENABLE_MDB
- // We can't yet fully defer copies to textures, so GrTextureContext::copySurface will
- // execute the copy immediately. Ensure the data is ready.
- src->flushWrites();
+ +#ifndef ENABLE_MDB + // We can't yet fully defer copies to textures, so GrTextureContext::copySurface will + // execute the copy immediately. Ensure the data is ready. + src->flushWrites(); #endif // TODO: this needs to be fixed up since it ends the deferrable of the GrTexture @@ -100,3 +101,50 @@ bool GrTextureContext::onCopy(GrSurfaceProxy* srcProxy, return result; } + +// TODO: move this (and GrRenderTargetContext::onReadPixels) to GrSurfaceContext? +bool GrTextureContext::onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer, + size_t dstRowBytes, int x, int y) { + // TODO: teach GrTexture to take ImageInfo directly to specify the src pixels + GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo, *fContext->caps()); + if (kUnknown_GrPixelConfig == config) { + return false; + } + + uint32_t flags = 0; + if (kUnpremul_SkAlphaType == dstInfo.alphaType()) { + flags = GrContext::kUnpremul_PixelOpsFlag; + } + + // Deferral of the VRAM resources must end in this instance anyway + sk_sp<GrTexture> tex(sk_ref_sp(fTextureProxy->instantiate(fContext->textureProvider()))); + if (!tex) { + return false; + } + + return tex->readPixels(this->getColorSpace(), x, y, dstInfo.width(), dstInfo.height(), + config, dstInfo.colorSpace(), dstBuffer, dstRowBytes, flags); +} + +// TODO: move this (and GrRenderTargetContext::onReadPixels) to GrSurfaceContext? +bool GrTextureContext::onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer, + size_t srcRowBytes, int x, int y) { + // TODO: teach GrTexture to take ImageInfo directly to specify the src pixels + GrPixelConfig config = SkImageInfo2GrPixelConfig(srcInfo, *fContext->caps()); + if (kUnknown_GrPixelConfig == config) { + return false; + } + uint32_t flags = 0; + if (kUnpremul_SkAlphaType == srcInfo.alphaType()) { + flags = GrContext::kUnpremul_PixelOpsFlag; + } + + // Deferral of the VRAM resources must end in this instance anyway + sk_sp<GrTexture> tex(sk_ref_sp(fTextureProxy->instantiate(fContext->textureProvider()))); + if (!tex) { + return false; + } + + return tex->writePixels(this->getColorSpace(), x, y, srcInfo.width(), srcInfo.height(), + config, srcInfo.colorSpace(), srcBuffer, srcRowBytes, flags); +} |