| 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  | 
 |   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  Loading... | 
|  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 } | 
| OLD | NEW |