32class GradientRampEffectAdapter final :
public AnimatablePropertyContainer {
36 const AnimationBuilder* abuilder) {
47 const AnimationBuilder* abuilder)
48 : fShaderEffect(
sksg::ShaderEffect::
Make(
std::move(layer))) {
50 kStartPoint_Index = 0,
51 kStartColor_Index = 1,
55 kRampScatter_Index = 5,
56 kBlendRatio_Index = 6,
59 EffectBinder(jprops, *abuilder,
this)
60 .bind( kStartPoint_Index, fStartPoint)
61 .bind( kStartColor_Index, fStartColor)
62 .bind( kEndPoint_Index, fEndPoint )
63 .bind( kEndColor_Index, fEndColor )
64 .bind( kRampShape_Index,
fShape )
65 .bind(kRampScatter_Index, fScatter )
66 .bind( kBlendRatio_Index, fBlend );
69 enum class InstanceType {
75 void onSync()
override {
84 auto update_gradient = [
this] (InstanceType new_type) {
85 if (new_type != fInstanceType) {
90 fShaderEffect->setShader(fGradient);
91 fInstanceType = new_type;
94 fGradient->setColorStops({{0, fStartColor},
98 static constexpr int kLinearShapeValue = 1;
101 : InstanceType::kRadial;
104 update_gradient(instance_type);
107 const auto start_point =
SkPoint{fStartPoint.x, fStartPoint.y},
108 end_point =
SkPoint{ fEndPoint.x, fEndPoint.y};
111 lg->setStartPoint(start_point);
112 lg->setEndPoint(end_point);
114 SkASSERT(instance_type == InstanceType::kRadial);
117 rg->setStartCenter(start_point);
118 rg->setEndCenter(start_point);
130 ColorValue fStartColor,
#define SkScalarRoundToInt(x)
void attachDiscardableAdapter(sk_sp< T > adapter) const
static sk_sp< LinearGradient > Make()
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
static constexpr skcms_TransferFunction kLinear
SK_API sk_sp< PrecompileShader > RadialGradient()
static float Distance(const SkPoint &a, const SkPoint &b)