Remove check for whole image in the cache in SkGpuDevice::shouldTileImage
This was never that well justified. Review URL: https://codereview.chromium.org/1405383002
This commit is contained in:
parent
fa694ad067
commit
1a1d0b8d07
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user