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

Unified Diff: src/gpu/GrContext.cpp

Issue 29263004: Add support for reading non-rendertarget textures. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix nit. Created 7 years, 2 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 | « src/gpu/GrAtlas.cpp ('k') | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrContext.cpp
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index dca58745d7d04f46cbc757b156ba7e23ff9dcc05..9b980c9910319919b9d06bb9a44963cf6a8636dd 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -1238,7 +1238,6 @@ bool GrContext::readTexturePixels(GrTexture* texture,
SK_TRACE_EVENT0("GrContext::readTexturePixels");
ASSERT_OWNED_RESOURCE(texture);
- // TODO: code read pixels for textures that aren't also rendertargets
GrRenderTarget* target = texture->asRenderTarget();
if (NULL != target) {
return this->readRenderTargetPixels(target,
@@ -1246,6 +1245,27 @@ bool GrContext::readTexturePixels(GrTexture* texture,
config, buffer, rowBytes,
flags);
} else {
+ // TODO: make this more efficient for cases where we're reading the entire
+ // texture, i.e., use GetTexImage() instead
+
+ // create scratch rendertarget and read from that
+ GrAutoScratchTexture ast;
+ GrTextureDesc desc;
+ desc.fFlags = kRenderTarget_GrTextureFlagBit;
+ desc.fWidth = width;
+ desc.fHeight = height;
+ desc.fConfig = config;
+ desc.fOrigin = kTopLeft_GrSurfaceOrigin;
+ ast.set(this, desc, kExact_ScratchTexMatch);
+ GrTexture* dst = ast.texture();
+ if (NULL != dst && NULL != (target = dst->asRenderTarget())) {
+ this->copyTexture(texture, target, NULL);
+ return this->readRenderTargetPixels(target,
+ left, top, width, height,
+ config, buffer, rowBytes,
+ flags);
+ }
+
return false;
}
}
« no previous file with comments | « src/gpu/GrAtlas.cpp ('k') | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698