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

Side by Side Diff: src/gpu/gl/builders/GrGLShaderBuilder.h

Issue 1417123002: Move GrGLShaderVar to GrGLSL (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix gyp Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.cpp ('k') | src/gpu/gl/builders/GrGLShaderBuilder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrGLShaderBuilder_DEFINED 8 #ifndef GrGLShaderBuilder_DEFINED
9 #define GrGLShaderBuilder_DEFINED 9 #define GrGLShaderBuilder_DEFINED
10 10
(...skipping 12 matching lines...) Expand all
23 /** 23 /**
24 base class for all shaders builders 24 base class for all shaders builders
25 */ 25 */
26 class GrGLShaderBuilder { 26 class GrGLShaderBuilder {
27 public: 27 public:
28 typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; 28 typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray;
29 typedef GrGLProcessor::TextureSampler TextureSampler; 29 typedef GrGLProcessor::TextureSampler TextureSampler;
30 30
31 GrGLShaderBuilder(GrGLProgramBuilder* program); 31 GrGLShaderBuilder(GrGLProgramBuilder* program);
32 32
33 void addInput(GrGLShaderVar i) { fInputs.push_back(i); } 33 void addInput(const GrGLSLShaderVar& input) { fInputs.push_back(input); }
34 void addOutput(GrGLShaderVar i) { fOutputs.push_back(i); } 34 void addOutput(const GrGLSLShaderVar& output) { fOutputs.push_back(output); }
35 35
36 /* 36 /*
37 * We put texture lookups in the base class because it is TECHNICALLY possib le to do texture 37 * We put texture lookups in the base class because it is TECHNICALLY possib le to do texture
38 * lookups in any kind of shader. However, for the time being using these c alls on non-fragment 38 * lookups in any kind of shader. However, for the time being using these c alls on non-fragment
39 * shaders will result in a shader compilation error as texture sampler unif orms are only 39 * shaders will result in a shader compilation error as texture sampler unif orms are only
40 * visible to the fragment shader. It would not be hard to change this beha vior, if someone 40 * visible to the fragment shader. It would not be hard to change this beha vior, if someone
41 * actually wants to do texture lookups in a non-fragment shader 41 * actually wants to do texture lookups in a non-fragment shader
42 * 42 *
43 * TODO if append texture lookup is used on a non-fragment shader, sampler u niforms should be 43 * TODO if append texture lookup is used on a non-fragment shader, sampler u niforms should be
44 * made visible to that shaders 44 * made visible to that shaders
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 void codePrependf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { 85 void codePrependf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
86 va_list args; 86 va_list args;
87 va_start(args, format); 87 va_start(args, format);
88 this->code().prependVAList(format, args); 88 this->code().prependVAList(format, args);
89 va_end(args); 89 va_end(args);
90 } 90 }
91 91
92 /** 92 /**
93 * Appends a variable declaration to one of the shaders 93 * Appends a variable declaration to one of the shaders
94 */ 94 */
95 void declAppend(const GrGLShaderVar& var); 95 void declAppend(const GrGLSLShaderVar& var);
96 96
97 /** Emits a helper function outside of main() in the fragment shader. */ 97 /** Emits a helper function outside of main() in the fragment shader. */
98 void emitFunction(GrSLType returnType, 98 void emitFunction(GrSLType returnType,
99 const char* name, 99 const char* name,
100 int argCnt, 100 int argCnt,
101 const GrGLShaderVar* args, 101 const GrGLSLShaderVar* args,
102 const char* body, 102 const char* body,
103 SkString* outName); 103 SkString* outName);
104 104
105 /* 105 /*
106 * Get parent builder for adding uniforms 106 * Get parent builder for adding uniforms
107 */ 107 */
108 GrGLProgramBuilder* getProgramBuilder() { return fProgramBuilder; } 108 GrGLProgramBuilder* getProgramBuilder() { return fProgramBuilder; }
109 109
110 /** 110 /**
111 * Helper for begining and ending a block in the shader code. 111 * Helper for begining and ending a block in the shader code.
112 */ 112 */
113 class ShaderBlock { 113 class ShaderBlock {
114 public: 114 public:
115 ShaderBlock(GrGLShaderBuilder* builder) : fBuilder(builder) { 115 ShaderBlock(GrGLShaderBuilder* builder) : fBuilder(builder) {
116 SkASSERT(builder); 116 SkASSERT(builder);
117 fBuilder->codeAppend("{"); 117 fBuilder->codeAppend("{");
118 } 118 }
119 119
120 ~ShaderBlock() { 120 ~ShaderBlock() {
121 fBuilder->codeAppend("}"); 121 fBuilder->codeAppend("}");
122 } 122 }
123 private: 123 private:
124 GrGLShaderBuilder* fBuilder; 124 GrGLShaderBuilder* fBuilder;
125 }; 125 };
126 126
127 protected: 127 protected:
128 typedef GrTAllocator<GrGLShaderVar> VarArray; 128 typedef GrTAllocator<GrGLSLShaderVar> VarArray;
129 void appendDecls(const VarArray& vars, SkString* out) const; 129 void appendDecls(const VarArray& vars, SkString* out) const;
130 130
131 /* 131 /*
132 * this super low level function is just for use internally to builders 132 * this super low level function is just for use internally to builders
133 */ 133 */
134 void appendTextureLookup(const char* samplerName, 134 void appendTextureLookup(const char* samplerName,
135 const char* coordName, 135 const char* coordName,
136 uint32_t configComponentMask, 136 uint32_t configComponentMask,
137 const char* swizzle); 137 const char* swizzle);
138 138
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 VarArray fOutputs; 201 VarArray fOutputs;
202 uint32_t fFeaturesAddedMask; 202 uint32_t fFeaturesAddedMask;
203 SkSTArray<1, SkString> fLayoutParams[kLastInterfaceQualifier + 1]; 203 SkSTArray<1, SkString> fLayoutParams[kLastInterfaceQualifier + 1];
204 int fCodeIndex; 204 int fCodeIndex;
205 bool fFinalized; 205 bool fFinalized;
206 206
207 friend class GrGLProgramBuilder; 207 friend class GrGLProgramBuilder;
208 friend class GrGLPathProgramBuilder; // to access fInputs. 208 friend class GrGLPathProgramBuilder; // to access fInputs.
209 }; 209 };
210 #endif 210 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.cpp ('k') | src/gpu/gl/builders/GrGLShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698