Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: src/gpu/GrPendingProgramElement.h

Issue 739673002: Create GrOptDrawState before recording draw in GrInOrderDrawBuffer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove unused function in pendingprogramelement Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrPendingFragmentStage.h ('k') | src/gpu/GrProcOptInfo.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrPendingProgramElement.h
diff --git a/src/gpu/GrPendingProgramElement.h b/src/gpu/GrPendingProgramElement.h
new file mode 100644
index 0000000000000000000000000000000000000000..7285ecba009bdb7e0c07a8a75e862741bf27d394
--- /dev/null
+++ b/src/gpu/GrPendingProgramElement.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrPendingProgramElement_DEFINED
+#define GrPendingProgramElement_DEFINED
+
+#include "SkRefCnt.h"
+#include "GrTypes.h"
+
+/**
+ * Helper for owning a pending execution on a GrProgramElement. Using this rather than ref allows
+ * resources that are owned by the program element to be correctly tracked as having pending reads
+ * and writes rather than refs.
+ */
+template <typename T> class GrPendingProgramElement : SkNoncopyable {
+public:
+ GrPendingProgramElement() : fObj(NULL) { };
+
+ // Adds a pending execution on obj.
+ explicit GrPendingProgramElement(T* obj) : fObj(obj) {
+ if (obj) {
+ obj->addPendingExecution();
+ }
+ }
+
+ void reset(T* obj) {
+ if (obj) {
+ obj->addPendingExecution();
+ }
+ if (fObj) {
+ fObj->completedExecution();
+ }
+ fObj = obj;
+ }
+
+ T* get() const { return fObj; }
+ operator T*() { return fObj; }
+
+ T *operator->() const { return fObj; }
+
+ ~GrPendingProgramElement() {
+ if (fObj) {
+ fObj->completedExecution();
+ }
+ }
+
+private:
+ T* fObj;
+
+ typedef SkNoncopyable INHERITED;
+};
+#endif
« no previous file with comments | « src/gpu/GrPendingFragmentStage.h ('k') | src/gpu/GrProcOptInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698