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 "GrDrawEffect.h" |
12 #include "GrGLEffect.h" | 13 #include "GrGLEffect.h" |
13 #include "GrGpuGL.h" | 14 #include "GrGpuGL.h" |
14 #include "GrGLShaderVar.h" | 15 #include "GrGLShaderVar.h" |
15 #include "GrBackendEffectFactory.h" | 16 #include "GrBackendEffectFactory.h" |
16 #include "SkTrace.h" | 17 #include "SkTrace.h" |
17 #include "SkXfermode.h" | 18 #include "SkXfermode.h" |
18 | 19 |
19 #include "SkRTConf.h" | 20 #include "SkRTConf.h" |
20 | 21 |
21 SK_DEFINE_INST_COUNT(GrGLProgram) | 22 SK_DEFINE_INST_COUNT(GrGLProgram) |
22 | 23 |
23 #define GL_CALL(X) GR_GL_CALL(fContext.interface(), X) | 24 #define GL_CALL(X) GR_GL_CALL(fContext.interface(), X) |
24 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fContext.interface(), R, X) | 25 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fContext.interface(), R, X) |
25 | 26 |
26 SK_CONF_DECLARE(bool, c_PrintShaders, "gpu.printShaders", false, | 27 SK_CONF_DECLARE(bool, c_PrintShaders, "gpu.printShaders", false, |
27 "Print the source code for all shaders generated."); | 28 "Print the source code for all shaders generated."); |
28 | 29 |
29 #define TEX_ATTR_NAME "aTexCoord" | |
30 #define COL_ATTR_NAME "aColor" | 30 #define COL_ATTR_NAME "aColor" |
31 #define COV_ATTR_NAME "aCoverage" | 31 #define COV_ATTR_NAME "aCoverage" |
32 #define EDGE_ATTR_NAME "aEdge" | 32 #define EDGE_ATTR_NAME "aEdge" |
33 | 33 |
34 namespace { | 34 namespace { |
35 inline const char* declared_color_output_name() { return "fsColorOut"; } | 35 inline const char* declared_color_output_name() { return "fsColorOut"; } |
36 inline const char* dual_source_output_name() { return "dualSourceOut"; } | 36 inline const char* dual_source_output_name() { return "dualSourceOut"; } |
37 } | 37 } |
38 | 38 |
39 const GrGLProgram::AttribLayout GrGLProgram::kAttribLayouts[kGrVertexAttribTypeC
ount] = { | 39 const GrGLProgram::AttribLayout GrGLProgram::kAttribLayouts[kGrVertexAttribTypeC
ount] = { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 desc->fDiscardIfOutsideEdge = false; | 127 desc->fDiscardIfOutsideEdge = false; |
128 } | 128 } |
129 | 129 |
130 for (int s = 0; s < GrDrawState::kNumStages; ++s) { | 130 for (int s = 0; s < GrDrawState::kNumStages; ++s) { |
131 | 131 |
132 bool skip = s < drawState.getFirstCoverageStage() ? skipColor : skipCove
rage; | 132 bool skip = s < drawState.getFirstCoverageStage() ? skipColor : skipCove
rage; |
133 if (!skip && drawState.isStageEnabled(s)) { | 133 if (!skip && drawState.isStageEnabled(s)) { |
134 lastEnabledStage = s; | 134 lastEnabledStage = s; |
135 const GrEffectRef& effect = *drawState.getStage(s).getEffect(); | 135 const GrEffectRef& effect = *drawState.getStage(s).getEffect(); |
136 const GrBackendEffectFactory& factory = effect->getFactory(); | 136 const GrBackendEffectFactory& factory = effect->getFactory(); |
137 desc->fEffectKeys[s] = factory.glEffectKey(drawState.getStage(s), gp
u->glCaps()); | 137 bool explicitLocalCoords = (drawState.getAttribBindings() & |
| 138 GrDrawState::kLocalCoords_AttribBindings
Bit); |
| 139 GrDrawEffect drawEffect(drawState.getStage(s), explicitLocalCoords); |
| 140 desc->fEffectKeys[s] = factory.glEffectKey(drawEffect, gpu->glCaps()
); |
138 } else { | 141 } else { |
139 desc->fEffectKeys[s] = 0; | 142 desc->fEffectKeys[s] = 0; |
140 } | 143 } |
141 } | 144 } |
142 | 145 |
143 desc->fDualSrcOutput = Desc::kNone_DualSrcOutput; | 146 desc->fDualSrcOutput = Desc::kNone_DualSrcOutput; |
144 | 147 |
145 // 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 |
146 // 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). |
147 #if GR_GL_EXPERIMENTAL_GS | 150 #if GR_GL_EXPERIMENTAL_GS |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 desc->fColorAttributeIndex = GrDrawState::kColorOverrideAttribIndexValue
; | 203 desc->fColorAttributeIndex = GrDrawState::kColorOverrideAttribIndexValue
; |
201 } | 204 } |
202 if (requiresAttributeCoverage) { | 205 if (requiresAttributeCoverage) { |
203 desc->fCoverageAttributeIndex = drawState.getAttribIndex(GrDrawState::kC
overage_AttribIndex); | 206 desc->fCoverageAttributeIndex = drawState.getAttribIndex(GrDrawState::kC
overage_AttribIndex); |
204 } else { | 207 } else { |
205 desc->fCoverageAttributeIndex = GrDrawState::kCoverageOverrideAttribInde
xValue; | 208 desc->fCoverageAttributeIndex = GrDrawState::kCoverageOverrideAttribInde
xValue; |
206 } | 209 } |
207 if (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) { | 210 if (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) { |
208 desc->fEdgeAttributeIndex = drawState.getAttribIndex(GrDrawState::kEdge_
AttribIndex); | 211 desc->fEdgeAttributeIndex = drawState.getAttribIndex(GrDrawState::kEdge_
AttribIndex); |
209 } | 212 } |
210 if (GrDrawState::AttributesBindExplicitTexCoords(desc->fAttribBindings)) { | 213 if (desc->fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) { |
211 desc->fTexCoordAttributeIndex = drawState.getAttribIndex(GrDrawState::kT
exCoord_AttribIndex); | 214 desc->fLocalCoordsAttributeIndex = drawState.getAttribIndex(GrDrawState:
:kLocalCoords_AttribIndex); |
212 } | 215 } |
213 | 216 |
214 #if GR_DEBUG | 217 #if GR_DEBUG |
215 // verify valid vertex attribute state | 218 // verify valid vertex attribute state |
216 const GrVertexAttrib* vertexAttribs = drawState.getVertexAttribs(); | 219 const GrVertexAttrib* vertexAttribs = drawState.getVertexAttribs(); |
217 GrAssert(desc->fPositionAttributeIndex < GrDrawState::kVertexAttribCnt); | 220 GrAssert(desc->fPositionAttributeIndex < GrDrawState::kVertexAttribCnt); |
218 GrAssert(kAttribLayouts[vertexAttribs[desc->fPositionAttributeIndex].fType].
fCount == 2); | 221 GrAssert(kAttribLayouts[vertexAttribs[desc->fPositionAttributeIndex].fType].
fCount == 2); |
219 if (requiresAttributeColors) { | 222 if (requiresAttributeColors) { |
220 GrAssert(desc->fColorAttributeIndex < GrDrawState::kVertexAttribCnt); | 223 GrAssert(desc->fColorAttributeIndex < GrDrawState::kVertexAttribCnt); |
221 GrAssert(kAttribLayouts[vertexAttribs[desc->fColorAttributeIndex].fType]
.fCount == 4); | 224 GrAssert(kAttribLayouts[vertexAttribs[desc->fColorAttributeIndex].fType]
.fCount == 4); |
222 } | 225 } |
223 if (requiresAttributeCoverage) { | 226 if (requiresAttributeCoverage) { |
224 GrAssert(desc->fCoverageAttributeIndex < GrDrawState::kVertexAttribCnt); | 227 GrAssert(desc->fCoverageAttributeIndex < GrDrawState::kVertexAttribCnt); |
225 GrAssert(kAttribLayouts[vertexAttribs[desc->fCoverageAttributeIndex].fTy
pe].fCount == 4); | 228 GrAssert(kAttribLayouts[vertexAttribs[desc->fCoverageAttributeIndex].fTy
pe].fCount == 4); |
226 } | 229 } |
227 if (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) { | 230 if (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) { |
228 GrAssert(desc->fEdgeAttributeIndex < GrDrawState::kVertexAttribCnt); | 231 GrAssert(desc->fEdgeAttributeIndex < GrDrawState::kVertexAttribCnt); |
229 GrAssert(kAttribLayouts[vertexAttribs[desc->fEdgeAttributeIndex].fType].
fCount == 4); | 232 GrAssert(kAttribLayouts[vertexAttribs[desc->fEdgeAttributeIndex].fType].
fCount == 4); |
230 } | 233 } |
231 if (GrDrawState::AttributesBindExplicitTexCoords(desc->fAttribBindings)) { | 234 if (desc->fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) { |
232 GrAssert(desc->fTexCoordAttributeIndex < GrDrawState::kVertexAttribCnt); | 235 GrAssert(desc->fLocalCoordsAttributeIndex < GrDrawState::kVertexAttribCn
t); |
233 GrAssert(kAttribLayouts[vertexAttribs[desc->fTexCoordAttributeIndex].fTy
pe].fCount == 2); | 236 GrAssert(kAttribLayouts[vertexAttribs[desc->fLocalCoordsAttributeIndex].
fType].fCount == 2); |
234 } | 237 } |
235 #endif | 238 #endif |
236 } | 239 } |
237 | 240 |
238 GrGLProgram* GrGLProgram::Create(const GrGLContext& gl, | 241 GrGLProgram* GrGLProgram::Create(const GrGLContext& gl, |
239 const Desc& desc, | 242 const Desc& desc, |
240 const GrEffectStage* stages[]) { | 243 const GrEffectStage* stages[]) { |
241 GrGLProgram* program = SkNEW_ARGS(GrGLProgram, (gl, desc, stages)); | 244 GrGLProgram* program = SkNEW_ARGS(GrGLProgram, (gl, desc, stages)); |
242 if (!program->succeeded()) { | 245 if (!program->succeeded()) { |
243 delete program; | 246 delete program; |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 if (!(fFShaderID = compile_shader(fContext, GR_GL_FRAGMENT_SHADER, shader)))
{ | 675 if (!(fFShaderID = compile_shader(fContext, GR_GL_FRAGMENT_SHADER, shader)))
{ |
673 return false; | 676 return false; |
674 } | 677 } |
675 | 678 |
676 return true; | 679 return true; |
677 } | 680 } |
678 | 681 |
679 bool GrGLProgram::genProgram(const GrEffectStage* stages[]) { | 682 bool GrGLProgram::genProgram(const GrEffectStage* stages[]) { |
680 GrAssert(0 == fProgramID); | 683 GrAssert(0 == fProgramID); |
681 | 684 |
682 GrGLShaderBuilder builder(fContext.info(), fUniformManager); | |
683 const GrAttribBindings& attribBindings = fDesc.fAttribBindings; | 685 const GrAttribBindings& attribBindings = fDesc.fAttribBindings; |
| 686 bool hasExplicitLocalCoords = |
| 687 SkToBool(attribBindings & GrDrawState::kLocalCoords_AttribBindingsBit); |
| 688 GrGLShaderBuilder builder(fContext.info(), fUniformManager, hasExplicitLocal
Coords); |
684 | 689 |
685 #if GR_GL_EXPERIMENTAL_GS | 690 #if GR_GL_EXPERIMENTAL_GS |
686 builder.fUsesGS = fDesc.fExperimentalGS; | 691 builder.fUsesGS = fDesc.fExperimentalGS; |
687 #endif | 692 #endif |
688 | 693 |
689 SkXfermode::Coeff colorCoeff, uniformCoeff; | 694 SkXfermode::Coeff colorCoeff, uniformCoeff; |
690 // The rest of transfer mode color filters have not been implemented | 695 // The rest of transfer mode color filters have not been implemented |
691 if (fDesc.fColorFilterXfermode < SkXfermode::kCoeffModesCnt) { | 696 if (fDesc.fColorFilterXfermode < SkXfermode::kCoeffModesCnt) { |
692 GR_DEBUGCODE(bool success =) | 697 GR_DEBUGCODE(bool success =) |
693 SkXfermode::ModeAsCoeff(static_cast<SkXfermode::Mode> | 698 SkXfermode::ModeAsCoeff(static_cast<SkXfermode::Mode> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 | 758 |
754 if (needComputedColor) { | 759 if (needComputedColor) { |
755 this->genInputColor(&builder, &inColor); | 760 this->genInputColor(&builder, &inColor); |
756 } | 761 } |
757 | 762 |
758 // we output point size in the GS if present | 763 // we output point size in the GS if present |
759 if (fDesc.fEmitsPointSize && !builder.fUsesGS){ | 764 if (fDesc.fEmitsPointSize && !builder.fUsesGS){ |
760 builder.vsCodeAppend("\tgl_PointSize = 1.0;\n"); | 765 builder.vsCodeAppend("\tgl_PointSize = 1.0;\n"); |
761 } | 766 } |
762 | 767 |
763 // add texture coordinates that are used to the list of vertex attr decls | |
764 if (GrDrawState::AttributesBindExplicitTexCoords(attribBindings)) { | |
765 builder.addAttribute(kVec2f_GrSLType, TEX_ATTR_NAME); | |
766 } | |
767 | |
768 /////////////////////////////////////////////////////////////////////////// | 768 /////////////////////////////////////////////////////////////////////////// |
769 // compute the final color | 769 // compute the final color |
770 | 770 |
771 // if we have color stages string them together, feeding the output color | 771 // if we have color stages string them together, feeding the output color |
772 // of each to the next and generating code for each stage. | 772 // of each to the next and generating code for each stage. |
773 if (needComputedColor) { | 773 if (needComputedColor) { |
774 SkString outColor; | 774 SkString outColor; |
775 for (int s = 0; s < fDesc.fFirstCoverageStage; ++s) { | 775 for (int s = 0; s < fDesc.fFirstCoverageStage; ++s) { |
776 if (GrGLEffect::kNoEffectKey != fDesc.fEffectKeys[s]) { | 776 if (GrGLEffect::kNoEffectKey != fDesc.fEffectKeys[s]) { |
777 // create var to hold stage result | 777 // create var to hold stage result |
778 outColor = "color"; | 778 outColor = "color"; |
779 outColor.appendS32(s); | 779 outColor.appendS32(s); |
780 builder.fsCodeAppendf("\tvec4 %s;\n", outColor.c_str()); | 780 builder.fsCodeAppendf("\tvec4 %s;\n", outColor.c_str()); |
781 | 781 |
782 const char* inCoords; | |
783 // figure out what our input coords are | |
784 if (!GrDrawState::StageBindsExplicitTexCoords(attribBindings, s)
) { | |
785 inCoords = builder.positionAttribute().c_str(); | |
786 } else { | |
787 // must have input tex coordinates if stage is enabled. | |
788 inCoords = TEX_ATTR_NAME; | |
789 } | |
790 | |
791 builder.setCurrentStage(s); | 782 builder.setCurrentStage(s); |
792 fEffects[s] = builder.createAndEmitGLEffect(*stages[s], | 783 fEffects[s] = builder.createAndEmitGLEffect(*stages[s], |
793 fDesc.fEffectKeys[s]
, | 784 fDesc.fEffectKeys[s]
, |
794 inColor.size() ? inC
olor.c_str() : NULL, | 785 inColor.size() ? inC
olor.c_str() : NULL, |
795 outColor.c_str(), | 786 outColor.c_str(), |
796 inCoords, | |
797 &fUniformHandles.fSa
mplerUnis[s]); | 787 &fUniformHandles.fSa
mplerUnis[s]); |
798 builder.setNonStage(); | 788 builder.setNonStage(); |
799 inColor = outColor; | 789 inColor = outColor; |
800 } | 790 } |
801 } | 791 } |
802 } | 792 } |
803 | 793 |
804 // if have all ones or zeros for the "dst" input to the color filter then we | 794 // if have all ones or zeros for the "dst" input to the color filter then we |
805 // may be able to make additional optimizations. | 795 // may be able to make additional optimizations. |
806 if (needColorFilterUniform && needComputedColor && !inColor.size()) { | 796 if (needColorFilterUniform && needComputedColor && !inColor.size()) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 | 854 |
865 SkString outCoverage; | 855 SkString outCoverage; |
866 const int& startStage = fDesc.fFirstCoverageStage; | 856 const int& startStage = fDesc.fFirstCoverageStage; |
867 for (int s = startStage; s < GrDrawState::kNumStages; ++s) { | 857 for (int s = startStage; s < GrDrawState::kNumStages; ++s) { |
868 if (fDesc.fEffectKeys[s]) { | 858 if (fDesc.fEffectKeys[s]) { |
869 // create var to hold stage output | 859 // create var to hold stage output |
870 outCoverage = "coverage"; | 860 outCoverage = "coverage"; |
871 outCoverage.appendS32(s); | 861 outCoverage.appendS32(s); |
872 builder.fsCodeAppendf("\tvec4 %s;\n", outCoverage.c_str()); | 862 builder.fsCodeAppendf("\tvec4 %s;\n", outCoverage.c_str()); |
873 | 863 |
874 const char* inCoords; | |
875 // figure out what our input coords are | |
876 if (!GrDrawState::StageBindsExplicitTexCoords(attribBindings
, s)) { | |
877 inCoords = builder.positionAttribute().c_str(); | |
878 } else { | |
879 // must have input tex coordinates if stage is | |
880 // enabled. | |
881 inCoords = TEX_ATTR_NAME; | |
882 } | |
883 | |
884 // stages don't know how to deal with a scalar input. (Maybe
they should. We | 864 // stages don't know how to deal with a scalar input. (Maybe
they should. We |
885 // could pass a GrGLShaderVar) | 865 // could pass a GrGLShaderVar) |
886 if (inCoverageIsScalar) { | 866 if (inCoverageIsScalar) { |
887 builder.fsCodeAppendf("\tvec4 %s4 = vec4(%s);\n", | 867 builder.fsCodeAppendf("\tvec4 %s4 = vec4(%s);\n", |
888 inCoverage.c_str(), inCoverage.c_s
tr()); | 868 inCoverage.c_str(), inCoverage.c_s
tr()); |
889 inCoverage.append("4"); | 869 inCoverage.append("4"); |
890 } | 870 } |
891 builder.setCurrentStage(s); | 871 builder.setCurrentStage(s); |
892 fEffects[s] = builder.createAndEmitGLEffect( | 872 fEffects[s] = builder.createAndEmitGLEffect( |
893 *stages[s], | 873 *stages[s], |
894 fDesc.fEffectKeys[s], | 874 fDesc.fEffectKeys[s], |
895 inCoverage.size() ? inCovera
ge.c_str() : NULL, | 875 inCoverage.size() ? inCovera
ge.c_str() : NULL, |
896 outCoverage.c_str(), | 876 outCoverage.c_str(), |
897 inCoords, | |
898 &fUniformHandles.fSamplerUni
s[s]); | 877 &fUniformHandles.fSamplerUni
s[s]); |
899 builder.setNonStage(); | 878 builder.setNonStage(); |
900 inCoverage = outCoverage; | 879 inCoverage = outCoverage; |
901 } | 880 } |
902 } | 881 } |
903 | 882 |
904 // discard if coverage is zero | 883 // discard if coverage is zero |
905 if (fDesc.fDiscardIfOutsideEdge && !outCoverage.isEmpty()) { | 884 if (fDesc.fDiscardIfOutsideEdge && !outCoverage.isEmpty()) { |
906 builder.fsCodeAppendf( | 885 builder.fsCodeAppendf( |
907 "\tif (all(lessThanEqual(%s, vec4(0.0)))) {\n\t\tdiscard;\n\
t}\n", | 886 "\tif (all(lessThanEqual(%s, vec4(0.0)))) {\n\t\tdiscard;\n\
t}\n", |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 // Bind the attrib locations to same values for all shaders | 980 // Bind the attrib locations to same values for all shaders |
1002 GL_CALL(BindAttribLocation(fProgramID, | 981 GL_CALL(BindAttribLocation(fProgramID, |
1003 fDesc.fPositionAttributeIndex, | 982 fDesc.fPositionAttributeIndex, |
1004 builder.positionAttribute().c_str())); | 983 builder.positionAttribute().c_str())); |
1005 GL_CALL(BindAttribLocation(fProgramID, fDesc.fColorAttributeIndex, COL_ATTR_
NAME)); | 984 GL_CALL(BindAttribLocation(fProgramID, fDesc.fColorAttributeIndex, COL_ATTR_
NAME)); |
1006 GL_CALL(BindAttribLocation(fProgramID, fDesc.fCoverageAttributeIndex, COV_AT
TR_NAME)); | 985 GL_CALL(BindAttribLocation(fProgramID, fDesc.fCoverageAttributeIndex, COV_AT
TR_NAME)); |
1007 | 986 |
1008 if (fDesc.fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) { | 987 if (fDesc.fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) { |
1009 GL_CALL(BindAttribLocation(fProgramID, fDesc.fEdgeAttributeIndex, EDGE_A
TTR_NAME)); | 988 GL_CALL(BindAttribLocation(fProgramID, fDesc.fEdgeAttributeIndex, EDGE_A
TTR_NAME)); |
1010 } | 989 } |
1011 if (GrDrawState::AttributesBindExplicitTexCoords(fDesc.fAttribBindings)) { | 990 if (fDesc.fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) { |
1012 GL_CALL(BindAttribLocation(fProgramID, fDesc.fTexCoordAttributeIndex, TE
X_ATTR_NAME)); | 991 GL_CALL(BindAttribLocation(fProgramID, |
| 992 fDesc.fLocalCoordsAttributeIndex, |
| 993 builder.localCoordsAttribute().c_str())); |
1013 } | 994 } |
1014 | 995 |
1015 const GrGLShaderBuilder::AttributePair* attribEnd = builder.getEffectAttribu
tes().end(); | 996 const GrGLShaderBuilder::AttributePair* attribEnd = builder.getEffectAttribu
tes().end(); |
1016 for (const GrGLShaderBuilder::AttributePair* attrib = builder.getEffectAttri
butes().begin(); | 997 for (const GrGLShaderBuilder::AttributePair* attrib = builder.getEffectAttri
butes().begin(); |
1017 attrib != attribEnd; | 998 attrib != attribEnd; |
1018 ++attrib) { | 999 ++attrib) { |
1019 GL_CALL(BindAttribLocation(fProgramID, attrib->fIndex, attrib->fName.c_
str())); | 1000 GL_CALL(BindAttribLocation(fProgramID, attrib->fIndex, attrib->fName.c_
str())); |
1020 } | 1001 } |
1021 | 1002 |
1022 GL_CALL(LinkProgram(fProgramID)); | 1003 GL_CALL(LinkProgram(fProgramID)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 GrColorToRGBAFloat(drawState.getColorFilterColor(), c); | 1062 GrColorToRGBAFloat(drawState.getColorFilterColor(), c); |
1082 fUniformManager.set4fv(fUniformHandles.fColorFilterUni, 0, 1, c); | 1063 fUniformManager.set4fv(fUniformHandles.fColorFilterUni, 0, 1, c); |
1083 fColorFilterColor = drawState.getColorFilterColor(); | 1064 fColorFilterColor = drawState.getColorFilterColor(); |
1084 } | 1065 } |
1085 | 1066 |
1086 GrGLint texUnitIdx = 0; | 1067 GrGLint texUnitIdx = 0; |
1087 for (int s = 0; s < GrDrawState::kNumStages; ++s) { | 1068 for (int s = 0; s < GrDrawState::kNumStages; ++s) { |
1088 if (NULL != fEffects[s]) { | 1069 if (NULL != fEffects[s]) { |
1089 const GrEffectStage& stage = drawState.getStage(s); | 1070 const GrEffectStage& stage = drawState.getStage(s); |
1090 GrAssert(NULL != stage.getEffect()); | 1071 GrAssert(NULL != stage.getEffect()); |
1091 fEffects[s]->setData(fUniformManager, stage); | 1072 |
| 1073 bool explicitLocalCoords = |
| 1074 (fDesc.fAttribBindings & GrDrawState::kLocalCoords_AttribBinding
sBit); |
| 1075 GrDrawEffect drawEffect(stage, explicitLocalCoords); |
| 1076 fEffects[s]->setData(fUniformManager, drawEffect); |
1092 int numSamplers = fUniformHandles.fSamplerUnis[s].count(); | 1077 int numSamplers = fUniformHandles.fSamplerUnis[s].count(); |
1093 for (int u = 0; u < numSamplers; ++u) { | 1078 for (int u = 0; u < numSamplers; ++u) { |
1094 UniformHandle handle = fUniformHandles.fSamplerUnis[s][u]; | 1079 UniformHandle handle = fUniformHandles.fSamplerUnis[s][u]; |
1095 if (GrGLUniformManager::kInvalidUniformHandle != handle) { | 1080 if (GrGLUniformManager::kInvalidUniformHandle != handle) { |
1096 const GrTextureAccess& access = (*stage.getEffect())->textur
eAccess(u); | 1081 const GrTextureAccess& access = (*stage.getEffect())->textur
eAccess(u); |
1097 GrGLTexture* texture = static_cast<GrGLTexture*>(access.getT
exture()); | 1082 GrGLTexture* texture = static_cast<GrGLTexture*>(access.getT
exture()); |
1098 gpu->bindTexture(texUnitIdx, access.getParams(), texture); | 1083 gpu->bindTexture(texUnitIdx, access.getParams(), texture); |
1099 ++texUnitIdx; | 1084 ++texUnitIdx; |
1100 } | 1085 } |
1101 } | 1086 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 SkScalarToFloat(m[SkMatrix::kMTransX]), | 1195 SkScalarToFloat(m[SkMatrix::kMTransX]), |
1211 SkScalarToFloat(m[SkMatrix::kMTransY]), | 1196 SkScalarToFloat(m[SkMatrix::kMTransY]), |
1212 SkScalarToFloat(m[SkMatrix::kMPersp2]) | 1197 SkScalarToFloat(m[SkMatrix::kMPersp2]) |
1213 }; | 1198 }; |
1214 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, mt); | 1199 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, mt); |
1215 fMatrixState.fViewMatrix = drawState.getViewMatrix(); | 1200 fMatrixState.fViewMatrix = drawState.getViewMatrix(); |
1216 fMatrixState.fRenderTargetSize = size; | 1201 fMatrixState.fRenderTargetSize = size; |
1217 fMatrixState.fRenderTargetOrigin = rt->origin(); | 1202 fMatrixState.fRenderTargetOrigin = rt->origin(); |
1218 } | 1203 } |
1219 } | 1204 } |
OLD | NEW |