Index: src/gpu/draws/GrDraw.h |
diff --git a/src/gpu/draws/GrDraw.h b/src/gpu/draws/GrDraw.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..aaadeb4d43f491912630274e9396542c43bb2542 |
--- /dev/null |
+++ b/src/gpu/draws/GrDraw.h |
@@ -0,0 +1,74 @@ |
+/* |
+ * Copyright 2015 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#ifndef GrDraw_DEFINED |
+#define GrDraw_DEFINED |
+ |
+#include "GrNonAtomicRef.h" |
+ |
+#include "GrRenderTarget.h" |
+ |
+class GrDrawTarget; |
+ |
+#define GRDRAW_ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fContext) |
+ |
+/* |
+ * GrDraw is a virtual class which captures the scope of the entry point on SkGpuDevice where it |
+ * originates. After creation, it lives on the GrPipeline where it used as a potential fast path |
+ * for batching. |
bsalomon
2015/09/23 13:49:38
"fast path" needs some explanation. something abou
joshualitt
2015/09/25 18:17:12
Acknowledged.
|
+ * |
+ * A GrDraw must be able to fully draw itself if fastpath batching is not possible |
+ */ |
+ |
+class GrDraw { |
+public: |
+ GrDraw() : fClassID(kIllegalDrawClassID) {} |
+ virtual ~GrDraw() {} |
+ |
+ virtual void execute(GrDrawTarget*) const=0; |
robertphillips
2015/09/25 12:48:49
Some comments about how these class IDs work and w
joshualitt
2015/09/25 18:17:12
Acknowledged.
|
+ uint32_t classID() const { SkASSERT(!fClassID == kIllegalDrawClassID); return fClassID; } |
+ template <typename PROC_SUBCLASS> static uint32_t ClassID() { |
+ static uint32_t kClassID = GenID(&gCurrDrawClassID); |
+ return kClassID; |
+ } |
+ |
+protected: |
+ static uint32_t GenID(int32_t* idCounter) { |
+ // The atomic inc returns the old value not the incremented value. So we add |
+ // 1 to the returned value. |
+ uint32_t id = static_cast<uint32_t>(sk_atomic_inc(idCounter)) + 1; |
+ if (!id) { |
+ SkFAIL("This should never wrap as it should only be called once for each GrDraw " |
+ "subclass."); |
+ } |
+ return id; |
+ } |
+ |
+ enum { |
+ kIllegalDrawClassID = 0 |
+ }; |
+ |
+ static int32_t gCurrDrawClassID; |
robertphillips
2015/09/25 12:48:49
Do we need/even use 'fClassID'. Don't we just call
joshualitt
2015/09/25 18:17:12
Acknowledged.
|
+ uint32_t fClassID; |
+ |
+ friend class GrDrawSnap; // for class ID stuff |
+}; |
+ |
robertphillips
2015/09/25 12:48:48
I second the motion for a comment
joshualitt
2015/09/25 18:17:12
Acknowledged.
|
+class GrDrawSnap : public GrNonAtomicRef { |
bsalomon
2015/09/23 13:49:38
/** ... */
joshualitt
2015/09/25 18:17:12
Acknowledged.
|
+public: |
+ GrDrawSnap() : fClassID(GrDraw::kIllegalDrawClassID) {} |
+ uint32_t classID() const { |
robertphillips
2015/09/25 12:48:49
use != ?
|
+ SkASSERT(!fClassID == GrDraw::kIllegalDrawClassID); |
+ return fClassID; |
+ } |
+ |
+protected: |
+ uint32_t fClassID; |
+ typedef GrNonAtomicRef INHERITED; |
+}; |
+ |
+#endif |