Skip to content

Truly independent web browser

LibGfx: Remove OwnedPath and the C++ path shims

Aliaksandr Kalenik819906f88fec
diff --git a/Libraries/LibCompositing/Rust/src/test_stubs.rs b/Libraries/LibCompositing/Rust/src/test_stubs.rs
index 3fd06acd9ce..ce23df8d4d1 100644
--- a/Libraries/LibCompositing/Rust/src/test_stubs.rs
+++ b/Libraries/LibCompositing/Rust/src/test_stubs.rs
@@ -4,64 +4,10 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-//! Stand-ins for the LibGfx path entry points, which the unit tests link without the C++ runtime.
+//! Stand-ins for the LibGfx process-wide counters, which the unit tests link without the C++ runtime.
-use std::ffi::c_void;
use std::sync::atomic::{AtomicU64, Ordering};
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_destroy(path: *mut c_void) {
- if !path.is_null() {
- // SAFETY: Every stand-in path comes from the `Box<u8>` the deserializer stub leaked to the caller.
- drop(unsafe { Box::from_raw(path.cast::<u8>()) });
- }
-}
-
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_serialize(
- _path: *const c_void,
- append: unsafe extern "C" fn(*mut c_void, *const u8, usize),
- context: *mut c_void,
-) {
- let stand_in_path_bytes = [7u8, 8, 9];
- // SAFETY: The serializer hands its own sink and append function; the bytes are live for the call.
- unsafe { append(context, stand_in_path_bytes.as_ptr(), stand_in_path_bytes.len()) };
-}
-
-// A stand-in path remembers the first byte it was created from, so tests can tell paths apart.
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_create_from_serialized_bytes(bytes: *const u8, count: usize) -> *mut c_void {
- // SAFETY: The caller hands `count` readable bytes.
- let content = if count == 0 { 0u8 } else { unsafe { *bytes } };
- Box::into_raw(Box::new(content)).cast()
-}
-
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_equals(a: *const c_void, b: *const c_void) -> bool {
- // SAFETY: Both stand-in paths are the leaked `Box<u8>` the stub above created.
- unsafe { *a.cast::<u8>() == *b.cast::<u8>() }
-}
-
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_bounding_box(_path: *const c_void, out_x_y_width_height: *mut f32) {
- let stand_in_bounding_box = [0.0f32, 0.0, 1.0, 1.0];
- // SAFETY: The caller hands a writable array of four floats.
- unsafe { std::ptr::copy_nonoverlapping(stand_in_bounding_box.as_ptr(), out_x_y_width_height, 4) };
-}
-
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_contains(_path: *const c_void, _x: f32, _y: f32, _winding_rule: i32) -> bool {
- false
-}
-
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_append_svg_string(
- _path: *const c_void,
- _append: unsafe extern "C" fn(*mut c_void, *const u8, usize),
- _context: *mut c_void,
-) {
-}
-
// One counter stands in for each of LibGfx's process-wide counters: their values only need to be unique.
static NEXT: AtomicU64 = AtomicU64::new(1);
diff --git a/Libraries/LibGfx/Path.cpp b/Libraries/LibGfx/Path.cpp
index 85b187b3ca6..e54eb939f39 100644
--- a/Libraries/LibGfx/Path.cpp
+++ b/Libraries/LibGfx/Path.cpp
@@ -9,7 +9,6 @@
#include <LibGfx/Font/Font.h>
#include <LibGfx/Path.h>
#include <LibGfx/RustFFI.h>
-#include <LibGfx/TextLayout.h>
#include <LibIPC/Decoder.h>
#include <LibIPC/Encoder.h>
@@ -397,15 +396,6 @@ public:
#endif
}
- // Appends the outline of the glyph to the path, mapped by the affine transform with the values a, b, c, d, e and f.
- void append_outline(u32 glyph_id, FFI::PathGeometry* path, Array<float, 6> const& transform) const
- {
- auto* outline = FFI::path_geometry_create();
- ScopeGuard destroy_outline = [&] { FFI::path_geometry_destroy(outline); };
- draw_outline(glyph_id, outline);
- FFI::path_geometry_append_transformed_contours(path, outline, transform.data());
- }
-
void draw_outline(u32 glyph_id, FFI::PathGeometry* outline) const
{
#ifdef AK_OS_MACOS
@@ -439,51 +429,6 @@ public:
}
-void Path::glyph_run(GlyphRun const& glyph_run)
-{
- if (glyph_run.font().is_invisible())
- return;
- FFI::path_geometry_set_fill_rule(m_geometry, to_underlying(WindingRule::Nonzero));
- auto font_ascent = glyph_run.font().pixel_metrics().ascent;
- GlyphOutliner outliner { glyph_run.font() };
- for (auto const& glyph : glyph_run.glyphs())
- outliner.append_outline(glyph.glyph_id, m_geometry, { 1, 0, 0, 1, glyph.position.x(), glyph.position.y() + font_ascent });
- FFI::path_geometry_update_state_from_contours(m_geometry);
-}
-
-// Lays each glyph along the first subpath that has length, with its origin at the distance of its x position plus the
-// offset and its baseline along the direction of the path there, until a glyph's middle would go past the end.
-Path Path::place_glyph_runs_along(ReadonlySpan<NonnullRefPtr<GlyphRun>> glyph_runs, float offset) const
-{
- Path output;
- auto* measure = FFI::path_geometry_measure_first_contour(m_geometry);
- if (!measure)
- return output;
- ScopeGuard destroy_measure = [&] { FFI::contour_measure_destroy(measure); };
- auto path_length = FFI::contour_measure_length(measure);
-
- auto append_glyph_outlines = [&] {
- for (auto const& glyph_run : glyph_runs) {
- if (glyph_run->font().is_invisible())
- continue;
- GlyphOutliner outliner { glyph_run->font() };
- for (auto const& glyph : glyph_run->glyphs()) {
- auto glyph_distance = offset + glyph.position.x();
- if (glyph_distance + (glyph.glyph_width / 2.0f) > path_length)
- return;
-
- float point_and_tangent[4];
- FFI::contour_measure_position_and_tangent(measure, glyph_distance, point_and_tangent);
- auto [x, y, tangent_x, tangent_y] = point_and_tangent;
- outliner.append_outline(glyph.glyph_id, output.m_geometry, { tangent_x, tangent_y, -tangent_y, tangent_x, x, y });
- }
- }
- };
- append_glyph_outlines();
- FFI::path_geometry_update_state_from_contours(output.m_geometry);
- return output;
-}
-
}
namespace IPC {
@@ -503,179 +448,12 @@ ErrorOr<Gfx::Path> decode(Decoder& decoder)
}
-// The functions through which Rust code outside LibGfx builds and queries paths. See Rust/src/path.rs.
+// The function through which Rust code builds glyph outlines into paths. See Rust/src/path.rs.
extern "C" {
-void ladybird_gfx_path_destroy(void*);
-bool ladybird_gfx_path_equals(void const*, void const*);
-void ladybird_gfx_path_append_svg_string(void const*, void (*)(void*, u8 const*, size_t), void*);
-void ladybird_gfx_path_bounding_box(void const*, float*);
-void ladybird_gfx_path_serialize(void const*, void (*)(void*, u8 const*, size_t), void*);
-float ladybird_gfx_path_length(void const*);
-bool ladybird_gfx_path_point_at_length(void const*, float, float*);
-void* ladybird_gfx_path_create_from_ops(u8 const* kinds, float const* values, size_t count);
-void ladybird_gfx_path_append_ops(void*, u8 const* kinds, float const* values, size_t count);
-void ladybird_gfx_path_append_path(void*, void const* other);
-bool ladybird_gfx_path_is_empty(void const*);
-void ladybird_gfx_path_last_point(void const*, float* out_x_y);
-void* ladybird_gfx_path_clone(void const*);
-void* ladybird_gfx_path_create_from_serialized_bytes(u8 const* bytes, size_t count);
-void* ladybird_gfx_path_copy_transformed(void const*, float const* affine_values);
-bool ladybird_gfx_path_contains(void const*, float, float, i32);
-void* ladybird_gfx_path_stroke_to_fill(void const*, float thickness, i32 cap_style, i32 join_style, float miter_limit, float const* dash_array, size_t dash_count, float dash_offset);
-void ladybird_gfx_path_set_fill_type(void*, i32);
-void* ladybird_gfx_path_create_from_glyph_runs(Gfx::FFI::FfiGlyphRun const* runs, size_t run_count);
-void* ladybird_gfx_path_place_glyph_runs_along(void const* path, Gfx::FFI::FfiGlyphRun const* runs, size_t run_count, float offset);
-void ladybird_gfx_path_data(void const*, Gfx::FFI::PathGeometryData*);
void ladybird_gfx_font_glyph_outlines(void const* font, Gfx::FFI::DrawGlyph const* glyphs, size_t glyph_count, void (*visit)(void*, size_t, Gfx::FFI::PathGeometryData const*), void* context);
}
-extern "C" void ladybird_gfx_path_destroy(void* path)
-{
- delete static_cast<Gfx::Path*>(path);
-}
-
-extern "C" void ladybird_gfx_path_append_svg_string(void const* path, void (*append)(void*, u8 const*, size_t), void* context)
-{
- auto string = static_cast<Gfx::Path const*>(path)->to_svg_string();
- append(context, string.bytes().data(), string.bytes().size());
-}
-
-extern "C" void ladybird_gfx_path_set_fill_type(void* path, i32 winding_rule)
-{
- static_cast<Gfx::Path*>(path)->set_fill_type(static_cast<Gfx::WindingRule>(winding_rule));
-}
-
-extern "C" void ladybird_gfx_path_bounding_box(void const* path, float* out_x_y_width_height)
-{
- auto rect = static_cast<Gfx::Path const*>(path)->bounding_box();
- out_x_y_width_height[0] = rect.x();
- out_x_y_width_height[1] = rect.y();
- out_x_y_width_height[2] = rect.width();
- out_x_y_width_height[3] = rect.height();
-}
-
-extern "C" void ladybird_gfx_path_serialize(void const* path, void (*append)(void*, u8 const*, size_t), void* context)
-{
- static_cast<Gfx::Path const*>(path)->serialize_into(append, context);
-}
-
-extern "C" float ladybird_gfx_path_length(void const* path)
-{
- return static_cast<Gfx::Path const*>(path)->length();
-}
-
-extern "C" bool ladybird_gfx_path_point_at_length(void const* path, float distance, float* out)
-{
- auto point = static_cast<Gfx::Path const*>(path)->point_at_length(distance);
- if (!point.has_value())
- return false;
- out[0] = point->point.x();
- out[1] = point->point.y();
- out[2] = point->tangent.x();
- out[3] = point->tangent.y();
- return true;
-}
-
-enum class PathBuilderOpKind : u8 {
- MoveTo,
- LineTo,
- QuadraticBezierCurveTo,
- CubicBezierCurveTo,
- EllipticalArcTo,
- ArcTo,
- Close,
-};
-
-extern "C" void* ladybird_gfx_path_create_from_ops(u8 const* kinds, float const* values, size_t count)
-{
- auto* path = new Gfx::Path;
- ladybird_gfx_path_append_ops(path, kinds, values, count);
- return path;
-}
-
-extern "C" void ladybird_gfx_path_append_ops(void* raw_path, u8 const* kinds, float const* values, size_t count)
-{
- auto* path = static_cast<Gfx::Path*>(raw_path);
- for (size_t i = 0; i < count; ++i) {
- auto const* v = values + i * 7;
- switch (static_cast<PathBuilderOpKind>(kinds[i])) {
- case PathBuilderOpKind::MoveTo:
- path->move_to({ v[0], v[1] });
- break;
- case PathBuilderOpKind::LineTo:
- path->line_to({ v[0], v[1] });
- break;
- case PathBuilderOpKind::QuadraticBezierCurveTo:
- path->quadratic_bezier_curve_to({ v[0], v[1] }, { v[2], v[3] });
- break;
- case PathBuilderOpKind::CubicBezierCurveTo:
- path->cubic_bezier_curve_to({ v[0], v[1] }, { v[2], v[3] }, { v[4], v[5] });
- break;
- case PathBuilderOpKind::EllipticalArcTo:
- path->elliptical_arc_to({ v[0], v[1] }, { v[2], v[3] }, v[4], v[5] != 0, v[6] != 0);
- break;
- case PathBuilderOpKind::ArcTo:
- path->arc_to({ v[0], v[1] }, v[2], v[3] != 0, v[4] != 0);
- break;
- case PathBuilderOpKind::Close:
- path->close();
- break;
- default:
- VERIFY_NOT_REACHED();
- }
- }
-}
-
-extern "C" void ladybird_gfx_path_append_path(void* path, void const* other)
-{
- static_cast<Gfx::Path*>(path)->append_path(*static_cast<Gfx::Path const*>(other));
-}
-
-extern "C" bool ladybird_gfx_path_is_empty(void const* path)
-{
- return static_cast<Gfx::Path const*>(path)->is_empty();
-}
-
-extern "C" void ladybird_gfx_path_last_point(void const* path, float* out_x_y)
-{
- auto point = static_cast<Gfx::Path const*>(path)->last_point();
- out_x_y[0] = point.x();
- out_x_y[1] = point.y();
-}
-
-extern "C" void* ladybird_gfx_path_clone(void const* path)
-{
- return new Gfx::Path(static_cast<Gfx::Path const*>(path)->clone());
-}
-
-static Vector<NonnullRefPtr<Gfx::GlyphRun>> adopt_glyph_runs(Gfx::FFI::FfiGlyphRun const* runs, size_t run_count)
-{
- Vector<NonnullRefPtr<Gfx::GlyphRun>> glyph_runs;
- glyph_runs.ensure_capacity(run_count);
- for (size_t i = 0; i < run_count; ++i) {
- Vector<Gfx::DrawGlyph> glyphs;
- glyphs.append(reinterpret_cast<Gfx::DrawGlyph const*>(runs[i].glyphs), runs[i].glyph_count);
- // The text type and width only matter to a caller that slices or measures the run, which neither of the two
- // path operations below does.
- glyph_runs.unchecked_append(adopt_ref(*new Gfx::GlyphRun(move(glyphs), *static_cast<Gfx::Font const*>(runs[i].font), Gfx::GlyphRun::TextType::Common, 0)));
- }
- return glyph_runs;
-}
-
-extern "C" void* ladybird_gfx_path_create_from_glyph_runs(Gfx::FFI::FfiGlyphRun const* runs, size_t run_count)
-{
- auto* path = new Gfx::Path;
- for (auto const& glyph_run : adopt_glyph_runs(runs, run_count))
- path->glyph_run(glyph_run);
- return path;
-}
-
-extern "C" void* ladybird_gfx_path_place_glyph_runs_along(void const* path, Gfx::FFI::FfiGlyphRun const* runs, size_t run_count, float offset)
-{
- return new Gfx::Path(static_cast<Gfx::Path const*>(path)->place_glyph_runs_along(adopt_glyph_runs(runs, run_count), offset));
-}
-
// Calls the callback with the outline of each glyph, in pixels with its origin on the baseline.
extern "C" void ladybird_gfx_font_glyph_outlines(void const* font, Gfx::FFI::DrawGlyph const* glyphs, size_t glyph_count, void (*visit)(void*, size_t, Gfx::FFI::PathGeometryData const*), void* context)
{
@@ -690,51 +468,3 @@ extern "C" void ladybird_gfx_font_glyph_outlines(void const* font, Gfx::FFI::Dra
visit(context, index, &data);
}
}
-
-extern "C" void* ladybird_gfx_path_create_from_serialized_bytes(u8 const* bytes, size_t count)
-{
- return new Gfx::Path(Gfx::Path::from_serialized_bytes({ bytes, count }));
-}
-
-extern "C" void* ladybird_gfx_path_copy_transformed(void const* path, float const* affine_values)
-{
- Gfx::AffineTransform transform { affine_values[0], affine_values[1], affine_values[2], affine_values[3], affine_values[4], affine_values[5] };
- return new Gfx::Path(static_cast<Gfx::Path const*>(path)->copy_transformed(transform));
-}
-
-extern "C" bool ladybird_gfx_path_contains(void const* path, float x, float y, i32 winding_rule)
-{
- return static_cast<Gfx::Path const*>(path)->contains({ x, y }, static_cast<Gfx::WindingRule>(winding_rule));
-}
-
-extern "C" void* ladybird_gfx_path_stroke_to_fill(void const* path, float thickness, i32 cap_style, i32 join_style, float miter_limit, float const* dash_array, size_t dash_count, float dash_offset)
-{
- Gfx::Path::StrokeStyle style {
- .thickness = thickness,
- .cap_style = static_cast<Gfx::Path::CapStyle>(cap_style),
- .join_style = static_cast<Gfx::Path::JoinStyle>(join_style),
- .miter_limit = miter_limit,
- .dash_array = { dash_array, dash_count },
- .dash_offset = dash_offset,
- };
- return new Gfx::Path(static_cast<Gfx::Path const*>(path)->stroke_to_fill(style));
-}
-
-extern "C" void ladybird_gfx_path_data(void const* path, Gfx::FFI::PathGeometryData* out_data)
-{
- auto data = static_cast<Gfx::Path const*>(path)->data();
- *out_data = {
- .verbs = reinterpret_cast<u8 const*>(data.verbs.data()),
- .verb_count = data.verbs.size(),
- .points = reinterpret_cast<Gfx::FFI::FloatPoint const*>(data.points.data()),
- .point_count = data.points.size(),
- .conic_weights = data.conic_weights.data(),
- .conic_weight_count = data.conic_weights.size(),
- .fill_rule = static_cast<u8>(data.winding_rule),
- };
-}
-
-extern "C" bool ladybird_gfx_path_equals(void const* a, void const* b)
-{
- return *static_cast<Gfx::Path const*>(a) == *static_cast<Gfx::Path const*>(b);
-}
diff --git a/Libraries/LibGfx/Path.h b/Libraries/LibGfx/Path.h
index a57734f4ab1..de02e07de19 100644
--- a/Libraries/LibGfx/Path.h
+++ b/Libraries/LibGfx/Path.h
@@ -108,7 +108,6 @@ public:
void arc_to(FloatPoint point, float radius, bool large_arc, bool sweep);
void quadratic_bezier_curve_to(FloatPoint through, FloatPoint point);
void cubic_bezier_curve_to(FloatPoint c1, FloatPoint c2, FloatPoint p2);
- void glyph_run(GlyphRun const&);
void append_path(Gfx::Path const&);
@@ -126,7 +125,6 @@ public:
Gfx::Path clone() const { return *this; }
Gfx::Path copy_transformed(Gfx::AffineTransform const&) const;
- Gfx::Path place_glyph_runs_along(ReadonlySpan<NonnullRefPtr<GlyphRun>>, float offset = 0) const;
String to_svg_string() const;
diff --git a/Libraries/LibGfx/Rust/src/lib.rs b/Libraries/LibGfx/Rust/src/lib.rs
index b6f44c21e3c..d2cf581cccf 100644
--- a/Libraries/LibGfx/Rust/src/lib.rs
+++ b/Libraries/LibGfx/Rust/src/lib.rs
@@ -57,7 +57,6 @@ unsafe extern "C" {
const _: () = {
const fn assert_send_and_sync<T: Send + Sync>() {}
assert_send_and_sync::<font::FontHandle>();
- assert_send_and_sync::<path::OwnedPath>();
assert_send_and_sync::<path::Path>();
assert_send_and_sync::<image_frame::ImageFrameHandle>();
assert_send_and_sync::<text_layout::GlyphBuffer>();
diff --git a/Libraries/LibGfx/Rust/src/path.rs b/Libraries/LibGfx/Rust/src/path.rs
index 29d2c9daf92..fdec2e3599b 100644
--- a/Libraries/LibGfx/Rust/src/path.rs
+++ b/Libraries/LibGfx/Rust/src/path.rs
@@ -5,9 +5,6 @@
*/
use std::ffi::c_void;
-use std::marker::PhantomData;
-use std::mem::ManuallyDrop;
-use std::ptr::NonNull;
use std::sync::OnceLock;
use crate::geometry::{FloatPoint, FloatSize};
@@ -27,49 +24,6 @@ mod svg_text;
unsafe extern "C" {
fn ladybird_gfx_process_next_path_identity() -> u64;
- fn ladybird_gfx_path_destroy(path: *mut c_void);
- fn ladybird_gfx_path_equals(a: *const c_void, b: *const c_void) -> bool;
- fn ladybird_gfx_path_append_svg_string(
- path: *const c_void,
- append: unsafe extern "C" fn(*mut c_void, *const u8, usize),
- context: *mut c_void,
- );
- fn ladybird_gfx_path_bounding_box(path: *const c_void, out_x_y_width_height: *mut f32);
- fn ladybird_gfx_path_set_fill_type(path: *mut c_void, winding_rule: i32);
- fn ladybird_gfx_path_serialize(
- path: *const c_void,
- append: unsafe extern "C" fn(*mut c_void, *const u8, usize),
- context: *mut c_void,
- );
- fn ladybird_gfx_path_contains(path: *const c_void, x: f32, y: f32, winding_rule: i32) -> bool;
- fn ladybird_gfx_path_stroke_to_fill(
- path: *const c_void,
- thickness: f32,
- cap_style: i32,
- join_style: i32,
- miter_limit: f32,
- dash_array: *const f32,
- dash_count: usize,
- dash_offset: f32,
- ) -> *mut c_void;
- fn ladybird_gfx_path_length(path: *const c_void) -> f32;
- fn ladybird_gfx_path_point_at_length(path: *const c_void, distance: f32, out: *mut f32) -> bool;
- fn ladybird_gfx_path_create_from_ops(kinds: *const u8, values: *const f32, count: usize) -> *mut c_void;
- fn ladybird_gfx_path_append_ops(path: *mut c_void, kinds: *const u8, values: *const f32, count: usize);
- fn ladybird_gfx_path_append_path(path: *mut c_void, other: *const c_void);
- fn ladybird_gfx_path_is_empty(path: *const c_void) -> bool;
- fn ladybird_gfx_path_last_point(path: *const c_void, out_x_y: *mut f32);
- fn ladybird_gfx_path_clone(path: *const c_void) -> *mut c_void;
- fn ladybird_gfx_path_create_from_serialized_bytes(bytes: *const u8, count: usize) -> *mut c_void;
- fn ladybird_gfx_path_copy_transformed(path: *const c_void, affine_values: *const f32) -> *mut c_void;
- fn ladybird_gfx_path_create_from_glyph_runs(runs: *const FfiGlyphRun, run_count: usize) -> *mut c_void;
- fn ladybird_gfx_path_place_glyph_runs_along(
- path: *const c_void,
- runs: *const FfiGlyphRun,
- run_count: usize,
- offset: f32,
- ) -> *mut c_void;
- fn ladybird_gfx_path_data(path: *const c_void, out_data: *mut ffi::PathGeometryData);
fn ladybird_gfx_font_glyph_outlines(
font: *const c_void,
glyphs: *const crate::text_layout::DrawGlyph,
@@ -85,13 +39,6 @@ pub struct GlyphRun {
pub glyphs: Vec<crate::text_layout::DrawGlyph>,
}
-#[repr(C)]
-struct FfiGlyphRun {
- font: *const c_void,
- glyphs: *const crate::text_layout::DrawGlyph,
- glyph_count: usize,
-}
-
struct GlyphOutlineSink<'a> {
geometry: &'a mut PathGeometry,
transforms: &'a [AffineTransform],
@@ -136,259 +83,7 @@ fn append_glyph_outlines(
}
}
-fn to_ffi_glyph_runs(runs: &[GlyphRun]) -> Vec<FfiGlyphRun> {
- runs.iter()
- .map(|run| FfiGlyphRun {
- font: run.font.as_raw(),
- glyphs: run.glyphs.as_ptr(),
- glyph_count: run.glyphs.len(),
- })
- .collect()
-}
-
-#[derive(Clone, Copy, Debug)]
-#[repr(u8)]
-enum PathBuilderOpKind {
- MoveTo,
- LineTo,
- QuadraticBezierCurveTo,
- CubicBezierCurveTo,
- EllipticalArcTo,
- ArcTo,
- Close,
-}
-
-#[derive(Clone, Debug, Default)]
-pub struct PathBuilder {
- kinds: Vec<u8>,
- values: Vec<f32>,
-}
-
-impl PathBuilder {
- pub fn new() -> Self {
- Self::default()
- }
-
- pub fn is_empty(&self) -> bool {
- self.kinds.is_empty()
- }
-
- fn push(&mut self, kind: PathBuilderOpKind, values: [f32; 7]) {
- self.kinds.push(kind as u8);
- self.values.extend_from_slice(&values);
- }
-
- pub fn move_to(&mut self, x: f32, y: f32) {
- self.push(PathBuilderOpKind::MoveTo, [x, y, 0.0, 0.0, 0.0, 0.0, 0.0]);
- }
-
- pub fn line_to(&mut self, x: f32, y: f32) {
- self.push(PathBuilderOpKind::LineTo, [x, y, 0.0, 0.0, 0.0, 0.0, 0.0]);
- }
-
- pub fn quadratic_bezier_curve_to(&mut self, through_x: f32, through_y: f32, x: f32, y: f32) {
- self.push(
- PathBuilderOpKind::QuadraticBezierCurveTo,
- [through_x, through_y, x, y, 0.0, 0.0, 0.0],
- );
- }
-
- pub fn cubic_bezier_curve_to(&mut self, c1x: f32, c1y: f32, c2x: f32, c2y: f32, x: f32, y: f32) {
- self.push(PathBuilderOpKind::CubicBezierCurveTo, [c1x, c1y, c2x, c2y, x, y, 0.0]);
- }
-
- #[allow(clippy::too_many_arguments)]
- pub fn elliptical_arc_to(
- &mut self,
- x: f32,
- y: f32,
- radius_x: f32,
- radius_y: f32,
- x_axis_rotation: f32,
- large_arc: bool,
- sweep: bool,
- ) {
- self.push(
- PathBuilderOpKind::EllipticalArcTo,
- [
- x,
- y,
- radius_x,
- radius_y,
- x_axis_rotation,
- if large_arc { 1.0 } else { 0.0 },
- if sweep { 1.0 } else { 0.0 },
- ],
- );
- }
-
- pub fn arc_to(&mut self, x: f32, y: f32, radius: f32, large_arc: bool, sweep: bool) {
- self.push(
- PathBuilderOpKind::ArcTo,
- [
- x,
- y,
- radius,
- if large_arc { 1.0 } else { 0.0 },
- if sweep { 1.0 } else { 0.0 },
- 0.0,
- 0.0,
- ],
- );
- }
-
- pub fn close(&mut self) {
- self.push(PathBuilderOpKind::Close, [0.0; 7]);
- }
-
- pub fn build(&self) -> OwnedPath {
- // SAFETY: The op arrays are live for the call, and the returned pointer is a fresh
- // heap-allocated Gfx::Path that only the OwnedPath owns.
- unsafe {
- OwnedPath::adopt(ladybird_gfx_path_create_from_ops(
- self.kinds.as_ptr(),
- self.values.as_ptr(),
- self.kinds.len(),
- ))
- }
- }
-}
-
-/// A `Gfx::Path` that is built on where it is: one that an [`OwnedPath`] or C++ owns, borrowed mutably for `'a`.
-/// Each operation is that of the path, with its rules for a path that has no current point.
-pub struct PathMut<'a> {
- raw: NonNull<c_void>,
- path: PhantomData<&'a mut c_void>,
-}
-
-impl PathMut<'_> {
- /// Borrows a `Gfx::Path` that C++ owns.
- ///
- /// # Safety
- ///
- /// `raw` must be a live `Gfx::Path`, which nothing else uses while the value lives.
- pub unsafe fn from_raw(raw: *mut c_void) -> Self {
- Self {
- raw: NonNull::new(raw).expect("Gfx::Path pointer must not be null"),
- path: PhantomData,
- }
- }
-
- fn apply(&mut self, kind: PathBuilderOpKind, values: [f32; 7]) {
- let kind = kind as u8;
- // SAFETY: The path is live and borrowed mutably, and the op is live for the call.
- unsafe { ladybird_gfx_path_append_ops(self.raw.as_ptr(), &raw const kind, values.as_ptr(), 1) };
- }
-
- /// Whether the path has no current point, which Gfx::Path::is_empty() calls empty.
- pub fn is_empty(&self) -> bool {
- // SAFETY: The path is live.
- unsafe { ladybird_gfx_path_is_empty(self.raw.as_ptr()) }
- }
-
- pub fn last_point(&self) -> FloatPoint {
- last_point_of(self.raw)
- }
-
- pub fn move_to(&mut self, point: FloatPoint) {
- self.apply(PathBuilderOpKind::MoveTo, [point.x, point.y, 0.0, 0.0, 0.0, 0.0, 0.0]);
- }
-
- pub fn line_to(&mut self, point: FloatPoint) {
- self.apply(PathBuilderOpKind::LineTo, [point.x, point.y, 0.0, 0.0, 0.0, 0.0, 0.0]);
- }
-
- pub fn quadratic_bezier_curve_to(&mut self, through: FloatPoint, point: FloatPoint) {
- self.apply(
- PathBuilderOpKind::QuadraticBezierCurveTo,
- [through.x, through.y, point.x, point.y, 0.0, 0.0, 0.0],
- );
- }
-
- pub fn cubic_bezier_curve_to(&mut self, c1: FloatPoint, c2: FloatPoint, point: FloatPoint) {
- self.apply(
- PathBuilderOpKind::CubicBezierCurveTo,
- [c1.x, c1.y, c2.x, c2.y, point.x, point.y, 0.0],
- );
- }
-
- pub fn elliptical_arc_to(
- &mut self,
- point: FloatPoint,
- radii: FloatSize,
- x_axis_rotation: f32,
- large_arc: bool,
- sweep: bool,
- ) {
- self.apply(
- PathBuilderOpKind::EllipticalArcTo,
- [
- point.x,
- point.y,
- radii.width,
- radii.height,
- x_axis_rotation,
- if large_arc { 1.0 } else { 0.0 },
- if sweep { 1.0 } else { 0.0 },
- ],
- );
- }
-
- pub fn arc_to(&mut self, point: FloatPoint, radius: f32, large_arc: bool, sweep: bool) {
- self.apply(
- PathBuilderOpKind::ArcTo,
- [
- point.x,
- point.y,
- radius,
- if large_arc { 1.0 } else { 0.0 },
- if sweep { 1.0 } else { 0.0 },
- 0.0,
- 0.0,
- ],
- );
- }
-
- pub fn close(&mut self) {
- self.apply(PathBuilderOpKind::Close, [0.0; 7]);
- }
-
- /// Adds all the subpaths of the other path to this one.
- pub fn append_path(&mut self, other: &OwnedPath) {
- // SAFETY: Both paths are live, and this one is borrowed mutably.
- unsafe { ladybird_gfx_path_append_path(self.raw.as_ptr(), other.raw.as_ptr()) };
- }
-}
-
-fn last_point_of(path: NonNull<c_void>) -> FloatPoint {
- let mut x_y = [0.0f32; 2];
- // SAFETY: The path is live for the call; the out-array holds two floats.
- unsafe { ladybird_gfx_path_last_point(path.as_ptr(), x_y.as_mut_ptr()) };
- FloatPoint { x: x_y[0], y: x_y[1] }
-}
-
-unsafe extern "C" fn append_to_vec(context: *mut c_void, bytes: *const u8, length: usize) {
- if length == 0 {
- return;
- }
- // SAFETY: `context` is the Vec pointer handed out by serialize_to_bytes; the bytes are live
- // for this synchronous call.
- let out = unsafe { &mut *context.cast::<Vec<u8>>() };
- out.extend_from_slice(unsafe { ak::slice_from_raw_parts(bytes, length) });
-}
-
-unsafe extern "C" fn append_to_string(context: *mut c_void, bytes: *const u8, length: usize) {
- // SAFETY: `context` is the String pointer passed by to_svg_string below, and the bytes are
- // live UTF-8 for this synchronous call.
- unsafe {
- let output = &mut *context.cast::<String>();
- if length > 0 {
- output.push_str(&String::from_utf8_lossy(ak::slice_from_raw_parts(bytes, length)));
- }
- }
-}
-
-/// How a path is stroked, as `OwnedPath::stroke_to_fill()` takes it.
+/// How a path is stroked, as `Path::stroke_to_fill()` takes it.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct StrokeStyle {
pub thickness: f32,
@@ -634,229 +329,3 @@ impl PartialEq for Path {
// The contours are compared bit for bit, which is reflexive even for NaN.
impl Eq for Path {}
-
-/// The sole owner of a heap-allocated `Gfx::Path`, destroying it on drop.
-pub struct OwnedPath {
- raw: NonNull<c_void>,
- identity: u64,
-}
-
-// SAFETY: OwnedPath uniquely owns its Gfx::Path. Every operation on a shared reference is a const
-// query, which only reads the path.
-unsafe impl Send for OwnedPath {}
-// SAFETY: See the Send implementation above.
-unsafe impl Sync for OwnedPath {}
-
-impl std::fmt::Debug for OwnedPath {
- fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- formatter
- .debug_struct("OwnedPath")
- .field("identity", &self.identity)
- .finish()
- }
-}
-
-impl OwnedPath {
- /// Assumes sole ownership of a heap-allocated `Gfx::Path`.
- ///
- /// # Safety
- ///
- /// `raw` must be the only pointer through which the heap-allocated
- /// `Gfx::Path` is owned or destroyed.
- #[inline]
- pub unsafe fn adopt(raw: *mut c_void) -> Self {
- Self {
- raw: NonNull::new(raw).expect("Gfx::Path pointer must not be null"),
- // The counter is LibGfx's: this crate is compiled into more than one library, and a
- // counter here would let each of them hand out the same identities. See
- // `LibGfx/RustProcessState.cpp`.
- // SAFETY: The counter is an atomic on the other side of the boundary.
- identity: unsafe { ladybird_gfx_process_next_path_identity() },
- }
- }
-
- /// The raw `Gfx::Path` pointer, still owned by this value.
- #[inline]
- pub fn as_raw(&self) -> *mut c_void {
- self.raw.as_ptr()
- }
-
- /// Transfers ownership of the heap-allocated `Gfx::Path` to the caller.
- #[inline]
- pub fn into_raw(self) -> *mut c_void {
- let this = ManuallyDrop::new(self);
- this.raw.as_ptr()
- }
-
- /// The path, borrowed to be built on. The path gets a new identity, as it may no longer be the
- /// path that a snapshot holding the old identity copied.
- pub fn as_path_mut(&mut self) -> PathMut<'_> {
- // SAFETY: The counter is an atomic on the other side of the boundary.
- self.identity = unsafe { ladybird_gfx_process_next_path_identity() };
- PathMut {
- raw: self.raw,
- path: PhantomData,
- }
- }
-
- /// Whether the path has no current point, which Gfx::Path::is_empty() calls empty.
- pub fn is_empty(&self) -> bool {
- // SAFETY: The path is live for the duration of the call.
- unsafe { ladybird_gfx_path_is_empty(self.raw.as_ptr()) }
- }
-
- pub fn last_point(&self) -> FloatPoint {
- last_point_of(self.raw)
- }
-
- /// A process-unique, never-reused identity for this path allocation, so
- /// consumers holding a copied snapshot can recognize an unchanged path
- /// without comparing contents.
- #[inline]
- pub fn identity(&self) -> u64 {
- self.identity
- }
-
- pub fn set_fill_type(&mut self, winding_rule: i32) {
- // SAFETY: The path is live and owned by this handle.
- unsafe { ladybird_gfx_path_set_fill_type(self.as_raw(), winding_rule) };
- }
-
- pub fn bounding_box(&self) -> [f32; 4] {
- let mut out = [0.0f32; 4];
- // SAFETY: The path is live for the duration of the call; the out-array holds four floats.
- unsafe { ladybird_gfx_path_bounding_box(self.raw.as_ptr(), out.as_mut_ptr()) };
- out
- }
-
- pub fn length(&self) -> f32 {
- // SAFETY: The path is live for the duration of the call.
- unsafe { ladybird_gfx_path_length(self.raw.as_ptr()) }
- }
-
- /// The point at the given distance along the path, followed by the path's tangent there.
- pub fn point_at_length(&self, distance: f32) -> Option<[f32; 4]> {
- let mut out = [0.0f32; 4];
- // SAFETY: The path is live for the duration of the call; the out-array holds four floats.
- unsafe { ladybird_gfx_path_point_at_length(self.raw.as_ptr(), distance, out.as_mut_ptr()) }.then_some(out)
- }
-
- pub fn copy_transformed(&self, affine_values: [f32; 6]) -> OwnedPath {
- // SAFETY: The path is live for the call; the result is a fresh heap-allocated Gfx::Path.
- unsafe {
- OwnedPath::adopt(ladybird_gfx_path_copy_transformed(
- self.raw.as_ptr(),
- affine_values.as_ptr(),
- ))
- }
- }
-
- /// The outlines of the given glyphs, as one path.
- pub fn from_glyph_runs(runs: &[GlyphRun]) -> OwnedPath {
- let ffi_runs = to_ffi_glyph_runs(runs);
- // SAFETY: Each handle keeps its font live and each glyph slice stays valid for the
- // synchronous call, which returns a fresh heap-allocated Gfx::Path.
- unsafe {
- OwnedPath::adopt(ladybird_gfx_path_create_from_glyph_runs(
- ffi_runs.as_ptr(),
- ffi_runs.len(),
- ))
- }
- }
-
- /// The outlines of the given glyphs, laid along this path from `offset`.
- pub fn place_glyph_runs_along(&self, runs: &[GlyphRun], offset: f32) -> OwnedPath {
- let ffi_runs = to_ffi_glyph_runs(runs);
- // SAFETY: This path and every run's font stay live for the synchronous call, which
- // returns a fresh heap-allocated Gfx::Path.
- unsafe {
- OwnedPath::adopt(ladybird_gfx_path_place_glyph_runs_along(
- self.as_raw(),
- ffi_runs.as_ptr(),
- ffi_runs.len(),
- offset,
- ))
- }
- }
-
- pub fn from_serialized_bytes(bytes: &[u8]) -> OwnedPath {
- // SAFETY: The bytes are live for the call, and the result is a fresh heap-allocated Gfx::Path;
- // malformed bytes yield an empty path rather than a failure.
- let raw = unsafe { ladybird_gfx_path_create_from_serialized_bytes(bytes.as_ptr(), bytes.len()) };
- // SAFETY: The host handed over sole ownership of the fresh path.
- unsafe { OwnedPath::adopt(raw) }
- }
-
- pub fn serialize_to_bytes(&self) -> Vec<u8> {
- let mut bytes: Vec<u8> = Vec::new();
- // SAFETY: The path is live for the duration of the call, and the callback only writes
- // into the Vec whose pointer it receives.
- unsafe { ladybird_gfx_path_serialize(self.raw.as_ptr(), append_to_vec, (&raw mut bytes).cast()) };
- bytes
- }
-
- pub fn contains(&self, x: f32, y: f32, winding_rule: i32) -> bool {
- // SAFETY: The path is live for the duration of the call.
- unsafe { ladybird_gfx_path_contains(self.raw.as_ptr(), x, y, winding_rule) }
- }
-
- /// The outline of the area that stroking this path with the given style covers, as a path to fill with the
- /// nonzero winding rule.
- pub fn stroke_to_fill(&self, style: &StrokeStyle) -> OwnedPath {
- // SAFETY: The path and the dash array are live for the synchronous call, which returns a fresh heap-allocated
- // Gfx::Path.
- unsafe {
- OwnedPath::adopt(ladybird_gfx_path_stroke_to_fill(
- self.raw.as_ptr(),
- style.thickness,
- style.cap_style as i32,
- style.join_style as i32,
- style.miter_limit,
- style.dash_array.as_ptr(),
- style.dash_array.len(),
- style.dash_offset,
- ))
- }
- }
-
- pub fn to_svg_string(&self) -> String {
- let mut output = String::new();
- // SAFETY: The path is live for the duration of the call, and the callback only writes
- // into the String whose pointer it receives.
- unsafe { ladybird_gfx_path_append_svg_string(self.raw.as_ptr(), append_to_string, (&raw mut output).cast()) };
- output
- }
-
- /// The contours of the path, as C++ reads them, valid until the path changes or is dropped.
- pub fn geometry_data(&self) -> ffi::PathGeometryData {
- let mut data = std::mem::MaybeUninit::uninit();
- // SAFETY: The path is live for the duration of the call, which writes the data.
- unsafe {
- ladybird_gfx_path_data(self.raw.as_ptr(), data.as_mut_ptr());
- data.assume_init()
- }
- }
-}
-
-/// A copy of the path, which has an identity of its own.
-impl Clone for OwnedPath {
- fn clone(&self) -> Self {
- // SAFETY: The path is live for the call; the result is a fresh heap-allocated Gfx::Path.
- unsafe { OwnedPath::adopt(ladybird_gfx_path_clone(self.raw.as_ptr())) }
- }
-}
-
-impl PartialEq for OwnedPath {
- fn eq(&self, other: &Self) -> bool {
- self.identity == other.identity
- // SAFETY: Both sides own live heap-allocated paths for the duration of the call.
- || unsafe { ladybird_gfx_path_equals(self.raw.as_ptr(), other.raw.as_ptr()) }
- }
-}
-
-impl Drop for OwnedPath {
- fn drop(&mut self) {
- // SAFETY: adopt() took sole ownership of the heap-allocated path.
- unsafe { ladybird_gfx_path_destroy(self.raw.as_ptr()) };
- }
-}
diff --git a/Libraries/LibGfx/Rust/src/path/ffi.rs b/Libraries/LibGfx/Rust/src/path/ffi.rs
index 5af10c48792..d95a38e7ae1 100644
--- a/Libraries/LibGfx/Rust/src/path/ffi.rs
+++ b/Libraries/LibGfx/Rust/src/path/ffi.rs
@@ -6,13 +6,13 @@
//! The functions through which `Gfx::Path` in C++ owns, builds and queries a path.
//!
-//! Only LibGfx's copy of this crate makes and frees the paths of `Gfx::Path`. Rust code in other
-//! libraries reaches them through the `ladybird_gfx_path_*` functions of LibGfx.
+//! Only LibGfx's copy of this crate makes and frees the paths of `Gfx::Path`. Rust code builds and
+//! queries its own paths with `Path`.
use super::encoding;
use super::geometry::{PathGeometry, PathVerb};
use super::hit_test;
-use super::measure::{self, ContourMeasure, PathVertex};
+use super::measure::{self, PathVertex};
use super::stroke::{self, StrokeStyle};
use super::svg_text;
use crate::geometry::FloatPoint;
@@ -271,36 +271,6 @@ pub unsafe extern "C" fn path_geometry_append_path(path: *mut PathGeometry, othe
unsafe { with_other_path(path, other, |path, other| path.append_path(other)) };
}
-/// Adds the contours of the other path, mapped by the affine transform, without changing what the
-/// operations of Gfx::Path remember.
-///
-/// # Safety
-/// `path` and `other` must be live paths from this module; nothing else may use `path` for the call.
-/// `transform` must point to the six values a, b, c, d, e and f of an affine transform.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn path_geometry_append_transformed_contours(
- path: *mut PathGeometry,
- other: *const PathGeometry,
- transform: *const f32,
-) {
- // SAFETY: Forwarded from the caller.
- let transform = unsafe { read_transform(transform) };
- // SAFETY: Forwarded from the caller.
- unsafe {
- with_other_path(path, other, |path, other| {
- path.append_mapped(other, |point| transform.map_point(point))
- })
- };
-}
-
-/// # Safety
-/// `path` must be a live path from this module, which nothing else uses for the call.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn path_geometry_update_state_from_contours(path: *mut PathGeometry) {
- // SAFETY: Forwarded from the caller.
- unsafe { &mut *path }.update_state_from_contours();
-}
-
/// # Safety
/// `path` must be a live path from this module, which nothing else uses for the call.
#[unsafe(no_mangle)]
@@ -548,51 +518,3 @@ pub unsafe extern "C" fn path_geometry_data(path: *const PathGeometry, out_data:
// SAFETY: The caller passes room for the data.
unsafe { std::ptr::write(out_data, data) };
}
-
-/// The measure of the first contour of the path that has length, or null if none has.
-///
-/// # Safety
-/// `path` must be a live path from this module.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn path_geometry_measure_first_contour(path: *const PathGeometry) -> *mut ContourMeasure {
- // SAFETY: Forwarded from the caller.
- ContourMeasure::contours_of(unsafe { &*path })
- .next()
- .map_or(std::ptr::null_mut(), |contour| Box::into_raw(Box::new(contour)))
-}
-
-/// # Safety
-/// `measure` must be a live measure from path_geometry_measure_first_contour().
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn contour_measure_length(measure: *const ContourMeasure) -> f32 {
- // SAFETY: Forwarded from the caller.
- unsafe { &*measure }.length()
-}
-
-/// Writes the point at the distance along the contour, clamped to its ends, and the unit tangent there.
-///
-/// # Safety
-/// `measure` must be a live measure from path_geometry_measure_first_contour(), and
-/// `out_point_and_tangent` must point to four floats.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn contour_measure_position_and_tangent(
- measure: *const ContourMeasure,
- distance: f32,
- out_point_and_tangent: *mut f32,
-) {
- // SAFETY: Forwarded from the caller.
- let point_and_tangent = unsafe { &*measure }.position_and_tangent(distance);
- // SAFETY: Forwarded from the caller.
- unsafe { write_point_and_tangent(out_point_and_tangent, point_and_tangent) };
-}
-
-/// # Safety
-/// `measure` must be a measure from path_geometry_measure_first_contour() that nothing uses afterwards,
-/// or null.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn contour_measure_destroy(measure: *mut ContourMeasure) {
- if !measure.is_null() {
- // SAFETY: The caller hands over the measure, which was made from a Box.
- drop(unsafe { Box::from_raw(measure) });
- }
-}
diff --git a/Libraries/LibWeb/Rust/src/css/style_compute.rs b/Libraries/LibWeb/Rust/src/css/style_compute.rs
index c9c3afb3eb9..913821af5f7 100644
--- a/Libraries/LibWeb/Rust/src/css/style_compute.rs
+++ b/Libraries/LibWeb/Rust/src/css/style_compute.rs
@@ -8005,60 +8005,6 @@ pub(crate) mod ffi_test_stubs {
}
}
#[unsafe(no_mangle)]
- extern "C" fn ladybird_gfx_path_destroy(path: *mut std::ffi::c_void) {
- if !path.is_null() {
- // SAFETY: Every stand-in path comes from the `Box<u8>` the deserializer stub leaked to the caller.
- drop(unsafe { Box::from_raw(path.cast::<u8>()) });
- }
- }
- #[unsafe(no_mangle)]
- extern "C" fn ladybird_gfx_path_serialize(
- _path: *const std::ffi::c_void,
- append: unsafe extern "C" fn(*mut std::ffi::c_void, *const u8, usize),
- context: *mut std::ffi::c_void,
- ) {
- let stand_in_path_bytes = [7u8, 8, 9];
- // SAFETY: The serializer hands its own sink and append function; the bytes are live for the call.
- unsafe { append(context, stand_in_path_bytes.as_ptr(), stand_in_path_bytes.len()) };
- }
- // A stand-in path remembers the first byte it was created from, so tests can tell paths apart.
- #[unsafe(no_mangle)]
- extern "C" fn ladybird_gfx_path_create_from_serialized_bytes(
- bytes: *const u8,
- count: usize,
- ) -> *mut std::ffi::c_void {
- // SAFETY: The caller hands `count` readable bytes.
- let content = if count == 0 { 0u8 } else { unsafe { *bytes } };
- Box::into_raw(Box::new(content)).cast()
- }
- #[unsafe(no_mangle)]
- extern "C" fn ladybird_gfx_path_equals(a: *const std::ffi::c_void, b: *const std::ffi::c_void) -> bool {
- // SAFETY: Both stand-in paths are the leaked `Box<u8>` the stub above created.
- unsafe { *a.cast::<u8>() == *b.cast::<u8>() }
- }
- #[unsafe(no_mangle)]
- extern "C" fn ladybird_gfx_path_bounding_box(_path: *const std::ffi::c_void, out_x_y_width_height: *mut f32) {
- let stand_in_bounding_box = [0.0f32, 0.0, 1.0, 1.0];
- // SAFETY: The caller hands a writable array of four floats.
- unsafe { std::ptr::copy_nonoverlapping(stand_in_bounding_box.as_ptr(), out_x_y_width_height, 4) };
- }
- #[unsafe(no_mangle)]
- extern "C" fn ladybird_gfx_path_contains(
- _path: *const std::ffi::c_void,
- _x: f32,
- _y: f32,
- _winding_rule: i32,
- ) -> bool {
- false
- }
- #[unsafe(no_mangle)]
- extern "C" fn ladybird_gfx_path_append_svg_string(
- _path: *const std::ffi::c_void,
- _append: unsafe extern "C" fn(*mut std::ffi::c_void, *const u8, usize),
- _context: *mut std::ffi::c_void,
- ) {
- }
- #[unsafe(no_mangle)]
extern "C" fn ladybird_gfx_process_next_structural_epoch() -> u64 {
static NEXT: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1);
NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed)
diff --git a/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs b/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs
index 88f782b17d0..5f9d86c636a 100644
--- a/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs
+++ b/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs
@@ -117,49 +117,9 @@ extern "C" fn ladybird_gfx_font_glyph_outlines(
unreachable!("no unit test reads a font");
}
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_create_from_ops(_kinds: *const u8, _values: *const f32, _count: usize) -> *mut c_void {
- unreachable!("no unit test builds a path");
-}
-
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_create_from_glyph_runs(_runs: *const c_void, _run_count: usize) -> *mut c_void {
- unreachable!("no unit test builds a path");
-}
-
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_copy_transformed(_path: *const c_void, _affine_values: *const f32) -> *mut c_void {
- unreachable!("no unit test builds a path");
-}
-
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_length(_path: *const c_void) -> f32 {
- unreachable!("no unit test builds a path");
-}
-
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_point_at_length(_path: *const c_void, _distance: f32, _out: *mut f32) -> bool {
- unreachable!("no unit test builds a path");
-}
-
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_place_glyph_runs_along(
- _path: *const c_void,
- _runs: *const c_void,
- _run_count: usize,
- _offset: f32,
-) -> *mut c_void {
- unreachable!("no unit test builds a path");
-}
-
-#[unsafe(no_mangle)]
-extern "C" fn ladybird_gfx_path_set_fill_type(_path: *mut c_void, _winding_rule: i32) {
- unreachable!("no unit test builds a path");
-}
-
#[unsafe(no_mangle)]
extern "C" fn ladybird_gfx_process_next_path_identity() -> u64 {
- unreachable!("no unit test builds a path");
+ unreachable!("no unit test reads the identity of a path");
}
#[unsafe(no_mangle)]