Chromium Code Reviews| Index: src/gpu/GrFragmentProcessor.cpp |
| diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp |
| index bad7ebe0360cd046262d39b4fa639aeecb874445..c5bd637fa2ff27efa387b62ee17b6459f1a5abff 100644 |
| --- a/src/gpu/GrFragmentProcessor.cpp |
| +++ b/src/gpu/GrFragmentProcessor.cpp |
| @@ -143,6 +143,45 @@ sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputAlpha( |
| SkXfermode::kDstIn_Mode); |
| } |
| +sk_sp<GrFragmentProcessor> GrFragmentProcessor::PremulInput(sk_sp<GrFragmentProcessor> fp) { |
| + |
| + class PremulInputFragmentProcessor : public GrFragmentProcessor { |
| + public: |
| + PremulInputFragmentProcessor() { |
| + this->initClassID<PremulInputFragmentProcessor>(); |
| + } |
| + |
| + const char* name() const override { return "PremultiplyInput"; } |
| + |
| + private: |
| + GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { |
| + class GLFP : public GrGLSLFragmentProcessor { |
| + public: |
| + void emitCode(EmitArgs& args) override { |
| + GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| + |
| + fragBuilder->codeAppendf("%s = %s;", args.fOutputColor, args.fInputColor); |
| + fragBuilder->codeAppendf("%s.rgb *= %s.a;", args.fOutputColor, args.fInputColor); |
|
egdaniel
2016/07/14 03:22:47
100 chars
dvonbeck
2016/07/14 14:30:33
This was fixed in patch set 6
|
| + } |
| + }; |
| + return new GLFP; |
| + } |
| + |
| + void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override {} |
| + |
| + bool onIsEqual(const GrFragmentProcessor&) const override { return true; } |
| + |
| + void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
| + inout->mulByUnknownFourComponents(); |
|
egdaniel
2016/07/14 03:22:47
This doesn't seem right. I feel like it should be
dvonbeck
2016/07/14 14:30:33
Adding appropriate invariant option in separate CL
|
| + } |
| + }; |
| + if (!fp) { |
| + return nullptr; |
| + } |
| + sk_sp<GrFragmentProcessor> fpPipeline[] = { sk_make_sp<PremulInputFragmentProcessor>(), fp}; |
| + return GrFragmentProcessor::RunInSeries(fpPipeline, 2); |
| +} |
| + |
| sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputUnpremulColor( |
| sk_sp<GrFragmentProcessor> fp) { |