Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: src/gpu/GrGpu.cpp

Issue 859013002: Make stencil buffers uncached for uncached render target textures (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(), budgeted)) {
69 tex->unref(); 69 tex->unref();
70 return NULL; 70 return NULL;
71 } 71 }
72 } 72 }
73 } 73 }
74 return tex; 74 return tex;
75 } 75 }
76 76
77 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { 77 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt, bool budgeted) {
78 SkASSERT(NULL == rt->getStencilBuffer()); 78 SkASSERT(NULL == rt->getStencilBuffer());
79 GrScratchKey sbKey; 79 GrScratchKey sbKey;
80 GrStencilBuffer::ComputeKey(rt->width(), rt->height(), rt->numSamples(), &sb Key); 80 GrStencilBuffer::ComputeKey(rt->width(), rt->height(), rt->numSamples(), &sb Key);
81 SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>( 81 SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>(
82 this->getContext()->getResourceCache2()->findAndRefScratchResource(sbKey ))); 82 this->getContext()->getResourceCache2()->findAndRefScratchResource(sbKey )));
83 if (sb) { 83 if (sb) {
84 rt->setStencilBuffer(sb); 84 rt->setStencilBuffer(sb);
85 bool attached = this->attachStencilBufferToRenderTarget(sb, rt); 85 bool attached = this->attachStencilBufferToRenderTarget(sb, rt);
86 if (!attached) { 86 if (!attached) {
87 rt->setStencilBuffer(NULL); 87 rt->setStencilBuffer(NULL);
88 } 88 }
89 return attached; 89 return attached;
90 } 90 }
91 if (this->createStencilBufferForRenderTarget(rt, rt->width(), rt->height())) { 91 if (this->createStencilBufferForRenderTarget(rt, budgeted, rt->width(), rt-> height())) {
92 // Right now we're clearing the stencil buffer here after it is 92 // Right now we're clearing the stencil buffer here after it is
93 // attached to an RT for the first time. When we start matching 93 // attached to an RT for the first time. When we start matching
94 // stencil buffers with smaller color targets this will no longer 94 // stencil buffers with smaller color targets this will no longer
95 // be correct because it won't be guaranteed to clear the entire 95 // be correct because it won't be guaranteed to clear the entire
96 // sb. 96 // sb.
97 // We used to clear down in the GL subclass using a special purpose 97 // We used to clear down in the GL subclass using a special purpose
98 // FBO. But iOS doesn't allow a stencil-only FBO. It reports unsupported 98 // FBO. But iOS doesn't allow a stencil-only FBO. It reports unsupported
99 // FBO status. 99 // FBO status.
100 this->clearStencil(rt); 100 this->clearStencil(rt);
101 return true; 101 return true;
102 } else { 102 } else {
103 return false; 103 return false;
104 } 104 }
105 } 105 }
106 106
107 GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc) { 107 GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc) {
108 this->handleDirtyContext(); 108 this->handleDirtyContext();
109 GrTexture* tex = this->onWrapBackendTexture(desc); 109 GrTexture* tex = this->onWrapBackendTexture(desc);
110 if (NULL == tex) { 110 if (NULL == tex) {
111 return NULL; 111 return NULL;
112 } 112 }
113 // TODO: defer this and attach dynamically 113 // TODO: defer this and attach dynamically
114 GrRenderTarget* tgt = tex->asRenderTarget(); 114 GrRenderTarget* tgt = tex->asRenderTarget();
115 if (tgt && 115 if (tgt &&
116 !this->attachStencilBufferToRenderTarget(tgt)) { 116 !this->attachStencilBufferToRenderTarget(tgt, true /*budgeted*/)) {
117 tex->unref(); 117 tex->unref();
118 return NULL; 118 return NULL;
119 } else { 119 } else {
120 return tex; 120 return tex;
121 } 121 }
122 } 122 }
123 123
124 GrRenderTarget* GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc) { 124 GrRenderTarget* GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc) {
125 this->handleDirtyContext(); 125 this->handleDirtyContext();
126 return this->onWrapBackendRenderTarget(desc); 126 return this->onWrapBackendRenderTarget(desc);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 GrDrawTarget::PathIndexType indexType, 299 GrDrawTarget::PathIndexType indexType,
300 const float transformValues[], 300 const float transformValues[],
301 GrDrawTarget::PathTransformType transformType, 301 GrDrawTarget::PathTransformType transformType,
302 int count, 302 int count,
303 const GrStencilSettings& stencilSettings) { 303 const GrStencilSettings& stencilSettings) {
304 this->handleDirtyContext(); 304 this->handleDirtyContext();
305 pathRange->willDrawPaths(indices, indexType, count); 305 pathRange->willDrawPaths(indices, indexType, count);
306 this->onDrawPaths(ds, pathRange, indices, indexType, transformValues, 306 this->onDrawPaths(ds, pathRange, indices, indexType, transformValues,
307 transformType, count, stencilSettings); 307 transformType, count, stencilSettings);
308 } 308 }
OLDNEW
« src/gpu/GrGpu.h ('K') | « src/gpu/GrGpu.h ('k') | src/gpu/GrStencilBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698