| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrGLProgram.h" | 8 #include "GrGLProgram.h" |
| 9 | 9 |
| 10 #include "builders/GrGLFullProgramBuilder.h" |
| 10 #include "builders/GrGLFragmentOnlyProgramBuilder.h" | 11 #include "builders/GrGLFragmentOnlyProgramBuilder.h" |
| 11 #include "builders/GrGLFullProgramBuilder.h" | |
| 12 #include "GrAllocator.h" | 12 #include "GrAllocator.h" |
| 13 #include "GrEffect.h" | 13 #include "GrProcessor.h" |
| 14 #include "GrCoordTransform.h" | 14 #include "GrCoordTransform.h" |
| 15 #include "GrGLEffect.h" | 15 #include "GrGLProcessor.h" |
| 16 #include "GrGpuGL.h" | 16 #include "GrGpuGL.h" |
| 17 #include "GrGLPathRendering.h" | 17 #include "GrGLPathRendering.h" |
| 18 #include "GrGLShaderVar.h" | 18 #include "GrGLShaderVar.h" |
| 19 #include "GrGLSL.h" | 19 #include "GrGLSL.h" |
| 20 #include "GrOptDrawState.h" | 20 #include "GrOptDrawState.h" |
| 21 #include "SkXfermode.h" | 21 #include "SkXfermode.h" |
| 22 | 22 |
| 23 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) | 23 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) |
| 24 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X) | 24 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X) |
| 25 | 25 |
| 26 GrGLProgram* GrGLProgram::Create(GrGpuGL* gpu, | 26 GrGLProgram* GrGLProgram::Create(GrGpuGL* gpu, |
| 27 const GrGLProgramDesc& desc, | 27 const GrGLProgramDesc& desc, |
| 28 const GrEffectStage* geometryProcessor, | 28 const GrGeometryStage* geometryProcessor, |
| 29 const GrEffectStage* colorStages[], | 29 const GrFragmentStage* colorStages[], |
| 30 const GrEffectStage* coverageStages[]) { | 30 const GrFragmentStage* coverageStages[]) { |
| 31 SkAutoTDelete<GrGLProgramBuilder> builder; | 31 SkAutoTDelete<GrGLProgramBuilder> builder; |
| 32 if (desc.getHeader().fUseFragShaderOnly) { | 32 if (desc.getHeader().fUseFragShaderOnly) { |
| 33 SkASSERT(gpu->glCaps().pathRenderingSupport()); | 33 SkASSERT(gpu->glCaps().pathRenderingSupport()); |
| 34 SkASSERT(gpu->glPathRendering()->texturingMode() == | 34 SkASSERT(gpu->glPathRendering()->texturingMode() == |
| 35 GrGLPathRendering::FixedFunction_TexturingMode); | 35 GrGLPathRendering::FixedFunction_TexturingMode); |
| 36 SkASSERT(NULL == geometryProcessor); | 36 SkASSERT(NULL == geometryProcessor); |
| 37 builder.reset(SkNEW_ARGS(GrGLFragmentOnlyProgramBuilder, (gpu, desc))); | 37 builder.reset(SkNEW_ARGS(GrGLFragmentOnlyProgramBuilder, (gpu, desc))); |
| 38 } else { | 38 } else { |
| 39 builder.reset(SkNEW_ARGS(GrGLFullProgramBuilder, (gpu, desc))); | 39 builder.reset(SkNEW_ARGS(GrGLFullProgramBuilder, (gpu, desc))); |
| 40 } | 40 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 fGeometryProcessor->initSamplers(fProgramDataManager, &texUnitIdx); | 85 fGeometryProcessor->initSamplers(fProgramDataManager, &texUnitIdx); |
| 86 } | 86 } |
| 87 fColorEffects->initSamplers(fProgramDataManager, &texUnitIdx); | 87 fColorEffects->initSamplers(fProgramDataManager, &texUnitIdx); |
| 88 fCoverageEffects->initSamplers(fProgramDataManager, &texUnitIdx); | 88 fCoverageEffects->initSamplers(fProgramDataManager, &texUnitIdx); |
| 89 } | 89 } |
| 90 | 90 |
| 91 /////////////////////////////////////////////////////////////////////////////// | 91 /////////////////////////////////////////////////////////////////////////////// |
| 92 | 92 |
| 93 void GrGLProgram::setData(const GrOptDrawState& optState, | 93 void GrGLProgram::setData(const GrOptDrawState& optState, |
| 94 GrGpu::DrawType drawType, | 94 GrGpu::DrawType drawType, |
| 95 const GrEffectStage* geometryProcessor, | 95 const GrGeometryStage* geometryProcessor, |
| 96 const GrEffectStage* colorStages[], | 96 const GrFragmentStage* colorStages[], |
| 97 const GrEffectStage* coverageStages[], | 97 const GrFragmentStage* coverageStages[], |
| 98 const GrDeviceCoordTexture* dstCopy, | 98 const GrDeviceCoordTexture* dstCopy, |
| 99 SharedGLState* sharedState) { | 99 SharedGLState* sharedState) { |
| 100 GrColor color = optState.getColor(); | 100 GrColor color = optState.getColor(); |
| 101 GrColor coverage = optState.getCoverageColor(); | 101 GrColor coverage = optState.getCoverageColor(); |
| 102 | 102 |
| 103 this->setColor(optState, color, sharedState); | 103 this->setColor(optState, color, sharedState); |
| 104 this->setCoverage(optState, coverage, sharedState); | 104 this->setCoverage(optState, coverage, sharedState); |
| 105 this->setMatrixAndRenderTargetHeight(drawType, optState); | 105 this->setMatrixAndRenderTargetHeight(drawType, optState); |
| 106 | 106 |
| 107 if (dstCopy) { | 107 if (dstCopy) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 120 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid()); | 120 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid()); |
| 121 } | 121 } |
| 122 } else { | 122 } else { |
| 123 SkASSERT(!fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()); | 123 SkASSERT(!fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()); |
| 124 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid()); | 124 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid()); |
| 125 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid()); | 125 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid()); |
| 126 } | 126 } |
| 127 | 127 |
| 128 if (fGeometryProcessor.get()) { | 128 if (fGeometryProcessor.get()) { |
| 129 SkASSERT(geometryProcessor); | 129 SkASSERT(geometryProcessor); |
| 130 fGeometryProcessor->setData(fGpu, drawType, fProgramDataManager, &geomet
ryProcessor); | 130 fGeometryProcessor->setData(fGpu, drawType, fProgramDataManager, geometr
yProcessor); |
| 131 } | 131 } |
| 132 fColorEffects->setData(fGpu, drawType, fProgramDataManager, colorStages); | 132 fColorEffects->setData(fGpu, drawType, fProgramDataManager, colorStages); |
| 133 fCoverageEffects->setData(fGpu, drawType, fProgramDataManager, coverageStage
s); | 133 fCoverageEffects->setData(fGpu, drawType, fProgramDataManager, coverageStage
s); |
| 134 | 134 |
| 135 // PathTexGen state applies to the the fixed function vertex shader. For | 135 // PathTexGen state applies to the the fixed function vertex shader. For |
| 136 // custom shaders, it's ignored, so we don't need to change the texgen | 136 // custom shaders, it's ignored, so we don't need to change the texgen |
| 137 // settings in that case. | 137 // settings in that case. |
| 138 if (!fHasVertexShader) { | 138 if (!fHasVertexShader) { |
| 139 fGpu->glPathRendering()->flushPathTexGenSettings(fTexCoordSetCnt); | 139 fGpu->glPathRendering()->flushPathTexGenSettings(fTexCoordSetCnt); |
| 140 } | 140 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 | 243 |
| 244 GrGLfloat viewMatrix[3 * 3]; | 244 GrGLfloat viewMatrix[3 * 3]; |
| 245 fMatrixState.getGLMatrix<3>(viewMatrix); | 245 fMatrixState.getGLMatrix<3>(viewMatrix); |
| 246 fProgramDataManager.setMatrix3f(fBuiltinUniformHandles.fViewMatrixUni, v
iewMatrix); | 246 fProgramDataManager.setMatrix3f(fBuiltinUniformHandles.fViewMatrixUni, v
iewMatrix); |
| 247 | 247 |
| 248 GrGLfloat rtAdjustmentVec[4]; | 248 GrGLfloat rtAdjustmentVec[4]; |
| 249 fMatrixState.getRTAdjustmentVec(rtAdjustmentVec); | 249 fMatrixState.getRTAdjustmentVec(rtAdjustmentVec); |
| 250 fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, r
tAdjustmentVec); | 250 fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, r
tAdjustmentVec); |
| 251 } | 251 } |
| 252 } | 252 } |
| OLD | NEW |