diff --git a/Libraries/LibGfx/CMakeLists.txt b/Libraries/LibGfx/CMakeLists.txt index 894d1d9b69..923356b3e6 100644 --- a/Libraries/LibGfx/CMakeLists.txt +++ b/Libraries/LibGfx/CMakeLists.txt @@ -21,6 +21,7 @@ set(SOURCES Font/WOFF2/Loader.cpp FontCascadeList.cpp GradientPainting.cpp + Matrix4x4.cpp ImageFormats/AVIFLoader.cpp ImageFormats/BMPLoader.cpp ImageFormats/BMPWriter.cpp diff --git a/Libraries/LibGfx/Matrix4x4.cpp b/Libraries/LibGfx/Matrix4x4.cpp new file mode 100644 index 0000000000..828a763f1b --- /dev/null +++ b/Libraries/LibGfx/Matrix4x4.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2026-present, the Ladybird developers. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include + +namespace IPC { + +template<> +ErrorOr encode(Encoder& encoder, Gfx::FloatMatrix4x4 const& matrix) +{ + static constexpr size_t element_count = Gfx::FloatMatrix4x4::Size * Gfx::FloatMatrix4x4::Size; + TRY(encoder.append(reinterpret_cast(matrix.elements()), element_count * sizeof(float))); + return {}; +} + +template<> +ErrorOr decode(Decoder& decoder) +{ + static constexpr size_t element_count = Gfx::FloatMatrix4x4::Size * Gfx::FloatMatrix4x4::Size; + Gfx::FloatMatrix4x4 matrix; + TRY(decoder.decode_into(Bytes { reinterpret_cast(matrix.elements()), element_count * sizeof(float) })); + return matrix; +} + +} diff --git a/Libraries/LibGfx/Matrix4x4.h b/Libraries/LibGfx/Matrix4x4.h index 62c8c1dbea..de15453bd0 100644 --- a/Libraries/LibGfx/Matrix4x4.h +++ b/Libraries/LibGfx/Matrix4x4.h @@ -11,6 +11,7 @@ #include #include #include +#include namespace Gfx { @@ -96,3 +97,13 @@ typedef Matrix4x4 DoubleMatrix4x4; using Gfx::DoubleMatrix4x4; using Gfx::FloatMatrix4x4; using Gfx::Matrix4x4; + +namespace IPC { + +template<> +ErrorOr encode(Encoder&, Gfx::FloatMatrix4x4 const&); + +template<> +ErrorOr decode(Decoder&); + +}