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 #include "GrGLProgramBuilder.h" | 8 #include "GrGLProgramBuilder.h" |
9 | 9 |
10 #include "GrAutoLocaleSetter.h" | 10 #include "GrAutoLocaleSetter.h" |
11 #include "GrCoordTransform.h" | 11 #include "GrCoordTransform.h" |
12 #include "GrGLProgramBuilder.h" | 12 #include "GrGLProgramBuilder.h" |
13 #include "GrSwizzle.h" | 13 #include "GrSwizzle.h" |
14 #include "GrTexture.h" | 14 #include "GrTexture.h" |
15 #include "SkRTConf.h" | 15 #include "SkRTConf.h" |
16 #include "SkTraceEvent.h" | 16 #include "SkTraceEvent.h" |
17 #include "gl/GrGLGpu.h" | 17 #include "gl/GrGLGpu.h" |
18 #include "gl/GrGLProgram.h" | 18 #include "gl/GrGLProgram.h" |
| 19 #include "gl/GrGLProgramDesc.h" |
19 #include "gl/GrGLSLPrettyPrint.h" | 20 #include "gl/GrGLSLPrettyPrint.h" |
20 #include "gl/builders/GrGLShaderStringBuilder.h" | 21 #include "gl/builders/GrGLShaderStringBuilder.h" |
21 #include "glsl/GrGLSLCaps.h" | 22 #include "glsl/GrGLSLCaps.h" |
22 #include "glsl/GrGLSLFragmentProcessor.h" | 23 #include "glsl/GrGLSLFragmentProcessor.h" |
23 #include "glsl/GrGLSLGeometryProcessor.h" | 24 #include "glsl/GrGLSLGeometryProcessor.h" |
24 #include "glsl/GrGLSLProgramDataManager.h" | 25 #include "glsl/GrGLSLProgramDataManager.h" |
25 #include "glsl/GrGLSLTextureSampler.h" | 26 #include "glsl/GrGLSLTextureSampler.h" |
26 #include "glsl/GrGLSLXferProcessor.h" | 27 #include "glsl/GrGLSLXferProcessor.h" |
27 | 28 |
28 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) | 29 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) |
29 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) | 30 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) |
30 | 31 |
31 GrGLProgram* GrGLProgramBuilder::CreateProgram(const DrawArgs& args, GrGLGpu* gp
u) { | 32 GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrPipeline& pipeline, |
| 33 const GrPrimitiveProcessor& primP
roc, |
| 34 const GrGLProgramDesc& desc, |
| 35 GrGLGpu* gpu) { |
32 GrAutoLocaleSetter als("C"); | 36 GrAutoLocaleSetter als("C"); |
33 | 37 |
34 // create a builder. This will be handed off to effects so they can use it
to add | 38 // create a builder. This will be handed off to effects so they can use it
to add |
35 // uniforms, varyings, textures, etc | 39 // uniforms, varyings, textures, etc |
36 GrGLProgramBuilder builder(gpu, args); | 40 GrGLProgramBuilder builder(gpu, pipeline, primProc, desc); |
37 | 41 |
38 // TODO: Once all stages can handle taking a float or vec4 and correctly han
dling them we can | 42 // TODO: Once all stages can handle taking a float or vec4 and correctly han
dling them we can |
39 // seed correctly here | 43 // seed correctly here |
40 GrGLSLExpr4 inputColor; | 44 GrGLSLExpr4 inputColor; |
41 GrGLSLExpr4 inputCoverage; | 45 GrGLSLExpr4 inputCoverage; |
42 | 46 |
43 if (!builder.emitAndInstallProcs(&inputColor, &inputCoverage)) { | 47 if (!builder.emitAndInstallProcs(&inputColor, &inputCoverage)) { |
44 builder.cleanupFragmentProcessors(); | 48 builder.cleanupFragmentProcessors(); |
45 return nullptr; | 49 return nullptr; |
46 } | 50 } |
47 | 51 |
48 return builder.finalize(); | 52 return builder.finalize(); |
49 } | 53 } |
50 | 54 |
51 ///////////////////////////////////////////////////////////////////////////// | 55 ///////////////////////////////////////////////////////////////////////////// |
52 | 56 |
53 GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, const DrawArgs& args) | 57 GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, |
54 : INHERITED(args) | 58 const GrPipeline& pipeline, |
| 59 const GrPrimitiveProcessor& primProc, |
| 60 const GrGLProgramDesc& desc) |
| 61 : INHERITED(pipeline, primProc, desc) |
55 , fGpu(gpu) | 62 , fGpu(gpu) |
56 , fVaryingHandler(this) | 63 , fVaryingHandler(this) |
57 , fUniformHandler(this) { | 64 , fUniformHandler(this) { |
58 } | 65 } |
59 | 66 |
60 const GrCaps* GrGLProgramBuilder::caps() const { | 67 const GrCaps* GrGLProgramBuilder::caps() const { |
61 return fGpu->caps(); | 68 return fGpu->caps(); |
62 } | 69 } |
63 | 70 |
64 const GrGLSLCaps* GrGLProgramBuilder::glslCaps() const { | 71 const GrGLSLCaps* GrGLProgramBuilder::glslCaps() const { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 fUniformHandles, | 233 fUniformHandles, |
227 programID, | 234 programID, |
228 fUniformHandler.fUniforms, | 235 fUniformHandler.fUniforms, |
229 fVaryingHandler.fPathProcVaryingInfos, | 236 fVaryingHandler.fPathProcVaryingInfos, |
230 fGeometryProcessor, | 237 fGeometryProcessor, |
231 fXferProcessor, | 238 fXferProcessor, |
232 fFragmentProcessors, | 239 fFragmentProcessors, |
233 &fSamplerUniforms); | 240 &fSamplerUniforms); |
234 } | 241 } |
235 | 242 |
OLD | NEW |