Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Side by Side Diff: src/gpu/gl/GrGLProgram.cpp

Issue 13069003: Replace edge types with GrEdgeEffect. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // cache. 80 // cache.
81 desc->fAttribBindings &= 81 desc->fAttribBindings &=
82 ~(GrDrawState::kColor_AttribBindingsBit | GrDrawState::kCoverage_AttribB indingsBit); 82 ~(GrDrawState::kColor_AttribBindingsBit | GrDrawState::kCoverage_AttribB indingsBit);
83 83
84 desc->fColorFilterXfermode = skipColor ? 84 desc->fColorFilterXfermode = skipColor ?
85 SkXfermode::kDst_Mode : 85 SkXfermode::kDst_Mode :
86 drawState.getColorFilterMode(); 86 drawState.getColorFilterMode();
87 87
88 // no reason to do edge aa or look at per-vertex coverage if coverage is ign ored 88 // no reason to do edge aa or look at per-vertex coverage if coverage is ign ored
89 if (skipCoverage) { 89 if (skipCoverage) {
90 desc->fAttribBindings &= ~(GrDrawState::kEdge_AttribBindingsBit | 90 desc->fAttribBindings &= ~(GrDrawState::kCoverage_AttribBindingsBit);
91 GrDrawState::kCoverage_AttribBindingsBit);
92 } 91 }
93 92
94 bool colorIsTransBlack = SkToBool(blendOpts & GrDrawState::kEmitTransBlack_B lendOptFlag); 93 bool colorIsTransBlack = SkToBool(blendOpts & GrDrawState::kEmitTransBlack_B lendOptFlag);
95 bool colorIsSolidWhite = (blendOpts & GrDrawState::kEmitCoverage_BlendOptFla g) || 94 bool colorIsSolidWhite = (blendOpts & GrDrawState::kEmitCoverage_BlendOptFla g) ||
96 (!requiresAttributeColors && 0xffffffff == drawStat e.getColor()); 95 (!requiresAttributeColors && 0xffffffff == drawStat e.getColor());
97 if (colorIsTransBlack) { 96 if (colorIsTransBlack) {
98 desc->fColorInput = Desc::kTransBlack_ColorInput; 97 desc->fColorInput = Desc::kTransBlack_ColorInput;
99 } else if (colorIsSolidWhite) { 98 } else if (colorIsSolidWhite) {
100 desc->fColorInput = Desc::kSolidWhite_ColorInput; 99 desc->fColorInput = Desc::kSolidWhite_ColorInput;
101 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresAttributeColors) { 100 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresAttributeColors) {
102 desc->fColorInput = Desc::kUniform_ColorInput; 101 desc->fColorInput = Desc::kUniform_ColorInput;
103 } else { 102 } else {
104 desc->fColorInput = Desc::kAttribute_ColorInput; 103 desc->fColorInput = Desc::kAttribute_ColorInput;
105 } 104 }
106 105
107 bool covIsSolidWhite = !requiresAttributeCoverage && 0xffffffff == drawState .getCoverage(); 106 bool covIsSolidWhite = !requiresAttributeCoverage && 0xffffffff == drawState .getCoverage();
108 107
109 if (skipCoverage) { 108 if (skipCoverage) {
110 desc->fCoverageInput = Desc::kTransBlack_ColorInput; 109 desc->fCoverageInput = Desc::kTransBlack_ColorInput;
111 } else if (covIsSolidWhite) { 110 } else if (covIsSolidWhite) {
112 desc->fCoverageInput = Desc::kSolidWhite_ColorInput; 111 desc->fCoverageInput = Desc::kSolidWhite_ColorInput;
113 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresAttributeCoverage) { 112 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresAttributeCoverage) {
114 desc->fCoverageInput = Desc::kUniform_ColorInput; 113 desc->fCoverageInput = Desc::kUniform_ColorInput;
115 } else { 114 } else {
116 desc->fCoverageInput = Desc::kAttribute_ColorInput; 115 desc->fCoverageInput = Desc::kAttribute_ColorInput;
117 } 116 }
118 117
119 int lastEnabledStage = -1; 118 int lastEnabledStage = -1;
120 119
121 if (!skipCoverage && (desc->fAttribBindings & GrDrawState::kEdge_AttribBindi ngsBit)) { 120 if (!skipCoverage) {
122 desc->fVertexEdgeType = drawState.getVertexEdgeType();
123 desc->fDiscardIfOutsideEdge = drawState.getStencil().doesWrite(); 121 desc->fDiscardIfOutsideEdge = drawState.getStencil().doesWrite();
124 } else { 122 } else {
125 // Use canonical values when edge-aa is not enabled to avoid program cac he misses. 123 // Use canonical values when edge-aa is not enabled to avoid program cac he misses.
126 desc->fVertexEdgeType = GrDrawState::kHairLine_EdgeType;
127 desc->fDiscardIfOutsideEdge = false; 124 desc->fDiscardIfOutsideEdge = false;
128 } 125 }
129 126
130 for (int s = 0; s < GrDrawState::kNumStages; ++s) { 127 for (int s = 0; s < GrDrawState::kNumStages; ++s) {
131 128
132 bool skip = s < drawState.getFirstCoverageStage() ? skipColor : skipCove rage; 129 bool skip = s < drawState.getFirstCoverageStage() ? skipColor : skipCove rage;
133 if (!skip && drawState.isStageEnabled(s)) { 130 if (!skip && drawState.isStageEnabled(s)) {
134 lastEnabledStage = s; 131 lastEnabledStage = s;
135 const GrEffectRef& effect = *drawState.getStage(s).getEffect(); 132 const GrEffectRef& effect = *drawState.getStage(s).getEffect();
136 const GrBackendEffectFactory& factory = effect->getFactory(); 133 const GrBackendEffectFactory& factory = effect->getFactory();
(...skipping 23 matching lines...) Expand all
160 // coverage stages or the distinction between coverage and color is immateri al. 157 // coverage stages or the distinction between coverage and color is immateri al.
161 int firstCoverageStage = GrDrawState::kNumStages; 158 int firstCoverageStage = GrDrawState::kNumStages;
162 desc->fFirstCoverageStage = GrDrawState::kNumStages; 159 desc->fFirstCoverageStage = GrDrawState::kNumStages;
163 bool hasCoverage = drawState.getFirstCoverageStage() <= lastEnabledStage; 160 bool hasCoverage = drawState.getFirstCoverageStage() <= lastEnabledStage;
164 if (hasCoverage) { 161 if (hasCoverage) {
165 firstCoverageStage = drawState.getFirstCoverageStage(); 162 firstCoverageStage = drawState.getFirstCoverageStage();
166 } 163 }
167 164
168 // other coverage inputs 165 // other coverage inputs
169 if (!hasCoverage) { 166 if (!hasCoverage) {
170 hasCoverage = requiresAttributeCoverage || 167 hasCoverage = requiresAttributeCoverage;
171 (desc->fAttribBindings & GrDrawState::kEdge_AttribBindings Bit);
172 } 168 }
173 169
174 if (hasCoverage) { 170 if (hasCoverage) {
175 // color filter is applied between color/coverage computation 171 // color filter is applied between color/coverage computation
176 if (SkXfermode::kDst_Mode != desc->fColorFilterXfermode) { 172 if (SkXfermode::kDst_Mode != desc->fColorFilterXfermode) {
177 desc->fFirstCoverageStage = firstCoverageStage; 173 desc->fFirstCoverageStage = firstCoverageStage;
178 } 174 }
179 175
180 if (gpu->caps()->dualSourceBlendingSupport() && 176 if (gpu->caps()->dualSourceBlendingSupport() &&
181 !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag | 177 !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag |
(...skipping 18 matching lines...) Expand all
200 if (requiresAttributeColors) { 196 if (requiresAttributeColors) {
201 desc->fColorAttributeIndex = drawState.getAttribIndex(GrDrawState::kColo r_AttribIndex); 197 desc->fColorAttributeIndex = drawState.getAttribIndex(GrDrawState::kColo r_AttribIndex);
202 } else { 198 } else {
203 desc->fColorAttributeIndex = GrDrawState::kColorOverrideAttribIndexValue ; 199 desc->fColorAttributeIndex = GrDrawState::kColorOverrideAttribIndexValue ;
204 } 200 }
205 if (requiresAttributeCoverage) { 201 if (requiresAttributeCoverage) {
206 desc->fCoverageAttributeIndex = drawState.getAttribIndex(GrDrawState::kC overage_AttribIndex); 202 desc->fCoverageAttributeIndex = drawState.getAttribIndex(GrDrawState::kC overage_AttribIndex);
207 } else { 203 } else {
208 desc->fCoverageAttributeIndex = GrDrawState::kCoverageOverrideAttribInde xValue; 204 desc->fCoverageAttributeIndex = GrDrawState::kCoverageOverrideAttribInde xValue;
209 } 205 }
210 if (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) {
211 desc->fEdgeAttributeIndex = drawState.getAttribIndex(GrDrawState::kEdge_ AttribIndex);
212 }
213 if (desc->fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) { 206 if (desc->fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) {
214 desc->fLocalCoordsAttributeIndex = drawState.getAttribIndex(GrDrawState: :kLocalCoords_AttribIndex); 207 desc->fLocalCoordsAttributeIndex = drawState.getAttribIndex(GrDrawState: :kLocalCoords_AttribIndex);
215 } 208 }
216 209
217 #if GR_DEBUG 210 #if GR_DEBUG
218 // verify valid vertex attribute state 211 // verify valid vertex attribute state
219 const GrVertexAttrib* vertexAttribs = drawState.getVertexAttribs(); 212 const GrVertexAttrib* vertexAttribs = drawState.getVertexAttribs();
220 GrAssert(desc->fPositionAttributeIndex < GrDrawState::kVertexAttribCnt); 213 GrAssert(desc->fPositionAttributeIndex < GrDrawState::kVertexAttribCnt);
221 GrAssert(kAttribLayouts[vertexAttribs[desc->fPositionAttributeIndex].fType]. fCount == 2); 214 GrAssert(kAttribLayouts[vertexAttribs[desc->fPositionAttributeIndex].fType]. fCount == 2);
222 if (requiresAttributeColors) { 215 if (requiresAttributeColors) {
223 GrAssert(desc->fColorAttributeIndex < GrDrawState::kVertexAttribCnt); 216 GrAssert(desc->fColorAttributeIndex < GrDrawState::kVertexAttribCnt);
224 GrAssert(kAttribLayouts[vertexAttribs[desc->fColorAttributeIndex].fType] .fCount == 4); 217 GrAssert(kAttribLayouts[vertexAttribs[desc->fColorAttributeIndex].fType] .fCount == 4);
225 } 218 }
226 if (requiresAttributeCoverage) { 219 if (requiresAttributeCoverage) {
227 GrAssert(desc->fCoverageAttributeIndex < GrDrawState::kVertexAttribCnt); 220 GrAssert(desc->fCoverageAttributeIndex < GrDrawState::kVertexAttribCnt);
228 GrAssert(kAttribLayouts[vertexAttribs[desc->fCoverageAttributeIndex].fTy pe].fCount == 4); 221 GrAssert(kAttribLayouts[vertexAttribs[desc->fCoverageAttributeIndex].fTy pe].fCount == 4);
229 } 222 }
230 if (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) {
231 GrAssert(desc->fEdgeAttributeIndex < GrDrawState::kVertexAttribCnt);
232 GrAssert(kAttribLayouts[vertexAttribs[desc->fEdgeAttributeIndex].fType]. fCount == 4);
233 }
234 if (desc->fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) { 223 if (desc->fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) {
235 GrAssert(desc->fLocalCoordsAttributeIndex < GrDrawState::kVertexAttribCn t); 224 GrAssert(desc->fLocalCoordsAttributeIndex < GrDrawState::kVertexAttribCn t);
236 GrAssert(kAttribLayouts[vertexAttribs[desc->fLocalCoordsAttributeIndex]. fType].fCount == 2); 225 GrAssert(kAttribLayouts[vertexAttribs[desc->fLocalCoordsAttributeIndex]. fType].fCount == 2);
237 } 226 }
238 #endif 227 #endif
239 } 228 }
240 229
241 GrGLProgram* GrGLProgram::Create(const GrGLContext& gl, 230 GrGLProgram* GrGLProgram::Create(const GrGLContext& gl,
242 const Desc& desc, 231 const Desc& desc,
243 const GrEffectStage* stages[]) { 232 const GrEffectStage* stages[]) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 SkString colorStr, constStr; 401 SkString colorStr, constStr;
413 blend_term_string(&colorStr, colorCoeff, filterColor, inColor, inColor); 402 blend_term_string(&colorStr, colorCoeff, filterColor, inColor, inColor);
414 blend_term_string(&constStr, uniformCoeff, filterColor, inColor, filterColor ); 403 blend_term_string(&constStr, uniformCoeff, filterColor, inColor, filterColor );
415 404
416 SkString sum; 405 SkString sum;
417 GrGLSLAdd4f(&sum, colorStr.c_str(), constStr.c_str()); 406 GrGLSLAdd4f(&sum, colorStr.c_str(), constStr.c_str());
418 builder->fsCodeAppendf("\t%s = %s;\n", outputVar, sum.c_str()); 407 builder->fsCodeAppendf("\t%s = %s;\n", outputVar, sum.c_str());
419 } 408 }
420 } 409 }
421 410
422 bool GrGLProgram::genEdgeCoverage(SkString* coverageVar,
423 GrGLShaderBuilder* builder) const {
424 if (fDesc.fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) {
425 const char *vsName, *fsName;
426 builder->addVarying(kVec4f_GrSLType, "Edge", &vsName, &fsName);
427 builder->addAttribute(kVec4f_GrSLType, EDGE_ATTR_NAME);
428 builder->vsCodeAppendf("\t%s = " EDGE_ATTR_NAME ";\n", vsName);
429 switch (fDesc.fVertexEdgeType) {
430 case GrDrawState::kHairLine_EdgeType:
431 builder->fsCodeAppendf("\tfloat edgeAlpha = abs(dot(vec3(%s.xy,1), % s.xyz));\n",
432 builder->fragmentPosition(), fsName);
433 builder->fsCodeAppendf("\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n") ;
434 break;
435 case GrDrawState::kQuad_EdgeType:
436 builder->fsCodeAppendf("\tfloat edgeAlpha;\n");
437 // keep the derivative instructions outside the conditional
438 builder->fsCodeAppendf("\tvec2 duvdx = dFdx(%s.xy);\n", fsName);
439 builder->fsCodeAppendf("\tvec2 duvdy = dFdy(%s.xy);\n", fsName);
440 builder->fsCodeAppendf("\tif (%s.z > 0.0 && %s.w > 0.0) {\n", fsName , fsName);
441 // today we know z and w are in device space. We could use derivativ es
442 builder->fsCodeAppendf("\t\tedgeAlpha = min(min(%s.z, %s.w) + 0.5, 1 .0);\n", fsName,
443 fsName);
444 builder->fsCodeAppendf ("\t} else {\n");
445 builder->fsCodeAppendf("\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx. y,\n"
446 "\t\t 2.0*%s.x*duvdy.x - duvdy. y);\n",
447 fsName, fsName);
448 builder->fsCodeAppendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsNa me, fsName, fsName);
449 builder->fsCodeAppendf("\t\tedgeAlpha = clamp(0.5 - edgeAlpha / leng th(gF), 0.0, 1.0);\n"
450 "\t}\n");
451 if (kES2_GrGLBinding == fContext.info().binding()) {
452 builder->fHeader.append("#extension GL_OES_standard_derivatives: enable\n");
453 }
454 break;
455 case GrDrawState::kHairQuad_EdgeType:
456 builder->fsCodeAppendf("\tvec2 duvdx = dFdx(%s.xy);\n", fsName);
457 builder->fsCodeAppendf("\tvec2 duvdy = dFdy(%s.xy);\n", fsName);
458 builder->fsCodeAppendf("\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y, \n"
459 "\t 2.0*%s.x*duvdy.x - duvdy.y) ;\n",
460 fsName, fsName);
461 builder->fsCodeAppendf("\tfloat edgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName,
462 fsName);
463 builder->fsCodeAppend("\tedgeAlpha = sqrt(edgeAlpha*edgeAlpha / dot( gF, gF));\n");
464 builder->fsCodeAppend("\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
465 if (kES2_GrGLBinding == fContext.info().binding()) {
466 builder->fHeader.printf("#extension GL_OES_standard_derivatives: enable\n");
467 }
468 break;
469 default:
470 GrCrash("Unknown Edge Type!");
471 break;
472 }
473 if (fDesc.fDiscardIfOutsideEdge) {
474 builder->fsCodeAppend("\tif (edgeAlpha <= 0.0) {\n\t\tdiscard;\n\t}\ n");
475 }
476 *coverageVar = "edgeAlpha";
477 return true;
478 } else {
479 coverageVar->reset();
480 return false;
481 }
482 }
483
484 void GrGLProgram::genInputColor(GrGLShaderBuilder* builder, SkString* inColor) { 411 void GrGLProgram::genInputColor(GrGLShaderBuilder* builder, SkString* inColor) {
485 switch (fDesc.fColorInput) { 412 switch (fDesc.fColorInput) {
486 case GrGLProgram::Desc::kAttribute_ColorInput: { 413 case GrGLProgram::Desc::kAttribute_ColorInput: {
487 builder->addAttribute(kVec4f_GrSLType, COL_ATTR_NAME); 414 builder->addAttribute(kVec4f_GrSLType, COL_ATTR_NAME);
488 const char *vsName, *fsName; 415 const char *vsName, *fsName;
489 builder->addVarying(kVec4f_GrSLType, "Color", &vsName, &fsName); 416 builder->addVarying(kVec4f_GrSLType, "Color", &vsName, &fsName);
490 builder->vsCodeAppendf("\t%s = " COL_ATTR_NAME ";\n", vsName); 417 builder->vsCodeAppendf("\t%s = " COL_ATTR_NAME ";\n", vsName);
491 *inColor = fsName; 418 *inColor = fsName;
492 } break; 419 } break;
493 case GrGLProgram::Desc::kUniform_ColorInput: { 420 case GrGLProgram::Desc::kUniform_ColorInput: {
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 /////////////////////////////////////////////////////////////////////////// 754 ///////////////////////////////////////////////////////////////////////////
828 // compute the partial coverage (coverage stages and edge aa) 755 // compute the partial coverage (coverage stages and edge aa)
829 756
830 SkString inCoverage; 757 SkString inCoverage;
831 bool coverageIsZero = Desc::kTransBlack_ColorInput == fDesc.fCoverageInput; 758 bool coverageIsZero = Desc::kTransBlack_ColorInput == fDesc.fCoverageInput;
832 // we don't need to compute coverage at all if we know the final shader 759 // we don't need to compute coverage at all if we know the final shader
833 // output will be zero and we don't have a dual src blend output. 760 // output will be zero and we don't have a dual src blend output.
834 if (!wroteFragColorZero || Desc::kNone_DualSrcOutput != fDesc.fDualSrcOutput ) { 761 if (!wroteFragColorZero || Desc::kNone_DualSrcOutput != fDesc.fDualSrcOutput ) {
835 762
836 if (!coverageIsZero) { 763 if (!coverageIsZero) {
837 bool inCoverageIsScalar = this->genEdgeCoverage(&inCoverage, &build er);
838
839 switch (fDesc.fCoverageInput) { 764 switch (fDesc.fCoverageInput) {
840 case Desc::kSolidWhite_ColorInput: 765 case Desc::kSolidWhite_ColorInput:
841 // empty string implies solid white 766 // empty string implies solid white
842 break; 767 break;
843 case Desc::kAttribute_ColorInput: 768 case Desc::kAttribute_ColorInput:
844 gen_attribute_coverage(&builder, &inCoverage); 769 gen_attribute_coverage(&builder, &inCoverage);
845 inCoverageIsScalar = false;
846 break; 770 break;
847 case Desc::kUniform_ColorInput: 771 case Desc::kUniform_ColorInput:
848 this->genUniformCoverage(&builder, &inCoverage); 772 this->genUniformCoverage(&builder, &inCoverage);
849 inCoverageIsScalar = false;
850 break; 773 break;
851 default: 774 default:
852 GrCrash("Unexpected input coverage."); 775 GrCrash("Unexpected input coverage.");
853 } 776 }
854 777
855 SkString outCoverage; 778 SkString outCoverage;
856 const int& startStage = fDesc.fFirstCoverageStage; 779 const int& startStage = fDesc.fFirstCoverageStage;
857 for (int s = startStage; s < GrDrawState::kNumStages; ++s) { 780 for (int s = startStage; s < GrDrawState::kNumStages; ++s) {
858 if (fDesc.fEffectKeys[s]) { 781 if (fDesc.fEffectKeys[s]) {
859 // create var to hold stage output 782 // create var to hold stage output
860 outCoverage = "coverage"; 783 outCoverage = "coverage";
861 outCoverage.appendS32(s); 784 outCoverage.appendS32(s);
862 builder.fsCodeAppendf("\tvec4 %s;\n", outCoverage.c_str()); 785 builder.fsCodeAppendf("\tvec4 %s;\n", outCoverage.c_str());
863 786
864 // stages don't know how to deal with a scalar input. (Maybe they should. We
865 // could pass a GrGLShaderVar)
866 if (inCoverageIsScalar) {
867 builder.fsCodeAppendf("\tvec4 %s4 = vec4(%s);\n",
868 inCoverage.c_str(), inCoverage.c_s tr());
869 inCoverage.append("4");
870 }
871 builder.setCurrentStage(s); 787 builder.setCurrentStage(s);
872 fEffects[s] = builder.createAndEmitGLEffect( 788 fEffects[s] = builder.createAndEmitGLEffect(
873 *stages[s], 789 *stages[s],
874 fDesc.fEffectKeys[s], 790 fDesc.fEffectKeys[s],
875 inCoverage.size() ? inCovera ge.c_str() : NULL, 791 inCoverage.size() ? inCovera ge.c_str() : NULL,
876 outCoverage.c_str(), 792 outCoverage.c_str(),
877 &fUniformHandles.fSamplerUni s[s]); 793 &fUniformHandles.fSamplerUni s[s]);
878 builder.setNonStage(); 794 builder.setNonStage();
879 inCoverage = outCoverage; 795 inCoverage = outCoverage;
880 } 796 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 GL_CALL(BindFragDataLocationIndexed(fProgramID, 0, 1, dual_source_output _name())); 893 GL_CALL(BindFragDataLocationIndexed(fProgramID, 0, 1, dual_source_output _name()));
978 } 894 }
979 895
980 // Bind the attrib locations to same values for all shaders 896 // Bind the attrib locations to same values for all shaders
981 GL_CALL(BindAttribLocation(fProgramID, 897 GL_CALL(BindAttribLocation(fProgramID,
982 fDesc.fPositionAttributeIndex, 898 fDesc.fPositionAttributeIndex,
983 builder.positionAttribute().c_str())); 899 builder.positionAttribute().c_str()));
984 GL_CALL(BindAttribLocation(fProgramID, fDesc.fColorAttributeIndex, COL_ATTR_ NAME)); 900 GL_CALL(BindAttribLocation(fProgramID, fDesc.fColorAttributeIndex, COL_ATTR_ NAME));
985 GL_CALL(BindAttribLocation(fProgramID, fDesc.fCoverageAttributeIndex, COV_AT TR_NAME)); 901 GL_CALL(BindAttribLocation(fProgramID, fDesc.fCoverageAttributeIndex, COV_AT TR_NAME));
986 902
987 if (fDesc.fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) {
988 GL_CALL(BindAttribLocation(fProgramID, fDesc.fEdgeAttributeIndex, EDGE_A TTR_NAME));
989 }
990 if (fDesc.fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) { 903 if (fDesc.fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) {
991 GL_CALL(BindAttribLocation(fProgramID, 904 GL_CALL(BindAttribLocation(fProgramID,
992 fDesc.fLocalCoordsAttributeIndex, 905 fDesc.fLocalCoordsAttributeIndex,
993 builder.localCoordsAttribute().c_str())); 906 builder.localCoordsAttribute().c_str()));
994 } 907 }
995 908
996 const GrGLShaderBuilder::AttributePair* attribEnd = builder.getEffectAttribu tes().end(); 909 const GrGLShaderBuilder::AttributePair* attribEnd = builder.getEffectAttribu tes().end();
997 for (const GrGLShaderBuilder::AttributePair* attrib = builder.getEffectAttri butes().begin(); 910 for (const GrGLShaderBuilder::AttributePair* attrib = builder.getEffectAttri butes().begin();
998 attrib != attribEnd; 911 attrib != attribEnd;
999 ++attrib) { 912 ++attrib) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 SkScalarToFloat(m[SkMatrix::kMTransX]), 1108 SkScalarToFloat(m[SkMatrix::kMTransX]),
1196 SkScalarToFloat(m[SkMatrix::kMTransY]), 1109 SkScalarToFloat(m[SkMatrix::kMTransY]),
1197 SkScalarToFloat(m[SkMatrix::kMPersp2]) 1110 SkScalarToFloat(m[SkMatrix::kMPersp2])
1198 }; 1111 };
1199 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, mt); 1112 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, mt);
1200 fMatrixState.fViewMatrix = drawState.getViewMatrix(); 1113 fMatrixState.fViewMatrix = drawState.getViewMatrix();
1201 fMatrixState.fRenderTargetSize = size; 1114 fMatrixState.fRenderTargetSize = size;
1202 fMatrixState.fRenderTargetOrigin = rt->origin(); 1115 fMatrixState.fRenderTargetOrigin = rt->origin();
1203 } 1116 }
1204 } 1117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698