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

Unified Diff: src/gpu/draws/GrDraw.h

Issue 1336413006: Just an experiment (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 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 | « src/gpu/batches/GrRectBatchFactory.h ('k') | src/gpu/draws/GrDraw.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
+ *
+ * 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;
+ 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;
+ uint32_t fClassID;
+
+ friend class GrDrawSnap; // for class ID stuff
+};
+
+class GrDrawSnap : public GrNonAtomicRef {
+public:
+ GrDrawSnap() : fClassID(GrDraw::kIllegalDrawClassID) {}
+ uint32_t classID() const {
+ SkASSERT(!fClassID == GrDraw::kIllegalDrawClassID);
+ return fClassID;
+ }
+
+protected:
+ uint32_t fClassID;
+ typedef GrNonAtomicRef INHERITED;
+};
+
+#endif
« no previous file with comments | « src/gpu/batches/GrRectBatchFactory.h ('k') | src/gpu/draws/GrDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698