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

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

Issue 12531015: Adds local coords to GrEffect system. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLProgram.cpp ('k') | src/gpu/gl/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 2012 Google Inc. 2 * Copyright 2012 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 }; 73 };
74 74
75 typedef SkTArray<TextureSampler> TextureSamplerArray; 75 typedef SkTArray<TextureSampler> TextureSamplerArray;
76 76
77 enum ShaderType { 77 enum ShaderType {
78 kVertex_ShaderType = 0x1, 78 kVertex_ShaderType = 0x1,
79 kGeometry_ShaderType = 0x2, 79 kGeometry_ShaderType = 0x2,
80 kFragment_ShaderType = 0x4, 80 kFragment_ShaderType = 0x4,
81 }; 81 };
82 82
83 GrGLShaderBuilder(const GrGLContextInfo&, GrGLUniformManager&); 83 GrGLShaderBuilder(const GrGLContextInfo&, GrGLUniformManager&, bool explicit LocalCoords);
84 84
85 /** 85 /**
86 * Called by GrGLEffects to add code to one of the shaders. 86 * Called by GrGLEffects to add code to one of the shaders.
87 */ 87 */
88 void vsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { 88 void vsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
89 va_list args; 89 va_list args;
90 va_start(args, format); 90 va_start(args, format);
91 this->codeAppendf(kVertex_ShaderType, format, args); 91 this->codeAppendf(kVertex_ShaderType, format, args);
92 va_end(args); 92 va_end(args);
93 } 93 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 /** Returns a variable name that represents the position of the fragment in the FS. The position 199 /** Returns a variable name that represents the position of the fragment in the FS. The position
200 is in device space (e.g. 0,0 is the top left and pixel centers are at ha lf-integers). */ 200 is in device space (e.g. 0,0 is the top left and pixel centers are at ha lf-integers). */
201 const char* fragmentPosition(); 201 const char* fragmentPosition();
202 202
203 /** Returns a vertex attribute that represents the vertex position in the VS . This is the 203 /** Returns a vertex attribute that represents the vertex position in the VS . This is the
204 pre-matrix position and is commonly used by effects to compute texture c oords via a matrix. 204 pre-matrix position and is commonly used by effects to compute texture c oords via a matrix.
205 */ 205 */
206 const GrGLShaderVar& positionAttribute() const { return *fPositionVar; } 206 const GrGLShaderVar& positionAttribute() const { return *fPositionVar; }
207 207
208 /** Returns a vertex attribute that represents the local coords in the VS. T his may be the same
209 as positionAttribute() or it may not be. It depends upon whether the ren dering code
210 specified explicit local coords or not in the GrDrawState. */
211 const GrGLShaderVar& localCoordsAttribute() const { return *fLocalCoordsVar; }
212
213 /**
214 * Are explicit local coordinates provided as input to the vertex shader.
215 */
216 bool hasExplicitLocalCoords() const { return (fLocalCoordsVar != fPositionVa r); }
217
208 /** 218 /**
209 * Interfaces used by GrGLProgram. 219 * Interfaces used by GrGLProgram.
210 * TODO: Hide these from the GrEffects using friend or splitting this into t wo related classes. 220 * TODO: Hide these from the GrEffects using friend or splitting this into t wo related classes.
211 * Also, GrGLProgram's shader string construction should be moved to this cl ass. 221 * Also, GrGLProgram's shader string construction should be moved to this cl ass.
212 */ 222 */
213 223
214 /** Called after building is complete to get the final shader string. */ 224 /** Called after building is complete to get the final shader string. */
215 void getShader(ShaderType, SkString*) const; 225 void getShader(ShaderType, SkString*) const;
216 226
217 void setCurrentStage(int stageIdx) { fCurrentStageIdx = stageIdx; } 227 void setCurrentStage(int stageIdx) { fCurrentStageIdx = stageIdx; }
218 void setNonStage() { fCurrentStageIdx = kNonStageIdx; } 228 void setNonStage() { fCurrentStageIdx = kNonStageIdx; }
219 // TODO: move remainder of shader code generation to this class and call thi s privately 229 // TODO: move remainder of shader code generation to this class and call thi s privately
220 // Handles of sampler uniforms generated for the effect are appended to samp lerHandles. 230 // Handles of sampler uniforms generated for the effect are appended to samp lerHandles.
221 GrGLEffect* createAndEmitGLEffect( 231 GrGLEffect* createAndEmitGLEffect(
222 const GrEffectStage& stage, 232 const GrEffectStage& stage,
223 GrBackendEffectFactory::EffectKey key, 233 GrBackendEffectFactory::EffectKey key,
224 const char* fsInColor, // NULL means no incoming color 234 const char* fsInColor, // NULL means no incoming color
225 const char* fsOutColor, 235 const char* fsOutColor,
226 const char* vsInCoord,
227 SkTArray<GrGLUniformManager::UniformHandle, true >* samplerHandles); 236 SkTArray<GrGLUniformManager::UniformHandle, true >* samplerHandles);
228 GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHei ghtUniform; } 237 GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHei ghtUniform; }
229 238
230 struct AttributePair { 239 struct AttributePair {
231 void set(int index, const SkString& name) { 240 void set(int index, const SkString& name) {
232 fIndex = index; fName = name; 241 fIndex = index; fName = name;
233 } 242 }
234 int fIndex; 243 int fIndex;
235 SkString fName; 244 SkString fName;
236 }; 245 };
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 SkString fFSCode; 292 SkString fFSCode;
284 SkString fVSCode; 293 SkString fVSCode;
285 SkString fGSCode; 294 SkString fGSCode;
286 295
287 bool fSetupFragPosition; 296 bool fSetupFragPosition;
288 GrGLUniformManager::UniformHandle fRTHeightUniform; 297 GrGLUniformManager::UniformHandle fRTHeightUniform;
289 298
290 SkSTArray<10, AttributePair, true> fEffectAttributes; 299 SkSTArray<10, AttributePair, true> fEffectAttributes;
291 300
292 GrGLShaderVar* fPositionVar; 301 GrGLShaderVar* fPositionVar;
302 GrGLShaderVar* fLocalCoordsVar;
303
293 }; 304 };
294 305
295 #endif 306 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgram.cpp ('k') | src/gpu/gl/GrGLShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698