LibGfx: Add IPC serialization for CornerRadii
The compositor IPC boundary needs to transfer CSS corner radii without keeping their wire shape in Web-specific glue. Declare the IPC specializations on the LibGfx types and encode each corner radius pair next to the CornerRadii implementation. This is preparatory work required to add IPC between the main and compositor threads.
This commit is contained in:
parent
cded122a2d
commit
65962ba03d
2 changed files with 61 additions and 0 deletions
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <AK/Math.h>
|
||||
#include <LibGfx/CornerRadii.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Encoder.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
|
@ -44,3 +46,45 @@ void CornerRadii::adjust_corners_for_spread_distance(int spread_distance)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder& encoder, Gfx::CornerRadius const& radius)
|
||||
{
|
||||
TRY(encoder.encode(radius.horizontal_radius));
|
||||
TRY(encoder.encode(radius.vertical_radius));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<Gfx::CornerRadius> decode(Decoder& decoder)
|
||||
{
|
||||
return Gfx::CornerRadius {
|
||||
.horizontal_radius = TRY(decoder.decode<int>()),
|
||||
.vertical_radius = TRY(decoder.decode<int>()),
|
||||
};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder& encoder, Gfx::CornerRadii const& radii)
|
||||
{
|
||||
TRY(encoder.encode(radii.top_left));
|
||||
TRY(encoder.encode(radii.top_right));
|
||||
TRY(encoder.encode(radii.bottom_right));
|
||||
TRY(encoder.encode(radii.bottom_left));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<Gfx::CornerRadii> decode(Decoder& decoder)
|
||||
{
|
||||
return Gfx::CornerRadii {
|
||||
.top_left = TRY(decoder.decode<Gfx::CornerRadius>()),
|
||||
.top_right = TRY(decoder.decode<Gfx::CornerRadius>()),
|
||||
.bottom_right = TRY(decoder.decode<Gfx::CornerRadius>()),
|
||||
.bottom_left = TRY(decoder.decode<Gfx::CornerRadius>()),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <LibGfx/Point.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
|
@ -90,3 +91,19 @@ struct CornerRadii {
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder&, Gfx::CornerRadius const&);
|
||||
|
||||
template<>
|
||||
ErrorOr<Gfx::CornerRadius> decode(Decoder&);
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder&, Gfx::CornerRadii const&);
|
||||
|
||||
template<>
|
||||
ErrorOr<Gfx::CornerRadii> decode(Decoder&);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue