/src/serenity/Userland/Libraries/LibGfx/Size.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <AK/ByteString.h> |
8 | | #include <LibGfx/Size.h> |
9 | | #include <LibIPC/Decoder.h> |
10 | | #include <LibIPC/Encoder.h> |
11 | | |
12 | | namespace Gfx { |
13 | | |
14 | | template<> |
15 | | ByteString IntSize::to_byte_string() const |
16 | 0 | { |
17 | 0 | return ByteString::formatted("[{}x{}]", m_width, m_height); |
18 | 0 | } |
19 | | |
20 | | template<> |
21 | | ByteString FloatSize::to_byte_string() const |
22 | 0 | { |
23 | 0 | return ByteString::formatted("[{}x{}]", m_width, m_height); |
24 | 0 | } |
25 | | |
26 | | } |
27 | | |
28 | | namespace IPC { |
29 | | |
30 | | template<> |
31 | | ErrorOr<void> encode(Encoder& encoder, Gfx::IntSize const& size) |
32 | 0 | { |
33 | 0 | TRY(encoder.encode(size.width())); |
34 | 0 | TRY(encoder.encode(size.height())); |
35 | 0 | return {}; |
36 | 0 | } |
37 | | |
38 | | template<> |
39 | | ErrorOr<Gfx::IntSize> decode(Decoder& decoder) |
40 | 0 | { |
41 | 0 | auto width = TRY(decoder.decode<int>()); |
42 | 0 | auto height = TRY(decoder.decode<int>()); |
43 | 0 | return Gfx::IntSize { width, height }; |
44 | 0 | } |
45 | | |
46 | | } |
47 | | |
48 | | template class Gfx::Size<int>; |
49 | | template class Gfx::Size<float>; |