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

Unified Diff: src/effects/SkArithmeticMode_gpu.cpp

Issue 1334293003: Create fragment processor for performing input color blend with child processor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 5 years, 3 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 | « src/effects/SkArithmeticMode_gpu.h ('k') | src/effects/SkColorCubeFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkArithmeticMode_gpu.cpp
diff --git a/src/effects/SkArithmeticMode_gpu.cpp b/src/effects/SkArithmeticMode_gpu.cpp
index fd20b73cdc46770b0981ce1d2227fc56f8cddce1..5f149d0712694606d1e7c97d888aee043dcdc913 100644
--- a/src/effects/SkArithmeticMode_gpu.cpp
+++ b/src/effects/SkArithmeticMode_gpu.cpp
@@ -21,16 +21,16 @@
static const bool gUseUnpremul = false;
static void add_arithmetic_code(GrGLFragmentBuilder* fsBuilder,
- const char* inputColor,
+ const char* srcColor,
const char* dstColor,
const char* outputColor,
const char* kUni,
bool enforcePMColor) {
// We don't try to optimize for this case at all
- if (nullptr == inputColor) {
+ if (nullptr == srcColor) {
fsBuilder->codeAppend("const vec4 src = vec4(1);");
} else {
- fsBuilder->codeAppendf("vec4 src = %s;", inputColor);
+ fsBuilder->codeAppendf("vec4 src = %s;", srcColor);
if (gUseUnpremul) {
fsBuilder->codeAppend("src.rgb = clamp(src.rgb / src.a, 0.0, 1.0);");
}
@@ -54,26 +54,21 @@ static void add_arithmetic_code(GrGLFragmentBuilder* fsBuilder,
class GLArithmeticFP : public GrGLFragmentProcessor {
public:
- GLArithmeticFP(const GrProcessor&)
- : fEnforcePMColor(true) {
- }
+ GLArithmeticFP(const GrProcessor&) : fEnforcePMColor(true) {}
~GLArithmeticFP() override {}
void emitCode(EmitArgs& args) override {
GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
- fsBuilder->codeAppend("vec4 bgColor = ");
- fsBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_str(),
- args.fCoords[0].getType());
- fsBuilder->codeAppendf(";");
- const char* dstColor = "bgColor";
+ fsBuilder->codeAppend("vec4 _dstColor;");
+ this->emitChild(0, nullptr, "_dstColor", args);
fKUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision,
- "k");
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "k");
const char* kUni = args.fBuilder->getUniformCStr(fKUni);
- add_arithmetic_code(fsBuilder, args.fInputColor, dstColor, args.fOutputColor, kUni,
+ add_arithmetic_code(fsBuilder, args.fInputColor, "_dstColor", args.fOutputColor, kUni,
fEnforcePMColor);
}
@@ -100,17 +95,13 @@ private:
///////////////////////////////////////////////////////////////////////////////
GrArithmeticFP::GrArithmeticFP(GrProcessorDataManager*, float k1, float k2, float k3, float k4,
- bool enforcePMColor, GrTexture* background)
+ bool enforcePMColor, const GrFragmentProcessor* dst)
: fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) {
this->initClassID<GrArithmeticFP>();
- SkASSERT(background);
-
- fBackgroundTransform.reset(kLocal_GrCoordSet, background,
- GrTextureParams::kNone_FilterMode);
- this->addCoordTransform(&fBackgroundTransform);
- fBackgroundAccess.reset(background);
- this->addTextureAccess(&fBackgroundAccess);
+ SkASSERT(dst);
+ SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(dst);
+ SkASSERT(0 == dstIndex);
}
void GrArithmeticFP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
@@ -144,7 +135,8 @@ const GrFragmentProcessor* GrArithmeticFP::TestCreate(GrProcessorTestData* d) {
float k4 = d->fRandom->nextF();
bool enforcePMColor = d->fRandom->nextBool();
- return new GrArithmeticFP(d->fProcDataManager, k1, k2, k3, k4, enforcePMColor, d->fTextures[0]);
+ SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChildFP(d));
+ return new GrArithmeticFP(d->fProcDataManager, k1, k2, k3, k4, enforcePMColor, dst);
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP);
« no previous file with comments | « src/effects/SkArithmeticMode_gpu.h ('k') | src/effects/SkColorCubeFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698