1919#include " src/gpu/GrAuditTrail.h"
2020#include " src/gpu/GrClientMappedBufferManager.h"
2121#include " src/gpu/GrCopyRenderTask.h"
22+ #include " src/gpu/GrDDLTask.h"
2223#include " src/gpu/GrDirectContextPriv.h"
2324#include " src/gpu/GrGpu.h"
2425#include " src/gpu/GrMemoryPool.h"
3839#include " src/gpu/GrTextureResolveRenderTask.h"
3940#include " src/gpu/GrTracing.h"
4041#include " src/gpu/GrTransferFromRenderTask.h"
41- #include " src/gpu/GrUnrefDDLTask.h"
4242#include " src/gpu/GrWaitRenderTask.h"
4343#include " src/gpu/ccpr/GrCoverageCountingPathRenderer.h"
4444#include " src/gpu/text/GrSDFTOptions.h"
@@ -48,7 +48,7 @@ void GrDrawingManager::RenderTaskDAG::gatherIDs(SkSTArray<8, uint32_t, true>* id
4848 idArray->reset (fRenderTasks .count ());
4949 for (int i = 0 ; i < fRenderTasks .count (); ++i) {
5050 if (fRenderTasks [i]) {
51- (*idArray)[i] = fRenderTasks [i]->uniqueID ( );
51+ fRenderTasks [i]->gatherIDs (idArray );
5252 }
5353 }
5454}
@@ -464,8 +464,10 @@ void GrDrawingManager::removeRenderTasks(int startIndex, int stopIndex) {
464464 if (!task) {
465465 continue ;
466466 }
467- if (!task->unique ()) {
468- // TODO: Eventually this should be guaranteed unique: http://skbug.com/7111
467+ if (!task->unique () || task->requiresExplicitCleanup ()) {
468+ // TODO: Eventually uniqueness should be guaranteed: http://skbug.com/7111.
469+ // DDLs, however, will always require an explicit notification for when they
470+ // can clean up resources.
469471 task->endFlush (this );
470472 }
471473 task->disown (this );
@@ -557,8 +559,8 @@ void GrDrawingManager::testingOnly_removeOnFlushCallbackObject(GrOnFlushCallback
557559
558560void GrDrawingManager::setLastRenderTask (const GrSurfaceProxy* proxy, GrRenderTask* task) {
559561#ifdef SK_DEBUG
560- if (GrRenderTask* prior = this ->getLastRenderTask (proxy)) {
561- SkASSERT (prior->isClosed ());
562+ if (auto prior = this ->getLastRenderTask (proxy)) {
563+ SkASSERT (prior->isClosed () || prior == task );
562564 }
563565#endif
564566 uint32_t key = proxy->uniqueID ().asUInt ();
@@ -587,6 +589,8 @@ void GrDrawingManager::moveRenderTasksToDDL(SkDeferredDisplayList* ddl) {
587589 fDAG .closeAll (fContext ->priv ().caps ());
588590 fActiveOpsTask = nullptr ;
589591
592+ fDAG .prepForFlush ();
593+
590594 fDAG .swap (&ddl->fRenderTasks );
591595 SkASSERT (!fDAG .numRenderTasks ());
592596
@@ -608,8 +612,8 @@ void GrDrawingManager::moveRenderTasksToDDL(SkDeferredDisplayList* ddl) {
608612 SkDEBUGCODE (this ->validate ());
609613}
610614
611- void GrDrawingManager::copyRenderTasksFromDDL (sk_sp<const SkDeferredDisplayList> ddl,
612- GrRenderTargetProxy* newDest) {
615+ void GrDrawingManager::createDDLTask (sk_sp<const SkDeferredDisplayList> ddl,
616+ GrRenderTargetProxy* newDest) {
613617 SkDEBUGCODE (this ->validate ());
614618
615619 if (fActiveOpsTask ) {
@@ -621,7 +625,7 @@ void GrDrawingManager::copyRenderTasksFromDDL(sk_sp<const SkDeferredDisplayList>
621625 fActiveOpsTask = nullptr ;
622626 }
623627
624- // Propagate the DDL proxy's state information to the replaying DDL .
628+ // Propagate the DDL proxy's state information to the replay target .
625629 if (ddl->priv ().targetProxy ()->isMSAADirty ()) {
626630 newDest->markMSAADirty (ddl->priv ().targetProxy ()->msaaDirtyRect (),
627631 ddl->characterization ().origin ());
@@ -634,7 +638,7 @@ void GrDrawingManager::copyRenderTasksFromDDL(sk_sp<const SkDeferredDisplayList>
634638 this ->addDDLTarget (newDest, ddl->priv ().targetProxy ());
635639
636640 // Here we jam the proxy that backs the current replay SkSurface into the LazyProxyData.
637- // The lazy proxy that references it (in the copied opsTasks) will steal its GrTexture.
641+ // The lazy proxy that references it (in the DDL opsTasks) will then steal its GrTexture.
638642 ddl->fLazyProxyData ->fReplayDest = newDest;
639643
640644 if (ddl->fPendingPaths .size ()) {
@@ -643,11 +647,11 @@ void GrDrawingManager::copyRenderTasksFromDDL(sk_sp<const SkDeferredDisplayList>
643647 ccpr->mergePendingPaths (ddl->fPendingPaths );
644648 }
645649
646- fDAG . add (ddl-> fRenderTasks );
647-
648- // Add a task to unref the DDL after flush.
649- GrRenderTask* unrefTask = fDAG . add (sk_make_sp<GrUnrefDDLTask>( std::move (ddl)));
650- unrefTask-> makeClosed (* fContext -> priv (). caps ());
650+ // Add a task to handle drawing and lifetime management of the DDL.
651+ SkDEBUGCODE ( auto ddlTask =) fDAG . add (sk_make_sp<GrDDLTask>( this ,
652+ sk_ref_sp (newDest),
653+ std::move (ddl)));
654+ SkASSERT (ddlTask-> isClosed ());
651655
652656 SkDEBUGCODE (this ->validate ());
653657}
0 commit comments