| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "gl/GrGLShaderBuilder.h" | 8 #include "gl/GrGLShaderBuilder.h" |
| 9 #include "gl/GrGLProgram.h" | 9 #include "gl/GrGLProgram.h" |
| 10 #include "gl/GrGLUniformHandle.h" | 10 #include "gl/GrGLUniformHandle.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 , fVSAttrs(kVarsPerBlock) | 98 , fVSAttrs(kVarsPerBlock) |
| 99 , fVSOutputs(kVarsPerBlock) | 99 , fVSOutputs(kVarsPerBlock) |
| 100 , fGSInputs(kVarsPerBlock) | 100 , fGSInputs(kVarsPerBlock) |
| 101 , fGSOutputs(kVarsPerBlock) | 101 , fGSOutputs(kVarsPerBlock) |
| 102 , fFSInputs(kVarsPerBlock) | 102 , fFSInputs(kVarsPerBlock) |
| 103 , fFSOutputs(kMaxFSOutputs) | 103 , fFSOutputs(kMaxFSOutputs) |
| 104 , fCtxInfo(ctxInfo) | 104 , fCtxInfo(ctxInfo) |
| 105 , fUniformManager(uniformManager) | 105 , fUniformManager(uniformManager) |
| 106 , fFSFeaturesAddedMask(0) | 106 , fFSFeaturesAddedMask(0) |
| 107 #if GR_GL_EXPERIMENTAL_GS | 107 #if GR_GL_EXPERIMENTAL_GS |
| 108 , fUsesGS(desc.fExperimentalGS) | 108 , fUsesGS(SkToBool(desc.getHeader().fExperimentalGS)) |
| 109 #else | 109 #else |
| 110 , fUsesGS(false) | 110 , fUsesGS(false) |
| 111 #endif | 111 #endif |
| 112 , fSetupFragPosition(false) | 112 , fSetupFragPosition(false) |
| 113 , fRTHeightUniform(GrGLUniformManager::kInvalidUniformHandle) | 113 , fRTHeightUniform(GrGLUniformManager::kInvalidUniformHandle) |
| 114 , fDstCopyTopLeftUniform (GrGLUniformManager::kInvalidUniformHandle) | 114 , fDstCopyTopLeftUniform (GrGLUniformManager::kInvalidUniformHandle) |
| 115 , fDstCopyScaleUniform (GrGLUniformManager::kInvalidUniformHandle) | 115 , fDstCopyScaleUniform (GrGLUniformManager::kInvalidUniformHandle) |
| 116 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.fFragPosKey) { | 116 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFr
agPosKey) { |
| 117 |
| 118 const GrGLProgramDesc::KeyHeader& header = desc.getHeader(); |
| 117 | 119 |
| 118 fPositionVar = &fVSAttrs.push_back(); | 120 fPositionVar = &fVSAttrs.push_back(); |
| 119 fPositionVar->set(kVec2f_GrSLType, GrGLShaderVar::kAttribute_TypeModifier, "
aPosition"); | 121 fPositionVar->set(kVec2f_GrSLType, GrGLShaderVar::kAttribute_TypeModifier, "
aPosition"); |
| 120 if (-1 != desc.fLocalCoordAttributeIndex) { | 122 if (-1 != header.fLocalCoordAttributeIndex) { |
| 121 fLocalCoordsVar = &fVSAttrs.push_back(); | 123 fLocalCoordsVar = &fVSAttrs.push_back(); |
| 122 fLocalCoordsVar->set(kVec2f_GrSLType, | 124 fLocalCoordsVar->set(kVec2f_GrSLType, |
| 123 GrGLShaderVar::kAttribute_TypeModifier, | 125 GrGLShaderVar::kAttribute_TypeModifier, |
| 124 "aLocalCoords"); | 126 "aLocalCoords"); |
| 125 } else { | 127 } else { |
| 126 fLocalCoordsVar = fPositionVar; | 128 fLocalCoordsVar = fPositionVar; |
| 127 } | 129 } |
| 128 // Emit code to read the dst copy textue if necessary. | 130 // Emit code to read the dst copy textue if necessary. |
| 129 if (kNoDstRead_DstReadKey != desc.fDstReadKey && | 131 if (kNoDstRead_DstReadKey != header.fDstReadKey && |
| 130 GrGLCaps::kNone_FBFetchType == ctxInfo.caps()->fbFetchType()) { | 132 GrGLCaps::kNone_FBFetchType == ctxInfo.caps()->fbFetchType()) { |
| 131 bool topDown = SkToBool(kTopLeftOrigin_DstReadKeyBit & desc.fDstReadKey)
; | 133 bool topDown = SkToBool(kTopLeftOrigin_DstReadKeyBit & header.fDstReadKe
y); |
| 132 const char* dstCopyTopLeftName; | 134 const char* dstCopyTopLeftName; |
| 133 const char* dstCopyCoordScaleName; | 135 const char* dstCopyCoordScaleName; |
| 134 uint32_t configMask; | 136 uint32_t configMask; |
| 135 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & desc.fDstReadKey)) { | 137 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & header.fDstReadKey)) { |
| 136 configMask = kA_GrColorComponentFlag; | 138 configMask = kA_GrColorComponentFlag; |
| 137 } else { | 139 } else { |
| 138 configMask = kRGBA_GrColorComponentFlags; | 140 configMask = kRGBA_GrColorComponentFlags; |
| 139 } | 141 } |
| 140 fDstCopySampler.init(this, configMask, "rgba", 0); | 142 fDstCopySampler.init(this, configMask, "rgba", 0); |
| 141 | 143 |
| 142 fDstCopyTopLeftUniform = this->addUniform(kFragment_ShaderType, | 144 fDstCopyTopLeftUniform = this->addUniform(kFragment_ShaderType, |
| 143 kVec2f_GrSLType, | 145 kVec2f_GrSLType, |
| 144 "DstCopyUpperLeft", | 146 "DstCopyUpperLeft", |
| 145 &dstCopyTopLeftName); | 147 &dstCopyTopLeftName); |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 SkString* fsInOutColor, | 651 SkString* fsInOutColor, |
| 650 GrSLConstantVec* fsInOutColorKnownValue, | 652 GrSLConstantVec* fsInOutColorKnownValue, |
| 651 SkTArray<GrGLUniformManager::UniformHandle, true>* effec
tSamplerHandles[], | 653 SkTArray<GrGLUniformManager::UniformHandle, true>* effec
tSamplerHandles[], |
| 652 GrGLEffect* glEffects[]) { | 654 GrGLEffect* glEffects[]) { |
| 653 bool effectEmitted = false; | 655 bool effectEmitted = false; |
| 654 | 656 |
| 655 SkString inColor = *fsInOutColor; | 657 SkString inColor = *fsInOutColor; |
| 656 SkString outColor; | 658 SkString outColor; |
| 657 | 659 |
| 658 for (int e = 0; e < effectCnt; ++e) { | 660 for (int e = 0; e < effectCnt; ++e) { |
| 659 if (NULL == effectStages[e] || GrGLEffect::kNoEffectKey == effectKeys[e]
) { | 661 GrAssert(NULL != effectStages[e] && NULL != effectStages[e]->getEffect()
); |
| 660 continue; | |
| 661 } | |
| 662 | |
| 663 GrAssert(NULL != effectStages[e]->getEffect()); | |
| 664 const GrEffectStage& stage = *effectStages[e]; | 662 const GrEffectStage& stage = *effectStages[e]; |
| 665 const GrEffectRef& effect = *stage.getEffect(); | 663 const GrEffectRef& effect = *stage.getEffect(); |
| 666 | 664 |
| 667 CodeStage::AutoStageRestore csar(&fCodeStage, &stage); | 665 CodeStage::AutoStageRestore csar(&fCodeStage, &stage); |
| 668 | 666 |
| 669 int numTextures = effect->numTextures(); | 667 int numTextures = effect->numTextures(); |
| 670 SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers; | 668 SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers; |
| 671 textureSamplers.push_back_n(numTextures); | 669 textureSamplers.push_back_n(numTextures); |
| 672 for (int t = 0; t < numTextures; ++t) { | 670 for (int t = 0; t < numTextures; ++t) { |
| 673 textureSamplers[t].init(this, &effect->textureAccess(t), t); | 671 textureSamplers[t].init(this, &effect->textureAccess(t), t); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 for (const AttributePair* attrib = this->getEffectAttributes().begin(); | 727 for (const AttributePair* attrib = this->getEffectAttributes().begin(); |
| 730 attrib != attribEnd; | 728 attrib != attribEnd; |
| 731 ++attrib) { | 729 ++attrib) { |
| 732 if (attrib->fIndex == attributeIndex) { | 730 if (attrib->fIndex == attributeIndex) { |
| 733 return &attrib->fName; | 731 return &attrib->fName; |
| 734 } | 732 } |
| 735 } | 733 } |
| 736 | 734 |
| 737 return NULL; | 735 return NULL; |
| 738 } | 736 } |
| OLD | NEW |