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

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

Issue 1416423003: Make GrGLSLProgramBuilder base class for ProgramBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 5 years, 1 month 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
11 #include "GrAllocator.h" 11 #include "GrAllocator.h"
12 #include "glsl/GrGLSLShaderVar.h" 12 #include "glsl/GrGLSLShaderVar.h"
13 #include "SkTDArray.h" 13 #include "SkTDArray.h"
14 14
15 #include <stdarg.h> 15 #include <stdarg.h>
16 16
17 class GrGLProgramBuilder; 17 class GrGLSLProgramBuilder;
18 class GrGLSLTextureSampler; 18 class GrGLSLTextureSampler;
19 19
20 /** 20 /**
21 base class for all shaders builders 21 base class for all shaders builders
22 */ 22 */
23 class GrGLShaderBuilder { 23 class GrGLShaderBuilder {
24 public: 24 public:
25 GrGLShaderBuilder(GrGLProgramBuilder* program); 25 GrGLShaderBuilder(GrGLSLProgramBuilder* program);
26 virtual ~GrGLShaderBuilder() {} 26 virtual ~GrGLShaderBuilder() {}
27 27
28 void addInput(const GrGLSLShaderVar& input) { fInputs.push_back(input); } 28 void addInput(const GrGLSLShaderVar& input) { fInputs.push_back(input); }
29 void addOutput(const GrGLSLShaderVar& output) { fOutputs.push_back(output); } 29 void addOutput(const GrGLSLShaderVar& output) { fOutputs.push_back(output); }
30 30
31 /* 31 /*
32 * We put texture lookups in the base class because it is TECHNICALLY possib le to do texture 32 * We put texture lookups in the base class because it is TECHNICALLY possib le to do texture
33 * lookups in any kind of shader. However, for the time being using these c alls on non-fragment 33 * lookups in any kind of shader. However, for the time being using these c alls on non-fragment
34 * shaders will result in a shader compilation error as texture sampler unif orms are only 34 * shaders will result in a shader compilation error as texture sampler unif orms are only
35 * visible to the fragment shader. It would not be hard to change this beha vior, if someone 35 * visible to the fragment shader. It would not be hard to change this beha vior, if someone
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 SkString* outName); 95 SkString* outName);
96 96
97 /* 97 /*
98 * Combines the various parts of the shader to create a single finalized sha der string. 98 * Combines the various parts of the shader to create a single finalized sha der string.
99 */ 99 */
100 void finalize(uint32_t visibility); 100 void finalize(uint32_t visibility);
101 101
102 /* 102 /*
103 * Get parent builder for adding uniforms 103 * Get parent builder for adding uniforms
104 */ 104 */
105 GrGLProgramBuilder* getProgramBuilder() { return fProgramBuilder; } 105 GrGLSLProgramBuilder* getProgramBuilder() { return fProgramBuilder; }
106 106
107 /** 107 /**
108 * Helper for begining and ending a block in the shader code. 108 * Helper for begining and ending a block in the shader code.
109 */ 109 */
110 class ShaderBlock { 110 class ShaderBlock {
111 public: 111 public:
112 ShaderBlock(GrGLShaderBuilder* builder) : fBuilder(builder) { 112 ShaderBlock(GrGLShaderBuilder* builder) : fBuilder(builder) {
113 SkASSERT(builder); 113 SkASSERT(builder);
114 fBuilder->codeAppend("{"); 114 fBuilder->codeAppend("{");
115 } 115 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 kPrecisionQualifier, 172 kPrecisionQualifier,
173 kLayoutQualifiers, 173 kLayoutQualifiers,
174 kUniforms, 174 kUniforms,
175 kInputs, 175 kInputs,
176 kOutputs, 176 kOutputs,
177 kFunctions, 177 kFunctions,
178 kMain, 178 kMain,
179 kCode, 179 kCode,
180 }; 180 };
181 181
182 GrGLProgramBuilder* fProgramBuilder; 182 GrGLSLProgramBuilder* fProgramBuilder;
183 SkSTArray<kCode, const char*, true> fCompilerStrings; 183 SkSTArray<kCode, const char*, true> fCompilerStrings;
184 SkSTArray<kCode, int, true> fCompilerStringLengths; 184 SkSTArray<kCode, int, true> fCompilerStringLengths;
185 SkSTArray<kCode, SkString> fShaderStrings; 185 SkSTArray<kCode, SkString> fShaderStrings;
186 SkString fCode; 186 SkString fCode;
187 SkString fFunctions; 187 SkString fFunctions;
188 SkString fExtensions; 188 SkString fExtensions;
189 189
190 VarArray fInputs; 190 VarArray fInputs;
191 VarArray fOutputs; 191 VarArray fOutputs;
192 uint32_t fFeaturesAddedMask; 192 uint32_t fFeaturesAddedMask;
193 SkSTArray<1, SkString> fLayoutParams[kLastInterfaceQualifier + 1]; 193 SkSTArray<1, SkString> fLayoutParams[kLastInterfaceQualifier + 1];
194 int fCodeIndex; 194 int fCodeIndex;
195 bool fFinalized; 195 bool fFinalized;
196 196
197 friend class GrGLProgramBuilder; 197 friend class GrGLProgramBuilder;
198 friend class GrGLPathProgramBuilder; // to access fInputs. 198 friend class GrGLPathProgramBuilder; // to access fInputs.
199 }; 199 };
200 #endif 200 #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