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

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: rebase Created 5 years, 10 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
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrStencilBuffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 if (!this->caps()->reuseScratchTextures() && !isRT) { 74 if (!this->caps()->reuseScratchTextures() && !isRT) {
75 tex->cacheAccess().removeScratchKey(); 75 tex->cacheAccess().removeScratchKey();
76 } 76 }
77 return tex; 77 return tex;
78 } 78 }
79 79
80 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { 80 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt, bool budgeted) {
81 SkASSERT(NULL == rt->getStencilBuffer()); 81 SkASSERT(NULL == rt->getStencilBuffer());
82 GrScratchKey sbKey; 82 GrScratchKey sbKey;
83 GrStencilBuffer::ComputeKey(rt->width(), rt->height(), rt->numSamples(), &sb Key); 83 GrStencilBuffer::ComputeKey(rt->width(), rt->height(), rt->numSamples(), &sb Key);
84 SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>( 84 SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>(
85 this->getContext()->getResourceCache2()->findAndRefScratchResource(sbKey ))); 85 this->getContext()->getResourceCache2()->findAndRefScratchResource(sbKey )));
86 if (sb) { 86 if (sb) {
87 rt->setStencilBuffer(sb); 87 rt->setStencilBuffer(sb);
88 bool attached = this->attachStencilBufferToRenderTarget(sb, rt); 88 bool attached = this->attachStencilBufferToRenderTarget(sb, rt);
89 if (!attached) { 89 if (!attached) {
90 rt->setStencilBuffer(NULL); 90 rt->setStencilBuffer(NULL);
91 } 91 }
92 return attached; 92 return attached;
93 } 93 }
94 if (this->createStencilBufferForRenderTarget(rt, rt->width(), rt->height())) { 94 if (this->createStencilBufferForRenderTarget(rt, budgeted, rt->width(), rt-> height())) {
95 // Right now we're clearing the stencil buffer here after it is 95 // Right now we're clearing the stencil buffer here after it is
96 // attached to an RT for the first time. When we start matching 96 // attached to an RT for the first time. When we start matching
97 // stencil buffers with smaller color targets this will no longer 97 // stencil buffers with smaller color targets this will no longer
98 // be correct because it won't be guaranteed to clear the entire 98 // be correct because it won't be guaranteed to clear the entire
99 // sb. 99 // sb.
100 // We used to clear down in the GL subclass using a special purpose 100 // We used to clear down in the GL subclass using a special purpose
101 // FBO. But iOS doesn't allow a stencil-only FBO. It reports unsupported 101 // FBO. But iOS doesn't allow a stencil-only FBO. It reports unsupported
102 // FBO status. 102 // FBO status.
103 this->clearStencil(rt); 103 this->clearStencil(rt);
104 return true; 104 return true;
105 } else { 105 } else {
106 return false; 106 return false;
107 } 107 }
108 } 108 }
109 109
110 GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc) { 110 GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc) {
111 this->handleDirtyContext(); 111 this->handleDirtyContext();
112 GrTexture* tex = this->onWrapBackendTexture(desc); 112 GrTexture* tex = this->onWrapBackendTexture(desc);
113 if (NULL == tex) { 113 if (NULL == tex) {
114 return NULL; 114 return NULL;
115 } 115 }
116 // TODO: defer this and attach dynamically 116 // TODO: defer this and attach dynamically
117 GrRenderTarget* tgt = tex->asRenderTarget(); 117 GrRenderTarget* tgt = tex->asRenderTarget();
118 if (tgt && 118 if (tgt &&
119 !this->attachStencilBufferToRenderTarget(tgt)) { 119 !this->attachStencilBufferToRenderTarget(tgt, true /*budgeted*/)) {
120 tex->unref(); 120 tex->unref();
121 return NULL; 121 return NULL;
122 } else { 122 } else {
123 return tex; 123 return tex;
124 } 124 }
125 } 125 }
126 126
127 GrRenderTarget* GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc) { 127 GrRenderTarget* GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc) {
128 this->handleDirtyContext(); 128 this->handleDirtyContext();
129 return this->onWrapBackendRenderTarget(desc); 129 return this->onWrapBackendRenderTarget(desc);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 GrDrawTarget::PathIndexType indexType, 302 GrDrawTarget::PathIndexType indexType,
303 const float transformValues[], 303 const float transformValues[],
304 GrDrawTarget::PathTransformType transformType, 304 GrDrawTarget::PathTransformType transformType,
305 int count, 305 int count,
306 const GrStencilSettings& stencilSettings) { 306 const GrStencilSettings& stencilSettings) {
307 this->handleDirtyContext(); 307 this->handleDirtyContext();
308 pathRange->willDrawPaths(indices, indexType, count); 308 pathRange->willDrawPaths(indices, indexType, count);
309 this->onDrawPaths(args, pathRange, indices, indexType, transformValues, 309 this->onDrawPaths(args, pathRange, indices, indexType, transformValues,
310 transformType, count, stencilSettings); 310 transformType, count, stencilSettings);
311 } 311 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrStencilBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698