| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 this->emitAndInstallProc(primProc, inputColor, inputCoverage); | 89 this->emitAndInstallProc(primProc, inputColor, inputCoverage); |
| 90 | 90 |
| 91 fFragmentProcessors.reset(new GrGLInstalledFragProcs); | 91 fFragmentProcessors.reset(new GrGLInstalledFragProcs); |
| 92 int numProcs = this->pipeline().numFragmentProcessors(); | 92 int numProcs = this->pipeline().numFragmentProcessors(); |
| 93 this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentProcessors
(), inputColor); | 93 this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentProcessors
(), inputColor); |
| 94 this->emitAndInstallFragProcs(this->pipeline().numColorFragmentProcessors(),
numProcs, | 94 this->emitAndInstallFragProcs(this->pipeline().numColorFragmentProcessors(),
numProcs, |
| 95 inputCoverage); | 95 inputCoverage); |
| 96 this->emitAndInstallXferProc(*this->pipeline().getXferProcessor(), *inputCol
or, *inputCoverage, | 96 if (primProc.getPixelLocalStorageState() != GrPixelLocalStorageState::kDraw_
State) { |
| 97 this->pipeline().ignoresCoverage()); | 97 this->emitAndInstallXferProc(*this->pipeline().getXferProcessor(), *inpu
tColor, |
| 98 *inputCoverage, this->pipeline().ignoresCov
erage(), |
| 99 primProc.getPixelLocalStorageState()); |
| 100 } |
| 98 return true; | 101 return true; |
| 99 } | 102 } |
| 100 | 103 |
| 101 void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset, | 104 void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset, |
| 102 int numProcs, | 105 int numProcs, |
| 103 GrGLSLExpr4* inOut) { | 106 GrGLSLExpr4* inOut) { |
| 104 for (int i = procOffset; i < numProcs; ++i) { | 107 for (int i = procOffset; i < numProcs; ++i) { |
| 105 GrGLSLExpr4 output; | 108 GrGLSLExpr4 output; |
| 106 const GrFragmentProcessor& fp = this->pipeline().getFragmentProcessor(i)
; | 109 const GrFragmentProcessor& fp = this->pipeline().getFragmentProcessor(i)
; |
| 107 this->emitAndInstallProc(fp, i, *inOut, &output); | 110 this->emitAndInstallProc(fp, i, *inOut, &output); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 fGeometryProcessor->fGLProc->emitCode(args); | 217 fGeometryProcessor->fGLProc->emitCode(args); |
| 215 | 218 |
| 216 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 219 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
| 217 // asks for dst color, then the emit code needs to follow suit | 220 // asks for dst color, then the emit code needs to follow suit |
| 218 verify(gp); | 221 verify(gp); |
| 219 } | 222 } |
| 220 | 223 |
| 221 void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp, | 224 void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp, |
| 222 const GrGLSLExpr4& colorIn, | 225 const GrGLSLExpr4& colorIn, |
| 223 const GrGLSLExpr4& coverageIn, | 226 const GrGLSLExpr4& coverageIn, |
| 224 bool ignoresCoverage) { | 227 bool ignoresCoverage, |
| 228 GrPixelLocalStorageState plsStat
e) { |
| 225 // Program builders have a bit of state we need to clear with each effect | 229 // Program builders have a bit of state we need to clear with each effect |
| 226 AutoStageAdvance adv(this); | 230 AutoStageAdvance adv(this); |
| 227 | 231 |
| 228 SkASSERT(!fXferProcessor); | 232 SkASSERT(!fXferProcessor); |
| 229 fXferProcessor = new GrGLInstalledXferProc; | 233 fXferProcessor = new GrGLInstalledXferProc; |
| 230 | 234 |
| 231 fXferProcessor->fGLProc.reset(xp.createGLSLInstance()); | 235 fXferProcessor->fGLProc.reset(xp.createGLSLInstance()); |
| 232 | 236 |
| 233 // Enable dual source secondary output if we have one | 237 // Enable dual source secondary output if we have one |
| 234 if (xp.hasSecondaryOutput()) { | 238 if (xp.hasSecondaryOutput()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 246 SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures()); | 250 SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures()); |
| 247 this->emitSamplers(xp, &samplers, fXferProcessor); | 251 this->emitSamplers(xp, &samplers, fXferProcessor); |
| 248 | 252 |
| 249 GrGLSLXferProcessor::EmitArgs args(&fFS, | 253 GrGLSLXferProcessor::EmitArgs args(&fFS, |
| 250 &fUniformHandler, | 254 &fUniformHandler, |
| 251 this->glslCaps(), | 255 this->glslCaps(), |
| 252 xp, colorIn.c_str(), | 256 xp, colorIn.c_str(), |
| 253 ignoresCoverage ? nullptr : coverageIn.c_
str(), | 257 ignoresCoverage ? nullptr : coverageIn.c_
str(), |
| 254 fFS.getPrimaryColorOutputName(), | 258 fFS.getPrimaryColorOutputName(), |
| 255 fFS.getSecondaryColorOutputName(), | 259 fFS.getSecondaryColorOutputName(), |
| 256 samplers); | 260 samplers, |
| 261 plsState == GrPixelLocalStorageState::kFi
nish_State); |
| 257 fXferProcessor->fGLProc->emitCode(args); | 262 fXferProcessor->fGLProc->emitCode(args); |
| 258 | 263 |
| 259 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 264 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
| 260 // asks for dst color, then the emit code needs to follow suit | 265 // asks for dst color, then the emit code needs to follow suit |
| 261 verify(xp); | 266 verify(xp); |
| 262 fFS.codeAppend("}"); | 267 fFS.codeAppend("}"); |
| 263 } | 268 } |
| 264 | 269 |
| 265 void GrGLProgramBuilder::verify(const GrPrimitiveProcessor& gp) { | 270 void GrGLProgramBuilder::verify(const GrPrimitiveProcessor& gp) { |
| 266 SkASSERT(fFS.hasReadFragmentPosition() == gp.willReadFragmentPosition()); | 271 SkASSERT(fFS.hasReadFragmentPosition() == gp.willReadFragmentPosition()); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 } | 483 } |
| 479 | 484 |
| 480 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 485 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 481 | 486 |
| 482 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 487 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
| 483 int numProcs = fProcs.count(); | 488 int numProcs = fProcs.count(); |
| 484 for (int i = 0; i < numProcs; ++i) { | 489 for (int i = 0; i < numProcs; ++i) { |
| 485 delete fProcs[i]; | 490 delete fProcs[i]; |
| 486 } | 491 } |
| 487 } | 492 } |
| OLD | NEW |