1 /* 2 * Copyright 2021 Google LLC 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 SkBlendModeBlender_DEFINED 9 #define SkBlendModeBlender_DEFINED 10 11 #include "src/core/SkBlenderBase.h" 12 13 class SkBlendModeBlender : public SkBlenderBase { 14 public: SkBlendModeBlender(SkBlendMode mode)15 SkBlendModeBlender(SkBlendMode mode) : fMode(mode) {} 16 asBlendMode()17 skstd::optional<SkBlendMode> asBlendMode() const final { return fMode; } 18 19 #if SK_SUPPORT_GPU 20 std::unique_ptr<GrFragmentProcessor> asFragmentProcessor( 21 std::unique_ptr<GrFragmentProcessor> srcFP, 22 std::unique_ptr<GrFragmentProcessor> dstFP, 23 const GrFPArgs& fpArgs) const override; 24 #endif 25 26 SK_FLATTENABLE_HOOKS(SkBlendModeBlender) 27 28 private: 29 using INHERITED = SkBlenderBase; 30 31 void flatten(SkWriteBuffer& buffer) const override; 32 33 skvm::Color onProgram(skvm::Builder* p, skvm::Color src, skvm::Color dst, 34 const SkColorInfo& colorInfo, skvm::Uniforms* uniforms, 35 SkArenaAlloc* alloc) const override; 36 37 SkBlendMode fMode; 38 }; 39 40 #endif 41