OLD | NEW |
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" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 if (fResolveRect.isEmpty()) { | 48 if (fResolveRect.isEmpty()) { |
49 fResolveRect.setLargestInverted(); | 49 fResolveRect.setLargestInverted(); |
50 } else { | 50 } else { |
51 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) { | 51 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) { |
52 fResolveRect.setLargestInverted(); | 52 fResolveRect.setLargestInverted(); |
53 } | 53 } |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 void GrRenderTarget::onRelease() { | 57 void GrRenderTarget::onRelease() { |
58 this->renderTargetPriv().didAttachStencilAttachment(nullptr); | 58 SkSafeSetNull(fStencilAttachment); |
59 | 59 |
60 INHERITED::onRelease(); | 60 INHERITED::onRelease(); |
61 } | 61 } |
62 | 62 |
63 void GrRenderTarget::onAbandon() { | 63 void GrRenderTarget::onAbandon() { |
64 this->renderTargetPriv().didAttachStencilAttachment(nullptr); | 64 SkSafeSetNull(fStencilAttachment); |
65 | 65 |
66 INHERITED::onAbandon(); | 66 INHERITED::onAbandon(); |
67 } | 67 } |
68 | 68 |
69 /////////////////////////////////////////////////////////////////////////////// | 69 /////////////////////////////////////////////////////////////////////////////// |
70 | 70 |
71 void GrRenderTargetPriv::didAttachStencilAttachment(GrStencilAttachment* stencil
Attachment) { | 71 bool GrRenderTargetPriv::attachStencilAttachment(GrStencilAttachment* stencil) { |
72 SkRefCnt_SafeAssign(fRenderTarget->fStencilAttachment, stencilAttachment); | 72 fRenderTarget->fStencilAttachment = stencil; |
| 73 if (!fRenderTarget->completeStencilAttachment()) { |
| 74 SkSafeSetNull(fRenderTarget->fStencilAttachment); |
| 75 return false; |
| 76 } |
| 77 return true; |
73 } | 78 } |
74 | |
75 GrStencilAttachment* GrRenderTargetPriv::attachStencilAttachment() const { | |
76 if (fRenderTarget->fStencilAttachment) { | |
77 return fRenderTarget->fStencilAttachment; | |
78 } | |
79 if (!fRenderTarget->wasDestroyed() && fRenderTarget->canAttemptStencilAttach
ment()) { | |
80 fRenderTarget->getGpu()->attachStencilAttachmentToRenderTarget(fRenderTa
rget); | |
81 } | |
82 return fRenderTarget->fStencilAttachment; | |
83 } | |
OLD | NEW |