19
19
#include " src/gpu/GrAuditTrail.h"
20
20
#include " src/gpu/GrClientMappedBufferManager.h"
21
21
#include " src/gpu/GrCopyRenderTask.h"
22
+ #include " src/gpu/GrDDLTask.h"
22
23
#include " src/gpu/GrDirectContextPriv.h"
23
24
#include " src/gpu/GrGpu.h"
24
25
#include " src/gpu/GrMemoryPool.h"
38
39
#include " src/gpu/GrTextureResolveRenderTask.h"
39
40
#include " src/gpu/GrTracing.h"
40
41
#include " src/gpu/GrTransferFromRenderTask.h"
41
- #include " src/gpu/GrUnrefDDLTask.h"
42
42
#include " src/gpu/GrWaitRenderTask.h"
43
43
#include " src/gpu/ccpr/GrCoverageCountingPathRenderer.h"
44
44
#include " src/gpu/text/GrSDFTOptions.h"
@@ -48,7 +48,7 @@ void GrDrawingManager::RenderTaskDAG::gatherIDs(SkSTArray<8, uint32_t, true>* id
48
48
idArray->reset (fRenderTasks .count ());
49
49
for (int i = 0 ; i < fRenderTasks .count (); ++i) {
50
50
if (fRenderTasks [i]) {
51
- (*idArray)[i] = fRenderTasks [i]->uniqueID ( );
51
+ fRenderTasks [i]->gatherIDs (idArray );
52
52
}
53
53
}
54
54
}
@@ -464,8 +464,10 @@ void GrDrawingManager::removeRenderTasks(int startIndex, int stopIndex) {
464
464
if (!task) {
465
465
continue ;
466
466
}
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.
469
471
task->endFlush (this );
470
472
}
471
473
task->disown (this );
@@ -557,8 +559,8 @@ void GrDrawingManager::testingOnly_removeOnFlushCallbackObject(GrOnFlushCallback
557
559
558
560
void GrDrawingManager::setLastRenderTask (const GrSurfaceProxy* proxy, GrRenderTask* task) {
559
561
#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 );
562
564
}
563
565
#endif
564
566
uint32_t key = proxy->uniqueID ().asUInt ();
@@ -587,6 +589,8 @@ void GrDrawingManager::moveRenderTasksToDDL(SkDeferredDisplayList* ddl) {
587
589
fDAG .closeAll (fContext ->priv ().caps ());
588
590
fActiveOpsTask = nullptr ;
589
591
592
+ fDAG .prepForFlush ();
593
+
590
594
fDAG .swap (&ddl->fRenderTasks );
591
595
SkASSERT (!fDAG .numRenderTasks ());
592
596
@@ -608,8 +612,8 @@ void GrDrawingManager::moveRenderTasksToDDL(SkDeferredDisplayList* ddl) {
608
612
SkDEBUGCODE (this ->validate ());
609
613
}
610
614
611
- void GrDrawingManager::copyRenderTasksFromDDL (sk_sp<const SkDeferredDisplayList> ddl,
612
- GrRenderTargetProxy* newDest) {
615
+ void GrDrawingManager::createDDLTask (sk_sp<const SkDeferredDisplayList> ddl,
616
+ GrRenderTargetProxy* newDest) {
613
617
SkDEBUGCODE (this ->validate ());
614
618
615
619
if (fActiveOpsTask ) {
@@ -621,7 +625,7 @@ void GrDrawingManager::copyRenderTasksFromDDL(sk_sp<const SkDeferredDisplayList>
621
625
fActiveOpsTask = nullptr ;
622
626
}
623
627
624
- // Propagate the DDL proxy's state information to the replaying DDL .
628
+ // Propagate the DDL proxy's state information to the replay target .
625
629
if (ddl->priv ().targetProxy ()->isMSAADirty ()) {
626
630
newDest->markMSAADirty (ddl->priv ().targetProxy ()->msaaDirtyRect (),
627
631
ddl->characterization ().origin ());
@@ -634,7 +638,7 @@ void GrDrawingManager::copyRenderTasksFromDDL(sk_sp<const SkDeferredDisplayList>
634
638
this ->addDDLTarget (newDest, ddl->priv ().targetProxy ());
635
639
636
640
// 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.
638
642
ddl->fLazyProxyData ->fReplayDest = newDest;
639
643
640
644
if (ddl->fPendingPaths .size ()) {
@@ -643,11 +647,11 @@ void GrDrawingManager::copyRenderTasksFromDDL(sk_sp<const SkDeferredDisplayList>
643
647
ccpr->mergePendingPaths (ddl->fPendingPaths );
644
648
}
645
649
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 ());
651
655
652
656
SkDEBUGCODE (this ->validate ());
653
657
}
0 commit comments