mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibGfx: Implement AK::min/max
for Gfx::VectorN
These return a new `Gfx::VectorN` with the minimum or maximum value of each element.
This commit is contained in:
parent
e46b217e42
commit
55668c3e48
Notes:
sideshowbarker
2024-07-17 11:33:34 +09:00
Author: https://github.com/gmta
Commit: 55668c3e48
Pull-request: https://github.com/SerenityOS/serenity/pull/23207
Reviewed-by: https://github.com/nico ✅
1 changed files with 24 additions and 0 deletions
|
@ -300,3 +300,27 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
|
||||
template<size_t N, typename T>
|
||||
constexpr Gfx::VectorN<N, T> min(Gfx::VectorN<N, T> const& a, Gfx::VectorN<N, T> const& b)
|
||||
{
|
||||
Gfx::VectorN<N, T> result;
|
||||
UNROLL_LOOP
|
||||
for (auto i = 0u; i < N; ++i)
|
||||
result[i] = min(a[i], b[i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<size_t N, typename T>
|
||||
constexpr Gfx::VectorN<N, T> max(Gfx::VectorN<N, T> const& a, Gfx::VectorN<N, T> const& b)
|
||||
{
|
||||
Gfx::VectorN<N, T> result;
|
||||
UNROLL_LOOP
|
||||
for (auto i = 0u; i < N; ++i)
|
||||
result[i] = max(a[i], b[i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue