| Index: src/gpu/GrDrawTarget.cpp
|
| diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
|
| index 5a3feccc1753e44f8c57cfd0d45602dd0ef76c4d..7b1464ca7fb94d3151d785dc1c57d03e4eafd68a 100644
|
| --- a/src/gpu/GrDrawTarget.cpp
|
| +++ b/src/gpu/GrDrawTarget.cpp
|
| @@ -32,7 +32,7 @@
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| -GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider,
|
| +GrDrawTarget::GrDrawTarget(GrRenderTarget* rt, GrGpu* gpu, GrResourceProvider* resourceProvider,
|
| const Options& options)
|
| : fGpu(SkRef(gpu))
|
| , fResourceProvider(resourceProvider)
|
| @@ -40,7 +40,8 @@ GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider,
|
| , fFlushing(false)
|
| , fFirstUnpreparedBatch(0)
|
| , fFlags(0)
|
| - , fOptions(options) {
|
| + , fOptions(options)
|
| + , fRenderTarget(rt) {
|
| // TODO: Stop extracting the context (currently needed by GrClipMaskManager)
|
| fContext = fGpu->getContext();
|
| fClipMaskManager.reset(new GrClipMaskManager(this));
|
| @@ -52,6 +53,10 @@ GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider,
|
| }
|
|
|
| GrDrawTarget::~GrDrawTarget() {
|
| + if (fRenderTarget && this == fRenderTarget->getLastDrawTarget()) {
|
| + fRenderTarget->setLastDrawTarget(nullptr);
|
| + }
|
| +
|
| fGpu->unref();
|
| }
|
|
|
| @@ -184,7 +189,7 @@ void GrDrawTarget::flush() {
|
| // drawTargets will be created to replace them if the SkGpuDevice(s) write to them again.
|
| this->makeClosed();
|
|
|
| - // Loop over all batches and generate geometry
|
| + // Loop over the batches that haven't yet generated their geometry
|
| for (; fFirstUnpreparedBatch < fBatches.count(); ++fFirstUnpreparedBatch) {
|
| fBatches[fFirstUnpreparedBatch]->prepare(&fFlushState);
|
| }
|
| @@ -227,6 +232,11 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat
|
| return;
|
| }
|
|
|
| +#ifdef ENABLE_MDB
|
| + SkASSERT(fRenderTarget);
|
| + batch->pipeline()->addDependenciesTo(fRenderTarget);
|
| +#endif
|
| +
|
| this->recordBatch(batch);
|
| }
|
|
|
| @@ -455,6 +465,10 @@ void GrDrawTarget::copySurface(GrSurface* dst,
|
| const SkIPoint& dstPoint) {
|
| GrBatch* batch = GrCopySurfaceBatch::Create(dst, src, srcRect, dstPoint);
|
| if (batch) {
|
| +#ifdef ENABLE_MDB
|
| + this->addDependency(src);
|
| +#endif
|
| +
|
| this->recordBatch(batch);
|
| batch->unref();
|
| }
|
|
|