OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "GrRenderTarget.h" | 9 #include "GrRenderTarget.h" |
10 | 10 |
11 #include "GrContext.h" | 11 #include "GrContext.h" |
| 12 #include "GrContextPriv.h" |
12 #include "GrDrawContext.h" | 13 #include "GrDrawContext.h" |
13 #include "GrDrawTarget.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 GrRenderTarget::~GrRenderTarget() { | 19 GrRenderTarget::~GrRenderTarget() { |
19 if (fLastDrawTarget) { | 20 if (fLastDrawTarget) { |
20 fLastDrawTarget->clearRT(); | 21 fLastDrawTarget->clearRT(); |
21 } | 22 } |
22 SkSafeUnref(fLastDrawTarget); | 23 SkSafeUnref(fLastDrawTarget); |
23 } | 24 } |
24 | 25 |
25 void GrRenderTarget::discard() { | 26 void GrRenderTarget::discard() { |
26 // go through context so that all necessary flushing occurs | 27 // go through context so that all necessary flushing occurs |
27 GrContext* context = this->getContext(); | 28 GrContext* context = this->getContext(); |
28 if (!context) { | 29 if (!context) { |
29 return; | 30 return; |
30 } | 31 } |
31 | 32 |
32 sk_sp<GrDrawContext> drawContext(context->makeDrawContext(sk_ref_sp(this), n
ullptr)); | 33 sk_sp<GrDrawContext> drawContext(context->contextPriv().makeWrappedDrawConte
xt(sk_ref_sp(this), |
| 34
nullptr)); |
33 if (!drawContext) { | 35 if (!drawContext) { |
34 return; | 36 return; |
35 } | 37 } |
36 | 38 |
37 drawContext->discard(); | 39 drawContext->discard(); |
38 } | 40 } |
39 | 41 |
40 void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) { | 42 void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) { |
41 if (kCanResolve_ResolveType == getResolveType()) { | 43 if (kCanResolve_ResolveType == getResolveType()) { |
42 if (rect) { | 44 if (rect) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 return fRenderTarget->getGpu()->getMultisampleSpecs(fRenderTarget, stencil); | 116 return fRenderTarget->getGpu()->getMultisampleSpecs(fRenderTarget, stencil); |
115 } | 117 } |
116 | 118 |
117 GrRenderTarget::SampleConfig GrRenderTarget::ComputeSampleConfig(const GrCaps& c
aps, | 119 GrRenderTarget::SampleConfig GrRenderTarget::ComputeSampleConfig(const GrCaps& c
aps, |
118 int sampleCnt)
{ | 120 int sampleCnt)
{ |
119 return (caps.usesMixedSamples() && sampleCnt > 0) | 121 return (caps.usesMixedSamples() && sampleCnt > 0) |
120 ? GrRenderTarget::kStencil_SampleConfig | 122 ? GrRenderTarget::kStencil_SampleConfig |
121 : GrRenderTarget::kUnified_SampleConfig; | 123 : GrRenderTarget::kUnified_SampleConfig; |
122 } | 124 } |
123 | 125 |
OLD | NEW |