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

Unified Diff: src/gpu/effects/GrPorterDuffXferProcessor.cpp

Issue 1254833003: Added GrGLBlend.h|cpp with helper function AppendPorterDuffBlend() in preparation for SkComposeShad… (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: More nits by Greg Created 5 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/gl/GrGLBlend.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrPorterDuffXferProcessor.cpp
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index b6b57aefead08b0ccbcd477c73a6e28d53ad1f2c..0e1bc514698e214cdf5e1900f9c330609d0c9b42 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -13,6 +13,7 @@
#include "GrProcOptInfo.h"
#include "GrTypes.h"
#include "GrXferProcessor.h"
+#include "gl/GrGLBlend.h"
#include "gl/GrGLXferProcessor.h"
#include "gl/builders/GrGLFragmentShaderBuilder.h"
#include "gl/builders/GrGLProgramBuilder.h"
@@ -488,50 +489,6 @@ private:
///////////////////////////////////////////////////////////////////////////////
-static bool append_porterduff_term(GrGLXPFragmentBuilder* fsBuilder, SkXfermode::Coeff coeff,
- const char* colorName, const char* srcColorName,
- const char* dstColorName, bool hasPrevious) {
- if (SkXfermode::kZero_Coeff == coeff) {
- return hasPrevious;
- } else {
- if (hasPrevious) {
- fsBuilder->codeAppend(" + ");
- }
- fsBuilder->codeAppendf("%s", colorName);
- switch (coeff) {
- case SkXfermode::kOne_Coeff:
- break;
- case SkXfermode::kSC_Coeff:
- fsBuilder->codeAppendf(" * %s", srcColorName);
- break;
- case SkXfermode::kISC_Coeff:
- fsBuilder->codeAppendf(" * (vec4(1.0) - %s)", srcColorName);
- break;
- case SkXfermode::kDC_Coeff:
- fsBuilder->codeAppendf(" * %s", dstColorName);
- break;
- case SkXfermode::kIDC_Coeff:
- fsBuilder->codeAppendf(" * (vec4(1.0) - %s)", dstColorName);
- break;
- case SkXfermode::kSA_Coeff:
- fsBuilder->codeAppendf(" * %s.a", srcColorName);
- break;
- case SkXfermode::kISA_Coeff:
- fsBuilder->codeAppendf(" * (1.0 - %s.a)", srcColorName);
- break;
- case SkXfermode::kDA_Coeff:
- fsBuilder->codeAppendf(" * %s.a", dstColorName);
- break;
- case SkXfermode::kIDA_Coeff:
- fsBuilder->codeAppendf(" * (1.0 - %s.a)", dstColorName);
- break;
- default:
- SkFAIL("Unsupported Blend Coeff");
- }
- return true;
- }
-}
-
class GLShaderPDXferProcessor : public GrGLXferProcessor {
public:
static void GenKey(const GrProcessor& processor, GrProcessorKeyBuilder* b) {
@@ -545,17 +502,7 @@ private:
const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>();
GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
- SkXfermode::Coeff srcCoeff, dstCoeff;
- SkXfermode::ModeAsCoeff(xp.getXfermode(), &srcCoeff, &dstCoeff);
-
- fsBuilder->codeAppendf("%s =", outColor);
- // append src blend
- bool didAppend = append_porterduff_term(fsBuilder, srcCoeff, srcColor, srcColor, dstColor,
- false);
- // append dst blend
- SkAssertResult(append_porterduff_term(fsBuilder, dstCoeff, dstColor, srcColor, dstColor,
- didAppend));
- fsBuilder->codeAppend(";");
+ GrGLBlend::AppendPorterDuffBlend(fsBuilder, srcColor, dstColor, outColor, xp.getXfermode());
}
void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {}
@@ -824,4 +771,3 @@ void GrPorterDuffXPFactory::TestGetXPOutputTypes(const GrXferProcessor* xp,
*outPrimary = blendFormula.fPrimaryOutputType;
*outSecondary = blendFormula.fSecondaryOutputType;
}
-
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/gl/GrGLBlend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698