33class CCTonerAdapter final :
public DiscardableAdapterBase<CCTonerAdapter,
34 sksg::GradientColorFilter> {
38 const AnimationBuilder& abuilder,
41 , fColorNodes(
std::move(colorNodes))
46 kBrightColor_Index = 2,
49 kShadowColor_Index = 5,
50 kBlendAmount_Index = 6,
54 EffectBinder(jprops, abuilder,
this)
55 .bind( kTone_Index, fTone)
56 .bind( kHiColor_Index, fHighlights)
57 .bind(kBrightColor_Index, fBrights)
58 .bind( kMidColor_Index, fMidtones)
59 .bind( kDarkColor_Index, fDarktones)
60 .bind(kShadowColor_Index, fShadows);
67 c_4f = c0_4f + (c1_4f - c0_4f) * t;
72 void onSync()
override {
75 case 1: fColorNodes.at(0)->setColor(fShadows);
76 fColorNodes.at(1)->setColor(lerpColor(fShadows, fHighlights, 0.25));
77 fColorNodes.at(2)->setColor(lerpColor(fShadows, fHighlights, 0.5));
78 fColorNodes.at(3)->setColor(lerpColor(fShadows, fHighlights, 0.75));
79 fColorNodes.at(4)->setColor(fHighlights);
82 case 2: fColorNodes.at(0)->setColor(fShadows);
83 fColorNodes.at(1)->setColor(lerpColor(fShadows, fMidtones, 0.5));
84 fColorNodes.at(2)->setColor(fMidtones);
85 fColorNodes.at(3)->setColor(lerpColor(fMidtones, fHighlights, 0.5));
86 fColorNodes.at(4)->setColor(fHighlights);
89 case 3: fColorNodes.at(0)->setColor(fShadows);
90 fColorNodes.at(1)->setColor(fDarktones);
91 fColorNodes.at(2)->setColor(fMidtones);
92 fColorNodes.at(3)->setColor(fBrights);
93 fColorNodes.at(4)->setColor(fHighlights);
96 default: fColorNodes.at(0)->setColor(fMidtones);
97 fColorNodes.at(1)->setColor(fMidtones);
98 fColorNodes.at(2)->setColor(fMidtones);
99 fColorNodes.at(3)->setColor(fMidtones);
100 fColorNodes.at(4)->setColor(fMidtones);
104 this->node()->setWeight((100-fBlend)/100);
108 const std::vector<sk_sp<sksg::Color>> fColorNodes;
111 ColorValue fHighlights,
118 using INHERITED = DiscardableAdapterBase<CCTonerAdapter, sksg::GradientColorFilter>;
125 std::vector<sk_sp<sksg::Color>> colorNodes = {
135 std::move(colorNodes));
constexpr SkColor SK_ColorRED
#define INHERITED(method,...)
#define SkScalarRoundToInt(x)
static skvx::float4 Sk4f_fromL32(uint32_t px)
static uint32_t Sk4f_toL32(const skvx::float4 &px)
void attachDiscardableAdapter(sk_sp< T > adapter) const
static sk_sp< Color > Make(SkColor c)
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)