| 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" | |
| 11 #include "GrDrawEffect.h" | 10 #include "GrDrawEffect.h" |
| 12 #include "GrTexture.h" | 11 #include "GrTexture.h" |
| 13 | 12 |
| 14 // number of each input/output type in a single allocation block | 13 // number of each input/output type in a single allocation block |
| 15 static const int kVarsPerBlock = 8; | 14 static const int kVarsPerBlock = 8; |
| 16 | 15 |
| 17 // except FS outputs where we expect 2 at most. | 16 // except FS outputs where we expect 2 at most. |
| 18 static const int kMaxFSOutputs = 2; | 17 static const int kMaxFSOutputs = 2; |
| 19 | 18 |
| 20 // ES2 FS only guarantees mediump and lowp support | 19 // ES2 FS only guarantees mediump and lowp support |
| 21 static const GrGLShaderVar::Precision kDefaultFragmentPrecision = GrGLShaderVar:
:kMedium_Precision; | 20 static const GrGLShaderVar::Precision kDefaultFragmentPrecision = GrGLShaderVar:
:kMedium_Precision; |
| 22 | 21 |
| 23 typedef GrGLUniformManager::UniformHandle UniformHandle; | |
| 24 /////////////////////////////////////////////////////////////////////////////// | 22 /////////////////////////////////////////////////////////////////////////////// |
| 25 | 23 |
| 26 namespace { | 24 namespace { |
| 27 | 25 |
| 28 inline const char* sample_function_name(GrSLType type, GrGLSLGeneration glslGen)
{ | 26 inline const char* sample_function_name(GrSLType type, GrGLSLGeneration glslGen)
{ |
| 29 if (kVec2f_GrSLType == type) { | 27 if (kVec2f_GrSLType == type) { |
| 30 return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D"; | 28 return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D"; |
| 31 } else { | 29 } else { |
| 32 GrAssert(kVec3f_GrSLType == type); | 30 GrAssert(kVec3f_GrSLType == type); |
| 33 return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj
"; | 31 return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj
"; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 83 } |
| 86 } | 84 } |
| 87 | 85 |
| 88 } | 86 } |
| 89 | 87 |
| 90 static const char kDstCopyColorName[] = "_dstColor"; | 88 static const char kDstCopyColorName[] = "_dstColor"; |
| 91 | 89 |
| 92 /////////////////////////////////////////////////////////////////////////////// | 90 /////////////////////////////////////////////////////////////////////////////// |
| 93 | 91 |
| 94 GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo, | 92 GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo, |
| 95 GrGLUniformManager& uniformManager, | 93 GrGLProgram& program, |
| 96 const GrGLProgramDesc& desc) | 94 const GrGLProgramDesc& desc) |
| 97 : fUniforms(kVarsPerBlock) | 95 : fUniforms(kVarsPerBlock) |
| 98 , fVSAttrs(kVarsPerBlock) | 96 , fVSAttrs(kVarsPerBlock) |
| 99 , fVSOutputs(kVarsPerBlock) | 97 , fVSOutputs(kVarsPerBlock) |
| 100 , fGSInputs(kVarsPerBlock) | 98 , fGSInputs(kVarsPerBlock) |
| 101 , fGSOutputs(kVarsPerBlock) | 99 , fGSOutputs(kVarsPerBlock) |
| 102 , fFSInputs(kVarsPerBlock) | 100 , fFSInputs(kVarsPerBlock) |
| 103 , fFSOutputs(kMaxFSOutputs) | 101 , fFSOutputs(kMaxFSOutputs) |
| 104 , fCtxInfo(ctxInfo) | 102 , fCtxInfo(ctxInfo) |
| 105 , fUniformManager(uniformManager) | 103 , fProgram(program) |
| 106 , fFSFeaturesAddedMask(0) | 104 , fFSFeaturesAddedMask(0) |
| 107 #if GR_GL_EXPERIMENTAL_GS | 105 #if GR_GL_EXPERIMENTAL_GS |
| 108 , fUsesGS(SkToBool(desc.getHeader().fExperimentalGS)) | 106 , fUsesGS(SkToBool(desc.getHeader().fExperimentalGS)) |
| 109 #else | 107 #else |
| 110 , fUsesGS(false) | 108 , fUsesGS(false) |
| 111 #endif | 109 #endif |
| 112 , fSetupFragPosition(false) | 110 , fSetupFragPosition(false) |
| 113 , fRTHeightUniform(GrGLUniformManager::kInvalidUniformHandle) | 111 , fRTHeightUniform(NULL) |
| 114 , fDstCopyTopLeftUniform (GrGLUniformManager::kInvalidUniformHandle) | 112 , fDstCopyTopLeftUniform(NULL) |
| 115 , fDstCopyScaleUniform (GrGLUniformManager::kInvalidUniformHandle) | 113 , fDstCopyScaleUniform(NULL) |
| 116 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFr
agPosKey) { | 114 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFr
agPosKey) { |
| 117 | 115 |
| 118 const GrGLProgramDesc::KeyHeader& header = desc.getHeader(); | 116 const GrGLProgramDesc::KeyHeader& header = desc.getHeader(); |
| 119 | 117 |
| 120 fPositionVar = &fVSAttrs.push_back(); | 118 fPositionVar = &fVSAttrs.push_back(); |
| 121 fPositionVar->set(kVec2f_GrSLType, GrGLShaderVar::kAttribute_TypeModifier, "
aPosition"); | 119 fPositionVar->set(kVec2f_GrSLType, GrGLShaderVar::kAttribute_TypeModifier, "
aPosition"); |
| 122 if (-1 != header.fLocalCoordAttributeIndex) { | 120 if (-1 != header.fLocalCoordAttributeIndex) { |
| 123 fLocalCoordsVar = &fVSAttrs.push_back(); | 121 fLocalCoordsVar = &fVSAttrs.push_back(); |
| 124 fLocalCoordsVar->set(kVec2f_GrSLType, | 122 fLocalCoordsVar->set(kVec2f_GrSLType, |
| 125 GrGLShaderVar::kAttribute_TypeModifier, | 123 GrGLShaderVar::kAttribute_TypeModifier, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 137 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & header.fDstReadKey)) { | 135 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & header.fDstReadKey)) { |
| 138 configMask = kA_GrColorComponentFlag; | 136 configMask = kA_GrColorComponentFlag; |
| 139 } else { | 137 } else { |
| 140 configMask = kRGBA_GrColorComponentFlags; | 138 configMask = kRGBA_GrColorComponentFlags; |
| 141 } | 139 } |
| 142 fDstCopySampler.init(this, configMask, "rgba", 0); | 140 fDstCopySampler.init(this, configMask, "rgba", 0); |
| 143 | 141 |
| 144 fDstCopyTopLeftUniform = this->addUniform(kFragment_ShaderType, | 142 fDstCopyTopLeftUniform = this->addUniform(kFragment_ShaderType, |
| 145 kVec2f_GrSLType, | 143 kVec2f_GrSLType, |
| 146 "DstCopyUpperLeft", | 144 "DstCopyUpperLeft", |
| 147 &dstCopyTopLeftName); | 145 &dstCopyTopLeftName)->glUnifor
m(); |
| 148 fDstCopyScaleUniform = this->addUniform(kFragment_ShaderType, | 146 fDstCopyScaleUniform = this->addUniform(kFragment_ShaderType, |
| 149 kVec2f_GrSLType, | 147 kVec2f_GrSLType, |
| 150 "DstCopyCoordScale", | 148 "DstCopyCoordScale", |
| 151 &dstCopyCoordScaleName); | 149 &dstCopyCoordScaleName)->glU
niform(); |
| 152 const char* fragPos = this->fragmentPosition(); | 150 const char* fragPos = this->fragmentPosition(); |
| 153 this->fsCodeAppend("\t// Read color from copy of the destination.\n"); | 151 this->fsCodeAppend("\t// Read color from copy of the destination.\n"); |
| 154 this->fsCodeAppendf("\tvec2 _dstTexCoord = (%s.xy - %s) * %s;\n", | 152 this->fsCodeAppendf("\tvec2 _dstTexCoord = (%s.xy - %s) * %s;\n", |
| 155 fragPos, dstCopyTopLeftName, dstCopyCoordScaleName); | 153 fragPos, dstCopyTopLeftName, dstCopyCoordScaleName); |
| 156 if (!topDown) { | 154 if (!topDown) { |
| 157 this->fsCodeAppend("\t_dstTexCoord.y = 1.0 - _dstTexCoord.y;\n"); | 155 this->fsCodeAppend("\t_dstTexCoord.y = 1.0 - _dstTexCoord.y;\n"); |
| 158 } | 156 } |
| 159 this->fsCodeAppendf("\tvec4 %s = ", kDstCopyColorName); | 157 this->fsCodeAppendf("\tvec4 %s = ", kDstCopyColorName); |
| 160 this->appendTextureLookup(kFragment_ShaderType, fDstCopySampler, "_dstTe
xCoord"); | 158 this->appendTextureLookup(kFragment_ShaderType, fDstCopySampler, "_dstTe
xCoord"); |
| 161 this->fsCodeAppend(";\n\n"); | 159 this->fsCodeAppend(";\n\n"); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 } | 291 } |
| 294 | 292 |
| 295 void GrGLShaderBuilder::appendTextureLookup(SkString* out, | 293 void GrGLShaderBuilder::appendTextureLookup(SkString* out, |
| 296 const GrGLShaderBuilder::TextureSamp
ler& sampler, | 294 const GrGLShaderBuilder::TextureSamp
ler& sampler, |
| 297 const char* coordName, | 295 const char* coordName, |
| 298 GrSLType varyingType) const { | 296 GrSLType varyingType) const { |
| 299 GrAssert(NULL != coordName); | 297 GrAssert(NULL != coordName); |
| 300 | 298 |
| 301 out->appendf("%s(%s, %s)", | 299 out->appendf("%s(%s, %s)", |
| 302 sample_function_name(varyingType, fCtxInfo.glslGeneration()), | 300 sample_function_name(varyingType, fCtxInfo.glslGeneration()), |
| 303 this->getUniformCStr(sampler.fSamplerUniform), | 301 sampler.fSamplerUniform->c_str(), |
| 304 coordName); | 302 coordName); |
| 305 append_swizzle(out, sampler, *fCtxInfo.caps()); | 303 append_swizzle(out, sampler, *fCtxInfo.caps()); |
| 306 } | 304 } |
| 307 | 305 |
| 308 void GrGLShaderBuilder::appendTextureLookup(ShaderType type, | 306 void GrGLShaderBuilder::appendTextureLookup(ShaderType type, |
| 309 const GrGLShaderBuilder::TextureSamp
ler& sampler, | 307 const GrGLShaderBuilder::TextureSamp
ler& sampler, |
| 310 const char* coordName, | 308 const char* coordName, |
| 311 GrSLType varyingType) { | 309 GrSLType varyingType) { |
| 312 GrAssert(kFragment_ShaderType == type); | 310 GrAssert(kFragment_ShaderType == type); |
| 313 this->appendTextureLookup(&fFSCode, sampler, coordName, varyingType); | 311 this->appendTextureLookup(&fFSCode, sampler, coordName, varyingType); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 static const GrGLenum gAlphaSmear[] = { GR_GL_ALPHA, GR_GL_ALPHA, | 371 static const GrGLenum gAlphaSmear[] = { GR_GL_ALPHA, GR_GL_ALPHA, |
| 374 GR_GL_ALPHA, GR_GL_ALPHA }; | 372 GR_GL_ALPHA, GR_GL_ALPHA }; |
| 375 return gAlphaSmear; | 373 return gAlphaSmear; |
| 376 } | 374 } |
| 377 } else { | 375 } else { |
| 378 static const GrGLenum gStraight[] = { GR_GL_RED, GR_GL_GREEN, GR_GL_BLUE
, GR_GL_ALPHA }; | 376 static const GrGLenum gStraight[] = { GR_GL_RED, GR_GL_GREEN, GR_GL_BLUE
, GR_GL_ALPHA }; |
| 379 return gStraight; | 377 return gStraight; |
| 380 } | 378 } |
| 381 } | 379 } |
| 382 | 380 |
| 383 GrGLUniformManager::UniformHandle GrGLShaderBuilder::addUniformArray(uint32_t vi
sibility, | 381 GrGLShaderBuilder::Uniform* GrGLShaderBuilder::addUniformArray(uint32_t visibili
ty, |
| 384 GrSLType ty
pe, | 382 GrSLType type, |
| 385 const char*
name, | 383 const char* name, |
| 386 int count, | 384 int count, |
| 387 const char*
* outName) { | 385 const char** outN
ame) { |
| 388 GrAssert(name && strlen(name)); | 386 GrAssert(name && strlen(name)); |
| 389 SkDEBUGCODE(static const uint32_t kVisibilityMask = kVertex_ShaderType | kFr
agment_ShaderType); | 387 SkDEBUGCODE(static const uint32_t kVisibilityMask = kVertex_ShaderType | kFr
agment_ShaderType); |
| 390 GrAssert(0 == (~kVisibilityMask & visibility)); | 388 GrAssert(0 == (~kVisibilityMask & visibility)); |
| 391 GrAssert(0 != visibility); | 389 GrAssert(0 != visibility); |
| 392 | 390 |
| 393 BuilderUniform& uni = fUniforms.push_back(); | 391 Uniform& uni = fUniforms.push_back(); |
| 394 UniformHandle h = index_to_handle(fUniforms.count() - 1); | 392 uni.fGLUniform = fProgram.appendUniform(); |
| 395 GR_DEBUGCODE(UniformHandle h2 =) | 393 GR_DEBUGCODE(uni.fGLUniform->initType(count, type)); |
| 396 fUniformManager.appendUniform(type, count); | 394 |
| 397 // We expect the uniform manager to initially have no uniforms and that all
uniforms are added | |
| 398 // by this function. Therefore, the handles should match. | |
| 399 GrAssert(h2 == h); | |
| 400 uni.fVariable.setType(type); | 395 uni.fVariable.setType(type); |
| 401 uni.fVariable.setTypeModifier(GrGLShaderVar::kUniform_TypeModifier); | 396 uni.fVariable.setTypeModifier(GrGLShaderVar::kUniform_TypeModifier); |
| 402 this->nameVariable(uni.fVariable.accessName(), 'u', name); | 397 this->nameVariable(uni.fVariable.accessName(), 'u', name); |
| 403 uni.fVariable.setArrayCount(count); | 398 uni.fVariable.setArrayCount(count); |
| 404 uni.fVisibility = visibility; | 399 uni.fVisibility = visibility; |
| 405 | 400 |
| 406 // If it is visible in both the VS and FS, the precision must match. | 401 // If it is visible in both the VS and FS, the precision must match. |
| 407 // We declare a default FS precision, but not a default VS. So set the var | 402 // We declare a default FS precision, but not a default VS. So set the var |
| 408 // to use the default FS precision. | 403 // to use the default FS precision. |
| 409 if ((kVertex_ShaderType | kFragment_ShaderType) == visibility) { | 404 if ((kVertex_ShaderType | kFragment_ShaderType) == visibility) { |
| 410 // the fragment and vertex precisions must match | 405 // the fragment and vertex precisions must match |
| 411 uni.fVariable.setPrecision(kDefaultFragmentPrecision); | 406 uni.fVariable.setPrecision(kDefaultFragmentPrecision); |
| 412 } | 407 } |
| 413 | 408 |
| 414 if (NULL != outName) { | 409 if (NULL != outName) { |
| 415 *outName = uni.fVariable.c_str(); | 410 *outName = uni.fVariable.c_str(); |
| 416 } | 411 } |
| 417 | 412 |
| 418 return h; | 413 return &uni; |
| 419 } | |
| 420 | |
| 421 const GrGLShaderVar& GrGLShaderBuilder::getUniformVariable(UniformHandle u) cons
t { | |
| 422 return fUniforms[handle_to_index(u)].fVariable; | |
| 423 } | 414 } |
| 424 | 415 |
| 425 bool GrGLShaderBuilder::addAttribute(GrSLType type, | 416 bool GrGLShaderBuilder::addAttribute(GrSLType type, |
| 426 const char* name) { | 417 const char* name) { |
| 427 for (int i = 0; i < fVSAttrs.count(); ++i) { | 418 for (int i = 0; i < fVSAttrs.count(); ++i) { |
| 428 const GrGLShaderVar& attr = fVSAttrs[i]; | 419 const GrGLShaderVar& attr = fVSAttrs[i]; |
| 429 // if attribute already added, don't add it again | 420 // if attribute already added, don't add it again |
| 430 if (attr.getName().equals(name)) { | 421 if (attr.getName().equals(name)) { |
| 431 GrAssert(attr.getType() == type); | 422 GrAssert(attr.getType() == type); |
| 432 return false; | 423 return false; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 GrGLShaderVar::kUpperLeft_Origin); | 496 GrGLShaderVar::kUpperLeft_Origin); |
| 506 fSetupFragPosition = true; | 497 fSetupFragPosition = true; |
| 507 } | 498 } |
| 508 return "gl_FragCoord"; | 499 return "gl_FragCoord"; |
| 509 } else { | 500 } else { |
| 510 static const char* kCoordName = "fragCoordYDown"; | 501 static const char* kCoordName = "fragCoordYDown"; |
| 511 if (!fSetupFragPosition) { | 502 if (!fSetupFragPosition) { |
| 512 // temporarily change the stage index because we're inserting non-st
age code. | 503 // temporarily change the stage index because we're inserting non-st
age code. |
| 513 CodeStage::AutoStageRestore csar(&fCodeStage, NULL); | 504 CodeStage::AutoStageRestore csar(&fCodeStage, NULL); |
| 514 | 505 |
| 515 GrAssert(GrGLUniformManager::kInvalidUniformHandle == fRTHeightUnifo
rm); | 506 GrAssert(NULL == fRTHeightUniform); |
| 516 const char* rtHeightName; | 507 const char* rtHeightName; |
| 517 | 508 |
| 518 fRTHeightUniform = this->addUniform(kFragment_ShaderType, | 509 fRTHeightUniform = this->addUniform(kFragment_ShaderType, |
| 519 kFloat_GrSLType, | 510 kFloat_GrSLType, |
| 520 "RTHeight", | 511 "RTHeight", |
| 521 &rtHeightName); | 512 &rtHeightName)->glUniform(); |
| 522 | 513 |
| 523 this->fFSCode.prependf("\tvec4 %s = vec4(gl_FragCoord.x, %s - gl_Fra
gCoord.y, gl_FragCoord.zw);\n", | 514 this->fFSCode.prependf("\tvec4 %s = vec4(gl_FragCoord.x, %s - gl_Fra
gCoord.y, gl_FragCoord.zw);\n", |
| 524 kCoordName, rtHeightName); | 515 kCoordName, rtHeightName); |
| 525 fSetupFragPosition = true; | 516 fSetupFragPosition = true; |
| 526 } | 517 } |
| 527 GrAssert(GrGLUniformManager::kInvalidUniformHandle != fRTHeightUniform); | 518 GrAssert(NULL != fRTHeightUniform); |
| 528 return kCoordName; | 519 return kCoordName; |
| 529 } | 520 } |
| 530 } | 521 } |
| 531 | 522 |
| 532 | 523 |
| 533 void GrGLShaderBuilder::emitFunction(ShaderType shader, | 524 void GrGLShaderBuilder::emitFunction(ShaderType shader, |
| 534 GrSLType returnType, | 525 GrSLType returnType, |
| 535 const char* name, | 526 const char* name, |
| 536 int argCnt, | 527 int argCnt, |
| 537 const GrGLShaderVar* args, | 528 const GrGLShaderVar* args, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 GrAssert(k110_GrGLSLGeneration != fCtxInfo.glslGeneration() || fFSOu
tputs.empty()); | 624 GrAssert(k110_GrGLSLGeneration != fCtxInfo.glslGeneration() || fFSOu
tputs.empty()); |
| 634 this->appendDecls(fFSOutputs, shaderStr); | 625 this->appendDecls(fFSOutputs, shaderStr); |
| 635 shaderStr->append(fFSFunctions); | 626 shaderStr->append(fFSFunctions); |
| 636 shaderStr->append("void main() {\n"); | 627 shaderStr->append("void main() {\n"); |
| 637 shaderStr->append(fFSCode); | 628 shaderStr->append(fFSCode); |
| 638 shaderStr->append("}\n"); | 629 shaderStr->append("}\n"); |
| 639 break; | 630 break; |
| 640 } | 631 } |
| 641 } | 632 } |
| 642 | 633 |
| 643 void GrGLShaderBuilder::finished(GrGLuint programID) { | 634 void GrGLShaderBuilder::finished(const GrGLContext& context, GrGLuint programID)
{ |
| 644 fUniformManager.getUniformLocations(programID, fUniforms); | 635 int count = fUniforms.count(); |
| 636 for (int i = 0; i < count; ++i) { |
| 637 fUniforms[i].glUniform()->initLocations(context, programID, fUniforms[i]
.c_str(), fUniforms[i].fVisibility); |
| 638 } |
| 645 } | 639 } |
| 646 | 640 |
| 647 void GrGLShaderBuilder::emitEffects( | 641 void GrGLShaderBuilder::emitEffects( |
| 648 const GrEffectStage* effectStages[], | 642 const GrEffectStage* effectStages[], |
| 649 const GrBackendEffectFactory::EffectKey effectKeys[], | 643 const GrBackendEffectFactory::EffectKey effectKeys[], |
| 650 int effectCnt, | 644 int effectCnt, |
| 651 SkString* fsInOutColor, | 645 SkString* fsInOutColor, |
| 652 GrSLConstantVec* fsInOutColorKnownValue, | 646 GrSLConstantVec* fsInOutColorKnownValue, |
| 653 SkTArray<GrGLUniformManager::UniformHandle, true>* effec
tSamplerHandles[], | 647 SkTArray<GrGLUniform*, true>* effectSamplerHandles[], |
| 654 GrGLEffect* glEffects[]) { | 648 GrGLEffect* glEffects[]) { |
| 655 bool effectEmitted = false; | 649 bool effectEmitted = false; |
| 656 | 650 |
| 657 SkString inColor = *fsInOutColor; | 651 SkString inColor = *fsInOutColor; |
| 658 SkString outColor; | 652 SkString outColor; |
| 659 | 653 |
| 660 for (int e = 0; e < effectCnt; ++e) { | 654 for (int e = 0; e < effectCnt; ++e) { |
| 661 GrAssert(NULL != effectStages[e] && NULL != effectStages[e]->getEffect()
); | 655 GrAssert(NULL != effectStages[e] && NULL != effectStages[e]->getEffect()
); |
| 662 const GrEffectStage& stage = *effectStages[e]; | 656 const GrEffectStage& stage = *effectStages[e]; |
| 663 const GrEffectRef& effect = *stage.getEffect(); | 657 const GrEffectRef& effect = *stage.getEffect(); |
| 664 | 658 |
| 665 CodeStage::AutoStageRestore csar(&fCodeStage, &stage); | 659 CodeStage::AutoStageRestore csar(&fCodeStage, &stage); |
| 666 | 660 |
| 667 int numTextures = effect->numTextures(); | 661 int numTextures = effect->numTextures(); |
| 668 SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers; | 662 SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers; |
| 669 textureSamplers.push_back_n(numTextures); | 663 textureSamplers.push_back_n(numTextures); |
| 670 for (int t = 0; t < numTextures; ++t) { | 664 for (int t = 0; t < numTextures; ++t) { |
| 671 textureSamplers[t].init(this, &effect->textureAccess(t), t); | 665 textureSamplers[t].init(this, &effect->textureAccess(t), t); |
| 672 effectSamplerHandles[e]->push_back(textureSamplers[t].fSamplerUnifor
m); | 666 effectSamplerHandles[e]->push_back(textureSamplers[t].fSamplerUnifor
m->glUniform()); |
| 673 } | 667 } |
| 674 GrDrawEffect drawEffect(stage, this->hasExplicitLocalCoords()); | 668 GrDrawEffect drawEffect(stage, this->hasExplicitLocalCoords()); |
| 675 | 669 |
| 676 int numAttributes = stage.getVertexAttribIndexCount(); | 670 int numAttributes = stage.getVertexAttribIndexCount(); |
| 677 const int* attributeIndices = stage.getVertexAttribIndices(); | 671 const int* attributeIndices = stage.getVertexAttribIndices(); |
| 678 SkSTArray<GrEffect::kMaxVertexAttribs, SkString> attributeNames; | 672 SkSTArray<GrEffect::kMaxVertexAttribs, SkString> attributeNames; |
| 679 for (int a = 0; a < numAttributes; ++a) { | 673 for (int a = 0; a < numAttributes; ++a) { |
| 680 // TODO: Make addAttribute mangle the name. | 674 // TODO: Make addAttribute mangle the name. |
| 681 SkString attributeName("aAttr"); | 675 SkString attributeName("aAttr"); |
| 682 attributeName.appendS32(attributeIndices[a]); | 676 attributeName.appendS32(attributeIndices[a]); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 for (const AttributePair* attrib = this->getEffectAttributes().begin(); | 721 for (const AttributePair* attrib = this->getEffectAttributes().begin(); |
| 728 attrib != attribEnd; | 722 attrib != attribEnd; |
| 729 ++attrib) { | 723 ++attrib) { |
| 730 if (attrib->fIndex == attributeIndex) { | 724 if (attrib->fIndex == attributeIndex) { |
| 731 return &attrib->fName; | 725 return &attrib->fName; |
| 732 } | 726 } |
| 733 } | 727 } |
| 734 | 728 |
| 735 return NULL; | 729 return NULL; |
| 736 } | 730 } |
| 731 |
| 732 |
| OLD | NEW |