| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 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 "GrGpu.h" | 10 #include "GrGpu.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 delete fVertexPool; | 54 delete fVertexPool; |
| 55 fVertexPool = NULL; | 55 fVertexPool = NULL; |
| 56 delete fIndexPool; | 56 delete fIndexPool; |
| 57 fIndexPool = NULL; | 57 fIndexPool = NULL; |
| 58 } | 58 } |
| 59 | 59 |
| 60 void GrGpu::contextAbandoned() {} | 60 void GrGpu::contextAbandoned() {} |
| 61 | 61 |
| 62 //////////////////////////////////////////////////////////////////////////////// | 62 //////////////////////////////////////////////////////////////////////////////// |
| 63 | 63 |
| 64 GrTexture* GrGpu::createTexture(const GrTextureDesc& desc, | 64 GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, |
| 65 const void* srcData, size_t rowBytes) { | 65 const void* srcData, size_t rowBytes) { |
| 66 if (!this->caps()->isConfigTexturable(desc.fConfig)) { | 66 if (!this->caps()->isConfigTexturable(desc.fConfig)) { |
| 67 return NULL; | 67 return NULL; |
| 68 } | 68 } |
| 69 | 69 |
| 70 if ((desc.fFlags & kRenderTarget_GrTextureFlagBit) && | 70 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && |
| 71 !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { | 71 !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { |
| 72 return NULL; | 72 return NULL; |
| 73 } | 73 } |
| 74 | 74 |
| 75 GrTexture *tex = NULL; | 75 GrTexture *tex = NULL; |
| 76 if (GrPixelConfigIsCompressed(desc.fConfig)) { | 76 if (GrPixelConfigIsCompressed(desc.fConfig)) { |
| 77 // We shouldn't be rendering into this | 77 // We shouldn't be rendering into this |
| 78 SkASSERT((desc.fFlags & kRenderTarget_GrTextureFlagBit) == 0); | 78 SkASSERT((desc.fFlags & kRenderTarget_GrSurfaceFlag) == 0); |
| 79 | 79 |
| 80 if (!this->caps()->npotTextureTileSupport() && | 80 if (!this->caps()->npotTextureTileSupport() && |
| 81 (!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) { | 81 (!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) { |
| 82 return NULL; | 82 return NULL; |
| 83 } | 83 } |
| 84 | 84 |
| 85 this->handleDirtyContext(); | 85 this->handleDirtyContext(); |
| 86 tex = this->onCreateCompressedTexture(desc, srcData); | 86 tex = this->onCreateCompressedTexture(desc, srcData); |
| 87 } else { | 87 } else { |
| 88 this->handleDirtyContext(); | 88 this->handleDirtyContext(); |
| 89 tex = this->onCreateTexture(desc, srcData, rowBytes); | 89 tex = this->onCreateTexture(desc, srcData, rowBytes); |
| 90 if (tex && | 90 if (tex && |
| 91 (kRenderTarget_GrTextureFlagBit & desc.fFlags) && | 91 (kRenderTarget_GrSurfaceFlag & desc.fFlags) && |
| 92 !(kNoStencil_GrTextureFlagBit & desc.fFlags)) { | 92 !(kNoStencil_GrSurfaceFlag & desc.fFlags)) { |
| 93 SkASSERT(tex->asRenderTarget()); | 93 SkASSERT(tex->asRenderTarget()); |
| 94 // TODO: defer this and attach dynamically | 94 // TODO: defer this and attach dynamically |
| 95 if (!this->attachStencilBufferToRenderTarget(tex->asRenderTarget()))
{ | 95 if (!this->attachStencilBufferToRenderTarget(tex->asRenderTarget()))
{ |
| 96 tex->unref(); | 96 tex->unref(); |
| 97 return NULL; | 97 return NULL; |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 return tex; | 101 return tex; |
| 102 } | 102 } |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 } | 533 } |
| 534 | 534 |
| 535 void GrGpu::releaseIndexArray() { | 535 void GrGpu::releaseIndexArray() { |
| 536 // if index source was array, we stowed data in the pool | 536 // if index source was array, we stowed data in the pool |
| 537 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 537 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
| 538 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); | 538 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); |
| 539 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); | 539 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
| 540 fIndexPool->putBack(bytes); | 540 fIndexPool->putBack(bytes); |
| 541 --fIndexPoolUseCnt; | 541 --fIndexPoolUseCnt; |
| 542 } | 542 } |
| OLD | NEW |