| 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 22 matching lines...) Expand all Loading... |
| 33 void GrGpu::contextAbandoned() {} | 33 void GrGpu::contextAbandoned() {} |
| 34 | 34 |
| 35 //////////////////////////////////////////////////////////////////////////////// | 35 //////////////////////////////////////////////////////////////////////////////// |
| 36 | 36 |
| 37 GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, bool budgeted, | 37 GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, bool budgeted, |
| 38 const void* srcData, size_t rowBytes) { | 38 const void* srcData, size_t rowBytes) { |
| 39 if (!this->caps()->isConfigTexturable(desc.fConfig)) { | 39 if (!this->caps()->isConfigTexturable(desc.fConfig)) { |
| 40 return NULL; | 40 return NULL; |
| 41 } | 41 } |
| 42 | 42 |
| 43 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && | 43 bool isRT = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); |
| 44 !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { | 44 if (isRT && !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt
> 0)) { |
| 45 return NULL; | 45 return NULL; |
| 46 } | 46 } |
| 47 | 47 |
| 48 GrTexture *tex = NULL; | 48 GrTexture *tex = NULL; |
| 49 if (GrPixelConfigIsCompressed(desc.fConfig)) { | 49 if (GrPixelConfigIsCompressed(desc.fConfig)) { |
| 50 // We shouldn't be rendering into this | 50 // We shouldn't be rendering into this |
| 51 SkASSERT((desc.fFlags & kRenderTarget_GrSurfaceFlag) == 0); | 51 SkASSERT((desc.fFlags & kRenderTarget_GrSurfaceFlag) == 0); |
| 52 | 52 |
| 53 if (!this->caps()->npotTextureTileSupport() && | 53 if (!this->caps()->npotTextureTileSupport() && |
| 54 (!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) { | 54 (!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) { |
| 55 return NULL; | 55 return NULL; |
| 56 } | 56 } |
| 57 | 57 |
| 58 this->handleDirtyContext(); | 58 this->handleDirtyContext(); |
| 59 tex = this->onCreateCompressedTexture(desc, budgeted, srcData); | 59 tex = this->onCreateCompressedTexture(desc, budgeted, srcData); |
| 60 } else { | 60 } else { |
| 61 this->handleDirtyContext(); | 61 this->handleDirtyContext(); |
| 62 tex = this->onCreateTexture(desc, budgeted, srcData, rowBytes); | 62 tex = this->onCreateTexture(desc, budgeted, srcData, rowBytes); |
| 63 if (tex && | 63 if (tex && |
| 64 (kRenderTarget_GrSurfaceFlag & desc.fFlags) && | 64 (kRenderTarget_GrSurfaceFlag & desc.fFlags) && |
| 65 !(kNoStencil_GrSurfaceFlag & desc.fFlags)) { | 65 !(kNoStencil_GrSurfaceFlag & desc.fFlags)) { |
| 66 SkASSERT(tex->asRenderTarget()); | 66 SkASSERT(tex->asRenderTarget()); |
| 67 // TODO: defer this and attach dynamically | 67 // TODO: defer this and attach dynamically |
| 68 if (!this->attachStencilBufferToRenderTarget(tex->asRenderTarget()))
{ | 68 if (!this->attachStencilBufferToRenderTarget(tex->asRenderTarget()))
{ |
| 69 tex->unref(); | 69 tex->unref(); |
| 70 return NULL; | 70 return NULL; |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 if (!this->caps()->reuseScratchTextures() && !isRT) { |
| 75 tex->cacheAccess().removeScratchKey(); |
| 76 } |
| 74 return tex; | 77 return tex; |
| 75 } | 78 } |
| 76 | 79 |
| 77 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { | 80 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { |
| 78 SkASSERT(NULL == rt->getStencilBuffer()); | 81 SkASSERT(NULL == rt->getStencilBuffer()); |
| 79 GrScratchKey sbKey; | 82 GrScratchKey sbKey; |
| 80 GrStencilBuffer::ComputeKey(rt->width(), rt->height(), rt->numSamples(), &sb
Key); | 83 GrStencilBuffer::ComputeKey(rt->width(), rt->height(), rt->numSamples(), &sb
Key); |
| 81 SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>( | 84 SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>( |
| 82 this->getContext()->getResourceCache2()->findAndRefScratchResource(sbKey
))); | 85 this->getContext()->getResourceCache2()->findAndRefScratchResource(sbKey
))); |
| 83 if (sb) { | 86 if (sb) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 GrDrawTarget::PathIndexType indexType, | 302 GrDrawTarget::PathIndexType indexType, |
| 300 const float transformValues[], | 303 const float transformValues[], |
| 301 GrDrawTarget::PathTransformType transformType, | 304 GrDrawTarget::PathTransformType transformType, |
| 302 int count, | 305 int count, |
| 303 const GrStencilSettings& stencilSettings) { | 306 const GrStencilSettings& stencilSettings) { |
| 304 this->handleDirtyContext(); | 307 this->handleDirtyContext(); |
| 305 pathRange->willDrawPaths(indices, indexType, count); | 308 pathRange->willDrawPaths(indices, indexType, count); |
| 306 this->onDrawPaths(args, pathRange, indices, indexType, transformValues, | 309 this->onDrawPaths(args, pathRange, indices, indexType, transformValues, |
| 307 transformType, count, stencilSettings); | 310 transformType, count, stencilSettings); |
| 308 } | 311 } |
| OLD | NEW |