LibGfx: Add IPC serialization for ShapeFeature

Font transport needs shape feature tags and values to cross the
compositor IPC boundary with their owning LibGfx representation. Add a
ShapeFeature specialization in its own source file and encode the fixed
tag bytes together with the feature value.

This is preparatory work required to add IPC between the main and
compositor threads.
This commit is contained in:
Aliaksandr Kalenik 2026-05-20 23:52:37 +02:00 committed by Alexander Kalenik
parent f07793aa0f
commit e0526d77cd
3 changed files with 42 additions and 0 deletions

View file

@ -53,6 +53,7 @@ set(SOURCES
SharedImage.cpp
SharedImageBuffer.cpp
ShareableBitmap.cpp
ShapeFeature.cpp
Size.cpp
SkiaBackendContext.cpp
SkiaUtils.cpp

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2026-present, the Ladybird developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibGfx/ShapeFeature.h>
#include <LibIPC/Decoder.h>
#include <LibIPC/Encoder.h>
namespace IPC {
template<>
ErrorOr<void> encode(Encoder& encoder, Gfx::ShapeFeature const& feature)
{
TRY(encoder.append(reinterpret_cast<u8 const*>(feature.tag), sizeof(feature.tag)));
TRY(encoder.encode(feature.value));
return {};
}
template<>
ErrorOr<Gfx::ShapeFeature> decode(Decoder& decoder)
{
Gfx::ShapeFeature feature {};
TRY(decoder.decode_into(Bytes { reinterpret_cast<u8*>(feature.tag), sizeof(feature.tag) }));
feature.value = TRY(decoder.decode<u32>());
return feature;
}
}

View file

@ -7,6 +7,7 @@
#pragma once
#include <AK/Vector.h>
#include <LibIPC/Forward.h>
namespace Gfx {
@ -22,6 +23,16 @@ using ShapeFeatures = Vector<ShapeFeature, 4>;
}
namespace IPC {
template<>
ErrorOr<void> encode(Encoder&, Gfx::ShapeFeature const&);
template<>
ErrorOr<Gfx::ShapeFeature> decode(Decoder&);
}
namespace AK {
template<>