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.
56 lines
1.1 KiB
C++
56 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2025, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Vector.h>
|
|
#include <LibIPC/Forward.h>
|
|
|
|
namespace Gfx {
|
|
|
|
struct ShapeFeature {
|
|
char tag[4];
|
|
u32 value;
|
|
|
|
bool operator==(ShapeFeature const&) const = default;
|
|
bool operator!=(ShapeFeature const&) const = default;
|
|
};
|
|
|
|
using ShapeFeatures = Vector<ShapeFeature, 4>;
|
|
|
|
}
|
|
|
|
namespace IPC {
|
|
|
|
template<>
|
|
ErrorOr<void> encode(Encoder&, Gfx::ShapeFeature const&);
|
|
|
|
template<>
|
|
ErrorOr<Gfx::ShapeFeature> decode(Decoder&);
|
|
|
|
}
|
|
|
|
namespace AK {
|
|
|
|
template<>
|
|
struct Traits<Gfx::ShapeFeatures> : public DefaultTraits<Gfx::ShapeFeatures> {
|
|
static unsigned hash(Gfx::ShapeFeatures const& feature)
|
|
{
|
|
u32 hash = 0;
|
|
|
|
for (auto const& feature : feature) {
|
|
hash = pair_int_hash(hash, feature.tag[0]);
|
|
hash = pair_int_hash(hash, feature.tag[1]);
|
|
hash = pair_int_hash(hash, feature.tag[2]);
|
|
hash = pair_int_hash(hash, feature.tag[3]);
|
|
hash = pair_int_hash(hash, feature.value);
|
|
}
|
|
|
|
return hash;
|
|
}
|
|
};
|
|
|
|
}
|