Change UnrefDDLTask to just be the DDLTask
Change-Id: Ib5ff9f3f3d9cbc8860e3a2ba74e6da4355197662
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332600
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrDDLTask.cpp b/src/gpu/GrDDLTask.cpp
new file mode 100644
index 0000000..f665de3
--- /dev/null
+++ b/src/gpu/GrDDLTask.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "src/gpu/GrDDLTask.h"
+
+#include "include/core/SkDeferredDisplayList.h"
+#include "src/core/SkDeferredDisplayListPriv.h"
+#include "src/gpu/GrResourceAllocator.h"
+
+GrDDLTask::GrDDLTask(GrDrawingManager* drawingMgr,
+ sk_sp<GrRenderTargetProxy> ddlTarget,
+ sk_sp<const SkDeferredDisplayList> ddl)
+ : fDDL(std::move(ddl))
+ , fDDLTarget(std::move(ddlTarget)) {
+ for (auto& task : fDDL->priv().renderTasks()) {
+ SkASSERT(task->isClosed());
+
+ for (int i = 0; i < task->numTargets(); ++i) {
+ this->addTarget(drawingMgr, task->target(i));
+ }
+ }
+
+ // The DDL task never accepts additional tasks
+ this->setFlag(kClosed_Flag);
+}
+
+GrDDLTask::~GrDDLTask() { }
+
+void GrDDLTask::endFlush(GrDrawingManager* drawingManager) {
+ for (auto& task : fDDL->priv().renderTasks()) {
+ task->endFlush(drawingManager);
+ }
+
+ INHERITED::endFlush(drawingManager);
+}
+
+void GrDDLTask::disown(GrDrawingManager* drawingManager) {
+ for (auto& task : fDDL->priv().renderTasks()) {
+ task->disown(drawingManager);
+ }
+
+ INHERITED::disown(drawingManager);
+}
+
+bool GrDDLTask::onIsUsed(GrSurfaceProxy* proxy) const {
+ // In the ctor we've added all the targets from the sub-renderTasks into the targets list
+ // of the this task. The base class' 'isUsed' call checks those so we don't want to check
+ // them again here. The following 'onIsUsed' methods just check the other (non-target) proxies.
+ for (auto& task : fDDL->priv().renderTasks()) {
+ if (task->onIsUsed(proxy)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void GrDDLTask::handleInternalAllocationFailure() {
+ for (auto& task : fDDL->priv().renderTasks()) {
+ task->handleInternalAllocationFailure();
+ }
+}
+
+void GrDDLTask::gatherProxyIntervals(GrResourceAllocator* alloc) const {
+ // We don't have any proxies, but the resource allocator will still bark
+ // if a task doesn't claim any op indices, so we oblige it.
+ alloc->incOps();
+
+ for (auto& task : fDDL->priv().renderTasks()) {
+ task->gatherProxyIntervals(alloc);
+ }
+}
+
+GrRenderTask::ExpectedOutcome GrDDLTask::onMakeClosed(const GrCaps& caps,
+ SkIRect* targetUpdateBounds) {
+ SkASSERT(0);
+ return ExpectedOutcome::kTargetUnchanged;
+}
+
+void GrDDLTask::gatherIDs(SkSTArray<8, uint32_t, true>* idArray) const {
+ for (auto& task : fDDL->priv().renderTasks()) {
+ task->gatherIDs(idArray);
+ }
+}
+
+void GrDDLTask::onPrepare(GrOpFlushState* flushState) {
+ for (auto& task : fDDL->priv().renderTasks()) {
+ task->prepare(flushState);
+ }
+}
+
+bool GrDDLTask::onExecute(GrOpFlushState* flushState) {
+ bool anyCommandsIssued = false;
+ for (auto& task : fDDL->priv().renderTasks()) {
+ if (task->execute(flushState)) {
+ anyCommandsIssued = true;
+ }
+ }
+
+ return anyCommandsIssued;
+}