2024-08-08 10:12:29 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibGfx/Path.h>
|
|
|
|
|
#include <LibGfx/PathSkia.h>
|
2026-05-20 18:52:16 -03:00
|
|
|
#include <LibIPC/Decoder.h>
|
|
|
|
|
#include <LibIPC/Encoder.h>
|
2024-08-08 10:12:29 -03:00
|
|
|
|
|
|
|
|
namespace Gfx {
|
|
|
|
|
|
2026-05-08 10:58:51 -03:00
|
|
|
Path Path::from_serialized_bytes(ReadonlyBytes bytes)
|
|
|
|
|
{
|
|
|
|
|
Gfx::Path path;
|
|
|
|
|
path.impl().deserialize_from_bytes(bytes);
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 10:12:29 -03:00
|
|
|
NonnullOwnPtr<Gfx::PathImpl> PathImpl::create()
|
|
|
|
|
{
|
|
|
|
|
return PathImplSkia::create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PathImpl::~PathImpl() = default;
|
|
|
|
|
|
|
|
|
|
}
|
2026-05-20 18:52:16 -03:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|