| 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" | |
| 20 #include "gl/GrGLSLPrettyPrint.h" | 19 #include "gl/GrGLSLPrettyPrint.h" |
| 21 #include "gl/builders/GrGLShaderStringBuilder.h" | 20 #include "gl/builders/GrGLShaderStringBuilder.h" |
| 22 #include "glsl/GrGLSLCaps.h" | 21 #include "glsl/GrGLSLCaps.h" |
| 23 #include "glsl/GrGLSLFragmentProcessor.h" | 22 #include "glsl/GrGLSLFragmentProcessor.h" |
| 24 #include "glsl/GrGLSLGeometryProcessor.h" | 23 #include "glsl/GrGLSLGeometryProcessor.h" |
| 25 #include "glsl/GrGLSLProgramDataManager.h" | 24 #include "glsl/GrGLSLProgramDataManager.h" |
| 25 #include "glsl/GrGLSLProgramDesc.h" |
| 26 #include "glsl/GrGLSLSampler.h" | 26 #include "glsl/GrGLSLSampler.h" |
| 27 #include "glsl/GrGLSLXferProcessor.h" | 27 #include "glsl/GrGLSLXferProcessor.h" |
| 28 | 28 |
| 29 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) | 29 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) |
| 30 #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) |
| 31 | 31 |
| 32 GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrPipeline& pipeline, | 32 GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrPipeline& pipeline, |
| 33 const GrPrimitiveProcessor& primP
roc, | 33 const GrPrimitiveProcessor& primP
roc, |
| 34 const GrGLProgramDesc& desc, | 34 const GrGLSLProgramDesc& desc, |
| 35 GrGLGpu* gpu) { | 35 GrGLGpu* gpu) { |
| 36 GrAutoLocaleSetter als("C"); | 36 GrAutoLocaleSetter als("C"); |
| 37 | 37 |
| 38 // 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 |
| 39 // uniforms, varyings, textures, etc | 39 // uniforms, varyings, textures, etc |
| 40 GrGLProgramBuilder builder(gpu, pipeline, primProc, desc); | 40 GrGLProgramBuilder builder(gpu, pipeline, primProc, desc); |
| 41 | 41 |
| 42 // 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 |
| 43 // seed correctly here | 43 // seed correctly here |
| 44 GrGLSLExpr4 inputColor; | 44 GrGLSLExpr4 inputColor; |
| 45 GrGLSLExpr4 inputCoverage; | 45 GrGLSLExpr4 inputCoverage; |
| 46 | 46 |
| 47 if (!builder.emitAndInstallProcs(&inputColor, &inputCoverage)) { | 47 if (!builder.emitAndInstallProcs(&inputColor, &inputCoverage)) { |
| 48 builder.cleanupFragmentProcessors(); | 48 builder.cleanupFragmentProcessors(); |
| 49 return nullptr; | 49 return nullptr; |
| 50 } | 50 } |
| 51 | 51 |
| 52 return builder.finalize(); | 52 return builder.finalize(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 ///////////////////////////////////////////////////////////////////////////// | 55 ///////////////////////////////////////////////////////////////////////////// |
| 56 | 56 |
| 57 GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, | 57 GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, |
| 58 const GrPipeline& pipeline, | 58 const GrPipeline& pipeline, |
| 59 const GrPrimitiveProcessor& primProc, | 59 const GrPrimitiveProcessor& primProc, |
| 60 const GrGLProgramDesc& desc) | 60 const GrGLSLProgramDesc& desc) |
| 61 : INHERITED(pipeline, primProc, desc) | 61 : INHERITED(pipeline, primProc, desc) |
| 62 , fGpu(gpu) | 62 , fGpu(gpu) |
| 63 , fVaryingHandler(this) | 63 , fVaryingHandler(this) |
| 64 , fUniformHandler(this) { | 64 , fUniformHandler(this) { |
| 65 } | 65 } |
| 66 | 66 |
| 67 const GrCaps* GrGLProgramBuilder::caps() const { | 67 const GrCaps* GrGLProgramBuilder::caps() const { |
| 68 return fGpu->caps(); | 68 return fGpu->caps(); |
| 69 } | 69 } |
| 70 | 70 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 this->desc(), | 232 this->desc(), |
| 233 fUniformHandles, | 233 fUniformHandles, |
| 234 programID, | 234 programID, |
| 235 fUniformHandler.fUniforms, | 235 fUniformHandler.fUniforms, |
| 236 fUniformHandler.fSamplers, | 236 fUniformHandler.fSamplers, |
| 237 fVaryingHandler.fPathProcVaryingInfos, | 237 fVaryingHandler.fPathProcVaryingInfos, |
| 238 fGeometryProcessor, | 238 fGeometryProcessor, |
| 239 fXferProcessor, | 239 fXferProcessor, |
| 240 fFragmentProcessors); | 240 fFragmentProcessors); |
| 241 } | 241 } |
| OLD | NEW |