From 9fc47345cecc7f026e23ef5fbb541ffe607f1c37 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 2 Feb 2024 21:51:14 -0500 Subject: [PATCH] LibGfx+LibPDF: Make sample() functions take ReadonlySpan<> ...instead of Vector<>. No behavior (or performance) change. --- Userland/Libraries/LibGfx/ICC/TagTypes.h | 10 +++++----- Userland/Libraries/LibPDF/Function.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibGfx/ICC/TagTypes.h b/Userland/Libraries/LibGfx/ICC/TagTypes.h index 83acd786b4..4eea96c050 100644 --- a/Userland/Libraries/LibGfx/ICC/TagTypes.h +++ b/Userland/Libraries/LibGfx/ICC/TagTypes.h @@ -35,7 +35,7 @@ float lerp_1d(ReadonlySpan values, float x) // Does multi-dimensional linear interpolation over a lookup table. // `size(i)` should returns the number of samples in the i'th dimension. // `sample()` gets a vector where 0 <= i'th coordinate < size(i) and should return the value of the look-up table at that position. -inline FloatVector3 lerp_nd(Function size, Function const&)> sample, Vector const& x) +inline FloatVector3 lerp_nd(Function size, Function const&)> sample, Vector const& x) { unsigned left_index[x.size()]; float factor[x.size()]; @@ -1077,7 +1077,7 @@ inline ErrorOr Lut16TagData::evaluate(ColorSpace input_space, Colo // The first sequential byte of the entry contains the function value for the first output function, // the second sequential byte of the entry contains the function value for the second output function, // and so on until all the output functions have been supplied." - auto sample = [this](Vector const& coordinates) { + auto sample = [this](ReadonlySpan const& coordinates) { size_t stride = 3; size_t offset = 0; for (int i = coordinates.size() - 1; i >= 0; --i) { @@ -1165,7 +1165,7 @@ inline ErrorOr Lut8TagData::evaluate(ColorSpace input_space, Color // The first sequential byte of the entry contains the function value for the first output function, // the second sequential byte of the entry contains the function value for the second output function, // and so on until all the output functions have been supplied." - auto sample = [this](Vector const& coordinates) { + auto sample = [this](ReadonlySpan const& coordinates) { size_t stride = 3; size_t offset = 0; for (int i = coordinates.size() - 1; i >= 0; --i) { @@ -1238,7 +1238,7 @@ inline ErrorOr LutAToBTagData::evaluate(ColorSpace connection_spac in_color.append(evaluate_curve(a_curves[c], color_u8[c] / 255.0f)); auto const& clut = m_clut.value(); - auto sample1 = [&clut](Vector const& data, Vector const& coordinates) { + auto sample1 = [&clut](Vector const& data, ReadonlySpan const& coordinates) { size_t stride = 3; size_t offset = 0; for (int i = coordinates.size() - 1; i >= 0; --i) { @@ -1247,7 +1247,7 @@ inline ErrorOr LutAToBTagData::evaluate(ColorSpace connection_spac } return FloatVector3 { (float)data[offset], (float)data[offset + 1], (float)data[offset + 2] }; }; - auto sample = [&clut, &sample1](Vector const& coordinates) { + auto sample = [&clut, &sample1](ReadonlySpan const& coordinates) { return clut.values.visit( [&](Vector const& v) { return sample1(v, coordinates) / 255.0f; }, [&](Vector const& v) { return sample1(v, coordinates) / 65535.0f; }); diff --git a/Userland/Libraries/LibPDF/Function.cpp b/Userland/Libraries/LibPDF/Function.cpp index 36834499d4..1c3867c750 100644 --- a/Userland/Libraries/LibPDF/Function.cpp +++ b/Userland/Libraries/LibPDF/Function.cpp @@ -28,7 +28,7 @@ public: private: SampledFunction(NonnullRefPtr); - float sample(Vector const& coordinates, size_t r) const + float sample(ReadonlySpan const& coordinates, size_t r) const { // "For a function with multidimensional input (more than one input variable), // the sample values in the first dimension vary fastest,