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/GrGLFragmentOnlyProgramBuilder.h" | 10 #include "builders/GrGLFragmentOnlyProgramBuilder.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 GrGLProgram::~GrGLProgram() { | 67 GrGLProgram::~GrGLProgram() { |
68 if (fProgramID) { | 68 if (fProgramID) { |
69 GL_CALL(DeleteProgram(fProgramID)); | 69 GL_CALL(DeleteProgram(fProgramID)); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 void GrGLProgram::abandon() { | 73 void GrGLProgram::abandon() { |
74 fProgramID = 0; | 74 fProgramID = 0; |
75 } | 75 } |
76 | 76 |
77 void GrGLProgram::overrideBlend(GrBlendCoeff* srcCoeff, | |
78 GrBlendCoeff* dstCoeff) const { | |
79 switch (fDesc.getHeader().fCoverageOutput) { | |
80 case GrGLProgramDesc::kModulate_CoverageOutput: | |
81 break; | |
82 // The prog will write a coverage value to the secondary | |
83 // output and the dst is blended by one minus that value. | |
84 case GrGLProgramDesc::kSecondaryCoverage_CoverageOutput: | |
85 case GrGLProgramDesc::kSecondaryCoverageISA_CoverageOutput: | |
86 case GrGLProgramDesc::kSecondaryCoverageISC_CoverageOutput: | |
87 *dstCoeff = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; | |
88 break; | |
89 case GrGLProgramDesc::kCombineWithDst_CoverageOutput: | |
90 // We should only have set this if the blend was specified as (1, 0) | |
91 SkASSERT(kOne_GrBlendCoeff == *srcCoeff && kZero_GrBlendCoeff == *ds
tCoeff); | |
92 break; | |
93 default: | |
94 SkFAIL("Unexpected coverage output"); | |
95 break; | |
96 } | |
97 } | |
98 | |
99 void GrGLProgram::initSamplerUniforms() { | 77 void GrGLProgram::initSamplerUniforms() { |
100 GL_CALL(UseProgram(fProgramID)); | 78 GL_CALL(UseProgram(fProgramID)); |
101 GrGLint texUnitIdx = 0; | 79 GrGLint texUnitIdx = 0; |
102 if (fBuiltinUniformHandles.fDstCopySamplerUni.isValid()) { | 80 if (fBuiltinUniformHandles.fDstCopySamplerUni.isValid()) { |
103 fProgramDataManager.setSampler(fBuiltinUniformHandles.fDstCopySamplerUni
, texUnitIdx); | 81 fProgramDataManager.setSampler(fBuiltinUniformHandles.fDstCopySamplerUni
, texUnitIdx); |
104 fDstCopyTexUnit = texUnitIdx++; | 82 fDstCopyTexUnit = texUnitIdx++; |
105 } | 83 } |
106 if (fGeometryProcessor.get()) { | 84 if (fGeometryProcessor.get()) { |
107 fGeometryProcessor->initSamplers(fProgramDataManager, &texUnitIdx); | 85 fGeometryProcessor->initSamplers(fProgramDataManager, &texUnitIdx); |
108 } | 86 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 243 |
266 GrGLfloat viewMatrix[3 * 3]; | 244 GrGLfloat viewMatrix[3 * 3]; |
267 fMatrixState.getGLMatrix<3>(viewMatrix); | 245 fMatrixState.getGLMatrix<3>(viewMatrix); |
268 fProgramDataManager.setMatrix3f(fBuiltinUniformHandles.fViewMatrixUni, v
iewMatrix); | 246 fProgramDataManager.setMatrix3f(fBuiltinUniformHandles.fViewMatrixUni, v
iewMatrix); |
269 | 247 |
270 GrGLfloat rtAdjustmentVec[4]; | 248 GrGLfloat rtAdjustmentVec[4]; |
271 fMatrixState.getRTAdjustmentVec(rtAdjustmentVec); | 249 fMatrixState.getRTAdjustmentVec(rtAdjustmentVec); |
272 fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, r
tAdjustmentVec); | 250 fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, r
tAdjustmentVec); |
273 } | 251 } |
274 } | 252 } |
OLD | NEW |