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

Unified Diff: src/gpu/effects/GrGeometryProcessor.h

Issue 543623004: Removing vertex attrib indices (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: warning fixed 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 | « src/gpu/effects/GrDistanceFieldTextureEffect.cpp ('k') | src/gpu/effects/GrVertexEffect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrGeometryProcessor.h
diff --git a/src/gpu/effects/GrGeometryProcessor.h b/src/gpu/effects/GrGeometryProcessor.h
new file mode 100644
index 0000000000000000000000000000000000000000..0e1c80c150aefc76632764daed8af4c090814249
--- /dev/null
+++ b/src/gpu/effects/GrGeometryProcessor.h
@@ -0,0 +1,41 @@
+/*
+ * 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 "GrEffect.h"
+
+/**
+ * If an effect needs specialized vertex shader code, then it must inherit from this class.
+ * Otherwise it won't be able to add vertex attribs, and it will be given a vertexless shader
+ * program in emitCode.
+ */
+class GrGeometryProcessor : public GrEffect {
+public:
+ GrGeometryProcessor() { fRequiresVertexShader = true; }
+
+protected:
+ /**
+ * Subclasses call this from their constructor to register vertex attributes (at most
+ * kMaxVertexAttribs). This must only be called from the constructor because GrEffects are
+ * immutable.
+ *
+ * We return a reference to the added var so that derived classes can name it nicely and use it
+ * in shader code.
+ */
+ const GrShaderVar& addVertexAttrib(const GrShaderVar& var) {
+ SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier());
+ SkASSERT(fVertexAttribs.count() < kMaxVertexAttribs);
+ return fVertexAttribs.push_back(var);
+ }
+
+private:
+ typedef GrEffect INHERITED;
+};
+
+#endif
« no previous file with comments | « src/gpu/effects/GrDistanceFieldTextureEffect.cpp ('k') | src/gpu/effects/GrVertexEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698