OLD | NEW |
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 GrGLProgramBuilder_DEFINED | 8 #ifndef GrGLProgramBuilder_DEFINED |
9 #define GrGLProgramBuilder_DEFINED | 9 #define GrGLProgramBuilder_DEFINED |
10 | 10 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 GrSLPrecision fsPrecision = kDefault_GrSLPrecision) SK_OVERRIDE; | 235 GrSLPrecision fsPrecision = kDefault_GrSLPrecision) SK_OVERRIDE; |
236 | 236 |
237 void addPassThroughAttribute(const GrGeometryProcessor::GrAttribute*, | 237 void addPassThroughAttribute(const GrGeometryProcessor::GrAttribute*, |
238 const char* output) SK_OVERRIDE; | 238 const char* output) SK_OVERRIDE; |
239 | 239 |
240 | 240 |
241 // Handles for program uniforms (other than per-effect uniforms) | 241 // Handles for program uniforms (other than per-effect uniforms) |
242 struct BuiltinUniformHandles { | 242 struct BuiltinUniformHandles { |
243 UniformHandle fViewMatrixUni; | 243 UniformHandle fViewMatrixUni; |
244 UniformHandle fRTAdjustmentUni; | 244 UniformHandle fRTAdjustmentUni; |
245 UniformHandle fColorUni; | |
246 UniformHandle fCoverageUni; | |
247 | 245 |
248 // We use the render target height to provide a y-down frag coord when s
pecifying | 246 // We use the render target height to provide a y-down frag coord when s
pecifying |
249 // origin_upper_left is not supported. | 247 // origin_upper_left is not supported. |
250 UniformHandle fRTHeightUni; | 248 UniformHandle fRTHeightUni; |
251 | 249 |
252 // Uniforms for computing texture coords to do the dst-copy lookup | 250 // Uniforms for computing texture coords to do the dst-copy lookup |
253 UniformHandle fDstCopyTopLeftUni; | 251 UniformHandle fDstCopyTopLeftUni; |
254 UniformHandle fDstCopyScaleUni; | 252 UniformHandle fDstCopyScaleUni; |
255 UniformHandle fDstCopySamplerUni; | 253 UniformHandle fDstCopySamplerUni; |
256 }; | 254 }; |
257 | 255 |
258 protected: | 256 protected: |
259 typedef GrGLProgramDataManager::UniformInfo UniformInfo; | 257 typedef GrGLProgramDataManager::UniformInfo UniformInfo; |
260 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 258 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
261 | 259 |
262 static GrGLProgramBuilder* CreateProgramBuilder(const GrOptDrawState&, | 260 static GrGLProgramBuilder* CreateProgramBuilder(const GrOptDrawState&, |
263 bool hasGeometryProcessor, | 261 bool hasGeometryProcessor, |
264 GrGpuGL*); | 262 GrGpuGL*); |
265 | 263 |
266 GrGLProgramBuilder(GrGpuGL*, const GrOptDrawState&); | 264 GrGLProgramBuilder(GrGpuGL*, const GrOptDrawState&); |
267 | 265 |
268 const GrOptDrawState& optState() const { return fOptState; } | 266 const GrOptDrawState& optState() const { return fOptState; } |
269 const GrProgramDesc& desc() const { return fDesc; } | 267 const GrProgramDesc& desc() const { return fDesc; } |
270 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); } | 268 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); } |
271 | 269 |
272 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix | 270 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix |
273 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're | 271 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're |
274 // generating stage code. | 272 // generating stage code. |
275 void nameVariable(SkString* out, char prefix, const char* name); | 273 void nameVariable(SkString* out, char prefix, const char* name); |
276 void setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* inputColor, GrGLSLExp
r1* inputCoverage); | |
277 // Generates a possibly mangled name for a stage variable and writes it to t
he fragment shader. | 274 // Generates a possibly mangled name for a stage variable and writes it to t
he fragment shader. |
278 // If GrGLSLExpr4 has a valid name then it will use that instead | 275 // If GrGLSLExpr4 has a valid name then it will use that instead |
279 void nameExpression(GrGLSLExpr4*, const char* baseName); | 276 void nameExpression(GrGLSLExpr4*, const char* baseName); |
280 void emitAndInstallProcs(GrGLSLExpr4* inputColor, | 277 void emitAndInstallProcs(GrGLSLExpr4* inputColor, |
281 GrGLSLExpr4* inputCoverage); | 278 GrGLSLExpr4* inputCoverage); |
282 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu
t); | 279 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu
t); |
283 void emitAndInstallProc(const GrPendingFragmentStage&, | 280 void emitAndInstallProc(const GrPendingFragmentStage&, |
284 int index, | 281 int index, |
285 const GrGLSLExpr4& input, | 282 const GrGLSLExpr4& input, |
286 GrGLSLExpr4* output); | 283 GrGLSLExpr4* output); |
287 | 284 |
288 void emitAndInstallProc(const GrGeometryProcessor&, | 285 void emitAndInstallProc(const GrPrimitiveProcessor&, |
289 GrGLSLExpr4* outputColor, | 286 GrGLSLExpr4* outputColor, |
290 GrGLSLExpr4* outputCoverage); | 287 GrGLSLExpr4* outputCoverage); |
291 | 288 |
292 // these emit functions help to keep the createAndEmitProcessors template ge
neral | 289 // these emit functions help to keep the createAndEmitProcessors template ge
neral |
293 void emitAndInstallProc(const GrPendingFragmentStage&, | 290 void emitAndInstallProc(const GrPendingFragmentStage&, |
294 const char* outColor, | 291 const char* outColor, |
295 const char* inColor); | 292 const char* inColor); |
296 void emitAndInstallProc(const GrGeometryProcessor&, | 293 void emitAndInstallProc(const GrPrimitiveProcessor&, |
297 const char* outColor, | 294 const char* outColor, |
298 const char* outCoverage); | 295 const char* outCoverage); |
299 void emitAndInstallXferProc(const GrXferProcessor&, | 296 void emitAndInstallXferProc(const GrXferProcessor&, |
300 const GrGLSLExpr4& colorIn, | 297 const GrGLSLExpr4& colorIn, |
301 const GrGLSLExpr4& coverageIn); | 298 const GrGLSLExpr4& coverageIn); |
302 | 299 |
303 void verify(const GrGeometryProcessor&); | 300 void verify(const GrPrimitiveProcessor&); |
304 void verify(const GrXferProcessor&); | 301 void verify(const GrXferProcessor&); |
305 void verify(const GrFragmentProcessor&); | 302 void verify(const GrFragmentProcessor&); |
306 void emitSamplers(const GrProcessor&, | 303 void emitSamplers(const GrProcessor&, |
307 GrGLProcessor::TextureSamplerArray* outSamplers, | 304 GrGLProcessor::TextureSamplerArray* outSamplers, |
308 GrGLInstalledProc*); | 305 GrGLInstalledProc*); |
309 | 306 |
310 // each specific program builder has a distinct transform and must override
this function | 307 // each specific program builder has a distinct transform and must override
this function |
311 virtual void emitTransforms(const GrPendingFragmentStage&, | 308 virtual void emitTransforms(const GrPendingFragmentStage&, |
312 GrGLProcessor::TransformedCoordsArray* outCoords
, | 309 GrGLProcessor::TransformedCoordsArray* outCoords
, |
313 GrGLInstalledFragProc*); | 310 GrGLInstalledFragProc*); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 SkAutoTDelete<GrGLFragmentProcessor> fGLProc; | 437 SkAutoTDelete<GrGLFragmentProcessor> fGLProc; |
441 SkSTArray<2, Transform, true> fTransforms; | 438 SkSTArray<2, Transform, true> fTransforms; |
442 }; | 439 }; |
443 | 440 |
444 struct GrGLInstalledFragProcs : public SkRefCnt { | 441 struct GrGLInstalledFragProcs : public SkRefCnt { |
445 virtual ~GrGLInstalledFragProcs(); | 442 virtual ~GrGLInstalledFragProcs(); |
446 SkSTArray<8, GrGLInstalledFragProc*, true> fProcs; | 443 SkSTArray<8, GrGLInstalledFragProc*, true> fProcs; |
447 }; | 444 }; |
448 | 445 |
449 #endif | 446 #endif |
OLD | NEW |