| 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" |
| 11 | 11 |
| 12 #include "GrContext.h" | 12 #include "GrContext.h" |
| 13 #include "GrDrawContext.h" | 13 #include "GrDrawContext.h" |
| 14 #include "GrDrawTarget.h" |
| 14 #include "GrGpu.h" | 15 #include "GrGpu.h" |
| 15 #include "GrRenderTargetPriv.h" | 16 #include "GrRenderTargetPriv.h" |
| 16 #include "GrStencilAttachment.h" | 17 #include "GrStencilAttachment.h" |
| 17 | 18 |
| 18 void GrRenderTarget::discard() { | 19 void GrRenderTarget::discard() { |
| 19 // go through context so that all necessary flushing occurs | 20 // go through context so that all necessary flushing occurs |
| 20 GrContext* context = this->getContext(); | 21 GrContext* context = this->getContext(); |
| 21 if (!context) { | 22 if (!context) { |
| 22 return; | 23 return; |
| 23 } | 24 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 49 fResolveRect.setLargestInverted(); | 50 fResolveRect.setLargestInverted(); |
| 50 } else { | 51 } else { |
| 51 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) { | 52 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) { |
| 52 fResolveRect.setLargestInverted(); | 53 fResolveRect.setLargestInverted(); |
| 53 } | 54 } |
| 54 } | 55 } |
| 55 } | 56 } |
| 56 | 57 |
| 57 void GrRenderTarget::onRelease() { | 58 void GrRenderTarget::onRelease() { |
| 58 SkSafeSetNull(fStencilAttachment); | 59 SkSafeSetNull(fStencilAttachment); |
| 60 fLastDrawTarget = nullptr; |
| 59 | 61 |
| 60 INHERITED::onRelease(); | 62 INHERITED::onRelease(); |
| 61 } | 63 } |
| 62 | 64 |
| 63 void GrRenderTarget::onAbandon() { | 65 void GrRenderTarget::onAbandon() { |
| 64 SkSafeSetNull(fStencilAttachment); | 66 SkSafeSetNull(fStencilAttachment); |
| 67 fLastDrawTarget = nullptr; |
| 65 | 68 |
| 66 INHERITED::onAbandon(); | 69 INHERITED::onAbandon(); |
| 67 } | 70 } |
| 68 | 71 |
| 72 void GrRenderTarget::setLastDrawTarget(GrDrawTarget* dt) { |
| 73 if (fLastDrawTarget) { |
| 74 SkASSERT(fLastDrawTarget->isClosed()); |
| 75 } |
| 76 |
| 77 fLastDrawTarget = dt; |
| 78 } |
| 79 |
| 69 /////////////////////////////////////////////////////////////////////////////// | 80 /////////////////////////////////////////////////////////////////////////////// |
| 70 | 81 |
| 71 bool GrRenderTargetPriv::attachStencilAttachment(GrStencilAttachment* stencil) { | 82 bool GrRenderTargetPriv::attachStencilAttachment(GrStencilAttachment* stencil) { |
| 72 if (!stencil && !fRenderTarget->fStencilAttachment) { | 83 if (!stencil && !fRenderTarget->fStencilAttachment) { |
| 73 // No need to do any work since we currently don't have a stencil attach
ment and | 84 // No need to do any work since we currently don't have a stencil attach
ment and |
| 74 // we're not acctually adding one. | 85 // we're not acctually adding one. |
| 75 return true; | 86 return true; |
| 76 } | 87 } |
| 77 fRenderTarget->fStencilAttachment = stencil; | 88 fRenderTarget->fStencilAttachment = stencil; |
| 78 if (!fRenderTarget->completeStencilAttachment()) { | 89 if (!fRenderTarget->completeStencilAttachment()) { |
| 79 SkSafeSetNull(fRenderTarget->fStencilAttachment); | 90 SkSafeSetNull(fRenderTarget->fStencilAttachment); |
| 80 return false; | 91 return false; |
| 81 } | 92 } |
| 82 return true; | 93 return true; |
| 83 } | 94 } |
| OLD | NEW |