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

Unified Diff: include/gpu/GrGeometryProcessor.h

Issue 582963002: Solo gp (Closed) Base URL: https://skia.googlesource.com/skia.git@no_peb
Patch Set: feddback inc 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/GrEffectUnitTest.h ('k') | include/gpu/GrPaint.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrGeometryProcessor.h
diff --git a/include/gpu/GrGeometryProcessor.h b/include/gpu/GrGeometryProcessor.h
new file mode 100644
index 0000000000000000000000000000000000000000..656398fe3f63b2d286e145ede24bef4878b2e771
--- /dev/null
+++ b/include/gpu/GrGeometryProcessor.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGeometryProcessor_DEFINED
+#define GrGeometryProcessor_DEFINED
+
+#include "GrProcessor.h"
+class GrBackendGeometryProcessorFactory;
+
+/**
+ * A GrGeomteryProcessor is used to perform computation in the vertex shader and
+ * add support for custom vertex attributes. A GrGemeotryProcessor is typically
+ * tied to the code that does a specific type of high-level primitive rendering
+ * (e.g. anti-aliased circle rendering). The GrGeometryProcessor used for a draw is
+ * specified using GrDrawState. There can only be one geometry processor active for
+ * a draw. The custom vertex attributes required by the geometry processor must be
+ * added to the vertex attribute array specified on the GrDrawState.
+ * GrGeometryProcessor subclasses should be immutable after construction.
+ */
+class GrGeometryProcessor : public GrProcessor {
+public:
+ GrGeometryProcessor() {}
+
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const = 0;
+
+ /*
+ * This only has a max because GLProgramsTest needs to generate test arrays, and these have to
+ * be static
+ * TODO make this truly dynamic
+ */
+ static const int kMaxVertexAttribs = 2;
+ typedef SkTArray<GrShaderVar, true> VertexAttribArray;
+
+ const VertexAttribArray& getVertexAttribs() const { return fVertexAttribs; }
+
+protected:
+ /**
+ * Subclasses call this from their constructor to register vertex attributes (at most
+ * kMaxVertexAttribs). This must only be called from the constructor because GrProcessors are
+ * immutable.
+ */
+ const GrShaderVar& addVertexAttrib(const GrShaderVar& var) {
+ SkASSERT(fVertexAttribs.count() < kMaxVertexAttribs);
+ return fVertexAttribs.push_back(var);
+ }
+
+private:
+ VertexAttribArray fVertexAttribs;
bsalomon 2014/09/22 19:15:37 Might still make sense to use an SkSTArray<2 or 4,
+
+ typedef GrProcessor INHERITED;
+};
+
+/**
+ * This creates an effect outside of the effect memory pool. The effect's destructor will be called
+ * at global destruction time. NAME will be the name of the created GrProcessor.
+ */
+#define GR_CREATE_STATIC_GEOMETRY_PROCESSOR(NAME, GP_CLASS, ARGS) \
+static SkAlignedSStorage<sizeof(GP_CLASS)> g_##NAME##_Storage; \
+static GrGeometryProcessor* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), GP_CLASS, ARGS); \
+static SkAutoTDestroy<GrGeometryProcessor> NAME##_ad(NAME);
+
+#endif
« no previous file with comments | « include/gpu/GrEffectUnitTest.h ('k') | include/gpu/GrPaint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698