OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "GrTexture.h" | 10 #include "GrTexture.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
37 | 37 |
38 // Note: "this" texture might be freed inside addExistingTextureToCache | 38 // Note: "this" texture might be freed inside addExistingTextureToCache |
39 // if it is purged. | 39 // if it is purged. |
40 return; | 40 return; |
41 } | 41 } |
42 | 42 |
43 SkASSERT(0 == this->getDeferredRefCount()); | 43 SkASSERT(0 == this->getDeferredRefCount()); |
44 this->INHERITED::internal_dispose(); | 44 this->INHERITED::internal_dispose(); |
45 } | 45 } |
46 | 46 |
47 void GrTexture::dirtyMipMaps(bool mipMapsDirty) { | |
48 if (mipMapsDirty) { | |
49 if (kValid_MipMapsStatus == fMipMapsStatus) { | |
50 fMipMapsStatus = kInvalid_MipMapsStatus; | |
51 } | |
52 } else { | |
53 const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus; | |
54 fMipMapsStatus = kValid_MipMapsStatus; | |
55 if (sizeChanged) { | |
56 // This must not be called until after changing fMipMapsStatus. | |
57 this->didChangeGpuMemorySize(); | |
58 } | |
59 } | |
60 } | |
61 | |
robertphillips
2014/04/29 13:46:25
no SK_OVERRIDE here
| |
62 size_t GrTexture::gpuMemorySize() const SK_OVERRIDE { | |
63 size_t textureSize = (size_t) fDesc.fWidth * | |
64 fDesc.fHeight * | |
65 GrBytesPerPixel(fDesc.fConfig); | |
66 if (kNotAllocated_MipMapsStatus != fMipMapsStatus) { | |
67 // We don't have to worry about the mipmaps being a different size than | |
68 // we'd expect because we never change fDesc.fWidth/fHeight. | |
69 textureSize *= 2; | |
70 } | |
71 return textureSize; | |
72 } | |
73 | |
47 bool GrTexture::readPixels(int left, int top, int width, int height, | 74 bool GrTexture::readPixels(int left, int top, int width, int height, |
48 GrPixelConfig config, void* buffer, | 75 GrPixelConfig config, void* buffer, |
49 size_t rowBytes, uint32_t pixelOpsFlags) { | 76 size_t rowBytes, uint32_t pixelOpsFlags) { |
50 // go through context so that all necessary flushing occurs | 77 // go through context so that all necessary flushing occurs |
51 GrContext* context = this->getContext(); | 78 GrContext* context = this->getContext(); |
52 if (NULL == context) { | 79 if (NULL == context) { |
53 return false; | 80 return false; |
54 } | 81 } |
55 return context->readTexturePixels(this, | 82 return context->readTexturePixels(this, |
56 left, top, width, height, | 83 left, top, width, height, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 return GrResourceKey(cacheID, texture_resource_type(), 0); | 213 return GrResourceKey(cacheID, texture_resource_type(), 0); |
187 } | 214 } |
188 | 215 |
189 bool GrTexture::NeedsResizing(const GrResourceKey& key) { | 216 bool GrTexture::NeedsResizing(const GrResourceKey& key) { |
190 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); | 217 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); |
191 } | 218 } |
192 | 219 |
193 bool GrTexture::NeedsBilerp(const GrResourceKey& key) { | 220 bool GrTexture::NeedsBilerp(const GrResourceKey& key) { |
194 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); | 221 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); |
195 } | 222 } |
OLD | NEW |