| 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" |
| 11 #include "GrEffect.h" | 11 #include "GrEffect.h" |
| 12 #include "GrCoordTransform.h" | 12 #include "GrCoordTransform.h" |
| 13 #include "GrDrawEffect.h" | 13 #include "GrDrawEffect.h" |
| 14 #include "GrGLEffect.h" | 14 #include "GrGLEffect.h" |
| 15 #include "GrGpuGL.h" | 15 #include "GrGpuGL.h" |
| 16 #include "GrGLShaderVar.h" | 16 #include "GrGLShaderVar.h" |
| 17 #include "GrGLSL.h" | 17 #include "GrGLSL.h" |
| 18 #include "SkXfermode.h" | 18 #include "SkXfermode.h" |
| 19 | 19 |
| 20 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) | 20 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) |
| 21 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X) | 21 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X) |
| 22 | 22 |
| 23 GrGLProgram* GrGLProgram::Create(GrGpuGL* gpu, | 23 GrGLProgram* GrGLProgram::Create(GrGpuGL* gpu, |
| 24 const GrGLProgramDesc& desc, | 24 const GrGLProgramDesc& desc, |
| 25 const GrEffectStage* colorStages[], | 25 const GrEffectStage* colorStages[], |
| 26 const GrEffectStage* coverageStages[]) { | 26 const GrEffectStage* coverageStages[]) { |
| 27 GrGLShaderBuilder::GenProgramOutput output; | 27 SkAutoTDelete<GrGLShaderBuilder> builder; |
| 28 SkAutoTUnref<GrGLProgramDataManager> pdman(SkNEW_ARGS(GrGLProgramDataManager
, (gpu))); | 28 if (desc.getHeader().fHasVertexCode ||!gpu->shouldUseFixedFunctionTexturing(
)) { |
| 29 if (GrGLShaderBuilder::GenProgram(gpu, pdman, desc, colorStages, coverageSta
ges, | 29 builder.reset(SkNEW_ARGS(GrGLFullShaderBuilder, (gpu, desc))); |
| 30 &output)) { | 30 } else { |
| 31 SkASSERT(0 != output.fProgramID); | 31 builder.reset(SkNEW_ARGS(GrGLFragmentOnlyShaderBuilder, (gpu, desc))); |
| 32 return SkNEW_ARGS(GrGLProgram, (gpu, desc, pdman, output)); | 32 } |
| 33 |
| 34 if (builder->genProgram(colorStages, coverageStages)) { |
| 35 SkASSERT(0 != builder->getProgramID()); |
| 36 return SkNEW_ARGS(GrGLProgram, (gpu, desc, *builder)); |
| 33 } | 37 } |
| 34 return NULL; | 38 return NULL; |
| 35 } | 39 } |
| 36 | 40 |
| 37 GrGLProgram::GrGLProgram(GrGpuGL* gpu, | 41 GrGLProgram::GrGLProgram(GrGpuGL* gpu, |
| 38 const GrGLProgramDesc& desc, | 42 const GrGLProgramDesc& desc, |
| 39 GrGLProgramDataManager* pdman, | 43 const GrGLShaderBuilder& builder) |
| 40 const GrGLShaderBuilder::GenProgramOutput& builderOutpu
t) | |
| 41 : fColor(GrColor_ILLEGAL) | 44 : fColor(GrColor_ILLEGAL) |
| 42 , fCoverage(GrColor_ILLEGAL) | 45 , fCoverage(GrColor_ILLEGAL) |
| 43 , fDstCopyTexUnit(-1) | 46 , fDstCopyTexUnit(-1) |
| 44 , fBuilderOutput(builderOutput) | 47 , fBuiltinUniformHandles(builder.getBuiltinUniformHandles()) |
| 48 , fColorEffects(SkRef(builder.getColorEffects())) |
| 49 , fCoverageEffects(SkRef(builder.getCoverageEffects())) |
| 50 , fProgramID(builder.getProgramID()) |
| 51 , fHasVertexShader(builder.hasVertexShader()) |
| 52 , fTexCoordSetCnt(builder.getTexCoordSetCount()) |
| 45 , fDesc(desc) | 53 , fDesc(desc) |
| 46 , fGpu(gpu) | 54 , fGpu(gpu) |
| 47 , fProgramDataManager(SkRef(pdman)) { | 55 , fProgramDataManager(gpu, this, builder) { |
| 48 this->initSamplerUniforms(); | 56 this->initSamplerUniforms(); |
| 49 } | 57 } |
| 50 | 58 |
| 51 GrGLProgram::~GrGLProgram() { | 59 GrGLProgram::~GrGLProgram() { |
| 52 if (fBuilderOutput.fProgramID) { | 60 if (fProgramID) { |
| 53 GL_CALL(DeleteProgram(fBuilderOutput.fProgramID)); | 61 GL_CALL(DeleteProgram(fProgramID)); |
| 54 } | 62 } |
| 55 } | 63 } |
| 56 | 64 |
| 57 void GrGLProgram::abandon() { | 65 void GrGLProgram::abandon() { |
| 58 fBuilderOutput.fProgramID = 0; | 66 fProgramID = 0; |
| 59 } | 67 } |
| 60 | 68 |
| 61 void GrGLProgram::overrideBlend(GrBlendCoeff* srcCoeff, | 69 void GrGLProgram::overrideBlend(GrBlendCoeff* srcCoeff, |
| 62 GrBlendCoeff* dstCoeff) const { | 70 GrBlendCoeff* dstCoeff) const { |
| 63 switch (fDesc.getHeader().fCoverageOutput) { | 71 switch (fDesc.getHeader().fCoverageOutput) { |
| 64 case GrGLProgramDesc::kModulate_CoverageOutput: | 72 case GrGLProgramDesc::kModulate_CoverageOutput: |
| 65 break; | 73 break; |
| 66 // The prog will write a coverage value to the secondary | 74 // The prog will write a coverage value to the secondary |
| 67 // output and the dst is blended by one minus that value. | 75 // output and the dst is blended by one minus that value. |
| 68 case GrGLProgramDesc::kSecondaryCoverage_CoverageOutput: | 76 case GrGLProgramDesc::kSecondaryCoverage_CoverageOutput: |
| 69 case GrGLProgramDesc::kSecondaryCoverageISA_CoverageOutput: | 77 case GrGLProgramDesc::kSecondaryCoverageISA_CoverageOutput: |
| 70 case GrGLProgramDesc::kSecondaryCoverageISC_CoverageOutput: | 78 case GrGLProgramDesc::kSecondaryCoverageISC_CoverageOutput: |
| 71 *dstCoeff = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; | 79 *dstCoeff = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; |
| 72 break; | 80 break; |
| 73 case GrGLProgramDesc::kCombineWithDst_CoverageOutput: | 81 case GrGLProgramDesc::kCombineWithDst_CoverageOutput: |
| 74 // We should only have set this if the blend was specified as (1, 0) | 82 // We should only have set this if the blend was specified as (1, 0) |
| 75 SkASSERT(kOne_GrBlendCoeff == *srcCoeff && kZero_GrBlendCoeff == *ds
tCoeff); | 83 SkASSERT(kOne_GrBlendCoeff == *srcCoeff && kZero_GrBlendCoeff == *ds
tCoeff); |
| 76 break; | 84 break; |
| 77 default: | 85 default: |
| 78 SkFAIL("Unexpected coverage output"); | 86 SkFAIL("Unexpected coverage output"); |
| 79 break; | 87 break; |
| 80 } | 88 } |
| 81 } | 89 } |
| 82 | 90 |
| 83 void GrGLProgram::initSamplerUniforms() { | 91 void GrGLProgram::initSamplerUniforms() { |
| 84 GL_CALL(UseProgram(fBuilderOutput.fProgramID)); | 92 GL_CALL(UseProgram(fProgramID)); |
| 85 GrGLint texUnitIdx = 0; | 93 GrGLint texUnitIdx = 0; |
| 86 if (fBuilderOutput.fUniformHandles.fDstCopySamplerUni.isValid()) { | 94 if (fBuiltinUniformHandles.fDstCopySamplerUni.isValid()) { |
| 87 fProgramDataManager->setSampler(fBuilderOutput.fUniformHandles.fDstCopyS
amplerUni, texUnitIdx); | 95 fProgramDataManager.setSampler(fBuiltinUniformHandles.fDstCopySamplerUni
, texUnitIdx); |
| 88 fDstCopyTexUnit = texUnitIdx++; | 96 fDstCopyTexUnit = texUnitIdx++; |
| 89 } | 97 } |
| 90 fBuilderOutput.fColorEffects->initSamplers(*fProgramDataManager, &texUnitIdx
); | 98 fColorEffects->initSamplers(fProgramDataManager, &texUnitIdx); |
| 91 fBuilderOutput.fCoverageEffects->initSamplers(*fProgramDataManager, &texUnit
Idx); | 99 fCoverageEffects->initSamplers(fProgramDataManager, &texUnitIdx); |
| 92 } | 100 } |
| 93 | 101 |
| 94 /////////////////////////////////////////////////////////////////////////////// | 102 /////////////////////////////////////////////////////////////////////////////// |
| 95 | 103 |
| 96 void GrGLProgram::setData(GrDrawState::BlendOptFlags blendOpts, | 104 void GrGLProgram::setData(GrDrawState::BlendOptFlags blendOpts, |
| 97 const GrEffectStage* colorStages[], | 105 const GrEffectStage* colorStages[], |
| 98 const GrEffectStage* coverageStages[], | 106 const GrEffectStage* coverageStages[], |
| 99 const GrDeviceCoordTexture* dstCopy, | 107 const GrDeviceCoordTexture* dstCopy, |
| 100 SharedGLState* sharedState) { | 108 SharedGLState* sharedState) { |
| 101 const GrDrawState& drawState = fGpu->getDrawState(); | 109 const GrDrawState& drawState = fGpu->getDrawState(); |
| 102 | 110 |
| 103 GrColor color; | 111 GrColor color; |
| 104 GrColor coverage; | 112 GrColor coverage; |
| 105 if (blendOpts & GrDrawState::kEmitTransBlack_BlendOptFlag) { | 113 if (blendOpts & GrDrawState::kEmitTransBlack_BlendOptFlag) { |
| 106 color = 0; | 114 color = 0; |
| 107 coverage = 0; | 115 coverage = 0; |
| 108 } else if (blendOpts & GrDrawState::kEmitCoverage_BlendOptFlag) { | 116 } else if (blendOpts & GrDrawState::kEmitCoverage_BlendOptFlag) { |
| 109 color = 0xffffffff; | 117 color = 0xffffffff; |
| 110 coverage = drawState.getCoverageColor(); | 118 coverage = drawState.getCoverageColor(); |
| 111 } else { | 119 } else { |
| 112 color = drawState.getColor(); | 120 color = drawState.getColor(); |
| 113 coverage = drawState.getCoverageColor(); | 121 coverage = drawState.getCoverageColor(); |
| 114 } | 122 } |
| 115 | 123 |
| 116 this->setColor(drawState, color, sharedState); | 124 this->setColor(drawState, color, sharedState); |
| 117 this->setCoverage(drawState, coverage, sharedState); | 125 this->setCoverage(drawState, coverage, sharedState); |
| 118 this->setMatrixAndRenderTargetHeight(drawState); | 126 this->setMatrixAndRenderTargetHeight(drawState); |
| 119 | 127 |
| 120 if (NULL != dstCopy) { | 128 if (NULL != dstCopy) { |
| 121 if (fBuilderOutput.fUniformHandles.fDstCopyTopLeftUni.isValid()) { | 129 if (fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()) { |
| 122 fProgramDataManager->set2f(fBuilderOutput.fUniformHandles.fDstCopyTo
pLeftUni, | 130 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyTopLeftUni, |
| 123 static_cast<GrGLfloat>(dstCopy->offset().
fX), | 131 static_cast<GrGLfloat>(dstCopy->offset().
fX), |
| 124 static_cast<GrGLfloat>(dstCopy->offset().
fY)); | 132 static_cast<GrGLfloat>(dstCopy->offset().
fY)); |
| 125 fProgramDataManager->set2f(fBuilderOutput.fUniformHandles.fDstCopySc
aleUni, | 133 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyScaleUni, |
| 126 1.f / dstCopy->texture()->width(), | 134 1.f / dstCopy->texture()->width(), |
| 127 1.f / dstCopy->texture()->height()); | 135 1.f / dstCopy->texture()->height()); |
| 128 GrGLTexture* texture = static_cast<GrGLTexture*>(dstCopy->texture())
; | 136 GrGLTexture* texture = static_cast<GrGLTexture*>(dstCopy->texture())
; |
| 129 static GrTextureParams kParams; // the default is clamp, nearest fil
tering. | 137 static GrTextureParams kParams; // the default is clamp, nearest fil
tering. |
| 130 fGpu->bindTexture(fDstCopyTexUnit, kParams, texture); | 138 fGpu->bindTexture(fDstCopyTexUnit, kParams, texture); |
| 131 } else { | 139 } else { |
| 132 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopyScaleUni.isValid())
; | 140 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid()); |
| 133 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopySamplerUni.isValid(
)); | 141 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid()); |
| 134 } | 142 } |
| 135 } else { | 143 } else { |
| 136 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopyTopLeftUni.isValid()); | 144 SkASSERT(!fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()); |
| 137 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopyScaleUni.isValid()); | 145 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid()); |
| 138 SkASSERT(!fBuilderOutput.fUniformHandles.fDstCopySamplerUni.isValid()); | 146 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid()); |
| 139 } | 147 } |
| 140 | 148 |
| 141 fBuilderOutput.fColorEffects->setData(fGpu, *fProgramDataManager, colorStage
s); | 149 fColorEffects->setData(fGpu, fProgramDataManager, colorStages); |
| 142 fBuilderOutput.fCoverageEffects->setData(fGpu, *fProgramDataManager, coverag
eStages); | 150 fCoverageEffects->setData(fGpu, fProgramDataManager, coverageStages); |
| 143 | 151 |
| 144 | 152 |
| 145 // PathTexGen state applies to the the fixed function vertex shader. For | 153 // PathTexGen state applies to the the fixed function vertex shader. For |
| 146 // custom shaders, it's ignored, so we don't need to change the texgen | 154 // custom shaders, it's ignored, so we don't need to change the texgen |
| 147 // settings in that case. | 155 // settings in that case. |
| 148 if (!fBuilderOutput.fHasVertexShader) { | 156 if (!fHasVertexShader) { |
| 149 fGpu->flushPathTexGenSettings(fBuilderOutput.fTexCoordSetCnt); | 157 fGpu->flushPathTexGenSettings(fTexCoordSetCnt); |
| 150 } | 158 } |
| 151 } | 159 } |
| 152 | 160 |
| 153 void GrGLProgram::setColor(const GrDrawState& drawState, | 161 void GrGLProgram::setColor(const GrDrawState& drawState, |
| 154 GrColor color, | 162 GrColor color, |
| 155 SharedGLState* sharedState) { | 163 SharedGLState* sharedState) { |
| 156 const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader(); | 164 const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader(); |
| 157 if (!drawState.hasColorVertexAttribute() || drawState.canIgnoreColorAttribut
e()) { | 165 if (!drawState.hasColorVertexAttribute() || drawState.canIgnoreColorAttribut
e()) { |
| 158 switch (header.fColorInput) { | 166 switch (header.fColorInput) { |
| 159 case GrGLProgramDesc::kAttribute_ColorInput: | 167 case GrGLProgramDesc::kAttribute_ColorInput: |
| 160 SkASSERT(-1 != header.fColorAttributeIndex); | 168 SkASSERT(-1 != header.fColorAttributeIndex); |
| 161 if (sharedState->fConstAttribColor != color || | 169 if (sharedState->fConstAttribColor != color || |
| 162 sharedState->fConstAttribColorIndex != header.fColorAttribut
eIndex) { | 170 sharedState->fConstAttribColorIndex != header.fColorAttribut
eIndex) { |
| 163 // OpenGL ES only supports the float varieties of glVertexAt
trib | 171 // OpenGL ES only supports the float varieties of glVertexAt
trib |
| 164 GrGLfloat c[4]; | 172 GrGLfloat c[4]; |
| 165 GrColorToRGBAFloat(color, c); | 173 GrColorToRGBAFloat(color, c); |
| 166 GL_CALL(VertexAttrib4fv(header.fColorAttributeIndex, c)); | 174 GL_CALL(VertexAttrib4fv(header.fColorAttributeIndex, c)); |
| 167 sharedState->fConstAttribColor = color; | 175 sharedState->fConstAttribColor = color; |
| 168 sharedState->fConstAttribColorIndex = header.fColorAttribute
Index; | 176 sharedState->fConstAttribColorIndex = header.fColorAttribute
Index; |
| 169 } | 177 } |
| 170 break; | 178 break; |
| 171 case GrGLProgramDesc::kUniform_ColorInput: | 179 case GrGLProgramDesc::kUniform_ColorInput: |
| 172 if (fColor != color && fBuilderOutput.fUniformHandles.fColorUni.
isValid()) { | 180 if (fColor != color && fBuiltinUniformHandles.fColorUni.isValid(
)) { |
| 173 // OpenGL ES doesn't support unsigned byte varieties of glUn
iform | 181 // OpenGL ES doesn't support unsigned byte varieties of glUn
iform |
| 174 GrGLfloat c[4]; | 182 GrGLfloat c[4]; |
| 175 GrColorToRGBAFloat(color, c); | 183 GrColorToRGBAFloat(color, c); |
| 176 fProgramDataManager->set4fv(fBuilderOutput.fUniformHandles.f
ColorUni, 1, c); | 184 fProgramDataManager.set4fv(fBuiltinUniformHandles.fColorUni,
1, c); |
| 177 fColor = color; | 185 fColor = color; |
| 178 } | 186 } |
| 179 sharedState->fConstAttribColorIndex = -1; | 187 sharedState->fConstAttribColorIndex = -1; |
| 180 break; | 188 break; |
| 181 default: | 189 default: |
| 182 SkFAIL("Unexpected color type."); | 190 SkFAIL("Unexpected color type."); |
| 183 } | 191 } |
| 184 } else { | 192 } else { |
| 185 sharedState->fConstAttribColorIndex = -1; | 193 sharedState->fConstAttribColorIndex = -1; |
| 186 } | 194 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 201 GL_CALL(VertexAttrib4fv(header.fCoverageAttributeIndex, c)); | 209 GL_CALL(VertexAttrib4fv(header.fCoverageAttributeIndex, c)); |
| 202 sharedState->fConstAttribCoverage = coverage; | 210 sharedState->fConstAttribCoverage = coverage; |
| 203 sharedState->fConstAttribCoverageIndex = header.fCoverageAtt
ributeIndex; | 211 sharedState->fConstAttribCoverageIndex = header.fCoverageAtt
ributeIndex; |
| 204 } | 212 } |
| 205 break; | 213 break; |
| 206 case GrGLProgramDesc::kUniform_ColorInput: | 214 case GrGLProgramDesc::kUniform_ColorInput: |
| 207 if (fCoverage != coverage) { | 215 if (fCoverage != coverage) { |
| 208 // OpenGL ES doesn't support unsigned byte varieties of glUn
iform | 216 // OpenGL ES doesn't support unsigned byte varieties of glUn
iform |
| 209 GrGLfloat c[4]; | 217 GrGLfloat c[4]; |
| 210 GrColorToRGBAFloat(coverage, c); | 218 GrColorToRGBAFloat(coverage, c); |
| 211 fProgramDataManager->set4fv(fBuilderOutput.fUniformHandles.f
CoverageUni, 1, c); | 219 fProgramDataManager.set4fv(fBuiltinUniformHandles.fCoverageU
ni, 1, c); |
| 212 fCoverage = coverage; | 220 fCoverage = coverage; |
| 213 } | 221 } |
| 214 sharedState->fConstAttribCoverageIndex = -1; | 222 sharedState->fConstAttribCoverageIndex = -1; |
| 215 break; | 223 break; |
| 216 case GrGLProgramDesc::kSolidWhite_ColorInput: | 224 case GrGLProgramDesc::kSolidWhite_ColorInput: |
| 217 sharedState->fConstAttribCoverageIndex = -1; | 225 sharedState->fConstAttribCoverageIndex = -1; |
| 218 break; | 226 break; |
| 219 default: | 227 default: |
| 220 SkFAIL("Unexpected coverage type."); | 228 SkFAIL("Unexpected coverage type."); |
| 221 } | 229 } |
| 222 } else { | 230 } else { |
| 223 sharedState->fConstAttribCoverageIndex = -1; | 231 sharedState->fConstAttribCoverageIndex = -1; |
| 224 } | 232 } |
| 225 } | 233 } |
| 226 | 234 |
| 227 void GrGLProgram::setMatrixAndRenderTargetHeight(const GrDrawState& drawState) { | 235 void GrGLProgram::setMatrixAndRenderTargetHeight(const GrDrawState& drawState) { |
| 228 const GrRenderTarget* rt = drawState.getRenderTarget(); | 236 const GrRenderTarget* rt = drawState.getRenderTarget(); |
| 229 SkISize size; | 237 SkISize size; |
| 230 size.set(rt->width(), rt->height()); | 238 size.set(rt->width(), rt->height()); |
| 231 | 239 |
| 232 // Load the RT height uniform if it is needed to y-flip gl_FragCoord. | 240 // Load the RT height uniform if it is needed to y-flip gl_FragCoord. |
| 233 if (fBuilderOutput.fUniformHandles.fRTHeightUni.isValid() && | 241 if (fBuiltinUniformHandles.fRTHeightUni.isValid() && |
| 234 fMatrixState.fRenderTargetSize.fHeight != size.fHeight) { | 242 fMatrixState.fRenderTargetSize.fHeight != size.fHeight) { |
| 235 fProgramDataManager->set1f(fBuilderOutput.fUniformHandles.fRTHeightUni, | 243 fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni, |
| 236 SkIntToScalar(size.fHeight)); | 244 SkIntToScalar(size.fHeight)); |
| 237 } | 245 } |
| 238 | 246 |
| 239 if (!fBuilderOutput.fHasVertexShader) { | 247 if (!fHasVertexShader) { |
| 240 SkASSERT(!fBuilderOutput.fUniformHandles.fViewMatrixUni.isValid()); | 248 SkASSERT(!fBuiltinUniformHandles.fViewMatrixUni.isValid()); |
| 241 SkASSERT(!fBuilderOutput.fUniformHandles.fRTAdjustmentUni.isValid()); | 249 SkASSERT(!fBuiltinUniformHandles.fRTAdjustmentUni.isValid()); |
| 242 fGpu->setProjectionMatrix(drawState.getViewMatrix(), size, rt->origin())
; | 250 fGpu->setProjectionMatrix(drawState.getViewMatrix(), size, rt->origin())
; |
| 243 } else if (fMatrixState.fRenderTargetOrigin != rt->origin() || | 251 } else if (fMatrixState.fRenderTargetOrigin != rt->origin() || |
| 244 fMatrixState.fRenderTargetSize != size || | 252 fMatrixState.fRenderTargetSize != size || |
| 245 !fMatrixState.fViewMatrix.cheapEqualTo(drawState.getViewMatrix())
) { | 253 !fMatrixState.fViewMatrix.cheapEqualTo(drawState.getViewMatrix())
) { |
| 246 SkASSERT(fBuilderOutput.fUniformHandles.fViewMatrixUni.isValid()); | 254 SkASSERT(fBuiltinUniformHandles.fViewMatrixUni.isValid()); |
| 247 | 255 |
| 248 fMatrixState.fViewMatrix = drawState.getViewMatrix(); | 256 fMatrixState.fViewMatrix = drawState.getViewMatrix(); |
| 249 fMatrixState.fRenderTargetSize = size; | 257 fMatrixState.fRenderTargetSize = size; |
| 250 fMatrixState.fRenderTargetOrigin = rt->origin(); | 258 fMatrixState.fRenderTargetOrigin = rt->origin(); |
| 251 | 259 |
| 252 GrGLfloat viewMatrix[3 * 3]; | 260 GrGLfloat viewMatrix[3 * 3]; |
| 253 fMatrixState.getGLMatrix<3>(viewMatrix); | 261 fMatrixState.getGLMatrix<3>(viewMatrix); |
| 254 fProgramDataManager->setMatrix3f(fBuilderOutput.fUniformHandles.fViewMat
rixUni, viewMatrix); | 262 fProgramDataManager.setMatrix3f(fBuiltinUniformHandles.fViewMatrixUni, v
iewMatrix); |
| 255 | 263 |
| 256 GrGLfloat rtAdjustmentVec[4]; | 264 GrGLfloat rtAdjustmentVec[4]; |
| 257 fMatrixState.getRTAdjustmentVec(rtAdjustmentVec); | 265 fMatrixState.getRTAdjustmentVec(rtAdjustmentVec); |
| 258 fProgramDataManager->set4fv(fBuilderOutput.fUniformHandles.fRTAdjustment
Uni, 1, rtAdjustmentVec); | 266 fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, r
tAdjustmentVec); |
| 259 } | 267 } |
| 260 } | 268 } |
| OLD | NEW |