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, "Print the sour
ce code for all shaders generated."); | 27 SK_CONF_DECLARE(bool, c_PrintShaders, "gpu.printShaders", false, "Print the sour
ce code for all shaders generated."); |
27 | 28 |
28 #define TEX_ATTR_NAME "aTexCoord" | |
29 #define COL_ATTR_NAME "aColor" | 29 #define COL_ATTR_NAME "aColor" |
30 #define COV_ATTR_NAME "aCoverage" | 30 #define COV_ATTR_NAME "aCoverage" |
31 #define EDGE_ATTR_NAME "aEdge" | 31 #define EDGE_ATTR_NAME "aEdge" |
32 | 32 |
33 namespace { | 33 namespace { |
34 inline const char* declared_color_output_name() { return "fsColorOut"; } | 34 inline const char* declared_color_output_name() { return "fsColorOut"; } |
35 inline const char* dual_source_output_name() { return "dualSourceOut"; } | 35 inline const char* dual_source_output_name() { return "dualSourceOut"; } |
36 } | 36 } |
37 | 37 |
38 const GrGLProgram::AttribLayout GrGLProgram::kAttribLayouts[kGrVertexAttribTypeC
ount] = { | 38 const GrGLProgram::AttribLayout GrGLProgram::kAttribLayouts[kGrVertexAttribTypeC
ount] = { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 desc->fDiscardIfOutsideEdge = false; | 125 desc->fDiscardIfOutsideEdge = false; |
126 } | 126 } |
127 | 127 |
128 for (int s = 0; s < GrDrawState::kNumStages; ++s) { | 128 for (int s = 0; s < GrDrawState::kNumStages; ++s) { |
129 | 129 |
130 bool skip = s < drawState.getFirstCoverageStage() ? skipColor : skipCove
rage; | 130 bool skip = s < drawState.getFirstCoverageStage() ? skipColor : skipCove
rage; |
131 if (!skip && drawState.isStageEnabled(s)) { | 131 if (!skip && drawState.isStageEnabled(s)) { |
132 lastEnabledStage = s; | 132 lastEnabledStage = s; |
133 const GrEffectRef& effect = *drawState.getStage(s).getEffect(); | 133 const GrEffectRef& effect = *drawState.getStage(s).getEffect(); |
134 const GrBackendEffectFactory& factory = effect->getFactory(); | 134 const GrBackendEffectFactory& factory = effect->getFactory(); |
135 desc->fEffectKeys[s] = factory.glEffectKey(drawState.getStage(s), gp
u->glCaps()); | 135 bool explicitLocalCoords = (drawState.getAttribBindings() & |
| 136 GrDrawState::kLocalCoords_AttribBindings
Bit); |
| 137 GrDrawEffect drawEffect(drawState.getStage(s), explicitLocalCoords); |
| 138 desc->fEffectKeys[s] = factory.glEffectKey(drawEffect, gpu->glCaps()
); |
136 } else { | 139 } else { |
137 desc->fEffectKeys[s] = 0; | 140 desc->fEffectKeys[s] = 0; |
138 } | 141 } |
139 } | 142 } |
140 | 143 |
141 desc->fDualSrcOutput = Desc::kNone_DualSrcOutput; | 144 desc->fDualSrcOutput = Desc::kNone_DualSrcOutput; |
142 | 145 |
143 // Currently the experimental GS will only work with triangle prims (and it
doesn't do anything | 146 // Currently the experimental GS will only work with triangle prims (and it
doesn't do anything |
144 // other than pass through values from the VS to the FS anyway). | 147 // other than pass through values from the VS to the FS anyway). |
145 #if GR_GL_EXPERIMENTAL_GS | 148 #if GR_GL_EXPERIMENTAL_GS |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 desc->fColorAttributeIndex = GrDrawState::kColorOverrideAttribIndexValue
; | 201 desc->fColorAttributeIndex = GrDrawState::kColorOverrideAttribIndexValue
; |
199 } | 202 } |
200 if (requiresAttributeCoverage) { | 203 if (requiresAttributeCoverage) { |
201 desc->fCoverageAttributeIndex = drawState.getAttribIndex(GrDrawState::kC
overage_AttribIndex); | 204 desc->fCoverageAttributeIndex = drawState.getAttribIndex(GrDrawState::kC
overage_AttribIndex); |
202 } else { | 205 } else { |
203 desc->fCoverageAttributeIndex = GrDrawState::kCoverageOverrideAttribInde
xValue; | 206 desc->fCoverageAttributeIndex = GrDrawState::kCoverageOverrideAttribInde
xValue; |
204 } | 207 } |
205 if (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) { | 208 if (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) { |
206 desc->fEdgeAttributeIndex = drawState.getAttribIndex(GrDrawState::kEdge_
AttribIndex); | 209 desc->fEdgeAttributeIndex = drawState.getAttribIndex(GrDrawState::kEdge_
AttribIndex); |
207 } | 210 } |
208 if (GrDrawState::AttributesBindExplicitTexCoords(desc->fAttribBindings)) { | 211 if (desc->fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) { |
209 desc->fTexCoordAttributeIndex = drawState.getAttribIndex(GrDrawState::kT
exCoord_AttribIndex); | 212 desc->fLocalCoordsAttributeIndex = drawState.getAttribIndex(GrDrawState:
:kLocalCoords_AttribIndex); |
210 } | 213 } |
211 | 214 |
212 #if GR_DEBUG | 215 #if GR_DEBUG |
213 // verify valid vertex attribute state | 216 // verify valid vertex attribute state |
214 const GrVertexAttrib* vertexAttribs = drawState.getVertexAttribs(); | 217 const GrVertexAttrib* vertexAttribs = drawState.getVertexAttribs(); |
215 GrAssert(desc->fPositionAttributeIndex < GrDrawState::kVertexAttribCnt); | 218 GrAssert(desc->fPositionAttributeIndex < GrDrawState::kVertexAttribCnt); |
216 GrAssert(kAttribLayouts[vertexAttribs[desc->fPositionAttributeIndex].fType].
fCount == 2); | 219 GrAssert(kAttribLayouts[vertexAttribs[desc->fPositionAttributeIndex].fType].
fCount == 2); |
217 if (requiresAttributeColors) { | 220 if (requiresAttributeColors) { |
218 GrAssert(desc->fColorAttributeIndex < GrDrawState::kVertexAttribCnt); | 221 GrAssert(desc->fColorAttributeIndex < GrDrawState::kVertexAttribCnt); |
219 GrAssert(kAttribLayouts[vertexAttribs[desc->fColorAttributeIndex].fType]
.fCount == 4); | 222 GrAssert(kAttribLayouts[vertexAttribs[desc->fColorAttributeIndex].fType]
.fCount == 4); |
220 } | 223 } |
221 if (requiresAttributeCoverage) { | 224 if (requiresAttributeCoverage) { |
222 GrAssert(desc->fCoverageAttributeIndex < GrDrawState::kVertexAttribCnt); | 225 GrAssert(desc->fCoverageAttributeIndex < GrDrawState::kVertexAttribCnt); |
223 GrAssert(kAttribLayouts[vertexAttribs[desc->fCoverageAttributeIndex].fTy
pe].fCount == 4); | 226 GrAssert(kAttribLayouts[vertexAttribs[desc->fCoverageAttributeIndex].fTy
pe].fCount == 4); |
224 } | 227 } |
225 if (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) { | 228 if (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) { |
226 GrAssert(desc->fEdgeAttributeIndex < GrDrawState::kVertexAttribCnt); | 229 GrAssert(desc->fEdgeAttributeIndex < GrDrawState::kVertexAttribCnt); |
227 GrAssert(kAttribLayouts[vertexAttribs[desc->fEdgeAttributeIndex].fType].
fCount == 4); | 230 GrAssert(kAttribLayouts[vertexAttribs[desc->fEdgeAttributeIndex].fType].
fCount == 4); |
228 } | 231 } |
229 if (GrDrawState::AttributesBindExplicitTexCoords(desc->fAttribBindings)) { | 232 if (desc->fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) { |
230 GrAssert(desc->fTexCoordAttributeIndex < GrDrawState::kVertexAttribCnt); | 233 GrAssert(desc->fLocalCoordsAttributeIndex < GrDrawState::kVertexAttribCn
t); |
231 GrAssert(kAttribLayouts[vertexAttribs[desc->fTexCoordAttributeIndex].fTy
pe].fCount == 2); | 234 GrAssert(kAttribLayouts[vertexAttribs[desc->fLocalCoordsAttributeIndex].
fType].fCount == 2); |
232 } | 235 } |
233 #endif | 236 #endif |
234 } | 237 } |
235 | 238 |
236 GrGLProgram* GrGLProgram::Create(const GrGLContext& gl, | 239 GrGLProgram* GrGLProgram::Create(const GrGLContext& gl, |
237 const Desc& desc, | 240 const Desc& desc, |
238 const GrEffectStage* stages[]) { | 241 const GrEffectStage* stages[]) { |
239 GrGLProgram* program = SkNEW_ARGS(GrGLProgram, (gl, desc, stages)); | 242 GrGLProgram* program = SkNEW_ARGS(GrGLProgram, (gl, desc, stages)); |
240 if (!program->succeeded()) { | 243 if (!program->succeeded()) { |
241 delete program; | 244 delete program; |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 if (!(fFShaderID = compile_shader(fContext, GR_GL_FRAGMENT_SHADER, shader)))
{ | 677 if (!(fFShaderID = compile_shader(fContext, GR_GL_FRAGMENT_SHADER, shader)))
{ |
675 return false; | 678 return false; |
676 } | 679 } |
677 | 680 |
678 return true; | 681 return true; |
679 } | 682 } |
680 | 683 |
681 bool GrGLProgram::genProgram(const GrEffectStage* stages[]) { | 684 bool GrGLProgram::genProgram(const GrEffectStage* stages[]) { |
682 GrAssert(0 == fProgramID); | 685 GrAssert(0 == fProgramID); |
683 | 686 |
684 GrGLShaderBuilder builder(fContext.info(), fUniformManager); | |
685 const GrAttribBindings& attribBindings = fDesc.fAttribBindings; | 687 const GrAttribBindings& attribBindings = fDesc.fAttribBindings; |
| 688 bool hasExplicitLocalCoords = |
| 689 SkToBool(attribBindings & GrDrawState::kLocalCoords_AttribBindingsBit); |
| 690 GrGLShaderBuilder builder(fContext.info(), fUniformManager, hasExplicitLocal
Coords); |
686 | 691 |
687 #if GR_GL_EXPERIMENTAL_GS | 692 #if GR_GL_EXPERIMENTAL_GS |
688 builder.fUsesGS = fDesc.fExperimentalGS; | 693 builder.fUsesGS = fDesc.fExperimentalGS; |
689 #endif | 694 #endif |
690 | 695 |
691 SkXfermode::Coeff colorCoeff, uniformCoeff; | 696 SkXfermode::Coeff colorCoeff, uniformCoeff; |
692 // The rest of transfer mode color filters have not been implemented | 697 // The rest of transfer mode color filters have not been implemented |
693 if (fDesc.fColorFilterXfermode < SkXfermode::kCoeffModesCnt) { | 698 if (fDesc.fColorFilterXfermode < SkXfermode::kCoeffModesCnt) { |
694 GR_DEBUGCODE(bool success =) | 699 GR_DEBUGCODE(bool success =) |
695 SkXfermode::ModeAsCoeff(static_cast<SkXfermode::Mode> | 700 SkXfermode::ModeAsCoeff(static_cast<SkXfermode::Mode> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 | 760 |
756 if (needComputedColor) { | 761 if (needComputedColor) { |
757 this->genInputColor(&builder, &inColor); | 762 this->genInputColor(&builder, &inColor); |
758 } | 763 } |
759 | 764 |
760 // we output point size in the GS if present | 765 // we output point size in the GS if present |
761 if (fDesc.fEmitsPointSize && !builder.fUsesGS){ | 766 if (fDesc.fEmitsPointSize && !builder.fUsesGS){ |
762 builder.vsCodeAppend("\tgl_PointSize = 1.0;\n"); | 767 builder.vsCodeAppend("\tgl_PointSize = 1.0;\n"); |
763 } | 768 } |
764 | 769 |
765 // add texture coordinates that are used to the list of vertex attr decls | |
766 if (GrDrawState::AttributesBindExplicitTexCoords(attribBindings)) { | |
767 builder.addAttribute(kVec2f_GrSLType, TEX_ATTR_NAME); | |
768 } | |
769 | |
770 /////////////////////////////////////////////////////////////////////////// | 770 /////////////////////////////////////////////////////////////////////////// |
771 // compute the final color | 771 // compute the final color |
772 | 772 |
773 // if we have color stages string them together, feeding the output color | 773 // if we have color stages string them together, feeding the output color |
774 // of each to the next and generating code for each stage. | 774 // of each to the next and generating code for each stage. |
775 if (needComputedColor) { | 775 if (needComputedColor) { |
776 SkString outColor; | 776 SkString outColor; |
777 for (int s = 0; s < fDesc.fFirstCoverageStage; ++s) { | 777 for (int s = 0; s < fDesc.fFirstCoverageStage; ++s) { |
778 if (GrGLEffect::kNoEffectKey != fDesc.fEffectKeys[s]) { | 778 if (GrGLEffect::kNoEffectKey != fDesc.fEffectKeys[s]) { |
779 // create var to hold stage result | 779 // create var to hold stage result |
780 outColor = "color"; | 780 outColor = "color"; |
781 outColor.appendS32(s); | 781 outColor.appendS32(s); |
782 builder.fsCodeAppendf("\tvec4 %s;\n", outColor.c_str()); | 782 builder.fsCodeAppendf("\tvec4 %s;\n", outColor.c_str()); |
783 | 783 |
784 const char* inCoords; | |
785 // figure out what our input coords are | |
786 if (!GrDrawState::StageBindsExplicitTexCoords(attribBindings, s)
) { | |
787 inCoords = builder.positionAttribute().c_str(); | |
788 } else { | |
789 // must have input tex coordinates if stage is enabled. | |
790 inCoords = TEX_ATTR_NAME; | |
791 } | |
792 | |
793 builder.setCurrentStage(s); | 784 builder.setCurrentStage(s); |
794 fEffects[s] = builder.createAndEmitGLEffect(*stages[s], | 785 fEffects[s] = builder.createAndEmitGLEffect(*stages[s], |
795 fDesc.fEffectKeys[s]
, | 786 fDesc.fEffectKeys[s]
, |
796 inColor.size() ? inC
olor.c_str() : NULL, | 787 inColor.size() ? inC
olor.c_str() : NULL, |
797 outColor.c_str(), | 788 outColor.c_str(), |
798 inCoords, | |
799 &fUniformHandles.fSa
mplerUnis[s]); | 789 &fUniformHandles.fSa
mplerUnis[s]); |
800 builder.setNonStage(); | 790 builder.setNonStage(); |
801 inColor = outColor; | 791 inColor = outColor; |
802 } | 792 } |
803 } | 793 } |
804 } | 794 } |
805 | 795 |
806 // if have all ones or zeros for the "dst" input to the color filter then we | 796 // if have all ones or zeros for the "dst" input to the color filter then we |
807 // may be able to make additional optimizations. | 797 // may be able to make additional optimizations. |
808 if (needColorFilterUniform && needComputedColor && !inColor.size()) { | 798 if (needColorFilterUniform && needComputedColor && !inColor.size()) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 | 856 |
867 SkString outCoverage; | 857 SkString outCoverage; |
868 const int& startStage = fDesc.fFirstCoverageStage; | 858 const int& startStage = fDesc.fFirstCoverageStage; |
869 for (int s = startStage; s < GrDrawState::kNumStages; ++s) { | 859 for (int s = startStage; s < GrDrawState::kNumStages; ++s) { |
870 if (fDesc.fEffectKeys[s]) { | 860 if (fDesc.fEffectKeys[s]) { |
871 // create var to hold stage output | 861 // create var to hold stage output |
872 outCoverage = "coverage"; | 862 outCoverage = "coverage"; |
873 outCoverage.appendS32(s); | 863 outCoverage.appendS32(s); |
874 builder.fsCodeAppendf("\tvec4 %s;\n", outCoverage.c_str()); | 864 builder.fsCodeAppendf("\tvec4 %s;\n", outCoverage.c_str()); |
875 | 865 |
876 const char* inCoords; | |
877 // figure out what our input coords are | |
878 if (!GrDrawState::StageBindsExplicitTexCoords(attribBindings
, s)) { | |
879 inCoords = builder.positionAttribute().c_str(); | |
880 } else { | |
881 // must have input tex coordinates if stage is | |
882 // enabled. | |
883 inCoords = TEX_ATTR_NAME; | |
884 } | |
885 | |
886 // stages don't know how to deal with a scalar input. (Maybe
they should. We | 866 // stages don't know how to deal with a scalar input. (Maybe
they should. We |
887 // could pass a GrGLShaderVar) | 867 // could pass a GrGLShaderVar) |
888 if (inCoverageIsScalar) { | 868 if (inCoverageIsScalar) { |
889 builder.fsCodeAppendf("\tvec4 %s4 = vec4(%s);\n", | 869 builder.fsCodeAppendf("\tvec4 %s4 = vec4(%s);\n", |
890 inCoverage.c_str(), inCoverage.c_s
tr()); | 870 inCoverage.c_str(), inCoverage.c_s
tr()); |
891 inCoverage.append("4"); | 871 inCoverage.append("4"); |
892 } | 872 } |
893 builder.setCurrentStage(s); | 873 builder.setCurrentStage(s); |
894 fEffects[s] = builder.createAndEmitGLEffect( | 874 fEffects[s] = builder.createAndEmitGLEffect( |
895 *stages[s], | 875 *stages[s], |
896 fDesc.fEffectKeys[s], | 876 fDesc.fEffectKeys[s], |
897 inCoverage.size() ? inCovera
ge.c_str() : NULL, | 877 inCoverage.size() ? inCovera
ge.c_str() : NULL, |
898 outCoverage.c_str(), | 878 outCoverage.c_str(), |
899 inCoords, | |
900 &fUniformHandles.fSamplerUni
s[s]); | 879 &fUniformHandles.fSamplerUni
s[s]); |
901 builder.setNonStage(); | 880 builder.setNonStage(); |
902 inCoverage = outCoverage; | 881 inCoverage = outCoverage; |
903 } | 882 } |
904 } | 883 } |
905 | 884 |
906 // discard if coverage is zero | 885 // discard if coverage is zero |
907 if (fDesc.fDiscardIfOutsideEdge && !outCoverage.isEmpty()) { | 886 if (fDesc.fDiscardIfOutsideEdge && !outCoverage.isEmpty()) { |
908 builder.fsCodeAppendf("\tif (all(lessThanEqual(%s, vec4(0.0))))
{\n\t\tdiscard;\n\t}\n", outCoverage.c_str()); | 887 builder.fsCodeAppendf("\tif (all(lessThanEqual(%s, vec4(0.0))))
{\n\t\tdiscard;\n\t}\n", outCoverage.c_str()); |
909 } | 888 } |
(...skipping 91 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 |