From f07793aa0f7e3248d66f26b326245890ffb7747b Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Wed, 20 May 2026 23:52:16 +0200 Subject: [PATCH] LibGfx: Add IPC serialization for Path The compositor IPC path needs to move vector paths without teaching Web code about the path wire format. Declare the Path specialization on the owning LibGfx type, then reuse the existing path byte serialization for IPC encode and decode. This is preparatory work required to add IPC between the main and compositor threads. --- Libraries/LibGfx/Path.cpp | 19 +++++++++++++++++++ Libraries/LibGfx/Path.h | 11 +++++++++++ 2 files changed, 30 insertions(+) diff --git a/Libraries/LibGfx/Path.cpp b/Libraries/LibGfx/Path.cpp index 67474d8901..8758bd0274 100644 --- a/Libraries/LibGfx/Path.cpp +++ b/Libraries/LibGfx/Path.cpp @@ -6,6 +6,8 @@ #include #include +#include +#include namespace Gfx { @@ -24,3 +26,20 @@ NonnullOwnPtr PathImpl::create() PathImpl::~PathImpl() = default; } + +namespace IPC { + +template<> +ErrorOr encode(Encoder& encoder, Gfx::Path const& path) +{ + return encoder.encode(path.serialize_to_bytes()); +} + +template<> +ErrorOr decode(Decoder& decoder) +{ + auto path_data = TRY(decoder.decode>()); + return Gfx::Path::from_serialized_bytes(path_data); +} + +} diff --git a/Libraries/LibGfx/Path.h b/Libraries/LibGfx/Path.h index 3ef00104b1..1526e01c8f 100644 --- a/Libraries/LibGfx/Path.h +++ b/Libraries/LibGfx/Path.h @@ -15,6 +15,7 @@ #include #include #include +#include namespace Gfx { @@ -140,3 +141,13 @@ private: }; } + +namespace IPC { + +template<> +ErrorOr encode(Encoder&, Gfx::Path const&); + +template<> +ErrorOr decode(Decoder&); + +}