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" |
11 #include "GrCoordTransform.h" | 11 #include "GrCoordTransform.h" |
12 #include "GrGLProgramBuilder.h" | 12 #include "GrGLProgramBuilder.h" |
| 13 #include "GrSwizzle.h" |
13 #include "GrTexture.h" | 14 #include "GrTexture.h" |
14 #include "SkRTConf.h" | 15 #include "SkRTConf.h" |
15 #include "SkTraceEvent.h" | 16 #include "SkTraceEvent.h" |
16 #include "gl/GrGLGpu.h" | 17 #include "gl/GrGLGpu.h" |
17 #include "gl/GrGLProgram.h" | 18 #include "gl/GrGLProgram.h" |
18 #include "gl/GrGLSLPrettyPrint.h" | 19 #include "gl/GrGLSLPrettyPrint.h" |
19 #include "gl/builders/GrGLShaderStringBuilder.h" | 20 #include "gl/builders/GrGLShaderStringBuilder.h" |
20 #include "glsl/GrGLSLCaps.h" | 21 #include "glsl/GrGLSLCaps.h" |
21 #include "glsl/GrGLSLFragmentProcessor.h" | 22 #include "glsl/GrGLSLFragmentProcessor.h" |
22 #include "glsl/GrGLSLGeometryProcessor.h" | 23 #include "glsl/GrGLSLGeometryProcessor.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 ignoresCoverage ? nullptr : coverageIn.c_
str(), | 254 ignoresCoverage ? nullptr : coverageIn.c_
str(), |
254 fFS.getPrimaryColorOutputName(), | 255 fFS.getPrimaryColorOutputName(), |
255 fFS.getSecondaryColorOutputName(), | 256 fFS.getSecondaryColorOutputName(), |
256 samplers); | 257 samplers); |
257 fXferProcessor->fGLProc->emitCode(args); | 258 fXferProcessor->fGLProc->emitCode(args); |
258 | 259 |
259 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 260 // 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 | 261 // asks for dst color, then the emit code needs to follow suit |
261 verify(xp); | 262 verify(xp); |
262 fFS.codeAppend("}"); | 263 fFS.codeAppend("}"); |
| 264 |
| 265 // Swizzle the fragment shader outputs if necessary. |
| 266 GrSwizzle swizzle; |
| 267 swizzle.setFromKey(this->desc().header().fOutputSwizzle); |
| 268 if (swizzle != GrSwizzle::RGBA()) { |
| 269 fFS.codeAppendf("%s = %s.%s;", fFS.getPrimaryColorOutputName(), |
| 270 fFS.getPrimaryColorOutputName(), |
| 271 swizzle.c_str()); |
| 272 if (xp.hasSecondaryOutput()) { |
| 273 fFS.codeAppendf("%s = %s.%s;", fFS.getSecondaryColorOutputName(), |
| 274 fFS.getSecondaryColorOutputName(), |
| 275 swizzle.c_str()); |
| 276 } |
| 277 } |
263 } | 278 } |
264 | 279 |
265 void GrGLProgramBuilder::verify(const GrPrimitiveProcessor& gp) { | 280 void GrGLProgramBuilder::verify(const GrPrimitiveProcessor& gp) { |
266 SkASSERT(fFS.hasReadFragmentPosition() == gp.willReadFragmentPosition()); | 281 SkASSERT(fFS.hasReadFragmentPosition() == gp.willReadFragmentPosition()); |
267 } | 282 } |
268 | 283 |
269 void GrGLProgramBuilder::verify(const GrXferProcessor& xp) { | 284 void GrGLProgramBuilder::verify(const GrXferProcessor& xp) { |
270 SkASSERT(fFS.hasReadDstColor() == xp.willReadDstColor()); | 285 SkASSERT(fFS.hasReadDstColor() == xp.willReadDstColor()); |
271 } | 286 } |
272 | 287 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 } | 493 } |
479 | 494 |
480 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 495 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
481 | 496 |
482 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 497 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
483 int numProcs = fProcs.count(); | 498 int numProcs = fProcs.count(); |
484 for (int i = 0; i < numProcs; ++i) { | 499 for (int i = 0; i < numProcs; ++i) { |
485 delete fProcs[i]; | 500 delete fProcs[i]; |
486 } | 501 } |
487 } | 502 } |
OLD | NEW |