| 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 "GrAllocator.h" | 10 #include "GrAllocator.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 desc->fEffectKeys[s] = 0; | 142 desc->fEffectKeys[s] = 0; |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 | 145 |
| 146 desc->fDualSrcOutput = Desc::kNone_DualSrcOutput; | 146 desc->fDualSrcOutput = Desc::kNone_DualSrcOutput; |
| 147 | 147 |
| 148 // Currently the experimental GS will only work with triangle prims (and it
doesn't do anything | 148 // Currently the experimental GS will only work with triangle prims (and it
doesn't do anything |
| 149 // other than pass through values from the VS to the FS anyway). | 149 // other than pass through values from the VS to the FS anyway). |
| 150 #if GR_GL_EXPERIMENTAL_GS | 150 #if GR_GL_EXPERIMENTAL_GS |
| 151 #if 0 | 151 #if 0 |
| 152 desc->fExperimentalGS = gpu->getCaps().geometryShaderSupport(); | 152 desc->fExperimentalGS = gpu->caps().geometryShaderSupport(); |
| 153 #else | 153 #else |
| 154 desc->fExperimentalGS = false; | 154 desc->fExperimentalGS = false; |
| 155 #endif | 155 #endif |
| 156 #endif | 156 #endif |
| 157 | 157 |
| 158 // We want to avoid generating programs with different "first cov stage" val
ues when they would | 158 // We want to avoid generating programs with different "first cov stage" val
ues when they would |
| 159 // compute the same result. We set field in the desc to kNumStages when eith
er there are no | 159 // compute the same result. We set field in the desc to kNumStages when eith
er there are no |
| 160 // coverage stages or the distinction between coverage and color is immateri
al. | 160 // coverage stages or the distinction between coverage and color is immateri
al. |
| 161 int firstCoverageStage = GrDrawState::kNumStages; | 161 int firstCoverageStage = GrDrawState::kNumStages; |
| 162 desc->fFirstCoverageStage = GrDrawState::kNumStages; | 162 desc->fFirstCoverageStage = GrDrawState::kNumStages; |
| 163 bool hasCoverage = drawState.getFirstCoverageStage() <= lastEnabledStage; | 163 bool hasCoverage = drawState.getFirstCoverageStage() <= lastEnabledStage; |
| 164 if (hasCoverage) { | 164 if (hasCoverage) { |
| 165 firstCoverageStage = drawState.getFirstCoverageStage(); | 165 firstCoverageStage = drawState.getFirstCoverageStage(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 // other coverage inputs | 168 // other coverage inputs |
| 169 if (!hasCoverage) { | 169 if (!hasCoverage) { |
| 170 hasCoverage = requiresAttributeCoverage || | 170 hasCoverage = requiresAttributeCoverage || |
| 171 (desc->fAttribBindings & GrDrawState::kEdge_AttribBindings
Bit); | 171 (desc->fAttribBindings & GrDrawState::kEdge_AttribBindings
Bit); |
| 172 } | 172 } |
| 173 | 173 |
| 174 if (hasCoverage) { | 174 if (hasCoverage) { |
| 175 // color filter is applied between color/coverage computation | 175 // color filter is applied between color/coverage computation |
| 176 if (SkXfermode::kDst_Mode != desc->fColorFilterXfermode) { | 176 if (SkXfermode::kDst_Mode != desc->fColorFilterXfermode) { |
| 177 desc->fFirstCoverageStage = firstCoverageStage; | 177 desc->fFirstCoverageStage = firstCoverageStage; |
| 178 } | 178 } |
| 179 | 179 |
| 180 if (gpu->getCaps().dualSourceBlendingSupport() && | 180 if (gpu->caps()->dualSourceBlendingSupport() && |
| 181 !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag | | 181 !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag | |
| 182 GrDrawState::kCoverageAsAlpha_BlendOptFlag))) { | 182 GrDrawState::kCoverageAsAlpha_BlendOptFlag))) { |
| 183 if (kZero_GrBlendCoeff == dstCoeff) { | 183 if (kZero_GrBlendCoeff == dstCoeff) { |
| 184 // write the coverage value to second color | 184 // write the coverage value to second color |
| 185 desc->fDualSrcOutput = Desc::kCoverage_DualSrcOutput; | 185 desc->fDualSrcOutput = Desc::kCoverage_DualSrcOutput; |
| 186 desc->fFirstCoverageStage = firstCoverageStage; | 186 desc->fFirstCoverageStage = firstCoverageStage; |
| 187 } else if (kSA_GrBlendCoeff == dstCoeff) { | 187 } else if (kSA_GrBlendCoeff == dstCoeff) { |
| 188 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. | 188 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. |
| 189 desc->fDualSrcOutput = Desc::kCoverageISA_DualSrcOutput; | 189 desc->fDualSrcOutput = Desc::kCoverageISA_DualSrcOutput; |
| 190 desc->fFirstCoverageStage = firstCoverageStage; | 190 desc->fFirstCoverageStage = firstCoverageStage; |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 SkScalarToFloat(m[SkMatrix::kMTransX]), | 1195 SkScalarToFloat(m[SkMatrix::kMTransX]), |
| 1196 SkScalarToFloat(m[SkMatrix::kMTransY]), | 1196 SkScalarToFloat(m[SkMatrix::kMTransY]), |
| 1197 SkScalarToFloat(m[SkMatrix::kMPersp2]) | 1197 SkScalarToFloat(m[SkMatrix::kMPersp2]) |
| 1198 }; | 1198 }; |
| 1199 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, mt); | 1199 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, mt); |
| 1200 fMatrixState.fViewMatrix = drawState.getViewMatrix(); | 1200 fMatrixState.fViewMatrix = drawState.getViewMatrix(); |
| 1201 fMatrixState.fRenderTargetSize = size; | 1201 fMatrixState.fRenderTargetSize = size; |
| 1202 fMatrixState.fRenderTargetOrigin = rt->origin(); | 1202 fMatrixState.fRenderTargetOrigin = rt->origin(); |
| 1203 } | 1203 } |
| 1204 } | 1204 } |
| OLD | NEW |