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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 if (srcData) { | 80 if (srcData) { |
81 fStats.incTextureUploads(); | 81 fStats.incTextureUploads(); |
82 } | 82 } |
83 } | 83 } |
84 return tex; | 84 return tex; |
85 } | 85 } |
86 | 86 |
87 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { | 87 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { |
88 SkASSERT(NULL == rt->getStencilBuffer()); | 88 SkASSERT(NULL == rt->getStencilBuffer()); |
89 GrUniqueKey sbKey; | 89 GrUniqueKey sbKey; |
90 GrStencilBuffer::ComputeSharedStencilBufferKey(rt->width(), rt->height(), rt
->numSamples(), | 90 |
91 &sbKey); | 91 int width = rt->width(); |
| 92 int height = rt->height(); |
| 93 if (this->caps()->oversizedStencilSupport()) { |
| 94 width = SkNextPow2(width); |
| 95 height = SkNextPow2(height); |
| 96 } |
| 97 |
| 98 GrStencilBuffer::ComputeSharedStencilBufferKey(width, height, rt->numSamples
(), &sbKey); |
92 SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>( | 99 SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>( |
93 this->getContext()->getResourceCache()->findAndRefUniqueResource(sbKey))
); | 100 this->getContext()->getResourceCache()->findAndRefUniqueResource(sbKey))
); |
94 if (sb) { | 101 if (sb) { |
95 rt->setStencilBuffer(sb); | 102 rt->setStencilBuffer(sb); |
96 bool attached = this->attachStencilBufferToRenderTarget(sb, rt); | 103 bool attached = this->attachStencilBufferToRenderTarget(sb, rt); |
97 if (!attached) { | 104 if (!attached) { |
98 rt->setStencilBuffer(NULL); | 105 rt->setStencilBuffer(NULL); |
99 } | 106 } |
100 return attached; | 107 return attached; |
101 } | 108 } |
102 if (this->createStencilBufferForRenderTarget(rt, rt->width(), rt->height()))
{ | 109 if (this->createStencilBufferForRenderTarget(rt, width, height)) { |
103 // Right now we're clearing the stencil buffer here after it is | 110 // 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 | 111 // attached to an RT for the first time. When we start matching |
105 // stencil buffers with smaller color targets this will no longer | 112 // stencil buffers with smaller color targets this will no longer |
106 // be correct because it won't be guaranteed to clear the entire | 113 // be correct because it won't be guaranteed to clear the entire |
107 // sb. | 114 // sb. |
108 // We used to clear down in the GL subclass using a special purpose | 115 // 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 | 116 // FBO. But iOS doesn't allow a stencil-only FBO. It reports unsupported |
110 // FBO status. | 117 // FBO status. |
111 this->clearStencil(rt); | 118 this->clearStencil(rt); |
112 rt->getStencilBuffer()->resourcePriv().setUniqueKey(sbKey); | 119 rt->getStencilBuffer()->resourcePriv().setUniqueKey(sbKey); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 GrDrawTarget::PathIndexType indexType, | 321 GrDrawTarget::PathIndexType indexType, |
315 const float transformValues[], | 322 const float transformValues[], |
316 GrDrawTarget::PathTransformType transformType, | 323 GrDrawTarget::PathTransformType transformType, |
317 int count, | 324 int count, |
318 const GrStencilSettings& stencilSettings) { | 325 const GrStencilSettings& stencilSettings) { |
319 this->handleDirtyContext(); | 326 this->handleDirtyContext(); |
320 pathRange->willDrawPaths(indices, indexType, count); | 327 pathRange->willDrawPaths(indices, indexType, count); |
321 this->onDrawPaths(args, pathRange, indices, indexType, transformValues, | 328 this->onDrawPaths(args, pathRange, indices, indexType, transformValues, |
322 transformType, count, stencilSettings); | 329 transformType, count, stencilSettings); |
323 } | 330 } |
OLD | NEW |