Revert "Further centralize computation of GrSurface VRAM consumption"
This reverts commit ccd3c8937fce4bb28df19533ed043cad209e277d.
Reason for revert: Blocking Chromium roll: https://codereview.chromium.org/2482643002/
Original change's description:
> Further centralize computation of GrSurface VRAM consumption
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4383
>
> Change-Id: I054b74f2cd15f904f8e05af0fda58d6e8a523eb9
> Reviewed-on: https://skia-review.googlesource.com/4383
> Commit-Queue: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=662630
Change-Id: I186db2a41eb2bd789e6f681b3547e32d9ca374cf
Reviewed-on: https://skia-review.googlesource.com/4443
Commit-Queue: Ben Wagner <benjaminwagner@google.com>
Reviewed-by: Ben Wagner <benjaminwagner@google.com>
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index de1135a..91036bc 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -35,8 +35,29 @@
}
}
+size_t GrTexture::ComputeSize(const GrSurfaceDesc& desc, bool hasMipMaps) {
+ size_t textureSize;
+
+ if (GrPixelConfigIsCompressed(desc.fConfig)) {
+ textureSize = GrCompressedFormatDataSize(desc.fConfig, desc.fWidth, desc.fHeight);
+ } else {
+ textureSize = (size_t) desc.fWidth * desc.fHeight * GrBytesPerPixel(desc.fConfig);
+ }
+
+ if (hasMipMaps) {
+ // We don't have to worry about the mipmaps being a different size than
+ // we'd expect because we never change fDesc.fWidth/fHeight.
+ textureSize += textureSize/3;
+ }
+
+ SkASSERT(!SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag));
+ SkASSERT(textureSize <= WorstCaseSize(desc));
+
+ return textureSize;
+}
+
size_t GrTexture::onGpuMemorySize() const {
- return GrSurface::ComputeSize(fDesc, 1, this->texturePriv().hasMipMaps());
+ return ComputeSize(fDesc, this->texturePriv().hasMipMaps());
}
void GrTexture::validateDesc() const {