| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrGLProgramBuilder.h" | 8 #include "GrGLProgramBuilder.h" |
| 9 | 9 |
| 10 #include "GrAutoLocaleSetter.h" | 10 #include "GrAutoLocaleSetter.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 return pb->finalize(); | 48 return pb->finalize(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 ///////////////////////////////////////////////////////////////////////////// | 51 ///////////////////////////////////////////////////////////////////////////// |
| 52 | 52 |
| 53 GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, const DrawArgs& args) | 53 GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, const DrawArgs& args) |
| 54 : INHERITED(args) | 54 : INHERITED(args) |
| 55 , fGeometryProcessor(nullptr) | 55 , fGeometryProcessor(nullptr) |
| 56 , fXferProcessor(nullptr) | 56 , fXferProcessor(nullptr) |
| 57 , fGpu(gpu) | 57 , fGpu(gpu) |
| 58 , fUniforms(kVarsPerBlock) | |
| 59 , fSamplerUniforms(4) | 58 , fSamplerUniforms(4) |
| 60 , fVaryingHandler(this) { | 59 , fVaryingHandler(this) |
| 61 } | 60 , fUniformHandler(this) { |
| 62 | |
| 63 GrGLSLProgramDataManager::UniformHandle GrGLProgramBuilder::internalAddUniformAr
ray( | |
| 64 uint32_t visibil
ity, | |
| 65 GrSLType type, | |
| 66 GrSLPrecision pr
ecision, | |
| 67 const char* name
, | |
| 68 bool mangleName, | |
| 69 int count, | |
| 70 const char** out
Name) { | |
| 71 SkASSERT(name && strlen(name)); | |
| 72 SkDEBUGCODE(static const uint32_t kVisibilityMask = kVertex_Visibility | kFr
agment_Visibility); | |
| 73 SkASSERT(0 == (~kVisibilityMask & visibility)); | |
| 74 SkASSERT(0 != visibility); | |
| 75 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type)); | |
| 76 | |
| 77 UniformInfo& uni = fUniforms.push_back(); | |
| 78 uni.fVariable.setType(type); | |
| 79 uni.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier); | |
| 80 // TODO this is a bit hacky, lets think of a better way. Basically we need
to be able to use | |
| 81 // the uniform view matrix name in the GP, and the GP is immutable so it has
to tell the PB | |
| 82 // exactly what name it wants to use for the uniform view matrix. If we pre
fix anythings, then | |
| 83 // the names will mismatch. I think the correct solution is to have all GPs
which need the | |
| 84 // uniform view matrix, they should upload the view matrix in their setData
along with regular | |
| 85 // uniforms. | |
| 86 char prefix = 'u'; | |
| 87 if ('u' == name[0]) { | |
| 88 prefix = '\0'; | |
| 89 } | |
| 90 this->nameVariable(uni.fVariable.accessName(), prefix, name, mangleName); | |
| 91 uni.fVariable.setArrayCount(count); | |
| 92 uni.fVisibility = visibility; | |
| 93 uni.fVariable.setPrecision(precision); | |
| 94 | |
| 95 if (outName) { | |
| 96 *outName = uni.fVariable.c_str(); | |
| 97 } | |
| 98 return GrGLSLProgramDataManager::UniformHandle(fUniforms.count() - 1); | |
| 99 } | |
| 100 | |
| 101 void GrGLProgramBuilder::onAppendUniformDecls(ShaderVisibility visibility, SkStr
ing* out) const { | |
| 102 for (int i = 0; i < fUniforms.count(); ++i) { | |
| 103 if (fUniforms[i].fVisibility & visibility) { | |
| 104 fUniforms[i].fVariable.appendDecl(this->glslCaps(), out); | |
| 105 out->append(";\n"); | |
| 106 } | |
| 107 } | |
| 108 } | 61 } |
| 109 | 62 |
| 110 const GrGLSLCaps* GrGLProgramBuilder::glslCaps() const { | 63 const GrGLSLCaps* GrGLProgramBuilder::glslCaps() const { |
| 111 return this->fGpu->ctxInfo().caps()->glslCaps(); | 64 return this->fGpu->ctxInfo().caps()->glslCaps(); |
| 112 } | 65 } |
| 113 | 66 |
| 114 bool GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr
4* inputCoverage) { | 67 bool GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr
4* inputCoverage) { |
| 115 // First we loop over all of the installed processors and collect coord tran
sforms. These will | 68 // First we loop over all of the installed processors and collect coord tran
sforms. These will |
| 116 // be sent to the GrGLSLPrimitiveProcessor in its emitCode function | 69 // be sent to the GrGLSLPrimitiveProcessor in its emitCode function |
| 117 const GrPrimitiveProcessor& primProc = this->primitiveProcessor(); | 70 const GrPrimitiveProcessor& primProc = this->primitiveProcessor(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 int index, | 166 int index, |
| 214 const char* outColor, | 167 const char* outColor, |
| 215 const char* inColor) { | 168 const char* inColor) { |
| 216 GrGLInstalledFragProc* ifp = new GrGLInstalledFragProc; | 169 GrGLInstalledFragProc* ifp = new GrGLInstalledFragProc; |
| 217 | 170 |
| 218 ifp->fGLProc.reset(fp.createGLSLInstance()); | 171 ifp->fGLProc.reset(fp.createGLSLInstance()); |
| 219 | 172 |
| 220 SkSTArray<4, GrGLSLTextureSampler> samplers(fp.numTextures()); | 173 SkSTArray<4, GrGLSLTextureSampler> samplers(fp.numTextures()); |
| 221 this->emitSamplers(fp, &samplers, ifp); | 174 this->emitSamplers(fp, &samplers, ifp); |
| 222 | 175 |
| 223 GrGLSLFragmentProcessor::EmitArgs args(this, | 176 GrGLSLFragmentProcessor::EmitArgs args(&fFS, |
| 224 &fFS, | 177 &fUniformHandler, |
| 225 this->glslCaps(), | 178 this->glslCaps(), |
| 226 fp, | 179 fp, |
| 227 outColor, | 180 outColor, |
| 228 inColor, | 181 inColor, |
| 229 fOutCoords[index], | 182 fOutCoords[index], |
| 230 samplers); | 183 samplers); |
| 231 ifp->fGLProc->emitCode(args); | 184 ifp->fGLProc->emitCode(args); |
| 232 | 185 |
| 233 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 186 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
| 234 // asks for dst color, then the emit code needs to follow suit | 187 // asks for dst color, then the emit code needs to follow suit |
| 235 verify(fp); | 188 verify(fp); |
| 236 fFragmentProcessors->fProcs.push_back(ifp); | 189 fFragmentProcessors->fProcs.push_back(ifp); |
| 237 } | 190 } |
| 238 | 191 |
| 239 void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& gp, | 192 void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& gp, |
| 240 const char* outColor, | 193 const char* outColor, |
| 241 const char* outCoverage) { | 194 const char* outCoverage) { |
| 242 SkASSERT(!fGeometryProcessor); | 195 SkASSERT(!fGeometryProcessor); |
| 243 fGeometryProcessor = new GrGLInstalledGeoProc; | 196 fGeometryProcessor = new GrGLInstalledGeoProc; |
| 244 | 197 |
| 245 fGeometryProcessor->fGLProc.reset(gp.createGLSLInstance(*fGpu->glCaps().glsl
Caps())); | 198 fGeometryProcessor->fGLProc.reset(gp.createGLSLInstance(*fGpu->glCaps().glsl
Caps())); |
| 246 | 199 |
| 247 SkSTArray<4, GrGLSLTextureSampler> samplers(gp.numTextures()); | 200 SkSTArray<4, GrGLSLTextureSampler> samplers(gp.numTextures()); |
| 248 this->emitSamplers(gp, &samplers, fGeometryProcessor); | 201 this->emitSamplers(gp, &samplers, fGeometryProcessor); |
| 249 | 202 |
| 250 GrGLSLGeometryProcessor::EmitArgs args(this, | 203 GrGLSLGeometryProcessor::EmitArgs args(&fVS, |
| 251 &fVS, | |
| 252 &fFS, | 204 &fFS, |
| 253 &fVaryingHandler, | 205 &fVaryingHandler, |
| 206 &fUniformHandler, |
| 254 this->glslCaps(), | 207 this->glslCaps(), |
| 255 gp, | 208 gp, |
| 256 outColor, | 209 outColor, |
| 257 outCoverage, | 210 outCoverage, |
| 258 samplers, | 211 samplers, |
| 259 fCoordTransforms, | 212 fCoordTransforms, |
| 260 &fOutCoords); | 213 &fOutCoords); |
| 261 fGeometryProcessor->fGLProc->emitCode(args); | 214 fGeometryProcessor->fGLProc->emitCode(args); |
| 262 | 215 |
| 263 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 216 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
| (...skipping 22 matching lines...) Expand all Loading... |
| 286 fFS.enableCustomOutput(); | 239 fFS.enableCustomOutput(); |
| 287 } | 240 } |
| 288 | 241 |
| 289 SkString openBrace; | 242 SkString openBrace; |
| 290 openBrace.printf("{ // Xfer Processor: %s\n", xp.name()); | 243 openBrace.printf("{ // Xfer Processor: %s\n", xp.name()); |
| 291 fFS.codeAppend(openBrace.c_str()); | 244 fFS.codeAppend(openBrace.c_str()); |
| 292 | 245 |
| 293 SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures()); | 246 SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures()); |
| 294 this->emitSamplers(xp, &samplers, fXferProcessor); | 247 this->emitSamplers(xp, &samplers, fXferProcessor); |
| 295 | 248 |
| 296 GrGLSLXferProcessor::EmitArgs args(this, | 249 GrGLSLXferProcessor::EmitArgs args(&fFS, |
| 297 &fFS, | 250 &fUniformHandler, |
| 298 this->glslCaps(), | 251 this->glslCaps(), |
| 299 xp, colorIn.c_str(), | 252 xp, colorIn.c_str(), |
| 300 ignoresCoverage ? nullptr : coverageIn.c_
str(), | 253 ignoresCoverage ? nullptr : coverageIn.c_
str(), |
| 301 fFS.getPrimaryColorOutputName(), | 254 fFS.getPrimaryColorOutputName(), |
| 302 fFS.getSecondaryColorOutputName(), | 255 fFS.getSecondaryColorOutputName(), |
| 303 samplers); | 256 samplers); |
| 304 fXferProcessor->fGLProc->emitCode(args); | 257 fXferProcessor->fGLProc->emitCode(args); |
| 305 | 258 |
| 306 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 259 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
| 307 // asks for dst color, then the emit code needs to follow suit | 260 // asks for dst color, then the emit code needs to follow suit |
| (...skipping 27 matching lines...) Expand all Loading... |
| 335 void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor, | 288 void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor, |
| 336 GrGLSLTextureSampler::TextureSamplerArray*
outSamplers, | 289 GrGLSLTextureSampler::TextureSamplerArray*
outSamplers, |
| 337 GrGLInstalledProc<Proc>* ip) { | 290 GrGLInstalledProc<Proc>* ip) { |
| 338 SkDEBUGCODE(ip->fSamplersIdx = fSamplerUniforms.count();) | 291 SkDEBUGCODE(ip->fSamplersIdx = fSamplerUniforms.count();) |
| 339 int numTextures = processor.numTextures(); | 292 int numTextures = processor.numTextures(); |
| 340 UniformHandle* localSamplerUniforms = fSamplerUniforms.push_back_n(numTextur
es); | 293 UniformHandle* localSamplerUniforms = fSamplerUniforms.push_back_n(numTextur
es); |
| 341 SkString name; | 294 SkString name; |
| 342 for (int t = 0; t < numTextures; ++t) { | 295 for (int t = 0; t < numTextures; ++t) { |
| 343 name.printf("Sampler%d", t); | 296 name.printf("Sampler%d", t); |
| 344 GrSLType samplerType = get_sampler_type(processor.textureAccess(t)); | 297 GrSLType samplerType = get_sampler_type(processor.textureAccess(t)); |
| 345 localSamplerUniforms[t] = this->addUniform(GrGLProgramBuilder::kFragment
_Visibility, | 298 localSamplerUniforms[t] = |
| 346 samplerType, kDefault_GrSLPre
cision, | 299 fUniformHandler.addUniform(GrGLSLUniformHandler::kFragment_Visibilit
y, |
| 347 name.c_str()); | 300 samplerType, kDefault_GrSLPrecision, |
| 301 name.c_str()); |
| 348 SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLSLTextureSampler, | 302 SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLSLTextureSampler, |
| 349 (localSamplerUniforms[t], processor.textureAccess
(t))); | 303 (localSamplerUniforms[t], processor.textureAccess
(t))); |
| 350 if (kSamplerExternal_GrSLType == samplerType) { | 304 if (kSamplerExternal_GrSLType == samplerType) { |
| 351 const char* externalFeatureString = this->glslCaps()->externalTextur
eExtensionString(); | 305 const char* externalFeatureString = this->glslCaps()->externalTextur
eExtensionString(); |
| 352 // We shouldn't ever create a GrGLTexture that requires external sam
pler type | 306 // We shouldn't ever create a GrGLTexture that requires external sam
pler type |
| 353 SkASSERT(externalFeatureString); | 307 SkASSERT(externalFeatureString); |
| 354 fFS.addFeature(1 << GrGLSLFragmentShaderBuilder::kExternalTexture_GL
SLPrivateFeature, | 308 fFS.addFeature(1 << GrGLSLFragmentShaderBuilder::kExternalTexture_GL
SLPrivateFeature, |
| 355 externalFeatureString); | 309 externalFeatureString); |
| 356 } | 310 } |
| 357 } | 311 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 382 GrGLProgram* GrGLProgramBuilder::finalize() { | 336 GrGLProgram* GrGLProgramBuilder::finalize() { |
| 383 // verify we can get a program id | 337 // verify we can get a program id |
| 384 GrGLuint programID; | 338 GrGLuint programID; |
| 385 GL_CALL_RET(programID, CreateProgram()); | 339 GL_CALL_RET(programID, CreateProgram()); |
| 386 if (0 == programID) { | 340 if (0 == programID) { |
| 387 return nullptr; | 341 return nullptr; |
| 388 } | 342 } |
| 389 | 343 |
| 390 // compile shaders and bind attributes / uniforms | 344 // compile shaders and bind attributes / uniforms |
| 391 SkTDArray<GrGLuint> shadersToDelete; | 345 SkTDArray<GrGLuint> shadersToDelete; |
| 392 fVS.finalize(kVertex_Visibility); | 346 fVS.finalize(GrGLSLUniformHandler::kVertex_Visibility); |
| 393 if (!this->compileAndAttachShaders(fVS, programID, GR_GL_VERTEX_SHADER, &sha
dersToDelete)) { | 347 if (!this->compileAndAttachShaders(fVS, programID, GR_GL_VERTEX_SHADER, &sha
dersToDelete)) { |
| 394 this->cleanupProgram(programID, shadersToDelete); | 348 this->cleanupProgram(programID, shadersToDelete); |
| 395 return nullptr; | 349 return nullptr; |
| 396 } | 350 } |
| 397 | 351 |
| 398 // NVPR actually requires a vertex shader to compile | 352 // NVPR actually requires a vertex shader to compile |
| 399 bool useNvpr = primitiveProcessor().isPathRendering(); | 353 bool useNvpr = primitiveProcessor().isPathRendering(); |
| 400 if (!useNvpr) { | 354 if (!useNvpr) { |
| 401 const GrPrimitiveProcessor& primProc = this->primitiveProcessor(); | 355 const GrPrimitiveProcessor& primProc = this->primitiveProcessor(); |
| 402 | 356 |
| 403 int vaCount = primProc.numAttribs(); | 357 int vaCount = primProc.numAttribs(); |
| 404 for (int i = 0; i < vaCount; i++) { | 358 for (int i = 0; i < vaCount; i++) { |
| 405 GL_CALL(BindAttribLocation(programID, i, primProc.getAttrib(i).fName
)); | 359 GL_CALL(BindAttribLocation(programID, i, primProc.getAttrib(i).fName
)); |
| 406 } | 360 } |
| 407 } | 361 } |
| 408 | 362 |
| 409 fFS.finalize(kFragment_Visibility); | 363 fFS.finalize(GrGLSLUniformHandler::kFragment_Visibility); |
| 410 if (!this->compileAndAttachShaders(fFS, programID, GR_GL_FRAGMENT_SHADER, &s
hadersToDelete)) { | 364 if (!this->compileAndAttachShaders(fFS, programID, GR_GL_FRAGMENT_SHADER, &s
hadersToDelete)) { |
| 411 this->cleanupProgram(programID, shadersToDelete); | 365 this->cleanupProgram(programID, shadersToDelete); |
| 412 return nullptr; | 366 return nullptr; |
| 413 } | 367 } |
| 414 | 368 |
| 415 this->bindProgramResourceLocations(programID); | 369 this->bindProgramResourceLocations(programID); |
| 416 | 370 |
| 417 GL_CALL(LinkProgram(programID)); | 371 GL_CALL(LinkProgram(programID)); |
| 418 | 372 |
| 419 // Calling GetProgramiv is expensive in Chromium. Assume success in release
builds. | 373 // Calling GetProgramiv is expensive in Chromium. Assume success in release
builds. |
| 420 bool checkLinked = kChromium_GrGLDriver != fGpu->ctxInfo().driver(); | 374 bool checkLinked = kChromium_GrGLDriver != fGpu->ctxInfo().driver(); |
| 421 #ifdef SK_DEBUG | 375 #ifdef SK_DEBUG |
| 422 checkLinked = true; | 376 checkLinked = true; |
| 423 #endif | 377 #endif |
| 424 if (checkLinked) { | 378 if (checkLinked) { |
| 425 checkLinkStatus(programID); | 379 checkLinkStatus(programID); |
| 426 } | 380 } |
| 427 this->resolveProgramResourceLocations(programID); | 381 this->resolveProgramResourceLocations(programID); |
| 428 | 382 |
| 429 this->cleanupShaders(shadersToDelete); | 383 this->cleanupShaders(shadersToDelete); |
| 430 | 384 |
| 431 return this->createProgram(programID); | 385 return this->createProgram(programID); |
| 432 } | 386 } |
| 433 | 387 |
| 434 void GrGLProgramBuilder::bindProgramResourceLocations(GrGLuint programID) { | 388 void GrGLProgramBuilder::bindProgramResourceLocations(GrGLuint programID) { |
| 435 if (fGpu->glCaps().bindUniformLocationSupport()) { | 389 fUniformHandler.bindUniformLocations(programID, fGpu->glCaps()); |
| 436 int count = fUniforms.count(); | |
| 437 for (int i = 0; i < count; ++i) { | |
| 438 GL_CALL(BindUniformLocation(programID, i, fUniforms[i].fVariable.c_s
tr())); | |
| 439 fUniforms[i].fLocation = i; | |
| 440 } | |
| 441 } | |
| 442 | 390 |
| 443 const GrGLCaps& caps = this->gpu()->glCaps(); | 391 const GrGLCaps& caps = this->gpu()->glCaps(); |
| 444 if (fFS.hasCustomColorOutput() && caps.bindFragDataLocationSupport()) { | 392 if (fFS.hasCustomColorOutput() && caps.bindFragDataLocationSupport()) { |
| 445 GL_CALL(BindFragDataLocation(programID, 0, | 393 GL_CALL(BindFragDataLocation(programID, 0, |
| 446 GrGLSLFragmentShaderBuilder::DeclaredColorO
utputName())); | 394 GrGLSLFragmentShaderBuilder::DeclaredColorO
utputName())); |
| 447 } | 395 } |
| 448 if (fFS.hasSecondaryOutput() && caps.glslCaps()->mustDeclareFragmentShaderOu
tput()) { | 396 if (fFS.hasSecondaryOutput() && caps.glslCaps()->mustDeclareFragmentShaderOu
tput()) { |
| 449 GL_CALL(BindFragDataLocationIndexed(programID, 0, 1, | 397 GL_CALL(BindFragDataLocationIndexed(programID, 0, 1, |
| 450 GrGLSLFragmentShaderBuilder::DeclaredSecondary
ColorOutputName())); | 398 GrGLSLFragmentShaderBuilder::DeclaredSecondary
ColorOutputName())); |
| 451 } | 399 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 481 SkDebugf("%s", (char*)log.get()); | 429 SkDebugf("%s", (char*)log.get()); |
| 482 } | 430 } |
| 483 SkDEBUGFAIL("Error linking program"); | 431 SkDEBUGFAIL("Error linking program"); |
| 484 GL_CALL(DeleteProgram(programID)); | 432 GL_CALL(DeleteProgram(programID)); |
| 485 programID = 0; | 433 programID = 0; |
| 486 } | 434 } |
| 487 return SkToBool(linked); | 435 return SkToBool(linked); |
| 488 } | 436 } |
| 489 | 437 |
| 490 void GrGLProgramBuilder::resolveProgramResourceLocations(GrGLuint programID) { | 438 void GrGLProgramBuilder::resolveProgramResourceLocations(GrGLuint programID) { |
| 491 if (!fGpu->glCaps().bindUniformLocationSupport()) { | 439 fUniformHandler.getUniformLocations(programID, fGpu->glCaps()); |
| 492 int count = fUniforms.count(); | |
| 493 for (int i = 0; i < count; ++i) { | |
| 494 GrGLint location; | |
| 495 GL_CALL_RET(location, GetUniformLocation(programID, fUniforms[i].fVa
riable.c_str())); | |
| 496 fUniforms[i].fLocation = location; | |
| 497 } | |
| 498 } | |
| 499 | 440 |
| 500 // handle NVPR separable varyings | 441 // handle NVPR separable varyings |
| 501 if (!fGpu->glCaps().shaderCaps()->pathRenderingSupport() || | 442 if (!fGpu->glCaps().shaderCaps()->pathRenderingSupport() || |
| 502 !fGpu->glPathRendering()->shouldBindFragmentInputs()) { | 443 !fGpu->glPathRendering()->shouldBindFragmentInputs()) { |
| 503 return; | 444 return; |
| 504 } | 445 } |
| 505 int count = fVaryingHandler.fPathProcVaryingInfos.count(); | 446 int count = fVaryingHandler.fPathProcVaryingInfos.count(); |
| 506 for (int i = 0; i < count; ++i) { | 447 for (int i = 0; i < count; ++i) { |
| 507 GrGLint location; | 448 GrGLint location; |
| 508 GL_CALL_RET(location, GetProgramResourceLocation( | 449 GL_CALL_RET(location, GetProgramResourceLocation( |
| 509 programID, | 450 programID, |
| 510 GR_GL_FRAGMENT_INPUT, | 451 GR_GL_FRAGMENT_INPUT, |
| 511 fVaryingHandler.fPathProcVaryingInfos[i].
fVariable.c_str())); | 452 fVaryingHandler.fPathProcVaryingInfos[i].
fVariable.c_str())); |
| 512 fVaryingHandler.fPathProcVaryingInfos[i].fLocation = location; | 453 fVaryingHandler.fPathProcVaryingInfos[i].fLocation = location; |
| 513 } | 454 } |
| 514 } | 455 } |
| 515 | 456 |
| 516 void GrGLProgramBuilder::cleanupProgram(GrGLuint programID, const SkTDArray<GrGL
uint>& shaderIDs) { | 457 void GrGLProgramBuilder::cleanupProgram(GrGLuint programID, const SkTDArray<GrGL
uint>& shaderIDs) { |
| 517 GL_CALL(DeleteProgram(programID)); | 458 GL_CALL(DeleteProgram(programID)); |
| 518 cleanupShaders(shaderIDs); | 459 cleanupShaders(shaderIDs); |
| 519 } | 460 } |
| 520 void GrGLProgramBuilder::cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs) { | 461 void GrGLProgramBuilder::cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs) { |
| 521 for (int i = 0; i < shaderIDs.count(); ++i) { | 462 for (int i = 0; i < shaderIDs.count(); ++i) { |
| 522 GL_CALL(DeleteShader(shaderIDs[i])); | 463 GL_CALL(DeleteShader(shaderIDs[i])); |
| 523 } | 464 } |
| 524 } | 465 } |
| 525 | 466 |
| 526 GrGLProgram* GrGLProgramBuilder::createProgram(GrGLuint programID) { | 467 GrGLProgram* GrGLProgramBuilder::createProgram(GrGLuint programID) { |
| 527 return new GrGLProgram(fGpu, this->desc(), fUniformHandles, programID, fUnif
orms, | 468 return new GrGLProgram(fGpu, |
| 469 this->desc(), |
| 470 fUniformHandles, |
| 471 programID, |
| 472 fUniformHandler.fUniforms, |
| 528 fVaryingHandler.fPathProcVaryingInfos, | 473 fVaryingHandler.fPathProcVaryingInfos, |
| 529 fGeometryProcessor, fXferProcessor, fFragmentProcesso
rs.get(), | 474 fGeometryProcessor, |
| 475 fXferProcessor, |
| 476 fFragmentProcessors.get(), |
| 530 &fSamplerUniforms); | 477 &fSamplerUniforms); |
| 531 } | 478 } |
| 532 | 479 |
| 533 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 480 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 534 | 481 |
| 535 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 482 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
| 536 int numProcs = fProcs.count(); | 483 int numProcs = fProcs.count(); |
| 537 for (int i = 0; i < numProcs; ++i) { | 484 for (int i = 0; i < numProcs; ++i) { |
| 538 delete fProcs[i]; | 485 delete fProcs[i]; |
| 539 } | 486 } |
| 540 } | 487 } |
| OLD | NEW |