Add support for reading non-rendertarget textures.
Also removes rendertarget flag from GrAtlas texture creation (no longer needed) and re-enables GrFontCache::dump(). R=robertphillips@google.com Author: jvanverth@google.com Review URL: https://codereview.chromium.org/29263004 git-svn-id: http://skia.googlecode.com/svn/trunk@11917 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
338a66481e
commit
3f80dd5f01
@ -177,14 +177,7 @@ GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas,
|
||||
if (NULL == fTexture) {
|
||||
// TODO: Update this to use the cache rather than directly creating a texture.
|
||||
GrTextureDesc desc;
|
||||
#ifdef SK_DEVELOPER
|
||||
// RenderTarget so we can read the pixels to dump them
|
||||
// TODO: Fix to support RT
|
||||
desc.fFlags = kDynamicUpdate_GrTextureFlagBit;//|kRenderTarget_GrTextureFlagBit;
|
||||
//|kNoStencil_GrTextureFlagBit;
|
||||
#else
|
||||
desc.fFlags = kDynamicUpdate_GrTextureFlagBit;
|
||||
#endif
|
||||
desc.fWidth = GR_ATLAS_TEXTURE_WIDTH;
|
||||
desc.fHeight = GR_ATLAS_TEXTURE_HEIGHT;
|
||||
desc.fConfig = fPixelConfig;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,6 @@ void GrFontCache::validate() const {
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void GrFontCache::dump() const {
|
||||
/* Disabled for now
|
||||
static int gDumpCount = 0;
|
||||
for (int i = 0; i < kMaskFormatCount; ++i) {
|
||||
if (NULL != fAtlasMgr[i]) {
|
||||
@ -186,7 +185,6 @@ void GrFontCache::dump() const {
|
||||
}
|
||||
}
|
||||
++gDumpCount;
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user