| 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 "GrDrawTarget.h" |
| 15 #include "GrGpu.h" | 15 #include "GrGpu.h" |
| 16 #include "GrRenderTargetPriv.h" | 16 #include "GrRenderTargetPriv.h" |
| 17 #include "GrStencilAttachment.h" | 17 #include "GrStencilAttachment.h" |
| 18 | 18 |
| 19 GrRenderTarget::~GrRenderTarget() { | 19 GrRenderTarget::~GrRenderTarget() { |
| 20 if (fLastDrawTarget) { | 20 if (fLastDrawTarget) { |
| 21 fLastDrawTarget->clearRT(); | 21 fLastDrawTarget->clearRT(); |
| 22 } | 22 } |
| 23 SkSafeUnref(fLastDrawTarget); | 23 SkSafeUnref(fLastDrawTarget); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void GrRenderTarget::discard() { | 26 void GrRenderTarget::discard() { |
| 27 |
| 28 // since we're discarding we know we don't need the prior DC |
| 29 // TODO: we should be able to automatically know when a discard is possible: |
| 30 // once all pending reads are satisfied and there are no refs |
| 31 this->setFromRawPixels(false); |
| 27 // go through context so that all necessary flushing occurs | 32 // go through context so that all necessary flushing occurs |
| 28 GrContext* context = this->getContext(); | 33 GrContext* context = this->getContext(); |
| 29 if (!context) { | 34 if (!context) { |
| 30 return; | 35 return; |
| 31 } | 36 } |
| 32 | 37 |
| 33 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(this)); | 38 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(this)); |
| 34 if (!drawContext) { | 39 if (!drawContext) { |
| 35 return; | 40 return; |
| 36 } | 41 } |
| 37 | 42 |
| 38 drawContext->discard(); | 43 drawContext->discard(); |
| 44 |
| 45 this->setFromRawPixels(false); |
| 39 } | 46 } |
| 40 | 47 |
| 41 void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) { | 48 void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) { |
| 42 if (kCanResolve_ResolveType == getResolveType()) { | 49 if (kCanResolve_ResolveType == getResolveType()) { |
| 43 if (rect) { | 50 if (rect) { |
| 44 fResolveRect.join(*rect); | 51 fResolveRect.join(*rect); |
| 45 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) { | 52 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) { |
| 46 fResolveRect.setEmpty(); | 53 fResolveRect.setEmpty(); |
| 47 } | 54 } |
| 48 } else { | 55 } else { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // we're not acctually adding one. | 105 // we're not acctually adding one. |
| 99 return true; | 106 return true; |
| 100 } | 107 } |
| 101 fRenderTarget->fStencilAttachment = stencil; | 108 fRenderTarget->fStencilAttachment = stencil; |
| 102 if (!fRenderTarget->completeStencilAttachment()) { | 109 if (!fRenderTarget->completeStencilAttachment()) { |
| 103 SkSafeSetNull(fRenderTarget->fStencilAttachment); | 110 SkSafeSetNull(fRenderTarget->fStencilAttachment); |
| 104 return false; | 111 return false; |
| 105 } | 112 } |
| 106 return true; | 113 return true; |
| 107 } | 114 } |
| OLD | NEW |