| 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(GrDrawBatch* batch) { |
| 29 fBatchTarget.resetNumberOfDraws(); | 29 fBatchTarget.resetNumberOfDraws(); |
| 30 | 30 |
| 31 batch->generateGeometry(&fBatchTarget); | 31 // TODO: encapsulate the specialization of GrVertexBatch in GrVertexBatch so
that we can |
| 32 batch->setNumberOfDraws(fBatchTarget.numberOfDraws()); | 32 // remove this cast. Currently all GrDrawBatches are in fact GrVertexBatch. |
| 33 GrVertexBatch* vertexBatch = static_cast<GrVertexBatch*>(batch); |
| 34 vertexBatch->generateGeometry(&fBatchTarget); |
| 35 vertexBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); |
| 33 | 36 |
| 34 fBatchTarget.preFlush(); | 37 fBatchTarget.preFlush(); |
| 35 fBatchTarget.flushNext(batch->numberOfDraws()); | 38 fBatchTarget.flushNext(vertexBatch->numberOfDraws()); |
| 36 fBatchTarget.postFlush(); | 39 fBatchTarget.postFlush(); |
| 37 } | 40 } |
| 38 | 41 |
| 39 void GrImmediateDrawTarget::onClear(const SkIRect& rect, GrColor color, | 42 void GrImmediateDrawTarget::onClear(const SkIRect& rect, GrColor color, |
| 40 GrRenderTarget* renderTarget) { | 43 GrRenderTarget* renderTarget) { |
| 41 this->getGpu()->clear(rect, color, renderTarget); | 44 this->getGpu()->clear(rect, color, renderTarget); |
| 42 } | 45 } |
| 43 | 46 |
| 44 void GrImmediateDrawTarget::onCopySurface(GrSurface* dst, | 47 void GrImmediateDrawTarget::onCopySurface(GrSurface* dst, |
| 45 GrSurface* src, | 48 GrSurface* src, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 62 this->getGpu()->discard(renderTarget); | 65 this->getGpu()->discard(renderTarget); |
| 63 } | 66 } |
| 64 | 67 |
| 65 void GrImmediateDrawTarget::onReset() { | 68 void GrImmediateDrawTarget::onReset() { |
| 66 fBatchTarget.reset(); | 69 fBatchTarget.reset(); |
| 67 } | 70 } |
| 68 | 71 |
| 69 void GrImmediateDrawTarget::onFlush() { | 72 void GrImmediateDrawTarget::onFlush() { |
| 70 ++fDrawID; | 73 ++fDrawID; |
| 71 } | 74 } |
| OLD | NEW |