LibGfx: Add IPC serialization for Path
The compositor IPC path needs to move vector paths without teaching Web code about the path wire format. Declare the Path specialization on the owning LibGfx type, then reuse the existing path byte serialization for IPC encode and decode. This is preparatory work required to add IPC between the main and compositor threads.
This commit is contained in:
parent
7127b2c854
commit
f07793aa0f
2 changed files with 30 additions and 0 deletions
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include <LibGfx/Path.h>
|
||||
#include <LibGfx/PathSkia.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Encoder.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
|
@ -24,3 +26,20 @@ NonnullOwnPtr<Gfx::PathImpl> PathImpl::create()
|
|||
PathImpl::~PathImpl() = default;
|
||||
|
||||
}
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder& encoder, Gfx::Path const& path)
|
||||
{
|
||||
return encoder.encode(path.serialize_to_bytes());
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<Gfx::Path> decode(Decoder& decoder)
|
||||
{
|
||||
auto path_data = TRY(decoder.decode<Vector<u8>>());
|
||||
return Gfx::Path::from_serialized_bytes(path_data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <LibGfx/Point.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibGfx/WindingRule.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
|
@ -140,3 +141,13 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder&, Gfx::Path const&);
|
||||
|
||||
template<>
|
||||
ErrorOr<Gfx::Path> decode(Decoder&);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue