Consolidate GrDrawingManager <-> GrRenderTask lifecycle
This creates a funnel in the drawing manager (removeRenderTasks) that
opens the door for tighter integration between the two classes. Also we
add some assertions about the relationship and cut out duplicated code.
Bug: skia:10372
Change-Id: I0781ba7d45ac090cf7f6d430f0d56afe0f98b7e0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297195
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 5ae2684..df9bf30 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -58,7 +58,7 @@
fRenderTasks.reset();
}
-void GrDrawingManager::RenderTaskDAG::removeRenderTasks(int startIndex, int stopIndex) {
+void GrDrawingManager::RenderTaskDAG::rawRemoveRenderTasks(int startIndex, int stopIndex) {
for (int i = startIndex; i < stopIndex; ++i) {
fRenderTasks[i] = nullptr;
}
@@ -133,37 +133,13 @@
}
void GrDrawingManager::RenderTaskDAG::closeAll(const GrCaps* caps) {
- for (int i = 0; i < fRenderTasks.count(); ++i) {
- if (fRenderTasks[i]) {
- fRenderTasks[i]->makeClosed(*caps);
+ for (auto& task : fRenderTasks) {
+ if (task) {
+ task->makeClosed(*caps);
}
}
}
-void GrDrawingManager::RenderTaskDAG::cleanup(GrDrawingManager* drawingMgr, const GrCaps* caps) {
- for (int i = 0; i < fRenderTasks.count(); ++i) {
- if (!fRenderTasks[i]) {
- continue;
- }
-
- // no renderTask should receive a dependency
- fRenderTasks[i]->makeClosed(*caps);
-
- fRenderTasks[i]->disown(drawingMgr);
-
- // We shouldn't need to do this, but it turns out some clients still hold onto opsTasks
- // after a cleanup.
- // MDB TODO: is this still true?
- if (!fRenderTasks[i]->unique()) {
- // TODO: Eventually this should be guaranteed unique.
- // https://bugs.chromium.org/p/skia/issues/detail?id=7111
- fRenderTasks[i]->endFlush(drawingMgr);
- }
- }
-
- fRenderTasks.reset();
-}
-
///////////////////////////////////////////////////////////////////////////////////////////////////
GrDrawingManager::GrDrawingManager(GrRecordingContext* context,
const GrPathRendererChain::Options& optionsForPathRendererChain,
@@ -177,17 +153,9 @@
, fFlushing(false)
, fReduceOpsTaskSplitting(reduceOpsTaskSplitting) { }
-void GrDrawingManager::cleanup() {
- fDAG.cleanup(this, fContext->priv().caps());
-
- fPathRendererChain = nullptr;
- fSoftwarePathRenderer = nullptr;
-
- fOnFlushCBObjects.reset();
-}
-
GrDrawingManager::~GrDrawingManager() {
- this->cleanup();
+ fDAG.closeAll(fContext->priv().caps());
+ this->removeRenderTasks(0, fDAG.numRenderTasks());
}
bool GrDrawingManager::wasAbandoned() const {
@@ -360,6 +328,7 @@
}
renderTask->handleInternalAllocationFailure();
}
+ this->removeRenderTasks(startIndex, stopIndex);
}
if (this->executeRenderTasks(
@@ -371,10 +340,9 @@
#ifdef SK_DEBUG
for (int i = 0; i < fDAG.numRenderTasks(); ++i) {
- // If there are any remaining opsTaskss at this point, make sure they will not survive the
- // flush. Otherwise we need to call endFlush() on them.
- // http://skbug.com/7111
- SkASSERT(!fDAG.renderTask(i) || fDAG.renderTask(i)->unique());
+ // All render tasks should have been cleared out by now – we only reset the array below to
+ // reclaim storage.
+ SkASSERT(!fDAG.renderTask(i));
}
#endif
fLastRenderTasks.reset();
@@ -519,7 +487,7 @@
}
task->disown(this);
}
- fDAG.removeRenderTasks(startIndex, stopIndex);
+ fDAG.rawRemoveRenderTasks(startIndex, stopIndex);
}
static void resolve_and_mipmap(GrGpu* gpu, GrSurfaceProxy* proxy) {