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

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

Issue 938383004: Dynamically create stencil buffer when needed. (Closed) Base URL: https://skia.googlesource.com/skia.git@bigstencil
Patch Set: Actually save file before uploading 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.cpp ('k') | src/gpu/GrRenderTargetPriv.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 2011 Google Inc. 3 * Copyright 2011 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 "GrRenderTarget.h" 10 #include "GrRenderTarget.h"
11 11
12 #include "GrContext.h" 12 #include "GrContext.h"
13 #include "GrGpu.h" 13 #include "GrGpu.h"
14 #include "GrRenderTargetPriv.h"
14 #include "GrStencilBuffer.h" 15 #include "GrStencilBuffer.h"
15 16
16 void GrRenderTarget::discard() { 17 void GrRenderTarget::discard() {
17 // go through context so that all necessary flushing occurs 18 // go through context so that all necessary flushing occurs
18 GrContext* context = this->getContext(); 19 GrContext* context = this->getContext();
19 if (NULL == context) { 20 if (NULL == context) {
20 return; 21 return;
21 } 22 }
22 context->discardRenderTarget(this); 23 context->discardRenderTarget(this);
23 } 24 }
(...skipping 15 matching lines...) Expand all
39 fResolveRect = rect; 40 fResolveRect = rect;
40 if (fResolveRect.isEmpty()) { 41 if (fResolveRect.isEmpty()) {
41 fResolveRect.setLargestInverted(); 42 fResolveRect.setLargestInverted();
42 } else { 43 } else {
43 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) { 44 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) {
44 fResolveRect.setLargestInverted(); 45 fResolveRect.setLargestInverted();
45 } 46 }
46 } 47 }
47 } 48 }
48 49
49 void GrRenderTarget::setStencilBuffer(GrStencilBuffer* stencilBuffer) {
50 SkRefCnt_SafeAssign(fStencilBuffer, stencilBuffer);
51 }
52
53 void GrRenderTarget::onRelease() { 50 void GrRenderTarget::onRelease() {
54 this->setStencilBuffer(NULL); 51 this->renderTargetPriv().didAttachStencilBuffer(NULL);
55 52
56 INHERITED::onRelease(); 53 INHERITED::onRelease();
57 } 54 }
58 55
59 void GrRenderTarget::onAbandon() { 56 void GrRenderTarget::onAbandon() {
60 this->setStencilBuffer(NULL); 57 this->renderTargetPriv().didAttachStencilBuffer(NULL);
61 58
62 INHERITED::onAbandon(); 59 INHERITED::onAbandon();
63 } 60 }
61
62 ///////////////////////////////////////////////////////////////////////////////
63
64 void GrRenderTargetPriv::didAttachStencilBuffer(GrStencilBuffer* stencilBuffer) {
65 SkRefCnt_SafeAssign(fRenderTarget->fStencilBuffer, stencilBuffer);
66 }
67
68 GrStencilBuffer* GrRenderTargetPriv::attachStencilBuffer() const {
69 if (fRenderTarget->fStencilBuffer) {
70 return fRenderTarget->fStencilBuffer;
71 }
72 if (!fRenderTarget->wasDestroyed() && fRenderTarget->canAttemptStencilAttach ment()) {
73 fRenderTarget->getGpu()->attachStencilBufferToRenderTarget(fRenderTarget );
74 }
75 return fRenderTarget->fStencilBuffer;
76 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrRenderTargetPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698