aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrOpList.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-10-25 14:20:06 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-10-26 00:48:37 +0000
commitf2361d2d93c200cd4555b5e8ecea4531801abaaa (patch)
tree4f5cf70f8f805f3ef9447e24a48df5a97cbf5fce /src/gpu/GrOpList.cpp
parent618d304eb394d64779be0ecdc5eff898242faa8f (diff)
Add GrOpList and rename GrDrawTarget to GrRenderTargetOpList
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3910 Change-Id: I026aa26ecc61a0d002e98892dca728536259e8b1 Reviewed-on: https://skia-review.googlesource.com/3910 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrOpList.cpp')
-rw-r--r--src/gpu/GrOpList.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/gpu/GrOpList.cpp b/src/gpu/GrOpList.cpp
new file mode 100644
index 0000000000..ac7f1b274d
--- /dev/null
+++ b/src/gpu/GrOpList.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrOpList.h"
+
+#include "GrRenderTarget.h"
+#include "GrRenderTargetOpList.h"
+#include "GrSurface.h"
+
+GrOpList::GrOpList(GrSurface* surface)
+ : fFlags(0)
+ , fTarget(surface) {
+
+ surface->setLastOpList(this);
+
+#ifdef SK_DEBUG
+ static int debugID = 0;
+ fDebugID = debugID++;
+#endif
+}
+
+GrOpList::~GrOpList() {
+ if (fTarget && this == fTarget->getLastOpList()) {
+ fTarget->setLastOpList(nullptr);
+ }
+}
+
+// Add a GrOpList-based dependency
+void GrOpList::addDependency(GrOpList* dependedOn) {
+ SkASSERT(!dependedOn->dependsOn(this)); // loops are bad
+
+ if (this->dependsOn(dependedOn)) {
+ return; // don't add duplicate dependencies
+ }
+
+ *fDependencies.push() = dependedOn;
+}
+
+// Convert from a GrSurface-based dependency to a GrOpList one
+void GrOpList::addDependency(GrSurface* dependedOn) {
+ if (dependedOn->getLastOpList()) {
+ // If it is still receiving dependencies, this GrOpList shouldn't be closed
+ SkASSERT(!this->isClosed());
+
+ GrOpList* opList = dependedOn->getLastOpList();
+ if (opList == this) {
+ // self-read - presumably for dst reads
+ } else {
+ this->addDependency(opList);
+
+ // Can't make it closed in the self-read case
+ opList->makeClosed();
+ }
+ }
+}
+
+#ifdef SK_DEBUG
+void GrOpList::dump() const {
+ SkDebugf("--------------------------------------------------------------\n");
+ SkDebugf("node: %d -> RT: %d\n", fDebugID, fTarget ? fTarget->uniqueID() : -1);
+ SkDebugf("relies On (%d): ", fDependencies.count());
+ for (int i = 0; i < fDependencies.count(); ++i) {
+ SkDebugf("%d, ", fDependencies[i]->fDebugID);
+ }
+ SkDebugf("\n");
+}
+#endif