Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: src/gpu/gl/builders/GrGLProgramBuilder.cpp

Issue 1471293003: Create a static instances of SrcOver XferProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix Build Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.h ('k') | src/gpu/glsl/GrGLSLXferProcessor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 133 }
134 } 134 }
135 135
136 this->emitAndInstallProc(primProc, inputColor, inputCoverage); 136 this->emitAndInstallProc(primProc, inputColor, inputCoverage);
137 137
138 fFragmentProcessors.reset(new GrGLInstalledFragProcs); 138 fFragmentProcessors.reset(new GrGLInstalledFragProcs);
139 int numProcs = this->pipeline().numFragmentProcessors(); 139 int numProcs = this->pipeline().numFragmentProcessors();
140 this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentProcessors (), inputColor); 140 this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentProcessors (), inputColor);
141 this->emitAndInstallFragProcs(this->pipeline().numColorFragmentProcessors(), numProcs, 141 this->emitAndInstallFragProcs(this->pipeline().numColorFragmentProcessors(), numProcs,
142 inputCoverage); 142 inputCoverage);
143 this->emitAndInstallXferProc(*this->pipeline().getXferProcessor(), *inputCol or, *inputCoverage); 143 this->emitAndInstallXferProc(*this->pipeline().getXferProcessor(), *inputCol or, *inputCoverage,
144 this->pipeline().ignoresCoverage());
144 return true; 145 return true;
145 } 146 }
146 147
147 void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset, 148 void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset,
148 int numProcs, 149 int numProcs,
149 GrGLSLExpr4* inOut) { 150 GrGLSLExpr4* inOut) {
150 for (int i = procOffset; i < numProcs; ++i) { 151 for (int i = procOffset; i < numProcs; ++i) {
151 GrGLSLExpr4 output; 152 GrGLSLExpr4 output;
152 const GrFragmentProcessor& fp = this->pipeline().getFragmentProcessor(i) ; 153 const GrFragmentProcessor& fp = this->pipeline().getFragmentProcessor(i) ;
153 this->emitAndInstallProc(fp, i, *inOut, &output); 154 this->emitAndInstallProc(fp, i, *inOut, &output);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 &fOutCoords); 260 &fOutCoords);
260 fGeometryProcessor->fGLProc->emitCode(args); 261 fGeometryProcessor->fGLProc->emitCode(args);
261 262
262 // We have to check that effects and the code they emit are consistent, ie i f an effect 263 // We have to check that effects and the code they emit are consistent, ie i f an effect
263 // asks for dst color, then the emit code needs to follow suit 264 // asks for dst color, then the emit code needs to follow suit
264 verify(gp); 265 verify(gp);
265 } 266 }
266 267
267 void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp, 268 void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp,
268 const GrGLSLExpr4& colorIn, 269 const GrGLSLExpr4& colorIn,
269 const GrGLSLExpr4& coverageIn) { 270 const GrGLSLExpr4& coverageIn,
271 bool ignoresCoverage) {
270 // Program builders have a bit of state we need to clear with each effect 272 // Program builders have a bit of state we need to clear with each effect
271 AutoStageAdvance adv(this); 273 AutoStageAdvance adv(this);
272 274
273 SkASSERT(!fXferProcessor); 275 SkASSERT(!fXferProcessor);
274 fXferProcessor = new GrGLInstalledXferProc; 276 fXferProcessor = new GrGLInstalledXferProc;
275 277
276 fXferProcessor->fGLProc.reset(xp.createGLSLInstance()); 278 fXferProcessor->fGLProc.reset(xp.createGLSLInstance());
277 279
278 // Enable dual source secondary output if we have one 280 // Enable dual source secondary output if we have one
279 if (xp.hasSecondaryOutput()) { 281 if (xp.hasSecondaryOutput()) {
280 fFS.enableSecondaryOutput(); 282 fFS.enableSecondaryOutput();
281 } 283 }
282 284
283 if (this->glslCaps()->mustDeclareFragmentShaderOutput()) { 285 if (this->glslCaps()->mustDeclareFragmentShaderOutput()) {
284 fFS.enableCustomOutput(); 286 fFS.enableCustomOutput();
285 } 287 }
286 288
287 SkString openBrace; 289 SkString openBrace;
288 openBrace.printf("{ // Xfer Processor: %s\n", xp.name()); 290 openBrace.printf("{ // Xfer Processor: %s\n", xp.name());
289 fFS.codeAppend(openBrace.c_str()); 291 fFS.codeAppend(openBrace.c_str());
290 292
291 SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures()); 293 SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures());
292 this->emitSamplers(xp, &samplers, fXferProcessor); 294 this->emitSamplers(xp, &samplers, fXferProcessor);
293 295
294 GrGLSLXferProcessor::EmitArgs args(this, 296 GrGLSLXferProcessor::EmitArgs args(this,
295 &fFS, 297 &fFS,
296 this->glslCaps(), 298 this->glslCaps(),
297 xp, colorIn.c_str(), 299 xp, colorIn.c_str(),
298 coverageIn.c_str(), 300 ignoresCoverage ? nullptr : coverageIn.c_ str(),
299 fFS.getPrimaryColorOutputName(), 301 fFS.getPrimaryColorOutputName(),
300 fFS.getSecondaryColorOutputName(), 302 fFS.getSecondaryColorOutputName(),
301 samplers); 303 samplers);
302 fXferProcessor->fGLProc->emitCode(args); 304 fXferProcessor->fGLProc->emitCode(args);
303 305
304 // We have to check that effects and the code they emit are consistent, ie i f an effect 306 // We have to check that effects and the code they emit are consistent, ie i f an effect
305 // asks for dst color, then the emit code needs to follow suit 307 // asks for dst color, then the emit code needs to follow suit
306 verify(xp); 308 verify(xp);
307 fFS.codeAppend("}"); 309 fFS.codeAppend("}");
308 } 310 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 } 531 }
530 532
531 //////////////////////////////////////////////////////////////////////////////// /////////////////// 533 //////////////////////////////////////////////////////////////////////////////// ///////////////////
532 534
533 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { 535 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() {
534 int numProcs = fProcs.count(); 536 int numProcs = fProcs.count();
535 for (int i = 0; i < numProcs; ++i) { 537 for (int i = 0; i < numProcs; ++i) {
536 delete fProcs[i]; 538 delete fProcs[i];
537 } 539 }
538 } 540 }
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.h ('k') | src/gpu/glsl/GrGLSLXferProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698