aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/builders
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/gl/builders')
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp18
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 97fcce59b7..4360f7858d 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -10,6 +10,7 @@
#include "GrAutoLocaleSetter.h"
#include "GrCoordTransform.h"
#include "GrGLProgramBuilder.h"
+#include "GrSwizzle.h"
#include "GrTexture.h"
#include "SkRTConf.h"
#include "SkTraceEvent.h"
@@ -95,6 +96,7 @@ bool GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr
inputCoverage);
this->emitAndInstallXferProc(this->pipeline().getXferProcessor(), *inputColor, *inputCoverage,
this->pipeline().ignoresCoverage());
+ this->emitFSOutputSwizzle(this->pipeline().getXferProcessor().hasSecondaryOutput());
return true;
}
@@ -262,6 +264,22 @@ void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp,
fFS.codeAppend("}");
}
+void GrGLProgramBuilder::emitFSOutputSwizzle(bool hasSecondaryOutput) {
+ // Swizzle the fragment shader outputs if necessary.
+ GrSwizzle swizzle;
+ swizzle.setFromKey(this->desc().header().fOutputSwizzle);
+ if (swizzle != GrSwizzle::RGBA()) {
+ fFS.codeAppendf("%s = %s.%s;", fFS.getPrimaryColorOutputName(),
+ fFS.getPrimaryColorOutputName(),
+ swizzle.c_str());
+ if (hasSecondaryOutput) {
+ fFS.codeAppendf("%s = %s.%s;", fFS.getSecondaryColorOutputName(),
+ fFS.getSecondaryColorOutputName(),
+ swizzle.c_str());
+ }
+ }
+}
+
void GrGLProgramBuilder::verify(const GrPrimitiveProcessor& gp) {
SkASSERT(fFS.hasReadFragmentPosition() == gp.willReadFragmentPosition());
}
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index cbec5a9863..70cfad5633 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -92,6 +92,7 @@ private:
const GrGLSLExpr4& colorIn,
const GrGLSLExpr4& coverageIn,
bool ignoresCoverage);
+ void emitFSOutputSwizzle(bool hasSecondaryOutput);
void verify(const GrPrimitiveProcessor&);
void verify(const GrXferProcessor&);