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

Unified Diff: src/gpu/gl/builders/GrGLVertexShaderBuilder.h

Issue 491673002: Initial refactor of shaderbuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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/gl/builders/GrGLShaderStringBuilder.cpp ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/builders/GrGLVertexShaderBuilder.h
diff --git a/src/gpu/gl/builders/GrGLVertexShaderBuilder.h b/src/gpu/gl/builders/GrGLVertexShaderBuilder.h
new file mode 100644
index 0000000000000000000000000000000000000000..c576f5788210ddabf7eb2f371a90ef1a520aee3b
--- /dev/null
+++ b/src/gpu/gl/builders/GrGLVertexShaderBuilder.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLVertexShader_DEFINED
+#define GrGLVertexShader_DEFINED
+#include "GrGLShaderBuilder.h"
+
+class GrGLProgramBuilder;
+
+class GrGLVertexShaderBuilder : public GrGLFullShaderBuilder {
+public:
+ GrGLVertexShaderBuilder(GrGLFullProgramBuilder* program);
+
+ /*
+ * Add attribute will push a new attribute onto the end. It will also assert if there is
+ * a duplicate attribute
+ */
+ bool addAttribute(GrSLType type, const char* name);
+
+ bool addEffectAttribute(int attributeIndex, GrSLType type, const SkString& name);
+
+ /*
+ * this call is only for GrGLProgramEffects' internal use
+ */
+ void emitAttributes(const GrEffectStage& stage);
+
+ /**
+ * Are explicit local coordinates provided as input to the vertex shader.
+ */
+ bool hasExplicitLocalCoords() const { return (fLocalCoordsVar != fPositionVar); }
+
+ const SkString* getEffectAttributeName(int attributeIndex) const;
+
+ /** Returns a vertex attribute that represents the local coords in the VS. This may be the same
+ as positionAttribute() or it may not be. It depends upon whether the rendering code
+ specified explicit local coords or not in the GrDrawState. */
+ const GrGLShaderVar& localCoordsAttribute() const { return *fLocalCoordsVar; }
+
+ /** Returns a vertex attribute that represents the vertex position in the VS. This is the
+ pre-matrix position and is commonly used by effects to compute texture coords via a matrix.
+ */
+ const GrGLShaderVar& positionAttribute() const { return *fPositionVar; }
+
+private:
+ /*
+ * Internal call for GrGLFullProgramBuilder.addVarying
+ */
+ void addVarying(GrSLType type,
+ const char* name,
+ const char** vsOutName);
+
+ /*
+ * private helpers for compilation by GrGLProgramBuilder
+ */
+ void bindProgramLocations(GrGLuint programId);
+ bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shaderIds) const;
+ void emitCodeBeforeEffects(GrGLSLExpr4* color, GrGLSLExpr4* coverage);
+ void emitCodeAfterEffects();
+
+ struct AttributePair {
+ void set(int index, const SkString& name) {
+ fIndex = index; fName = name;
+ }
+ int fIndex;
+ SkString fName;
+ };
+
+ SkSTArray<10, AttributePair, true> fEffectAttributes;
+ GrGLShaderVar* fPositionVar;
+ GrGLShaderVar* fLocalCoordsVar;
+
+ friend class GrGLFullProgramBuilder;
+
+ typedef GrGLFullShaderBuilder INHERITED;
+};
+
+#endif
« no previous file with comments | « src/gpu/gl/builders/GrGLShaderStringBuilder.cpp ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698