OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "GrImmediateDrawTarget.h" | 8 #include "GrImmediateDrawTarget.h" |
9 | 9 |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
11 #include "GrPipeline.h" | 11 #include "GrPipeline.h" |
12 #include "GrRenderTarget.h" | 12 #include "GrRenderTarget.h" |
13 #include "SkRect.h" | 13 #include "SkRect.h" |
14 #include "SkTypes.h" | 14 #include "SkTypes.h" |
15 | 15 |
16 #include "batches/GrBatch.h" | 16 #include "batches/GrBatch.h" |
17 | 17 |
18 GrImmediateDrawTarget::GrImmediateDrawTarget(GrContext* context) | 18 GrImmediateDrawTarget::GrImmediateDrawTarget(GrContext* context) |
19 : INHERITED(context) | 19 : INHERITED(context) |
20 , fBatchTarget(this->getGpu()) | 20 , fBatchTarget(this->getGpu()) |
21 , fDrawID(0) { | 21 , fDrawID(0) { |
22 } | 22 } |
23 | 23 |
24 GrImmediateDrawTarget::~GrImmediateDrawTarget() { | 24 GrImmediateDrawTarget::~GrImmediateDrawTarget() { |
25 this->reset(); | 25 this->reset(); |
26 } | 26 } |
27 | 27 |
28 void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch, | 28 void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch, |
29 const PipelineInfo& pipelineInfo) { | 29 const PipelineInfo& pipelineInfo) { |
| 30 GrPipelineOptimizations opts; |
30 SkAlignedSStorage<sizeof(GrPipeline)> pipelineStorage; | 31 SkAlignedSStorage<sizeof(GrPipeline)> pipelineStorage; |
31 bool shouldDraw = this->setupPipelineAndShouldDraw(pipelineStorage.get(), pi
pelineInfo); | 32 bool shouldDraw = this->setupPipelineAndShouldDraw(pipelineStorage.get(), pi
pelineInfo, &opts); |
32 GrPipeline* pipeline = reinterpret_cast<GrPipeline*>(pipelineStorage.get()); | 33 GrPipeline* pipeline = reinterpret_cast<GrPipeline*>(pipelineStorage.get()); |
33 | 34 |
34 if (!shouldDraw) { | 35 if (!shouldDraw) { |
35 pipeline->~GrPipeline(); | 36 pipeline->~GrPipeline(); |
36 return; | 37 return; |
37 } | 38 } |
38 | 39 |
39 batch->initBatchTracker(pipeline->infoForPrimitiveProcessor()); | 40 batch->initBatchTracker(opts); |
40 | 41 |
41 fBatchTarget.resetNumberOfDraws(); | 42 fBatchTarget.resetNumberOfDraws(); |
42 | 43 |
43 batch->generateGeometry(&fBatchTarget); | 44 batch->generateGeometry(&fBatchTarget); |
44 batch->setNumberOfDraws(fBatchTarget.numberOfDraws()); | 45 batch->setNumberOfDraws(fBatchTarget.numberOfDraws()); |
45 | 46 |
46 fBatchTarget.preFlush(); | 47 fBatchTarget.preFlush(); |
47 fBatchTarget.flushNext(batch->numberOfDraws()); | 48 fBatchTarget.flushNext(batch->numberOfDraws()); |
48 fBatchTarget.postFlush(); | 49 fBatchTarget.postFlush(); |
49 | 50 |
(...skipping 29 matching lines...) Expand all Loading... |
79 void GrImmediateDrawTarget::onReset() { | 80 void GrImmediateDrawTarget::onReset() { |
80 fBatchTarget.reset(); | 81 fBatchTarget.reset(); |
81 } | 82 } |
82 | 83 |
83 void GrImmediateDrawTarget::onFlush() { | 84 void GrImmediateDrawTarget::onFlush() { |
84 ++fDrawID; | 85 ++fDrawID; |
85 } | 86 } |
86 | 87 |
87 bool | 88 bool |
88 GrImmediateDrawTarget::setupPipelineAndShouldDraw(void* pipelineAddr, | 89 GrImmediateDrawTarget::setupPipelineAndShouldDraw(void* pipelineAddr, |
89 const GrDrawTarget::PipelineIn
fo& pipelineInfo) { | 90 const GrDrawTarget::PipelineIn
fo& pipelineInfo, |
90 const GrPipeline* pipeline = this->setupPipeline(pipelineInfo, pipelineAddr)
; | 91 GrPipelineOptimizations* opts)
{ |
| 92 const GrPipeline* pipeline = this->setupPipeline(pipelineInfo, pipelineAddr,
opts); |
91 | 93 |
92 if (pipeline->mustSkip()) { | 94 if (pipeline->mustSkip()) { |
93 return false; | 95 return false; |
94 } | 96 } |
95 | 97 |
96 this->recordXferBarrierIfNecessary(pipeline); | 98 this->recordXferBarrierIfNecessary(pipeline); |
97 return true; | 99 return true; |
98 } | 100 } |
99 | 101 |
100 void GrImmediateDrawTarget::recordXferBarrierIfNecessary(const GrPipeline* pipel
ine) { | 102 void GrImmediateDrawTarget::recordXferBarrierIfNecessary(const GrPipeline* pipel
ine) { |
101 const GrXferProcessor& xp = *pipeline->getXferProcessor(); | 103 const GrXferProcessor& xp = *pipeline->getXferProcessor(); |
102 GrRenderTarget* rt = pipeline->getRenderTarget(); | 104 GrRenderTarget* rt = pipeline->getRenderTarget(); |
103 | 105 |
104 GrXferBarrierType barrierType; | 106 GrXferBarrierType barrierType; |
105 if (xp.willNeedXferBarrier(rt, *this->caps(), &barrierType)) { | 107 if (xp.willNeedXferBarrier(rt, *this->caps(), &barrierType)) { |
106 this->getGpu()->xferBarrier(rt, barrierType); | 108 this->getGpu()->xferBarrier(rt, barrierType); |
107 } | 109 } |
108 } | 110 } |
OLD | NEW |