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

Unified Diff: include/gpu/GrProgramResource.h

Issue 537773004: Add GrProgramElement base class for GrEffect with deferred exec ref. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 6 years, 3 months 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 | « include/gpu/GrProgramElementRef.h ('k') | src/gpu/GrProgramElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrProgramResource.h
diff --git a/include/gpu/GrProgramResource.h b/include/gpu/GrProgramResource.h
new file mode 100644
index 0000000000000000000000000000000000000000..277ae9dc620c6175a05d294a561091248deed5fa
--- /dev/null
+++ b/include/gpu/GrProgramResource.h
@@ -0,0 +1,73 @@
+/*
+ * 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 GrProgramResource_DEFINED
+#define GrProgramResource_DEFINED
+
+#include "SkRefCnt.h"
+
+class GrGpuResource;
+
+/**
+ * Class that wraps a resource referenced by a GrProgramElement or GrDrawState. It manages
+ * converting refs to pending io operations. Like SkAutoTUnref, its constructor and setter adopt
+ * a ref from their caller. This class is intended only for internal use in core Gr code.
+ */
+class GrProgramResource : SkNoncopyable {
+public:
+ enum IOType {
+ kRead_IOType,
+ kWrite_IOType,
+ kRW_IOType,
+
+ kNone_IOType, // For internal use only, don't specify to constructor or setResource().
+ };
+
+ SK_DECLARE_INST_COUNT_ROOT(GrProgramResource);
+ GrProgramResource();
+
+ /** Adopts a ref from the caller. ioType expresses what type of IO operations will be marked as
+ pending on the resource when markPendingIO is called. */
+ explicit GrProgramResource(GrGpuResource*, IOType ioType);
+
+ ~GrProgramResource();
+
+ GrGpuResource* getResource() const { return fResource; }
+
+ /** Adopts a ref from the caller. ioType expresses what type of IO operations will be marked as
+ pending on the resource when markPendingIO is called. */
+ void setResource(GrGpuResource*, IOType ioType);
+
+ /** Does this object own a pending read or write on the resource it is wrapping. */
+ bool ownsPendingIO() const { return fPendingIO; }
+
+ /** Shortcut for calling setResource() with NULL. It cannot be called after markingPendingIO
+ is called. */
+ void reset();
+
+private:
+ /** Called by owning GrProgramElement when the program element is first scheduled for
+ execution. */
+ void markPendingIO() const;
+
+ /** Called when the program element/draw state is no longer owned by GrDrawTarget-client code.
+ This lets the cache know that the drawing code will no longer schedule additional reads or
+ writes to the resource using the program element or draw state. */
+ void removeRef() const;
+
+ friend class GrDrawState;
+ friend class GrProgramElement;
+
+ GrGpuResource* fResource;
+ mutable bool fOwnRef;
+ mutable bool fPendingIO;
+ IOType fIOType;
+
+ typedef SkNoncopyable INHERITED;
+};
+
+#endif
« no previous file with comments | « include/gpu/GrProgramElementRef.h ('k') | src/gpu/GrProgramElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698