Chromium Code Reviews| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 // This must not be called until after changing fMipMapsStatus. | 55 // This must not be called until after changing fMipMapsStatus. |
| 56 this->didChangeGpuMemorySize(); | 56 this->didChangeGpuMemorySize(); |
| 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 | |
| 66 if (GrPixelConfigIsCompressed(fDesc.fConfig)) { | |
| 67 // Figure out the width and height corresponding to the data... | |
| 68 SkASSERT((fDesc.fWidth & 3) == 0); | |
| 69 SkASSERT((fDesc.fHeight & 3) == 0); | |
| 70 | |
|
robertphillips
2014/05/29 12:53:18
// Both these formats have 4x4 blocks of 8 bytes ?
krajcevski
2014/05/29 14:28:22
Done.
| |
| 71 if (kETC1_GrPixelConfig == fDesc.fConfig) { | |
| 72 textureSize = (fDesc.fWidth >> 2) * (fDesc.fHeight >> 2) * 8; | |
| 73 } else if (kLATC_GrPixelConfig == fDesc.fConfig) { | |
| 74 textureSize = (fDesc.fWidth >> 2) * (fDesc.fHeight >> 2) * 8; | |
| 75 } else { | |
|
robertphillips
2014/05/29 12:53:18
Maybe: SkFAIL("Unknown compression format"); retur
krajcevski
2014/05/29 14:28:22
Done.
| |
| 76 SkASSERT(false); | |
| 77 } | |
| 78 } | |
| 79 | |
| 65 if (this->impl()->hasMipMaps()) { | 80 if (this->impl()->hasMipMaps()) { |
| 66 // We don't have to worry about the mipmaps being a different size than | 81 // We don't have to worry about the mipmaps being a different size than |
| 67 // we'd expect because we never change fDesc.fWidth/fHeight. | 82 // we'd expect because we never change fDesc.fWidth/fHeight. |
| 68 textureSize *= 2; | 83 textureSize *= 2; |
| 69 } | 84 } |
| 70 return textureSize; | 85 return textureSize; |
| 71 } | 86 } |
| 72 | 87 |
| 73 bool GrTexture::readPixels(int left, int top, int width, int height, | 88 bool GrTexture::readPixels(int left, int top, int width, int height, |
| 74 GrPixelConfig config, void* buffer, | 89 GrPixelConfig config, void* buffer, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 return GrResourceKey(cacheID, texture_resource_type(), 0); | 231 return GrResourceKey(cacheID, texture_resource_type(), 0); |
| 217 } | 232 } |
| 218 | 233 |
| 219 bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) { | 234 bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) { |
| 220 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); | 235 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); |
| 221 } | 236 } |
| 222 | 237 |
| 223 bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) { | 238 bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) { |
| 224 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); | 239 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); |
| 225 } | 240 } |
| OLD | NEW |