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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus; | 51 const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus; |
52 fMipMapsStatus = kValid_MipMapsStatus; | 52 fMipMapsStatus = kValid_MipMapsStatus; |
53 if (sizeChanged) { | 53 if (sizeChanged) { |
54 // This must not be called until after changing fMipMapsStatus. | 54 // This must not be called until after changing fMipMapsStatus. |
55 this->didChangeGpuMemorySize(); | 55 this->didChangeGpuMemorySize(); |
56 } | 56 } |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 size_t GrTexture::gpuMemorySize() const { | 60 size_t GrTexture::gpuMemorySize() const { |
61 size_t textureSize = (size_t) fDesc.fWidth * | 61 size_t textureSize; |
62 fDesc.fHeight * | |
63 GrBytesPerPixel(fDesc.fConfig); | |
64 | 62 |
65 if (GrPixelConfigIsCompressed(fDesc.fConfig)) { | 63 if (GrPixelConfigIsCompressed(fDesc.fConfig)) { |
66 textureSize = GrCompressedFormatDataSize(fDesc.fConfig, fDesc.fWidth, fD
esc.fHeight); | 64 textureSize = GrCompressedFormatDataSize(fDesc.fConfig, fDesc.fWidth, fD
esc.fHeight); |
| 65 } else { |
| 66 textureSize = (size_t) fDesc.fWidth * fDesc.fHeight * GrBytesPerPixel(fD
esc.fConfig); |
67 } | 67 } |
68 | 68 |
69 if (this->impl()->hasMipMaps()) { | 69 if (this->impl()->hasMipMaps()) { |
70 // We don't have to worry about the mipmaps being a different size than | 70 // We don't have to worry about the mipmaps being a different size than |
71 // we'd expect because we never change fDesc.fWidth/fHeight. | 71 // we'd expect because we never change fDesc.fWidth/fHeight. |
72 textureSize *= 2; | 72 textureSize *= 2; |
73 } | 73 } |
74 return textureSize; | 74 return textureSize; |
75 } | 75 } |
76 | 76 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 return GrResourceKey(cacheID, texture_resource_type(), 0); | 235 return GrResourceKey(cacheID, texture_resource_type(), 0); |
236 } | 236 } |
237 | 237 |
238 bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) { | 238 bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) { |
239 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); | 239 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); |
240 } | 240 } |
241 | 241 |
242 bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) { | 242 bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) { |
243 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); | 243 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); |
244 } | 244 } |
OLD | NEW |