From 5129c8b766b0bb1ba0dab193fbf1bf08d670c0d5 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sat, 17 Feb 2024 19:12:25 +0200 Subject: [PATCH] LibGfx/ICC: Stop using VectorN::length() as the vector size VectorN::length() returns the vector length (aka the square root of the dot product of the vector with itself), not the count of components. This is seemingly both wrong and slow. --- Userland/Libraries/LibGfx/ICC/TagTypes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/ICC/TagTypes.h b/Userland/Libraries/LibGfx/ICC/TagTypes.h index 680e10893a..010f16e11b 100644 --- a/Userland/Libraries/LibGfx/ICC/TagTypes.h +++ b/Userland/Libraries/LibGfx/ICC/TagTypes.h @@ -1093,7 +1093,7 @@ inline ErrorOr Lut16TagData::evaluate(ColorSpace input_space, Colo // Each output table entry is appropriately normalized to the range 0 to 65535. // The outputTable is of size (OutputChannels x outputTableEntries x 2) bytes. // When stored in this tag, the one-dimensional lookup tables are packed one after another" - for (u8 c = 0; c < output_color.length(); ++c) + for (u8 c = 0; c < 3; ++c) output_color[c] = lerp_1d(m_output_tables.span().slice(c * m_number_of_output_table_entries, m_number_of_output_table_entries), output_color[c]) / 65535.0f; if (connection_space == ColorSpace::PCSXYZ) { @@ -1181,7 +1181,7 @@ inline ErrorOr Lut8TagData::evaluate(ColorSpace input_space, Color // Each output table entry is appropriately normalized to the range 0 to 255. // The outputTable is of size (OutputChannels x 256) bytes. // When stored in this tag, the one-dimensional lookup tables are packed one after another" - for (u8 c = 0; c < output_color.length(); ++c) + for (u8 c = 0; c < 3; ++c) output_color[c] = lerp_1d(m_output_tables.span().slice(c * 256, 256), output_color[c]) / 255.0f; if (connection_space == ColorSpace::PCSXYZ) {