mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 06:34:57 +00:00
LibGfx: Make FloatPoint
compatible with IPC
This commit is contained in:
parent
41c76e6ba6
commit
8dd887b3c8
2 changed files with 17 additions and 2 deletions
|
@ -51,14 +51,17 @@ ByteString FloatPoint::to_byte_string() const
|
|||
|
||||
namespace IPC {
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder& encoder, Gfx::IntPoint const& point)
|
||||
template<OneOf<Gfx::IntPoint, Gfx::FloatPoint> Point>
|
||||
ErrorOr<void> encode(Encoder& encoder, Point const& point)
|
||||
{
|
||||
TRY(encoder.encode(point.x()));
|
||||
TRY(encoder.encode(point.y()));
|
||||
return {};
|
||||
}
|
||||
|
||||
template ErrorOr<void> encode(Encoder&, Gfx::IntPoint const& point);
|
||||
template ErrorOr<void> encode(Encoder&, Gfx::FloatPoint const& point);
|
||||
|
||||
template<>
|
||||
ErrorOr<Gfx::IntPoint> decode(Decoder& decoder)
|
||||
{
|
||||
|
@ -67,6 +70,14 @@ ErrorOr<Gfx::IntPoint> decode(Decoder& decoder)
|
|||
return Gfx::IntPoint { x, y };
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<Gfx::FloatPoint> decode(Decoder& decoder)
|
||||
{
|
||||
auto x = TRY(decoder.decode<float>());
|
||||
auto y = TRY(decoder.decode<float>());
|
||||
return Gfx::FloatPoint { x, y };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template class Gfx::Point<int>;
|
||||
|
|
|
@ -306,9 +306,13 @@ namespace IPC {
|
|||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder&, Gfx::IntPoint const&);
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder&, Gfx::FloatPoint const&);
|
||||
|
||||
template<>
|
||||
ErrorOr<Gfx::IntPoint> decode(Decoder&);
|
||||
template<>
|
||||
ErrorOr<Gfx::FloatPoint> decode(Decoder&);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue