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/GrDrawBatch.h" | 16 #include "batches/GrDrawBatch.h" |
17 #include "batches/GrVertexBatch.h" | 17 #include "batches/GrVertexBatch.h" |
18 | 18 |
19 GrImmediateDrawTarget::GrImmediateDrawTarget(GrContext* context) | 19 GrImmediateDrawTarget::GrImmediateDrawTarget(GrContext* context) |
20 : INHERITED(context) | 20 : INHERITED(context) |
21 , fBatchTarget(this->getGpu()) | |
22 , fDrawID(0) { | 21 , fDrawID(0) { |
23 } | 22 } |
24 | 23 |
25 GrImmediateDrawTarget::~GrImmediateDrawTarget() { | 24 GrImmediateDrawTarget::~GrImmediateDrawTarget() { |
26 this->reset(); | 25 this->reset(); |
27 } | 26 } |
28 | 27 |
29 void GrImmediateDrawTarget::onDrawBatch(GrDrawBatch* batch) { | 28 void GrImmediateDrawTarget::onDrawBatch(GrDrawBatch* batch) { |
30 fBatchTarget.resetNumberOfDraws(); | |
31 | 29 |
| 30 #if 0 |
32 // TODO: encapsulate the specialization of GrVertexBatch in GrVertexBatch so
that we can | 31 // TODO: encapsulate the specialization of GrVertexBatch in GrVertexBatch so
that we can |
33 // remove this cast. Currently all GrDrawBatches are in fact GrVertexBatch. | 32 // remove this cast. Currently all GrDrawBatches are in fact GrVertexBatch. |
34 GrVertexBatch* vertexBatch = static_cast<GrVertexBatch*>(batch); | 33 GrVertexBatch* vertexBatch = static_cast<GrVertexBatch*>(batch); |
35 vertexBatch->generateGeometry(&fBatchTarget); | 34 vertexBatch->prepareDraws(&fBatchTarget); |
36 vertexBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); | 35 vertexBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); |
37 | 36 |
38 fBatchTarget.preFlush(); | 37 fBatchTarget.preFlush(); |
39 fBatchTarget.flushNext(vertexBatch->numberOfDraws()); | 38 fBatchTarget.flushNext(vertexBatch->numberOfDraws()); |
40 fBatchTarget.postFlush(); | 39 fBatchTarget.postFlush(); |
| 40 #endif |
41 } | 41 } |
42 | 42 |
43 void GrImmediateDrawTarget::onClear(const SkIRect& rect, GrColor color, | 43 void GrImmediateDrawTarget::onClear(const SkIRect& rect, GrColor color, |
44 GrRenderTarget* renderTarget) { | 44 GrRenderTarget* renderTarget) { |
45 this->getGpu()->clear(rect, color, renderTarget); | 45 this->getGpu()->clear(rect, color, renderTarget); |
46 } | 46 } |
47 | 47 |
48 void GrImmediateDrawTarget::onCopySurface(GrSurface* dst, | 48 void GrImmediateDrawTarget::onCopySurface(GrSurface* dst, |
49 GrSurface* src, | 49 GrSurface* src, |
50 const SkIRect& srcRect, | 50 const SkIRect& srcRect, |
51 const SkIPoint& dstPoint) { | 51 const SkIPoint& dstPoint) { |
52 this->getGpu()->copySurface(dst, src, srcRect, dstPoint); | 52 this->getGpu()->copySurface(dst, src, srcRect, dstPoint); |
53 } | 53 } |
54 | 54 |
55 void GrImmediateDrawTarget::clearStencilClip(const SkIRect& rect, | 55 void GrImmediateDrawTarget::clearStencilClip(const SkIRect& rect, |
56 bool insideClip, | 56 bool insideClip, |
57 GrRenderTarget* renderTarget) { | 57 GrRenderTarget* renderTarget) { |
58 this->getGpu()->clearStencilClip(rect, insideClip, renderTarget); | 58 this->getGpu()->clearStencilClip(rect, insideClip, renderTarget); |
59 } | 59 } |
60 | 60 |
61 void GrImmediateDrawTarget::discard(GrRenderTarget* renderTarget) { | 61 void GrImmediateDrawTarget::discard(GrRenderTarget* renderTarget) { |
62 if (!this->caps()->discardRenderTargetSupport()) { | 62 if (!this->caps()->discardRenderTargetSupport()) { |
63 return; | 63 return; |
64 } | 64 } |
65 | 65 |
66 this->getGpu()->discard(renderTarget); | 66 this->getGpu()->discard(renderTarget); |
67 } | 67 } |
68 | 68 |
69 void GrImmediateDrawTarget::onReset() { | 69 void GrImmediateDrawTarget::onReset() {} |
70 fBatchTarget.reset(); | |
71 } | |
72 | 70 |
73 void GrImmediateDrawTarget::onFlush() { | 71 void GrImmediateDrawTarget::onFlush() { |
74 ++fDrawID; | 72 ++fDrawID; |
75 } | 73 } |
OLD | NEW |