Skip to content

Migrate off the deprecated gradient shader API #215

Description

@LeadcodeDev

Bumping to skia-safe 0.99 (#214) leaves 25 deprecation warnings, all on the
gradient shader API. They are silenced with narrowly scoped #[allow(deprecated)]
in that PR so the docs.rs fix can land; this issue is the follow-up.

Why it was not done in #214

It is a restructuring, not a rename. The old call takes the pieces flat:

gradient_shader::linear(
    (p0, p1),
    colors.as_slice(),
    positions.as_slice(),
    TileMode::Clamp,
    None,
    None,
)

The new one takes a Gradient struct and drops TileMode from the signature
entirely:

gradient::shaders::linear_gradient(
    points: (impl Into<Point>, impl Into<Point>),
    gradient: &Gradient<'_>,
    local_matrix: impl Into<Option<&Matrix>>,
) -> Option<Shader>

Gradient::new(colors: Colors, interpolation: impl Into<Interpolation>). Where the
tile mode now lives has to be established before touching anything — getting it
wrong changes rendering silently, and a gradient that clamps where it used to
repeat looks plausible in isolation.

Scope

25 sites across 8 files:

File Sites
rustmotion-core/src/engine/paint_pass.rs 6
rustmotion/src/engine/render/background.rs 5
rustmotion-components/src/shape.rs 4
rustmotion-components/src/stat.rs 2
rustmotion-components/src/sparkline.rs 2
rustmotion-components/src/skeleton.rs 2
rustmotion-components/src/gradient_text.rs 2
rustmotion-components/src/chart/line.rs 2

Both GradientShaderColors::Colors and ::ColorsInSpace are in use, so the
colour-space carrying case has to survive too.

How to verify

The pixel regression suite is the judge. A gradient that renders identically
before and after is the only acceptable outcome; anything else means the tile
mode or the interpolation moved.

Removing the #[allow(deprecated)] attributes is part of the fix — leaving one
behind would hide the next deprecation in the same function.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions