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

Unified Diff: src/gpu/SkGr.cpp

Issue 820683002: When bitmap is texture backed, don't download and reupload pixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove comment Created 6 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGr.cpp
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index e311ae2ace4c76991c59a889d9a4ce661dd1ba42..ff74fe92ca254a5fa21707e117c685c684e465fb 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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698