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 GrXferProcessor& xp = *batch->pipeline()->getXferProcessor(); | |
30 GrRenderTarget* rt = batch->pipeline()->getRenderTarget(); | |
31 | |
32 GrXferBarrierType barrierType; | |
33 if (xp.willNeedXferBarrier(rt, *this->caps(), &barrierType)) { | |
34 this->getGpu()->xferBarrier(rt, barrierType); | |
35 } | |
36 | |
37 fBatchTarget.resetNumberOfDraws(); | 29 fBatchTarget.resetNumberOfDraws(); |
38 | 30 |
39 batch->generateGeometry(&fBatchTarget); | 31 batch->generateGeometry(&fBatchTarget); |
40 batch->setNumberOfDraws(fBatchTarget.numberOfDraws()); | 32 batch->setNumberOfDraws(fBatchTarget.numberOfDraws()); |
41 | 33 |
42 fBatchTarget.preFlush(); | 34 fBatchTarget.preFlush(); |
43 fBatchTarget.flushNext(batch->numberOfDraws()); | 35 fBatchTarget.flushNext(batch->numberOfDraws()); |
44 fBatchTarget.postFlush(); | 36 fBatchTarget.postFlush(); |
45 } | 37 } |
46 | 38 |
(...skipping 23 matching lines...) Expand all Loading... |
70 this->getGpu()->discard(renderTarget); | 62 this->getGpu()->discard(renderTarget); |
71 } | 63 } |
72 | 64 |
73 void GrImmediateDrawTarget::onReset() { | 65 void GrImmediateDrawTarget::onReset() { |
74 fBatchTarget.reset(); | 66 fBatchTarget.reset(); |
75 } | 67 } |
76 | 68 |
77 void GrImmediateDrawTarget::onFlush() { | 69 void GrImmediateDrawTarget::onFlush() { |
78 ++fDrawID; | 70 ++fDrawID; |
79 } | 71 } |
OLD | NEW |