Return a size of 0 for external format GrSurfaces.

This fixes a case where Chrome was hitting the assert in ComputeSize that
colorSize > 0. In general this shouldn't affect our memory/budget tracking
since external textures are generally given to us as wrapped borrowed textures
so they're memory was not counted against our budget to begin with.

Change-Id: I2fd4eaaab52d9c3dc1af3a8f5b59a1b1f3c5dbb7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256656
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2019-11-26 09:55:20 -05:00 committed by Skia Commit-Bot
parent 0addbdf0fb
commit ada451ca67
2 changed files with 8 additions and 1 deletions

View File

@ -365,7 +365,8 @@ public:
void storeVkPipelineCacheData();
// Returns the gpu memory size of the the texture that backs the passed in SkImage. Returns 0 if
// the SkImage is not texture backed.
// the SkImage is not texture backed. For external format textures this will also return 0 as we
// cannot determine the correct size.
static size_t ComputeImageSize(sk_sp<SkImage> image, GrMipMapped, bool useNextPow2 = false);
/*

View File

@ -21,6 +21,12 @@ size_t GrSurface::ComputeSize(const GrCaps& caps,
int colorSamplesPerPixel,
GrMipMapped mipMapped,
bool binSize) {
// For external formats we do not actually know the real size of the resource so we just return
// 0 here to indicate this.
if (format.textureType() == GrTextureType::kExternal) {
return 0;
}
size_t colorSize;
if (binSize) {