diff options
author | bsalomon <bsalomon@google.com> | 2015-10-16 07:49:42 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-16 07:49:42 -0700 |
commit | 1a1d0b8d07d1d1cc2e56bb4790ff62179ba0c74c (patch) | |
tree | f31dd714f592b5ee5f46d2117c8418539bfa2598 | |
parent | fa694ad067976a5b713eec0b6f92ba5efeb0aa9d (diff) |
Remove check for whole image in the cache in SkGpuDevice::shouldTileImage
This was never that well justified.
Review URL: https://codereview.chromium.org/1405383002
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 9 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 33 | ||||
-rw-r--r-- | src/gpu/SkGrPriv.h | 3 |
3 files changed, 3 insertions, 42 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index cb532feb6b..f8b372417e 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -758,16 +758,12 @@ bool SkGpuDevice::shouldTileImageID(uint32_t imageID, const SkIRect& imageRect, return true; } + // If the image would only produce 4 tiles of the smaller size, don't bother tiling it. const size_t area = imageRect.width() * imageRect.height(); if (area < 4 * kBmpSmallTileSize * kBmpSmallTileSize) { return false; } - // if the entire image/bitmap is already in our cache then no reason to tile it - if (GrIsImageInCache(fContext, imageID, imageRect, nullptr, params)) { - return false; - } - // At this point we know we could do the draw by uploading the entire bitmap // as a texture. However, if the texture would be large compared to the // cache size and we don't require most of it for this draw then tile to @@ -782,7 +778,8 @@ bool SkGpuDevice::shouldTileImageID(uint32_t imageID, const SkIRect& imageRect, return false; } - // Figure out how much of the src we will need based on the src rect and clipping. + // Figure out how much of the src we will need based on the src rect and clipping. Reject if + // tiling memory savings would be < 50%. determine_clipped_src_rect(fRenderTarget, fClip, viewMatrix, imageRect.size(), srcRectPtr, clippedSubset); *tileSize = kBmpSmallTileSize; // already know whole bitmap fits in one max sized tile. diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 50cd5fa52a..1813433b30 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -173,14 +173,6 @@ void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& sub } } -static void make_image_keys(uint32_t imageID, const SkIRect& subset, const SkGrStretch& stretch, - GrUniqueKey* key, GrUniqueKey* stretchedKey) { - make_unstretched_key(key, imageID, subset); - if (SkGrStretch::kNone_Type != stretch.fType) { - GrMakeStretchedKey(*key, stretch, stretchedKey); - } -} - GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo& info) { GrSurfaceDesc desc; desc.fFlags = kNone_GrSurfaceFlags; @@ -476,31 +468,6 @@ static SkBitmap stretch_on_cpu(const SkBitmap& bmp, const SkGrStretch& stretch) return stretched; } -bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& subset, - GrTexture* nativeTexture, const GrTextureParams& params) { - SkGrStretch stretch; - get_stretch(*ctx->caps(), subset.width(), subset.height(), params, &stretch); - - // Handle the case where the bitmap/image is explicitly texture backed. - if (nativeTexture) { - if (SkGrStretch::kNone_Type == stretch.fType) { - return true; - } - const GrUniqueKey& key = nativeTexture->getUniqueKey(); - if (!key.isValid()) { - return false; - } - GrUniqueKey stretchedKey; - GrMakeStretchedKey(key, stretch, &stretchedKey); - return ctx->textureProvider()->existsTextureWithUniqueKey(stretchedKey); - } - - GrUniqueKey key, stretchedKey; - make_image_keys(imageID, subset, stretch, &key, &stretchedKey); - return ctx->textureProvider()->existsTextureWithUniqueKey( - (SkGrStretch::kNone_Type == stretch.fType) ? key : stretchedKey); -} - class Bitmap_GrTextureMaker : public GrTextureMaker { public: Bitmap_GrTextureMaker(const SkBitmap& bitmap) diff --git a/src/gpu/SkGrPriv.h b/src/gpu/SkGrPriv.h index 6c9f731af2..c92e580885 100644 --- a/src/gpu/SkGrPriv.h +++ b/src/gpu/SkGrPriv.h @@ -114,9 +114,6 @@ GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data, int expectedW, int expectedH, const void** outStartOfDataToUpload); -bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& subset, - GrTexture* nativeTexture, const GrTextureParams&); - GrTexture* GrCreateTextureForPixels(GrContext*, const GrUniqueKey& optionalKey, GrSurfaceDesc, SkPixelRef* pixelRefForInvalidationNotificationOrNull, const void* pixels, size_t rowBytesOrZero); |