45 static constexpr char BLACK_AND_WHITE_EFFECT[] =
46 "uniform half kR, kY, kG, kC, kB, kM;"
48 "half4 main(half4 c) {"
49 "half m = min(min(c.r, c.g), c.b),"
66 "l = m + kR*wr + kY*wy + kG*wg + kC*wc + kB*wb + kM*wm;"
68 "return half4(l, l, l, c.a);"
79class BlackAndWhiteAdapter final :
public DiscardableAdapterBase<BlackAndWhiteAdapter,
80 sksg::ExternalColorFilter> {
83 const AnimationBuilder& abuilder,
102 EffectBinder(jprops, abuilder,
this)
103 .bind( kReds_Index, fCoeffs[0])
104 .bind( kYellows_Index, fCoeffs[1])
105 .bind( kGreens_Index, fCoeffs[2])
106 .bind( kCyans_Index, fCoeffs[3])
107 .bind( kBlues_Index, fCoeffs[4])
108 .bind(kMagentas_Index, fCoeffs[5]);
112 void onSync()
override {
114 float normalized_coeffs[6];
124 this->node()->setColorFilter(
132 using INHERITED = DiscardableAdapterBase<BlackAndWhiteAdapter, sksg::ExternalColorFilter>;
static sk_sp< Effect > make_effect()
#define INHERITED(method,...)
sk_sp< T > sk_ref_sp(T *obj)
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
static Result MakeForColorFilter(SkString sksl, const Options &)
sk_sp< SkColorFilter > makeColorFilter(sk_sp< const SkData > uniforms) const
void attachDiscardableAdapter(sk_sp< T > adapter) const
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
sk_sp< SkRuntimeEffect > effect