1 /*
2  * Copyright 2006 The Android Open Source Project
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkComposeShader_DEFINED
9 #define SkComposeShader_DEFINED
10 
11 #include "include/core/SkBlendMode.h"
12 #include "src/shaders/SkShaderBase.h"
13 
14 class SkShader_Blend final : public SkShaderBase {
15 public:
SkShader_Blend(SkBlendMode mode,sk_sp<SkShader> dst,sk_sp<SkShader> src)16     SkShader_Blend(SkBlendMode mode, sk_sp<SkShader> dst, sk_sp<SkShader> src)
17         : fDst(std::move(dst))
18         , fSrc(std::move(src))
19         , fMode(mode)
20     {}
21 
22 #if SK_SUPPORT_GPU
23     std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
24 #endif
25 
26 protected:
27     SkShader_Blend(SkReadBuffer&);
28     void flatten(SkWriteBuffer&) const override;
29     bool onAppendStages(const SkStageRec&) const override;
30     skvm::Color onProgram(skvm::Builder*, skvm::Coord device, skvm::Coord local, skvm::Color paint,
31                           const SkMatrixProvider&, const SkMatrix* localM, const SkColorInfo& dst,
32                           skvm::Uniforms*, SkArenaAlloc*) const override;
33 
34 private:
35     SK_FLATTENABLE_HOOKS(SkShader_Blend)
36 
37     sk_sp<SkShader>     fDst;
38     sk_sp<SkShader>     fSrc;
39     const SkBlendMode   fMode;
40 
41     using INHERITED = SkShaderBase;
42 };
43 
44 #endif
45