aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-12-19 12:26:37 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-19 12:26:37 -0800
commit9ed7f573491217079cccf1d81792cf4520a3c0d0 (patch)
tree2ba4bfc059dd322aa5de28225bd83b83f3d255d3 /src/gpu
parent53b9e2e0f29e5613f8d8d0eeb4a4b4d4a8a40e91 (diff)
When bitmap is texture backed, don't download and reupload pixels
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/SkGr.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index e311ae2ace..ff74fe92ca 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -360,9 +360,29 @@ static GrTexture* sk_gr_create_bitmap_texture(GrContext* ctx,
bitmap->getPixels(), bitmap->rowBytes());
}
+static GrTexture* get_texture_backing_bmp(const SkBitmap& bitmap, const GrContext* context,
+ const GrTextureParams* params) {
+ if (GrTexture* texture = bitmap.getTexture()) {
+ // Our texture-resizing-for-tiling used to upscale NPOT textures for tiling only works with
+ // content-key cached resources. Rather than invest in that legacy code path, we'll just
+ // take the horribly slow route of causing a cache miss which will cause the pixels to be
+ // read and reuploaded to a texture with a content key.
+ if (params && !context->getGpu()->caps()->npotTextureTileSupport() &&
+ (params->isTiled() || GrTextureParams::kMipMap_FilterMode == params->filterMode())) {
+ return NULL;
+ }
+ return texture;
+ }
+ return NULL;
+}
+
bool GrIsBitmapInCache(const GrContext* ctx,
const SkBitmap& bitmap,
const GrTextureParams* params) {
+ if (get_texture_backing_bmp(bitmap, ctx, params)) {
+ return true;
+ }
+
GrCacheID cacheID;
generate_bitmap_cache_id(bitmap, &cacheID);
@@ -374,7 +394,10 @@ bool GrIsBitmapInCache(const GrContext* ctx,
GrTexture* GrRefCachedBitmapTexture(GrContext* ctx,
const SkBitmap& bitmap,
const GrTextureParams* params) {
- GrTexture* result = NULL;
+ GrTexture* result = get_texture_backing_bmp(bitmap, ctx, params);
+ if (result) {
+ return SkRef(result);
+ }
bool cache = !bitmap.isVolatile();