From 076977cc75f74b367df34319732a988549898043 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Fri, 25 Aug 2023 13:12:56 +0200 Subject: [PATCH] render: Rename DrawCommand::CurveTo to DrawCommand::QuadraticCurveTo --- core/src/avm1/globals/movie_clip.rs | 2 +- .../avm2/globals/flash/display/graphics.rs | 20 +++++++++---------- core/src/drawing.rs | 2 +- render/canvas/src/lib.rs | 2 +- render/src/shape_utils.rs | 10 +++++----- render/src/tessellator.rs | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/core/src/avm1/globals/movie_clip.rs b/core/src/avm1/globals/movie_clip.rs index f540b362b..8f92c5aad 100644 --- a/core/src/avm1/globals/movie_clip.rs +++ b/core/src/avm1/globals/movie_clip.rs @@ -738,7 +738,7 @@ fn curve_to<'gc>( let anchor_y = anchor_y.coerce_to_f64(activation)?; movie_clip .drawing(activation.context.gc_context) - .draw_command(DrawCommand::CurveTo { + .draw_command(DrawCommand::QuadraticCurveTo { control: Point::from_pixels(control_x, control_y), anchor: Point::from_pixels(anchor_x, anchor_y), }); diff --git a/core/src/avm2/globals/flash/display/graphics.rs b/core/src/avm2/globals/flash/display/graphics.rs index 52350b1ff..ae161aab6 100644 --- a/core/src/avm2/globals/flash/display/graphics.rs +++ b/core/src/avm2/globals/flash/display/graphics.rs @@ -241,7 +241,7 @@ pub fn curve_to<'gc>( let anchor_y = args.get_f64(activation, 3)?; 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), 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 = 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, 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 = Point::from_pixels(bl_point_x, bl_point_y); - draw.draw_command(DrawCommand::CurveTo { + draw.draw_command(DrawCommand::QuadraticCurveTo { control: b_bl_curve, 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 = 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, 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 = Point::from_pixels(tl_point_x, tl_point_y); - draw.draw_command(DrawCommand::CurveTo { + draw.draw_command(DrawCommand::QuadraticCurveTo { control: l_tl_curve, 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 = 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, 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 = Point::from_pixels(tr_point_x, tr_point_y); - draw.draw_command(DrawCommand::CurveTo { + draw.draw_command(DrawCommand::QuadraticCurveTo { control: t_tr_curve, 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 = 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, 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 = 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, anchor: br_point, }); @@ -1179,7 +1179,7 @@ fn process_commands<'gc>( // LINE_TO 2 => Some(DrawCommand::LineTo(read_point())), // CURVE_TO - 3 => Some(DrawCommand::CurveTo { + 3 => Some(DrawCommand::QuadraticCurveTo { control: read_point(), anchor: read_point(), }), diff --git a/core/src/drawing.rs b/core/src/drawing.rs index 2a17fdd2a..65acc02e4 100644 --- a/core/src/drawing.rs +++ b/core/src/drawing.rs @@ -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)) } - DrawCommand::CurveTo { control, anchor } => { + DrawCommand::QuadraticCurveTo { control, anchor } => { bounds.union(&quadratic_curve_bounds(from, stroke_width, control, anchor)) } } diff --git a/render/canvas/src/lib.rs b/render/canvas/src/lib.rs index f75b27dec..ca1497fa1 100644 --- a/render/canvas/src/lib.rs +++ b/render/canvas/src/lib.rs @@ -824,7 +824,7 @@ fn draw_commands_to_path2d(commands: &[DrawCommand], is_closed: bool) -> Path2d DrawCommand::LineTo(line_to) => { 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.y.get().into(), anchor.x.get().into(), diff --git a/render/src/shape_utils.rs b/render/src/shape_utils.rs index f885b0211..239f29f65 100644 --- a/render/src/shape_utils.rs +++ b/render/src/shape_utils.rs @@ -119,7 +119,7 @@ impl<'a> From<&'a swf::Shape> for DistilledShape<'a> { pub enum DrawCommand { MoveTo(swf::Point), LineTo(swf::Point), - CurveTo { + QuadraticCurveTo { control: swf::Point, anchor: swf::Point, }, @@ -130,7 +130,7 @@ impl DrawCommand { match self { DrawCommand::MoveTo(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"); - Some(DrawCommand::CurveTo { + Some(DrawCommand::QuadraticCurveTo { control: (*point).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); cursor = *line_to; } - DrawCommand::CurveTo { control, anchor } => { + DrawCommand::QuadraticCurveTo { control, anchor } => { winding += winding_number_curve(test_point, cursor, *control, *anchor); cursor = *anchor; } @@ -713,7 +713,7 @@ pub fn draw_command_stroke_hit_test( } cursor = *line_to; } - DrawCommand::CurveTo { control, anchor } => { + DrawCommand::QuadraticCurveTo { control, anchor } => { if hit_test_stroke_curve(test_point, cursor, *control, *anchor, stroke_widths) { return true; } diff --git a/render/src/tessellator.rs b/render/src/tessellator.rs index fa30884f9..f270debc9 100644 --- a/render/src/tessellator.rs +++ b/render/src/tessellator.rs @@ -347,7 +347,7 @@ fn ruffle_path_to_lyon_path(commands: &[DrawCommand], is_closed: bool) -> Path { } builder.line_to(point(*line_to)); } - DrawCommand::CurveTo { control, anchor } => { + DrawCommand::QuadraticCurveTo { control, anchor } => { if let Some(cursor) = cursor.take() { builder.begin(point(cursor)); }