| 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 #include "gl/GrGLProgram.h" | 9 #include "gl/GrGLProgram.h" |
| 10 #include "gl/GrGLSLPrettyPrint.h" | 10 #include "gl/GrGLSLPrettyPrint.h" |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 335 |
| 336 fFS.codeAppend("}"); | 336 fFS.codeAppend("}"); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs, | 339 void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs, |
| 340 const char* outColor, | 340 const char* outColor, |
| 341 const char* inColor) { | 341 const char* inColor) { |
| 342 GrGLInstalledFragProc* ifp = SkNEW(GrGLInstalledFragProc); | 342 GrGLInstalledFragProc* ifp = SkNEW(GrGLInstalledFragProc); |
| 343 | 343 |
| 344 const GrFragmentProcessor& fp = *fs.getProcessor(); | 344 const GrFragmentProcessor& fp = *fs.getProcessor(); |
| 345 ifp->fGLProc.reset(fp.getFactory().createGLInstance(fp)); | 345 ifp->fGLProc.reset(fp.createGLInstance()); |
| 346 | 346 |
| 347 SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures()); | 347 SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures()); |
| 348 this->emitSamplers(fp, &samplers, ifp); | 348 this->emitSamplers(fp, &samplers, ifp); |
| 349 | 349 |
| 350 // Fragment processors can have coord transforms | 350 // Fragment processors can have coord transforms |
| 351 SkSTArray<2, GrGLProcessor::TransformedCoords> coords(fp.numTransforms()); | 351 SkSTArray<2, GrGLProcessor::TransformedCoords> coords(fp.numTransforms()); |
| 352 this->emitTransforms(fs, &coords, ifp); | 352 this->emitTransforms(fs, &coords, ifp); |
| 353 | 353 |
| 354 ifp->fGLProc->emitCode(this, fp, outColor, inColor, coords, samplers); | 354 ifp->fGLProc->emitCode(this, fp, outColor, inColor, coords, samplers); |
| 355 | 355 |
| 356 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 356 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
| 357 // asks for dst color, then the emit code needs to follow suit | 357 // asks for dst color, then the emit code needs to follow suit |
| 358 verify(fp); | 358 verify(fp); |
| 359 fFragmentProcessors->fProcs.push_back(ifp); | 359 fFragmentProcessors->fProcs.push_back(ifp); |
| 360 } | 360 } |
| 361 | 361 |
| 362 void GrGLProgramBuilder::emitAndInstallProc(const GrGeometryProcessor& gp, | 362 void GrGLProgramBuilder::emitAndInstallProc(const GrGeometryProcessor& gp, |
| 363 const char* outColor, | 363 const char* outColor, |
| 364 const char* outCoverage) { | 364 const char* outCoverage) { |
| 365 SkASSERT(!fGeometryProcessor); | 365 SkASSERT(!fGeometryProcessor); |
| 366 fGeometryProcessor = SkNEW(GrGLInstalledGeoProc); | 366 fGeometryProcessor = SkNEW(GrGLInstalledGeoProc); |
| 367 | 367 |
| 368 const GrBatchTracker& bt = fOptState.getBatchTracker(); | 368 const GrBatchTracker& bt = fOptState.getBatchTracker(); |
| 369 fGeometryProcessor->fGLProc.reset(gp.getFactory().createGLInstance(gp, bt)); | 369 fGeometryProcessor->fGLProc.reset(gp.createGLInstance(bt)); |
| 370 | 370 |
| 371 SkSTArray<4, GrGLProcessor::TextureSampler> samplers(gp.numTextures()); | 371 SkSTArray<4, GrGLProcessor::TextureSampler> samplers(gp.numTextures()); |
| 372 this->emitSamplers(gp, &samplers, fGeometryProcessor); | 372 this->emitSamplers(gp, &samplers, fGeometryProcessor); |
| 373 | 373 |
| 374 GrGLGeometryProcessor::EmitArgs args(this, gp, bt, outColor, outCoverage, sa
mplers); | 374 GrGLGeometryProcessor::EmitArgs args(this, gp, bt, outColor, outCoverage, sa
mplers); |
| 375 fGeometryProcessor->fGLProc->emitCode(args); | 375 fGeometryProcessor->fGLProc->emitCode(args); |
| 376 | 376 |
| 377 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 377 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
| 378 // asks for dst color, then the emit code needs to follow suit | 378 // asks for dst color, then the emit code needs to follow suit |
| 379 verify(gp); | 379 verify(gp); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 } | 555 } |
| 556 | 556 |
| 557 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 557 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 558 | 558 |
| 559 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 559 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
| 560 int numProcs = fProcs.count(); | 560 int numProcs = fProcs.count(); |
| 561 for (int e = 0; e < numProcs; ++e) { | 561 for (int e = 0; e < numProcs; ++e) { |
| 562 SkDELETE(fProcs[e]); | 562 SkDELETE(fProcs[e]); |
| 563 } | 563 } |
| 564 } | 564 } |
| OLD | NEW |