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

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

Issue 1355353002: Create GrDraw and start fast pathing src over rects (Closed) Base URL: https://skia.googlesource.com/skia.git@strokerect2
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/GrTInstanceBatch.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..4d45b9a58a199c73b5e591d2cbe4495fde038585
--- /dev/null
+++ b/src/gpu/draws/GrDraw.h
@@ -0,0 +1,80 @@
+/*
+ * 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 base class which captures the scope of the entry point on SkGpuDevice where it
+ * originates. The purpose of a GrDraw is to encapsulate a set of decisions about the type of
+ * GrBatch Ganesh will create for a given primitive. It is also responsible for transforming the
+ * SkPaint. A GrDraw should also leave some kind of GrDrawSnap on the GrBatch it creates, as a way
+ * for it to fastpath drawing decisions. In the fastpath case, a GrDraw should batch draw calls
+ * without transforming the SkPaint, by directly pushing new geometry onto existing GrBatches
+ *
+ * A GrDraw must be able to fully draw itself if fastpath batching is not possible.
+ *
+ * The only reason this base class exists is so that all GrDraw's have separate class IDs
+ */
+
+class GrDraw {
+public:
+ // Each derived class must have a unique class id. This is achieved by providing each
+ // derived class with a templatized version of ClassID() which uses the GrDraw-global
+ // gCurrDrawClassID counter.
+ 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;
+
+ friend class GrDrawSnap; // for class ID stuff
+};
+
+/*
+ * A GrDrawSnap is the marker a GrDraw can use to determine whether or not it can take a fastpath.
+ * After creation, a GrDrawSnap subclass will live directly on a GrBatch
+ */
+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/GrTInstanceBatch.h ('k') | src/gpu/draws/GrDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698