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