Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: src/gpu/GrTexture.cpp

Issue 304743004: Move ETC1 and LATC enums value to GrPixelConfig (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Only generate mipmaps for uncompressed textures. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrDrawTargetCaps.h ('k') | src/gpu/gl/GrGLCaps.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 SkASSERT((fDesc.fWidth & 3) == 0);
75 SkASSERT((fDesc.fHeight & 3) == 0);
76 textureSize = (fDesc.fWidth >> 2) * (fDesc.fHeight >> 2) * 8;
77 break;
78
79 default:
80 SkFAIL("Unknown compressed config");
81 }
82 }
83
65 if (this->impl()->hasMipMaps()) { 84 if (this->impl()->hasMipMaps()) {
66 // We don't have to worry about the mipmaps being a different size than 85 // 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. 86 // we'd expect because we never change fDesc.fWidth/fHeight.
68 textureSize *= 2; 87 textureSize *= 2;
69 } 88 }
70 return textureSize; 89 return textureSize;
71 } 90 }
72 91
73 bool GrTexture::readPixels(int left, int top, int width, int height, 92 bool GrTexture::readPixels(int left, int top, int width, int height,
74 GrPixelConfig config, void* buffer, 93 GrPixelConfig config, void* buffer,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 return GrResourceKey(cacheID, texture_resource_type(), 0); 235 return GrResourceKey(cacheID, texture_resource_type(), 0);
217 } 236 }
218 237
219 bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) { 238 bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) {
220 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); 239 return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag);
221 } 240 }
222 241
223 bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) { 242 bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) {
224 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); 243 return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag);
225 } 244 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTargetCaps.h ('k') | src/gpu/gl/GrGLCaps.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698