32class InvertEffectAdapter final :
public AnimatablePropertyContainer {
36 const AnimationBuilder* abuilder) {
38 new InvertEffectAdapter(jprops, std::move(layer), abuilder));
46 const AnimationBuilder* abuilder)
47 : fColorFilter(
sksg::ExternalColorFilter::
Make(
std::move(layer))) {
52 EffectBinder(jprops, *abuilder,
this).bind(kChannel_Index, fChannel);
55 void onSync()
override {
56 enum class CS { kRGB, kHSL, kYIQ };
58 struct STColorMatrix {
59 std::array<float,4>
scale,
64 const auto stcm = [
this]() -> STColorMatrix {
86 switch (
static_cast<uint8_t
>(fChannel)) {
87 case kR_Channel:
return { {-1, 1, 1, 1}, { 1,0,0,0}, CS::kRGB };
88 case kG_Channel:
return { { 1,-1, 1, 1}, { 0,1,0,0}, CS::kRGB };
89 case kB_Channel:
return { { 1, 1,-1, 1}, { 0,0,1,0}, CS::kRGB };
90 case kA_Channel:
return { { 1, 1, 1,-1}, { 0,0,0,1}, CS::kRGB };
91 case kRGB_Channel:
return { {-1,-1,-1, 1}, { 1,1,1,0}, CS::kRGB };
93 case kH_Channel:
return { {-1, 1, 1, 1}, {.5f,0,0,0}, CS::kHSL };
94 case kS_Channel:
return { { 1,-1, 1, 1}, { 0,1,0,0}, CS::kHSL };
95 case kL_Channel:
return { { 1, 1,-1, 1}, { 0,0,1,0}, CS::kHSL };
96 case kHLS_Channel:
return { {-1,-1,-1, 1}, {.5f,1,1,0}, CS::kHSL };
98 case kY_Channel:
return { {-1, 1, 1, 1}, { 1,0,0,0}, CS::kYIQ };
99 case kI_Channel:
return { { 1,-1, 1, 1}, { 0,0,0,0}, CS::kYIQ };
100 case kQ_Channel:
return { { 1, 1,-1, 1}, { 0,0,0,0}, CS::kYIQ };
101 case kYIQ_Channel:
return { {-1,-1,-1, 1}, { 1,0,0,0}, CS::kYIQ };
103 default:
return { { 1, 1, 1, 1}, { 0,0,0,0}, CS::kRGB };
110 stcm.scale[0], 0, 0, 0, stcm.trans[0],
111 0, stcm.scale[1], 0, 0, stcm.trans[1],
112 0, 0, stcm.scale[2], 0, stcm.trans[2],
113 0, 0, 0, stcm.scale[3], stcm.trans[3]
117 if (stcm.cs == CS::kYIQ) {
120 0.2990f, 0.5870f, 0.1140f, 0, 0,
121 0.5959f, -0.2746f, -0.3213f, 0, 0,
122 0.2115f, -0.5227f, 0.3112f, 0, 0,
126 1, 0.9560f, 0.6190f, 0, 0,
127 1, -0.2720f, -0.6470f, 0, 0,
128 1, -1.1060f, 1.7030f, 0, 0,
132 m.preConcat (RGB2YIQ);
133 m.postConcat(YIQ2RGB);
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
static sk_sp< SkColorFilter > HSLAMatrix(const SkColorMatrix &)
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)