| 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" |
| 11 | 11 |
| 12 #include "GrBufferAllocPool.h" | 12 #include "GrBufferAllocPool.h" |
| 13 #include "GrContext.h" | 13 #include "GrContext.h" |
| 14 #include "GrDrawTargetCaps.h" | 14 #include "GrDrawTargetCaps.h" |
| 15 #include "GrGpuResourcePriv.h" | 15 #include "GrGpuResourcePriv.h" |
| 16 #include "GrIndexBuffer.h" | 16 #include "GrIndexBuffer.h" |
| 17 #include "GrResourceCache.h" | 17 #include "GrResourceCache.h" |
| 18 #include "GrRenderTargetPriv.h" | 18 #include "GrRenderTargetPriv.h" |
| 19 #include "GrStencilBuffer.h" | 19 #include "GrStencilAttachment.h" |
| 20 #include "GrVertexBuffer.h" | 20 #include "GrVertexBuffer.h" |
| 21 | 21 |
| 22 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
| 23 | 23 |
| 24 GrGpu::GrGpu(GrContext* context) | 24 GrGpu::GrGpu(GrContext* context) |
| 25 : fResetTimestamp(kExpiredTimestamp+1) | 25 : fResetTimestamp(kExpiredTimestamp+1) |
| 26 , fResetBits(kAll_GrBackendState) | 26 , fResetBits(kAll_GrBackendState) |
| 27 , fQuadIndexBuffer(NULL) | 27 , fQuadIndexBuffer(NULL) |
| 28 , fGpuTraceMarkerCount(0) | 28 , fGpuTraceMarkerCount(0) |
| 29 , fContext(context) { | 29 , fContext(context) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 if (tex) { | 70 if (tex) { |
| 71 fStats.incTextureCreates(); | 71 fStats.incTextureCreates(); |
| 72 if (srcData) { | 72 if (srcData) { |
| 73 fStats.incTextureUploads(); | 73 fStats.incTextureUploads(); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 return tex; | 76 return tex; |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { | 79 bool GrGpu::attachStencilAttachmentToRenderTarget(GrRenderTarget* rt) { |
| 80 SkASSERT(NULL == rt->renderTargetPriv().getStencilBuffer()); | 80 SkASSERT(NULL == rt->renderTargetPriv().getStencilAttachment()); |
| 81 GrUniqueKey sbKey; | 81 GrUniqueKey sbKey; |
| 82 | 82 |
| 83 int width = rt->width(); | 83 int width = rt->width(); |
| 84 int height = rt->height(); | 84 int height = rt->height(); |
| 85 #if 0 | 85 #if 0 |
| 86 if (this->caps()->oversizedStencilSupport()) { | 86 if (this->caps()->oversizedStencilSupport()) { |
| 87 width = SkNextPow2(width); | 87 width = SkNextPow2(width); |
| 88 height = SkNextPow2(height); | 88 height = SkNextPow2(height); |
| 89 } | 89 } |
| 90 #endif | 90 #endif |
| 91 | 91 |
| 92 GrStencilBuffer::ComputeSharedStencilBufferKey(width, height, rt->numSamples
(), &sbKey); | 92 GrStencilAttachment::ComputeSharedStencilAttachmentKey(width, height, rt->nu
mSamples(), &sbKey); |
| 93 SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>( | 93 SkAutoTUnref<GrStencilAttachment> sb(static_cast<GrStencilAttachment*>( |
| 94 this->getContext()->getResourceCache()->findAndRefUniqueResource(sbKey))
); | 94 this->getContext()->getResourceCache()->findAndRefUniqueResource(sbKey))
); |
| 95 if (sb) { | 95 if (sb) { |
| 96 if (this->attachStencilBufferToRenderTarget(sb, rt)) { | 96 if (this->attachStencilAttachmentToRenderTarget(sb, rt)) { |
| 97 rt->renderTargetPriv().didAttachStencilBuffer(sb); | 97 rt->renderTargetPriv().didAttachStencilAttachment(sb); |
| 98 return true; | 98 return true; |
| 99 } | 99 } |
| 100 return false; | 100 return false; |
| 101 } | 101 } |
| 102 if (this->createStencilBufferForRenderTarget(rt, width, height)) { | 102 if (this->createStencilAttachmentForRenderTarget(rt, width, height)) { |
| 103 // Right now we're clearing the stencil buffer here after it is | 103 // Right now we're clearing the stencil buffer here after it is |
| 104 // attached to an RT for the first time. When we start matching | 104 // attached to an RT for the first time. When we start matching |
| 105 // stencil buffers with smaller color targets this will no longer | 105 // stencil buffers with smaller color targets this will no longer |
| 106 // be correct because it won't be guaranteed to clear the entire | 106 // be correct because it won't be guaranteed to clear the entire |
| 107 // sb. | 107 // sb. |
| 108 // We used to clear down in the GL subclass using a special purpose | 108 // We used to clear down in the GL subclass using a special purpose |
| 109 // FBO. But iOS doesn't allow a stencil-only FBO. It reports unsupported | 109 // FBO. But iOS doesn't allow a stencil-only FBO. It reports unsupported |
| 110 // FBO status. | 110 // FBO status. |
| 111 this->clearStencil(rt); | 111 this->clearStencil(rt); |
| 112 GrStencilBuffer* sb = rt->renderTargetPriv().getStencilBuffer(); | 112 GrStencilAttachment* sb = rt->renderTargetPriv().getStencilAttachment(); |
| 113 sb->resourcePriv().setUniqueKey(sbKey); | 113 sb->resourcePriv().setUniqueKey(sbKey); |
| 114 return true; | 114 return true; |
| 115 } else { | 115 } else { |
| 116 return false; | 116 return false; |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc) { | 120 GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc) { |
| 121 this->handleDirtyContext(); | 121 this->handleDirtyContext(); |
| 122 GrTexture* tex = this->onWrapBackendTexture(desc); | 122 GrTexture* tex = this->onWrapBackendTexture(desc); |
| 123 if (NULL == tex) { | 123 if (NULL == tex) { |
| 124 return NULL; | 124 return NULL; |
| 125 } | 125 } |
| 126 // TODO: defer this and attach dynamically | 126 // TODO: defer this and attach dynamically |
| 127 GrRenderTarget* tgt = tex->asRenderTarget(); | 127 GrRenderTarget* tgt = tex->asRenderTarget(); |
| 128 if (tgt && !this->attachStencilBufferToRenderTarget(tgt)) { | 128 if (tgt && !this->attachStencilAttachmentToRenderTarget(tgt)) { |
| 129 tex->unref(); | 129 tex->unref(); |
| 130 return NULL; | 130 return NULL; |
| 131 } else { | 131 } else { |
| 132 return tex; | 132 return tex; |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 GrRenderTarget* GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc&
desc) { | 136 GrRenderTarget* GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc&
desc) { |
| 137 this->handleDirtyContext(); | 137 this->handleDirtyContext(); |
| 138 return this->onWrapBackendRenderTarget(desc); | 138 return this->onWrapBackendRenderTarget(desc); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 GrDrawTarget::PathIndexType indexType, | 315 GrDrawTarget::PathIndexType indexType, |
| 316 const float transformValues[], | 316 const float transformValues[], |
| 317 GrDrawTarget::PathTransformType transformType, | 317 GrDrawTarget::PathTransformType transformType, |
| 318 int count, | 318 int count, |
| 319 const GrStencilSettings& stencilSettings) { | 319 const GrStencilSettings& stencilSettings) { |
| 320 this->handleDirtyContext(); | 320 this->handleDirtyContext(); |
| 321 pathRange->willDrawPaths(indices, indexType, count); | 321 pathRange->willDrawPaths(indices, indexType, count); |
| 322 this->onDrawPaths(args, pathRange, indices, indexType, transformValues, | 322 this->onDrawPaths(args, pathRange, indices, indexType, transformValues, |
| 323 transformType, count, stencilSettings); | 323 transformType, count, stencilSettings); |
| 324 } | 324 } |
| OLD | NEW |