aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTexture.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-11-03 10:19:14 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-03 16:44:50 +0000
commit29e52f13f632c701bd33d802701f5ff29a567eea (patch)
tree15678f2a2076a706f5d25dd4f898616676e3f898 /src/gpu/GrTexture.cpp
parentd851795e7992565c1eb2b9474ee5ad01d1a01fad (diff)
Centralize computation of GrRenderTarget & GrTexture VRAM consumption
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4310 Change-Id: I676749ecf1e489f825799b619a15a45fc7dcd219 Reviewed-on: https://skia-review.googlesource.com/4310 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrTexture.cpp')
-rw-r--r--src/gpu/GrTexture.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index bb1a6bb081..91036bc156 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -35,27 +35,31 @@ void GrTexture::dirtyMipMaps(bool mipMapsDirty) {
}
}
-size_t GrTexture::onGpuMemorySize() const {
+size_t GrTexture::ComputeSize(const GrSurfaceDesc& desc, bool hasMipMaps) {
size_t textureSize;
- if (GrPixelConfigIsCompressed(fDesc.fConfig)) {
- textureSize = GrCompressedFormatDataSize(fDesc.fConfig, fDesc.fWidth, fDesc.fHeight);
+ if (GrPixelConfigIsCompressed(desc.fConfig)) {
+ textureSize = GrCompressedFormatDataSize(desc.fConfig, desc.fWidth, desc.fHeight);
} else {
- textureSize = (size_t) fDesc.fWidth * fDesc.fHeight * GrBytesPerPixel(fDesc.fConfig);
+ textureSize = (size_t) desc.fWidth * desc.fHeight * GrBytesPerPixel(desc.fConfig);
}
- if (this->texturePriv().hasMipMaps()) {
+ 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(fDesc.fFlags & kRenderTarget_GrSurfaceFlag));
- SkASSERT(textureSize <= WorstCaseSize(fDesc));
+ SkASSERT(!SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag));
+ SkASSERT(textureSize <= WorstCaseSize(desc));
return textureSize;
}
+size_t GrTexture::onGpuMemorySize() const {
+ return ComputeSize(fDesc, this->texturePriv().hasMipMaps());
+}
+
void GrTexture::validateDesc() const {
if (this->asRenderTarget()) {
// This texture has a render target