render: Rename DrawCommand::CurveTo to DrawCommand::QuadraticCurveTo

This commit is contained in:
Nathan Adams 2023-08-25 13:12:56 +02:00
parent 158beaffa5
commit 076977cc75
6 changed files with 19 additions and 19 deletions

View File

@ -738,7 +738,7 @@ fn curve_to<'gc>(
let anchor_y = anchor_y.coerce_to_f64(activation)?; let anchor_y = anchor_y.coerce_to_f64(activation)?;
movie_clip movie_clip
.drawing(activation.context.gc_context) .drawing(activation.context.gc_context)
.draw_command(DrawCommand::CurveTo { .draw_command(DrawCommand::QuadraticCurveTo {
control: Point::from_pixels(control_x, control_y), control: Point::from_pixels(control_x, control_y),
anchor: Point::from_pixels(anchor_x, anchor_y), anchor: Point::from_pixels(anchor_x, anchor_y),
}); });

View File

@ -241,7 +241,7 @@ pub fn curve_to<'gc>(
let anchor_y = args.get_f64(activation, 3)?; let anchor_y = args.get_f64(activation, 3)?;
if let Some(mut draw) = this.as_drawing(activation.context.gc_context) { if let Some(mut draw) = this.as_drawing(activation.context.gc_context) {
draw.draw_command(DrawCommand::CurveTo { draw.draw_command(DrawCommand::QuadraticCurveTo {
control: Point::from_pixels(control_x, control_y), control: Point::from_pixels(control_x, control_y),
anchor: Point::from_pixels(anchor_x, anchor_y), anchor: Point::from_pixels(anchor_x, anchor_y),
}); });
@ -538,7 +538,7 @@ fn draw_round_rect_internal(
let right_b_point_y = br_ellipse_center_y + ellipse_height / 2.0 * ucp[4].1; let right_b_point_y = br_ellipse_center_y + ellipse_height / 2.0 * ucp[4].1;
let right_b_point = Point::from_pixels(right_b_point_x, right_b_point_y); let right_b_point = Point::from_pixels(right_b_point_x, right_b_point_y);
draw.draw_command(DrawCommand::CurveTo { draw.draw_command(DrawCommand::QuadraticCurveTo {
control: br_b_curve, control: br_b_curve,
anchor: right_b_point, anchor: right_b_point,
}); });
@ -563,7 +563,7 @@ fn draw_round_rect_internal(
let bl_point_y = br_ellipse_center_y + ellipse_height / 2.0 * ucp[2].1; let bl_point_y = br_ellipse_center_y + ellipse_height / 2.0 * ucp[2].1;
let bl_point = Point::from_pixels(bl_point_x, bl_point_y); let bl_point = Point::from_pixels(bl_point_x, bl_point_y);
draw.draw_command(DrawCommand::CurveTo { draw.draw_command(DrawCommand::QuadraticCurveTo {
control: b_bl_curve, control: b_bl_curve,
anchor: bl_point, anchor: bl_point,
}); });
@ -576,7 +576,7 @@ fn draw_round_rect_internal(
let bottom_l_point_y = br_ellipse_center_y + ellipse_height / 2.0 * ucp[0].1; let bottom_l_point_y = br_ellipse_center_y + ellipse_height / 2.0 * ucp[0].1;
let bottom_l_point = Point::from_pixels(bottom_l_point_x, bottom_l_point_y); let bottom_l_point = Point::from_pixels(bottom_l_point_x, bottom_l_point_y);
draw.draw_command(DrawCommand::CurveTo { draw.draw_command(DrawCommand::QuadraticCurveTo {
control: bl_l_curve, control: bl_l_curve,
anchor: bottom_l_point, anchor: bottom_l_point,
}); });
@ -597,7 +597,7 @@ fn draw_round_rect_internal(
let tl_point_y = tl_ellipse_center_y + ellipse_height / -2.0 * ucp[2].1; let tl_point_y = tl_ellipse_center_y + ellipse_height / -2.0 * ucp[2].1;
let tl_point = Point::from_pixels(tl_point_x, tl_point_y); let tl_point = Point::from_pixels(tl_point_x, tl_point_y);
draw.draw_command(DrawCommand::CurveTo { draw.draw_command(DrawCommand::QuadraticCurveTo {
control: l_tl_curve, control: l_tl_curve,
anchor: tl_point, anchor: tl_point,
}); });
@ -610,7 +610,7 @@ fn draw_round_rect_internal(
let left_t_point_y = tl_ellipse_center_y + ellipse_height / -2.0 * ucp[4].1; let left_t_point_y = tl_ellipse_center_y + ellipse_height / -2.0 * ucp[4].1;
let left_t_point = Point::from_pixels(left_t_point_x, left_t_point_y); let left_t_point = Point::from_pixels(left_t_point_x, left_t_point_y);
draw.draw_command(DrawCommand::CurveTo { draw.draw_command(DrawCommand::QuadraticCurveTo {
control: tl_t_curve, control: tl_t_curve,
anchor: left_t_point, anchor: left_t_point,
}); });
@ -631,7 +631,7 @@ fn draw_round_rect_internal(
let tr_point_y = tl_ellipse_center_y + ellipse_height / -2.0 * ucp[2].1; let tr_point_y = tl_ellipse_center_y + ellipse_height / -2.0 * ucp[2].1;
let tr_point = Point::from_pixels(tr_point_x, tr_point_y); let tr_point = Point::from_pixels(tr_point_x, tr_point_y);
draw.draw_command(DrawCommand::CurveTo { draw.draw_command(DrawCommand::QuadraticCurveTo {
control: t_tr_curve, control: t_tr_curve,
anchor: tr_point, anchor: tr_point,
}); });
@ -644,7 +644,7 @@ fn draw_round_rect_internal(
let top_r_point_y = tl_ellipse_center_y + ellipse_height / -2.0 * ucp[0].1; let top_r_point_y = tl_ellipse_center_y + ellipse_height / -2.0 * ucp[0].1;
let top_r_point = Point::from_pixels(top_r_point_x, top_r_point_y); let top_r_point = Point::from_pixels(top_r_point_x, top_r_point_y);
draw.draw_command(DrawCommand::CurveTo { draw.draw_command(DrawCommand::QuadraticCurveTo {
control: tr_r_curve, control: tr_r_curve,
anchor: top_r_point, anchor: top_r_point,
}); });
@ -660,7 +660,7 @@ fn draw_round_rect_internal(
let r_br_curve_y = br_ellipse_center_y + ellipse_height / 2.0 * ucp[1].1; let r_br_curve_y = br_ellipse_center_y + ellipse_height / 2.0 * ucp[1].1;
let r_br_curve = Point::from_pixels(r_br_curve_x, r_br_curve_y); let r_br_curve = Point::from_pixels(r_br_curve_x, r_br_curve_y);
draw.draw_command(DrawCommand::CurveTo { draw.draw_command(DrawCommand::QuadraticCurveTo {
control: r_br_curve, control: r_br_curve,
anchor: br_point, anchor: br_point,
}); });
@ -1179,7 +1179,7 @@ fn process_commands<'gc>(
// LINE_TO // LINE_TO
2 => Some(DrawCommand::LineTo(read_point())), 2 => Some(DrawCommand::LineTo(read_point())),
// CURVE_TO // CURVE_TO
3 => Some(DrawCommand::CurveTo { 3 => Some(DrawCommand::QuadraticCurveTo {
control: read_point(), control: read_point(),
anchor: read_point(), anchor: read_point(),
}), }),

View File

@ -455,7 +455,7 @@ fn stretch_bounds(
.encompass(Point::new(point.x - radius, point.y - radius)) .encompass(Point::new(point.x - radius, point.y - radius))
.encompass(Point::new(point.x + radius, point.y + radius)) .encompass(Point::new(point.x + radius, point.y + radius))
} }
DrawCommand::CurveTo { control, anchor } => { DrawCommand::QuadraticCurveTo { control, anchor } => {
bounds.union(&quadratic_curve_bounds(from, stroke_width, control, anchor)) bounds.union(&quadratic_curve_bounds(from, stroke_width, control, anchor))
} }
} }

View File

@ -824,7 +824,7 @@ fn draw_commands_to_path2d(commands: &[DrawCommand], is_closed: bool) -> Path2d
DrawCommand::LineTo(line_to) => { DrawCommand::LineTo(line_to) => {
path.line_to(line_to.x.get().into(), line_to.y.get().into()) path.line_to(line_to.x.get().into(), line_to.y.get().into())
} }
DrawCommand::CurveTo { control, anchor } => path.quadratic_curve_to( DrawCommand::QuadraticCurveTo { control, anchor } => path.quadratic_curve_to(
control.x.get().into(), control.x.get().into(),
control.y.get().into(), control.y.get().into(),
anchor.x.get().into(), anchor.x.get().into(),

View File

@ -119,7 +119,7 @@ impl<'a> From<&'a swf::Shape> for DistilledShape<'a> {
pub enum DrawCommand { pub enum DrawCommand {
MoveTo(swf::Point<Twips>), MoveTo(swf::Point<Twips>),
LineTo(swf::Point<Twips>), LineTo(swf::Point<Twips>),
CurveTo { QuadraticCurveTo {
control: swf::Point<Twips>, control: swf::Point<Twips>,
anchor: swf::Point<Twips>, anchor: swf::Point<Twips>,
}, },
@ -130,7 +130,7 @@ impl DrawCommand {
match self { match self {
DrawCommand::MoveTo(point) DrawCommand::MoveTo(point)
| DrawCommand::LineTo(point) | DrawCommand::LineTo(point)
| DrawCommand::CurveTo { anchor: point, .. } => *point, | DrawCommand::QuadraticCurveTo { anchor: point, .. } => *point,
} }
} }
} }
@ -224,7 +224,7 @@ impl PathSegment {
}, },
) => { ) => {
let end = i.next().expect("Bezier without endpoint"); let end = i.next().expect("Bezier without endpoint");
Some(DrawCommand::CurveTo { Some(DrawCommand::QuadraticCurveTo {
control: (*point).into(), control: (*point).into(),
anchor: (*end).into(), anchor: (*end).into(),
}) })
@ -676,7 +676,7 @@ pub fn draw_command_fill_hit_test(commands: &[DrawCommand], test_point: swf::Poi
winding += winding_number_line(test_point, cursor, *line_to); winding += winding_number_line(test_point, cursor, *line_to);
cursor = *line_to; cursor = *line_to;
} }
DrawCommand::CurveTo { control, anchor } => { DrawCommand::QuadraticCurveTo { control, anchor } => {
winding += winding_number_curve(test_point, cursor, *control, *anchor); winding += winding_number_curve(test_point, cursor, *control, *anchor);
cursor = *anchor; cursor = *anchor;
} }
@ -713,7 +713,7 @@ pub fn draw_command_stroke_hit_test(
} }
cursor = *line_to; cursor = *line_to;
} }
DrawCommand::CurveTo { control, anchor } => { DrawCommand::QuadraticCurveTo { control, anchor } => {
if hit_test_stroke_curve(test_point, cursor, *control, *anchor, stroke_widths) { if hit_test_stroke_curve(test_point, cursor, *control, *anchor, stroke_widths) {
return true; return true;
} }

View File

@ -347,7 +347,7 @@ fn ruffle_path_to_lyon_path(commands: &[DrawCommand], is_closed: bool) -> Path {
} }
builder.line_to(point(*line_to)); builder.line_to(point(*line_to));
} }
DrawCommand::CurveTo { control, anchor } => { DrawCommand::QuadraticCurveTo { control, anchor } => {
if let Some(cursor) = cursor.take() { if let Some(cursor) = cursor.take() {
builder.begin(point(cursor)); builder.begin(point(cursor));
} }