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>
diff --git a/src/gpu/GrSurface.cpp b/src/gpu/GrSurface.cpp
index ead9401..b1707be 100644
--- a/src/gpu/GrSurface.cpp
+++ b/src/gpu/GrSurface.cpp
@@ -21,6 +21,12 @@
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) {