2020-02-15 00:58:14 +01:00
|
|
|
/*
|
2021-06-16 19:21:42 +02:00
|
|
|
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
2020-02-15 00:58:14 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-02-15 00:58:14 +01:00
|
|
|
*/
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
#include <AK/DeprecatedString.h>
|
2020-02-15 00:58:14 +01:00
|
|
|
#include <LibGfx/Size.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>
|
2020-02-15 00:58:14 +01:00
|
|
|
|
|
|
|
namespace Gfx {
|
|
|
|
|
2020-07-25 21:31:47 -07:00
|
|
|
template<>
|
2022-12-06 01:12:49 +00:00
|
|
|
DeprecatedString IntSize::to_deprecated_string() const
|
2020-02-15 00:58:14 +01:00
|
|
|
{
|
2022-12-04 18:02:33 +00:00
|
|
|
return DeprecatedString::formatted("[{}x{}]", m_width, m_height);
|
2020-02-15 00:58:14 +01:00
|
|
|
}
|
|
|
|
|
2020-07-25 21:31:47 -07:00
|
|
|
template<>
|
2022-12-06 01:12:49 +00:00
|
|
|
DeprecatedString FloatSize::to_deprecated_string() const
|
2020-02-15 00:58:14 +01:00
|
|
|
{
|
2022-12-04 18:02:33 +00:00
|
|
|
return DeprecatedString::formatted("[{}x{}]", m_width, m_height);
|
2020-02-15 00:58:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-02-15 12:04:35 +01:00
|
|
|
|
|
|
|
namespace IPC {
|
|
|
|
|
2022-11-15 11:24:59 -05:00
|
|
|
template<>
|
2021-06-16 19:20:35 +02:00
|
|
|
bool encode(Encoder& encoder, Gfx::IntSize const& size)
|
2020-05-12 18:05:43 +02:00
|
|
|
{
|
|
|
|
encoder << size.width() << size.height();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-11-15 11:24:59 -05:00
|
|
|
template<>
|
2022-12-22 20:40:33 -05:00
|
|
|
ErrorOr<Gfx::IntSize> decode(Decoder& decoder)
|
2020-02-15 12:04:35 +01:00
|
|
|
{
|
2022-12-22 20:40:33 -05:00
|
|
|
auto width = TRY(decoder.decode<int>());
|
|
|
|
auto height = TRY(decoder.decode<int>());
|
|
|
|
return Gfx::IntSize { width, height };
|
2020-02-15 12:04:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-07-25 21:31:47 -07:00
|
|
|
|
|
|
|
template class Gfx::Size<int>;
|
|
|
|
template class Gfx::Size<float>;
|