diff --git a/Userland/Libraries/LibGfx/Point.cpp b/Userland/Libraries/LibGfx/Point.cpp index c74af57d34..139f0b51ef 100644 --- a/Userland/Libraries/LibGfx/Point.cpp +++ b/Userland/Libraries/LibGfx/Point.cpp @@ -51,14 +51,17 @@ ByteString FloatPoint::to_byte_string() const namespace IPC { -template<> -ErrorOr encode(Encoder& encoder, Gfx::IntPoint const& point) +template Point> +ErrorOr encode(Encoder& encoder, Point const& point) { TRY(encoder.encode(point.x())); TRY(encoder.encode(point.y())); return {}; } +template ErrorOr encode(Encoder&, Gfx::IntPoint const& point); +template ErrorOr encode(Encoder&, Gfx::FloatPoint const& point); + template<> ErrorOr decode(Decoder& decoder) { @@ -67,6 +70,14 @@ ErrorOr decode(Decoder& decoder) return Gfx::IntPoint { x, y }; } +template<> +ErrorOr decode(Decoder& decoder) +{ + auto x = TRY(decoder.decode()); + auto y = TRY(decoder.decode()); + return Gfx::FloatPoint { x, y }; +} + } template class Gfx::Point; diff --git a/Userland/Libraries/LibGfx/Point.h b/Userland/Libraries/LibGfx/Point.h index bdf65b7144..2776d8c5d5 100644 --- a/Userland/Libraries/LibGfx/Point.h +++ b/Userland/Libraries/LibGfx/Point.h @@ -306,9 +306,13 @@ namespace IPC { template<> ErrorOr encode(Encoder&, Gfx::IntPoint const&); +template<> +ErrorOr encode(Encoder&, Gfx::FloatPoint const&); template<> ErrorOr decode(Decoder&); +template<> +ErrorOr decode(Decoder&); }