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