| 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 "GrDrawTargetCaps.h" | 10 #include "GrDrawTargetCaps.h" |
| 11 #include "GrGpu.h" | 11 #include "GrGpu.h" |
| 12 #include "GrResourceKey.h" | 12 #include "GrResourceKey.h" |
| 13 #include "GrRenderTarget.h" |
| 14 #include "GrRenderTargetPriv.h" |
| 13 #include "GrTexture.h" | 15 #include "GrTexture.h" |
| 14 #include "GrTexturePriv.h" | 16 #include "GrTexturePriv.h" |
| 15 | 17 |
| 16 void GrTexture::dirtyMipMaps(bool mipMapsDirty) { | 18 void GrTexture::dirtyMipMaps(bool mipMapsDirty) { |
| 17 if (mipMapsDirty) { | 19 if (mipMapsDirty) { |
| 18 if (kValid_MipMapsStatus == fMipMapsStatus) { | 20 if (kValid_MipMapsStatus == fMipMapsStatus) { |
| 19 fMipMapsStatus = kAllocated_MipMapsStatus; | 21 fMipMapsStatus = kAllocated_MipMapsStatus; |
| 20 } | 22 } |
| 21 } else { | 23 } else { |
| 22 const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus; | 24 const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 42 // we'd expect because we never change fDesc.fWidth/fHeight. | 44 // we'd expect because we never change fDesc.fWidth/fHeight. |
| 43 textureSize *= 2; | 45 textureSize *= 2; |
| 44 } | 46 } |
| 45 return textureSize; | 47 return textureSize; |
| 46 } | 48 } |
| 47 | 49 |
| 48 void GrTexture::validateDesc() const { | 50 void GrTexture::validateDesc() const { |
| 49 if (this->asRenderTarget()) { | 51 if (this->asRenderTarget()) { |
| 50 // This texture has a render target | 52 // This texture has a render target |
| 51 SkASSERT(0 != (fDesc.fFlags & kRenderTarget_GrSurfaceFlag)); | 53 SkASSERT(0 != (fDesc.fFlags & kRenderTarget_GrSurfaceFlag)); |
| 52 | |
| 53 if (this->asRenderTarget()->getStencilBuffer()) { | |
| 54 SkASSERT(0 != (fDesc.fFlags & kNoStencil_GrSurfaceFlag)); | |
| 55 } else { | |
| 56 SkASSERT(0 == (fDesc.fFlags & kNoStencil_GrSurfaceFlag)); | |
| 57 } | |
| 58 | |
| 59 SkASSERT(fDesc.fSampleCnt == this->asRenderTarget()->numSamples()); | 54 SkASSERT(fDesc.fSampleCnt == this->asRenderTarget()->numSamples()); |
| 60 } else { | 55 } else { |
| 61 SkASSERT(0 == (fDesc.fFlags & kRenderTarget_GrSurfaceFlag)); | 56 SkASSERT(0 == (fDesc.fFlags & kRenderTarget_GrSurfaceFlag)); |
| 62 SkASSERT(0 == (fDesc.fFlags & kNoStencil_GrSurfaceFlag)); | |
| 63 SkASSERT(0 == fDesc.fSampleCnt); | 57 SkASSERT(0 == fDesc.fSampleCnt); |
| 64 } | 58 } |
| 65 } | 59 } |
| 66 | 60 |
| 67 ////////////////////////////////////////////////////////////////////////////// | 61 ////////////////////////////////////////////////////////////////////////////// |
| 68 | 62 |
| 69 namespace { | 63 namespace { |
| 70 | 64 |
| 71 // FIXME: This should be refactored with the code in gl/GrGLGpu.cpp. | 65 // FIXME: This should be refactored with the code in gl/GrGLGpu.cpp. |
| 72 GrSurfaceOrigin resolve_origin(const GrSurfaceDesc& desc) { | 66 GrSurfaceOrigin resolve_origin(const GrSurfaceDesc& desc) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 SkASSERT(desc.fWidth <= SK_MaxU16); | 102 SkASSERT(desc.fWidth <= SK_MaxU16); |
| 109 SkASSERT(desc.fHeight <= SK_MaxU16); | 103 SkASSERT(desc.fHeight <= SK_MaxU16); |
| 110 SkASSERT(static_cast<int>(desc.fConfig) < (1 << 6)); | 104 SkASSERT(static_cast<int>(desc.fConfig) < (1 << 6)); |
| 111 SkASSERT(desc.fSampleCnt < (1 << 8)); | 105 SkASSERT(desc.fSampleCnt < (1 << 8)); |
| 112 SkASSERT(flags < (1 << 10)); | 106 SkASSERT(flags < (1 << 10)); |
| 113 SkASSERT(static_cast<int>(origin) < (1 << 8)); | 107 SkASSERT(static_cast<int>(origin) < (1 << 8)); |
| 114 | 108 |
| 115 builder[0] = desc.fWidth | (desc.fHeight << 16); | 109 builder[0] = desc.fWidth | (desc.fHeight << 16); |
| 116 builder[1] = desc.fConfig | (desc.fSampleCnt << 6) | (flags << 14) | (origin
<< 24); | 110 builder[1] = desc.fConfig | (desc.fSampleCnt << 6) | (flags << 14) | (origin
<< 24); |
| 117 } | 111 } |
| OLD | NEW |