| 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 , 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(GrDrawBatch* batch) { | 28 void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch) { |
| 29 | 29 |
| 30 #if 0 | 30 #if 0 |
| 31 // 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 |
| 32 // remove this cast. Currently all GrDrawBatches are in fact GrVertexBatch. | 32 // remove this cast. Currently all GrDrawBatches are in fact GrVertexBatch. |
| 33 GrVertexBatch* vertexBatch = static_cast<GrVertexBatch*>(batch); | 33 GrVertexBatch* vertexBatch = static_cast<GrVertexBatch*>(batch); |
| 34 vertexBatch->prepareDraws(&fBatchTarget); | 34 vertexBatch->prepareDraws(&fBatchTarget); |
| 35 vertexBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); | 35 vertexBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); |
| 36 | 36 |
| 37 fBatchTarget.preFlush(); | 37 fBatchTarget.preFlush(); |
| 38 fBatchTarget.flushNext(vertexBatch->numberOfDraws()); | 38 fBatchTarget.flushNext(vertexBatch->numberOfDraws()); |
| 39 fBatchTarget.postFlush(); | 39 fBatchTarget.postFlush(); |
| 40 #endif | 40 #endif |
| 41 } | 41 } |
| 42 | 42 |
| 43 void GrImmediateDrawTarget::onClear(const SkIRect& rect, GrColor color, | |
| 44 GrRenderTarget* renderTarget) { | |
| 45 this->getGpu()->clear(rect, color, renderTarget); | |
| 46 } | |
| 47 | |
| 48 void GrImmediateDrawTarget::onCopySurface(GrSurface* dst, | 43 void GrImmediateDrawTarget::onCopySurface(GrSurface* dst, |
| 49 GrSurface* src, | 44 GrSurface* src, |
| 50 const SkIRect& srcRect, | 45 const SkIRect& srcRect, |
| 51 const SkIPoint& dstPoint) { | 46 const SkIPoint& dstPoint) { |
| 52 this->getGpu()->copySurface(dst, src, srcRect, dstPoint); | 47 this->getGpu()->copySurface(dst, src, srcRect, dstPoint); |
| 53 } | 48 } |
| 54 | 49 |
| 55 void GrImmediateDrawTarget::clearStencilClip(const SkIRect& rect, | 50 void GrImmediateDrawTarget::clearStencilClip(const SkIRect& rect, |
| 56 bool insideClip, | 51 bool insideClip, |
| 57 GrRenderTarget* renderTarget) { | 52 GrRenderTarget* renderTarget) { |
| 58 this->getGpu()->clearStencilClip(rect, insideClip, renderTarget); | 53 this->getGpu()->clearStencilClip(rect, insideClip, renderTarget); |
| 59 } | 54 } |
| 60 | 55 |
| 61 void GrImmediateDrawTarget::discard(GrRenderTarget* renderTarget) { | |
| 62 if (!this->caps()->discardRenderTargetSupport()) { | |
| 63 return; | |
| 64 } | |
| 65 | |
| 66 this->getGpu()->discard(renderTarget); | |
| 67 } | |
| 68 | |
| 69 void GrImmediateDrawTarget::onReset() {} | 56 void GrImmediateDrawTarget::onReset() {} |
| 70 | 57 |
| 71 void GrImmediateDrawTarget::onFlush() { | 58 void GrImmediateDrawTarget::onFlush() { |
| 72 ++fDrawID; | 59 ++fDrawID; |
| 73 } | 60 } |
| OLD | NEW |