From 92852b84770a29ba1eeeaca03d7df5a4001346d3 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 8 Jan 2024 22:09:48 -0500 Subject: [PATCH] LibGfx/ICC: Move MatrixMatrixConversion curve type check to ctor A bit faster: ``` N Min Max Median Avg Stddev x 50 0.97179127 1.0031381 0.98313618 0.98407591 0.0092019442 + 50 0.95996714 0.99507213 0.96965885 0.97242294 0.0095455053 Difference at 95.0% confidence -0.011653 +/- 0.00372012 -1.18415% +/- 0.378032% (Student's t, pooled s = 0.0093753) ``` --- Userland/Libraries/LibGfx/ICC/Profile.cpp | 9 +++++++++ Userland/Libraries/LibGfx/ICC/Profile.h | 2 -- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/ICC/Profile.cpp b/Userland/Libraries/LibGfx/ICC/Profile.cpp index c38716d844..041e571c0b 100644 --- a/Userland/Libraries/LibGfx/ICC/Profile.cpp +++ b/Userland/Libraries/LibGfx/ICC/Profile.cpp @@ -1586,6 +1586,15 @@ MatrixMatrixConversion::MatrixMatrixConversion(LutCurveType source_red_TRC, , m_destination_green_TRC(move(destination_green_TRC)) , m_destination_blue_TRC(move(destination_blue_TRC)) { + auto check = [](auto const& trc) { + VERIFY(trc->type() == CurveTagData::Type || trc->type() == ParametricCurveTagData::Type); + }; + check(m_source_red_TRC); + check(m_source_green_TRC); + check(m_source_blue_TRC); + check(m_destination_red_TRC); + check(m_destination_green_TRC); + check(m_destination_blue_TRC); } Optional Profile::matrix_matrix_conversion(Profile const& source_profile) const diff --git a/Userland/Libraries/LibGfx/ICC/Profile.h b/Userland/Libraries/LibGfx/ICC/Profile.h index 52321df3d7..5826c5ec4e 100644 --- a/Userland/Libraries/LibGfx/ICC/Profile.h +++ b/Userland/Libraries/LibGfx/ICC/Profile.h @@ -175,14 +175,12 @@ private: inline Color MatrixMatrixConversion::map(FloatVector3 in_rgb) const { auto evaluate_curve = [](TagData const& trc, float f) { - VERIFY(trc.type() == CurveTagData::Type || trc.type() == ParametricCurveTagData::Type); if (trc.type() == CurveTagData::Type) return static_cast(trc).evaluate(f); return static_cast(trc).evaluate(f); }; auto evaluate_curve_inverse = [](TagData const& trc, float f) { - VERIFY(trc.type() == CurveTagData::Type || trc.type() == ParametricCurveTagData::Type); if (trc.type() == CurveTagData::Type) return static_cast(trc).evaluate_inverse(f); return static_cast(trc).evaluate_inverse(f);