2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2018-2021, Andreas Kling <andreas@ladybird.org>
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
#include <AK/ByteString.h>
|
2020-02-14 21:41:10 +01:00
|
|
|
#include <LibGfx/Rect.h>
|
2020-03-29 19:03:13 +02:00
|
|
|
#include <LibIPC/Decoder.h>
|
2020-05-12 18:05:43 +02:00
|
|
|
#include <LibIPC/Encoder.h>
|
2019-01-09 02:06:04 +01:00
|
|
|
|
2020-02-06 13:02:38 +01:00
|
|
|
namespace Gfx {
|
|
|
|
|
2020-07-25 21:31:47 -07:00
|
|
|
template<>
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString IntRect::to_byte_string() const
|
2020-02-15 00:58:14 +01:00
|
|
|
{
|
2023-12-16 17:49:34 +03:30
|
|
|
return ByteString::formatted("[{},{} {}x{}]", x(), y(), width(), height());
|
2020-02-15 00:58:14 +01:00
|
|
|
}
|
|
|
|
|
2020-07-25 21:31:47 -07:00
|
|
|
template<>
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString FloatRect::to_byte_string() const
|
2020-02-15 00:58:14 +01:00
|
|
|
{
|
2023-12-16 17:49:34 +03:30
|
|
|
return ByteString::formatted("[{},{} {}x{}]", x(), y(), width(), height());
|
2020-02-15 00:58:14 +01:00
|
|
|
}
|
|
|
|
|
2020-02-06 13:02:38 +01:00
|
|
|
}
|
2020-02-15 12:04:35 +01:00
|
|
|
|
|
|
|
namespace IPC {
|
|
|
|
|
2022-11-15 11:24:59 -05:00
|
|
|
template<>
|
2023-01-01 23:37:35 -05:00
|
|
|
ErrorOr<void> encode(Encoder& encoder, Gfx::IntRect const& rect)
|
2020-05-12 18:05:43 +02:00
|
|
|
{
|
2023-01-01 23:37:35 -05:00
|
|
|
TRY(encoder.encode(rect.location()));
|
|
|
|
TRY(encoder.encode(rect.size()));
|
|
|
|
return {};
|
2020-05-12 18:05:43 +02:00
|
|
|
}
|
|
|
|
|
2022-11-15 11:24:59 -05:00
|
|
|
template<>
|
2022-12-22 20:40:33 -05:00
|
|
|
ErrorOr<Gfx::IntRect> decode(Decoder& decoder)
|
2020-02-15 12:04:35 +01:00
|
|
|
{
|
2022-12-22 20:40:33 -05:00
|
|
|
auto point = TRY(decoder.decode<Gfx::IntPoint>());
|
|
|
|
auto size = TRY(decoder.decode<Gfx::IntSize>());
|
|
|
|
return Gfx::IntRect { point, size };
|
2020-02-15 12:04:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-07-25 21:31:47 -07:00
|
|
|
|
|
|
|
template class Gfx::Rect<int>;
|
|
|
|
template class Gfx::Rect<float>;
|