| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 size_t GrTexture::gpuMemorySize() const { | 61 size_t GrTexture::gpuMemorySize() const { |
| 62 size_t textureSize = (size_t) fDesc.fWidth * | 62 size_t textureSize = (size_t) fDesc.fWidth * |
| 63 fDesc.fHeight * | 63 fDesc.fHeight * |
| 64 GrBytesPerPixel(fDesc.fConfig); | 64 GrBytesPerPixel(fDesc.fConfig); |
| 65 | 65 |
| 66 if (GrPixelConfigIsCompressed(fDesc.fConfig)) { | 66 if (GrPixelConfigIsCompressed(fDesc.fConfig)) { |
| 67 // Figure out the width and height corresponding to the data... | 67 textureSize = GrCompressedFormatDataSize(fDesc.fConfig, fDesc.fWidth, fD
esc.fHeight); |
| 68 | |
| 69 // Both of the available formats (ETC1 and LATC) have 4x4 | |
| 70 // blocks that compress down to 8 bytes. | |
| 71 switch(fDesc.fConfig) { | |
| 72 case kETC1_GrPixelConfig: | |
| 73 case kLATC_GrPixelConfig: | |
| 74 case kR11_EAC_GrPixelConfig: | |
| 75 SkASSERT((fDesc.fWidth & 3) == 0); | |
| 76 SkASSERT((fDesc.fHeight & 3) == 0); | |
| 77 textureSize = (fDesc.fWidth >> 2) * (fDesc.fHeight >> 2) * 8; | |
| 78 break; | |
| 79 | |
| 80 default: | |
| 81 SkFAIL("Unknown compressed config"); | |
| 82 } | |
| 83 } | 68 } |
| 84 | 69 |
| 85 if (this->impl()->hasMipMaps()) { | 70 if (this->impl()->hasMipMaps()) { |
| 86 // We don't have to worry about the mipmaps being a different size than | 71 // We don't have to worry about the mipmaps being a different size than |
| 87 // we'd expect because we never change fDesc.fWidth/fHeight. | 72 // we'd expect because we never change fDesc.fWidth/fHeight. |
| 88 textureSize *= 2; | 73 textureSize *= 2; |
| 89 } | 74 } |
| 90 return textureSize; | 75 return textureSize; |
| 91 } | 76 } |
| 92 | 77 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 return GrResourceKey(cacheID, texture_resource_type(), 0); | 221 return GrResourceKey(cacheID, texture_resource_type(), 0); |
| 237 } | 222 } |
| 238 | 223 |
| 239 bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) { | 224 bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) { |
| 240 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); | 225 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); |
| 241 } | 226 } |
| 242 | 227 |
| 243 bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) { | 228 bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) { |
| 244 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); | 229 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); |
| 245 } | 230 } |
| OLD | NEW |