aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTexture.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-05 19:09:13 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-05 19:09:13 +0000
commit11c6b39cfa24f812ceb115589f51a60a56ef14fe (patch)
treec485379fe950057e163ce2f41962d2607125e7e3 /src/gpu/GrTexture.cpp
parent7e9fb8ddd63fecbc469a2eb011793e08fb0adea5 (diff)
Adds a mechanism for GrCacheable objects to notify the resource cache
when their size has changed. GrResourceCacheEntry now holds a reference to the cache, and a cached value of the resource's most recent size. Also utilizes this new functionality for mipmaps, and adds a test for changing resource sizes. R=bsalomon@google.com, robertphillips@google.com Author: cdalton@nvidia.com Review URL: https://codereview.chromium.org/257093002 git-svn-id: http://skia.googlecode.com/svn/trunk@14576 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrTexture.cpp')
-rw-r--r--src/gpu/GrTexture.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index f851515371..3186d89d77 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -44,6 +44,33 @@ void GrTexture::internal_dispose() const {
this->INHERITED::internal_dispose();
}
+void GrTexture::dirtyMipMaps(bool mipMapsDirty) {
+ if (mipMapsDirty) {
+ if (kValid_MipMapsStatus == fMipMapsStatus) {
+ fMipMapsStatus = kAllocated_MipMapsStatus;
+ }
+ } else {
+ const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus;
+ fMipMapsStatus = kValid_MipMapsStatus;
+ if (sizeChanged) {
+ // This must not be called until after changing fMipMapsStatus.
+ this->didChangeGpuMemorySize();
+ }
+ }
+}
+
+size_t GrTexture::gpuMemorySize() const {
+ size_t textureSize = (size_t) fDesc.fWidth *
+ fDesc.fHeight *
+ GrBytesPerPixel(fDesc.fConfig);
+ if (kNotAllocated_MipMapsStatus != fMipMapsStatus) {
+ // 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 *= 2;
+ }
+ return textureSize;
+}
+
bool GrTexture::readPixels(int left, int top, int width, int height,
GrPixelConfig config, void* buffer,
size_t rowBytes, uint32_t pixelOpsFlags) {