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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrAtlas.cpp ('k') | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 config, buffer, rowBytes); 1231 config, buffer, rowBytes);
1232 } 1232 }
1233 1233
1234 bool GrContext::readTexturePixels(GrTexture* texture, 1234 bool GrContext::readTexturePixels(GrTexture* texture,
1235 int left, int top, int width, int height, 1235 int left, int top, int width, int height,
1236 GrPixelConfig config, void* buffer, size_t row Bytes, 1236 GrPixelConfig config, void* buffer, size_t row Bytes,
1237 uint32_t flags) { 1237 uint32_t flags) {
1238 SK_TRACE_EVENT0("GrContext::readTexturePixels"); 1238 SK_TRACE_EVENT0("GrContext::readTexturePixels");
1239 ASSERT_OWNED_RESOURCE(texture); 1239 ASSERT_OWNED_RESOURCE(texture);
1240 1240
1241 // TODO: code read pixels for textures that aren't also rendertargets
1242 GrRenderTarget* target = texture->asRenderTarget(); 1241 GrRenderTarget* target = texture->asRenderTarget();
1243 if (NULL != target) { 1242 if (NULL != target) {
1244 return this->readRenderTargetPixels(target, 1243 return this->readRenderTargetPixels(target,
1245 left, top, width, height, 1244 left, top, width, height,
1246 config, buffer, rowBytes, 1245 config, buffer, rowBytes,
1247 flags); 1246 flags);
1248 } else { 1247 } else {
1248 // TODO: make this more efficient for cases where we're reading the enti re
1249 // texture, i.e., use GetTexImage() instead
1250
1251 // create scratch rendertarget and read from that
1252 GrAutoScratchTexture ast;
1253 GrTextureDesc desc;
1254 desc.fFlags = kRenderTarget_GrTextureFlagBit;
1255 desc.fWidth = width;
1256 desc.fHeight = height;
1257 desc.fConfig = config;
1258 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
1259 ast.set(this, desc, kExact_ScratchTexMatch);
1260 GrTexture* dst = ast.texture();
1261 if (NULL != dst && NULL != (target = dst->asRenderTarget())) {
1262 this->copyTexture(texture, target, NULL);
1263 return this->readRenderTargetPixels(target,
1264 left, top, width, height,
1265 config, buffer, rowBytes,
1266 flags);
1267 }
1268
1249 return false; 1269 return false;
1250 } 1270 }
1251 } 1271 }
1252 1272
1253 #include "SkConfig8888.h" 1273 #include "SkConfig8888.h"
1254 1274
1255 namespace { 1275 namespace {
1256 /** 1276 /**
1257 * Converts a GrPixelConfig to a SkCanvas::Config8888. Only byte-per-channel 1277 * Converts a GrPixelConfig to a SkCanvas::Config8888. Only byte-per-channel
1258 * formats are representable as Config8888 and so the function returns false 1278 * formats are representable as Config8888 and so the function returns false
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 return NULL; 1791 return NULL;
1772 } 1792 }
1773 } 1793 }
1774 1794
1775 /////////////////////////////////////////////////////////////////////////////// 1795 ///////////////////////////////////////////////////////////////////////////////
1776 #if GR_CACHE_STATS 1796 #if GR_CACHE_STATS
1777 void GrContext::printCacheStats() const { 1797 void GrContext::printCacheStats() const {
1778 fTextureCache->printStats(); 1798 fTextureCache->printStats();
1779 } 1799 }
1780 #endif 1800 #endif
OLDNEW
« 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