Skip to content

Commit 5e0269e

Browse files
Update to Vello 0.3, Peniko 0.2 (#37)
1 parent 6fb9579 commit 5e0269e

File tree

6 files changed

+117
-64
lines changed

6 files changed

+117
-64
lines changed

Cargo.lock

+111-35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ vello = ["dep:vello"]
2828
[dependencies]
2929
hashbrown = "0.15.1"
3030
keyframe = { version = "1.1.1", default-features = false, features = ["mint_types"] }
31-
kurbo = { version = "0.11", default-features = false }
32-
peniko = { version = "0.1.1", default-features = false }
33-
vello = { version = "0.2.0", default-features = false, optional = true }
31+
kurbo = { version = "0.11.1", default-features = false }
32+
peniko = { version = "0.2.0", default-features = false }
33+
vello = { version = "0.3.0", default-features = false, optional = true }
3434

3535
[lints]
3636
rust.unsafe_code = "forbid"

src/animated.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ impl Brush {
407407
/// Evaluates the animation at the specified time.
408408
pub fn evaluate(&self, alpha: f64, frame: f64) -> fixed::Brush {
409409
match self {
410-
Self::Solid(value) => value.evaluate(frame).with_alpha_factor(alpha as f32).into(),
410+
Self::Solid(value) => value.evaluate(frame).multiply_alpha(alpha as f32).into(),
411411
Self::Gradient(value) => value.evaluate(frame),
412412
}
413413
}

src/fixed.rs

-23
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,3 @@ impl Repeater {
5959
* Affine::translate((-self.anchor_point.x, -self.anchor_point.y))
6060
}
6161
}
62-
63-
// TODO: probably move this to peniko. The better option is to add an alpha
64-
// parameter to the draw methods in vello. This is already handled at the
65-
// encoding level.
66-
pub(crate) fn brush_with_alpha(brush: &Brush, alpha: f64) -> Brush {
67-
if alpha == 1.0 {
68-
brush.clone()
69-
} else {
70-
match brush {
71-
Brush::Solid(color) => color.with_alpha_factor(alpha as f32).into(),
72-
Brush::Gradient(gradient) => Brush::Gradient(peniko::Gradient {
73-
kind: gradient.kind,
74-
extend: gradient.extend,
75-
stops: gradient
76-
.stops
77-
.iter()
78-
.map(|stop| stop.with_alpha_factor(alpha as f32))
79-
.collect(),
80-
}),
81-
_ => unreachable!(),
82-
}
83-
}
84-
}

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl Brush {
9191
if alpha == 1.0 {
9292
ValueRef::Borrowed(value)
9393
} else {
94-
ValueRef::Owned(fixed::brush_with_alpha(value, alpha))
94+
ValueRef::Owned(value.clone().multiply_alpha(alpha as f32))
9595
}
9696
}
9797
Self::Animated(value) => ValueRef::Owned(value.evaluate(alpha, frame)),

src/render.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl Batch {
353353
for draw in self.draws.iter().rev() {
354354
// Some nastiness to avoid cloning the brush if unnecessary
355355
let modified_brush = if draw.alpha != 1.0 {
356-
Some(fixed::brush_with_alpha(&draw.brush, draw.alpha))
356+
Some(draw.brush.clone().multiply_alpha(draw.alpha as f32))
357357
} else {
358358
None
359359
};

0 commit comments

Comments
 (0)