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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 if (fResolveRect.isEmpty()) { | 88 if (fResolveRect.isEmpty()) { |
89 fResolveRect.setLargestInverted(); | 89 fResolveRect.setLargestInverted(); |
90 } else { | 90 } else { |
91 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) { | 91 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) { |
92 fResolveRect.setLargestInverted(); | 92 fResolveRect.setLargestInverted(); |
93 } | 93 } |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 void GrRenderTarget::setStencilBuffer(GrStencilBuffer* stencilBuffer) { | 97 void GrRenderTarget::setStencilBuffer(GrStencilBuffer* stencilBuffer) { |
98 if (stencilBuffer == fStencilBuffer) { | 98 SkRefCnt_SafeAssign(fStencilBuffer, stencilBuffer); |
99 return; | |
100 } | |
101 | |
102 if (NULL != fStencilBuffer) { | |
103 fStencilBuffer->unref(); | |
104 | |
105 GrContext* context = this->getContext(); | |
106 if (NULL != context) { | |
107 context->purgeCache(); | |
108 } | |
109 | |
110 if (NULL != context) { | |
111 context->purgeCache(); | |
112 } | |
113 } | |
114 | |
115 fStencilBuffer = stencilBuffer; | |
116 | |
117 if (NULL != fStencilBuffer) { | |
118 fStencilBuffer->ref(); | |
119 } | |
120 } | 99 } |
121 | 100 |
122 void GrRenderTarget::onRelease() { | 101 void GrRenderTarget::onRelease() { |
123 this->setStencilBuffer(NULL); | 102 this->setStencilBuffer(NULL); |
124 | 103 |
125 INHERITED::onRelease(); | 104 INHERITED::onRelease(); |
126 } | 105 } |
127 | 106 |
128 void GrRenderTarget::onAbandon() { | 107 void GrRenderTarget::onAbandon() { |
129 this->setStencilBuffer(NULL); | 108 this->setStencilBuffer(NULL); |
130 | 109 |
131 INHERITED::onAbandon(); | 110 INHERITED::onAbandon(); |
132 } | 111 } |
OLD | NEW |