| 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 #include "GrContext.h" | 9 #include "GrContext.h" |
| 10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 if (GrPixelConfigIsCompressed(fDesc.fConfig)) { | 36 if (GrPixelConfigIsCompressed(fDesc.fConfig)) { |
| 37 textureSize = GrCompressedFormatDataSize(fDesc.fConfig, fDesc.fWidth, fD
esc.fHeight); | 37 textureSize = GrCompressedFormatDataSize(fDesc.fConfig, fDesc.fWidth, fD
esc.fHeight); |
| 38 } else { | 38 } else { |
| 39 textureSize = (size_t) fDesc.fWidth * fDesc.fHeight * GrBytesPerPixel(fD
esc.fConfig); | 39 textureSize = (size_t) fDesc.fWidth * fDesc.fHeight * GrBytesPerPixel(fD
esc.fConfig); |
| 40 } | 40 } |
| 41 | 41 |
| 42 if (this->texturePriv().hasMipMaps()) { | 42 if (this->texturePriv().hasMipMaps()) { |
| 43 // We don't have to worry about the mipmaps being a different size than | 43 // We don't have to worry about the mipmaps being a different size than |
| 44 // we'd expect because we never change fDesc.fWidth/fHeight. | 44 // we'd expect because we never change fDesc.fWidth/fHeight. |
| 45 textureSize *= 2; | 45 textureSize += textureSize/3; |
| 46 } | 46 } |
| 47 |
| 48 SkASSERT(!SkToBool(fDesc.fFlags & kRenderTarget_GrSurfaceFlag)); |
| 49 SkASSERT(textureSize <= WorseCaseSize(fDesc)); |
| 50 |
| 47 return textureSize; | 51 return textureSize; |
| 48 } | 52 } |
| 49 | 53 |
| 50 void GrTexture::validateDesc() const { | 54 void GrTexture::validateDesc() const { |
| 51 if (this->asRenderTarget()) { | 55 if (this->asRenderTarget()) { |
| 52 // This texture has a render target | 56 // This texture has a render target |
| 53 SkASSERT(0 != (fDesc.fFlags & kRenderTarget_GrSurfaceFlag)); | 57 SkASSERT(0 != (fDesc.fFlags & kRenderTarget_GrSurfaceFlag)); |
| 54 SkASSERT(fDesc.fSampleCnt == this->asRenderTarget()->numColorSamples()); | 58 SkASSERT(fDesc.fSampleCnt == this->asRenderTarget()->numColorSamples()); |
| 55 } else { | 59 } else { |
| 56 SkASSERT(0 == (fDesc.fFlags & kRenderTarget_GrSurfaceFlag)); | 60 SkASSERT(0 == (fDesc.fFlags & kRenderTarget_GrSurfaceFlag)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 SkASSERT(desc.fWidth <= SK_MaxU16); | 106 SkASSERT(desc.fWidth <= SK_MaxU16); |
| 103 SkASSERT(desc.fHeight <= SK_MaxU16); | 107 SkASSERT(desc.fHeight <= SK_MaxU16); |
| 104 SkASSERT(static_cast<int>(desc.fConfig) < (1 << 6)); | 108 SkASSERT(static_cast<int>(desc.fConfig) < (1 << 6)); |
| 105 SkASSERT(desc.fSampleCnt < (1 << 8)); | 109 SkASSERT(desc.fSampleCnt < (1 << 8)); |
| 106 SkASSERT(flags < (1 << 10)); | 110 SkASSERT(flags < (1 << 10)); |
| 107 SkASSERT(static_cast<int>(origin) < (1 << 8)); | 111 SkASSERT(static_cast<int>(origin) < (1 << 8)); |
| 108 | 112 |
| 109 builder[0] = desc.fWidth | (desc.fHeight << 16); | 113 builder[0] = desc.fWidth | (desc.fHeight << 16); |
| 110 builder[1] = desc.fConfig | (desc.fSampleCnt << 6) | (flags << 14) | (origin
<< 24); | 114 builder[1] = desc.fConfig | (desc.fSampleCnt << 6) | (flags << 14) | (origin
<< 24); |
| 111 } | 115 } |
| OLD | NEW |