mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03:00
LibGfx: Avoid some unnecessary Rounding in AffineTransform and Color
Casts suffice in these cases. (Assuming standard rounding mode)
This commit is contained in:
parent
65f57efb5b
commit
5fd49b9d9f
Notes:
sideshowbarker
2024-07-17 11:12:06 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/5fd49b9d9f Pull-request: https://github.com/SerenityOS/serenity/pull/13663 Reviewed-by: https://github.com/gmta Reviewed-by: https://github.com/linusg
@ -158,7 +158,7 @@ IntPoint AffineTransform::map(IntPoint const& point) const
|
||||
float mapped_x;
|
||||
float mapped_y;
|
||||
map(static_cast<float>(point.x()), static_cast<float>(point.y()), mapped_x, mapped_y);
|
||||
return { roundf(mapped_x), roundf(mapped_y) };
|
||||
return { round_to<int>(mapped_x), round_to<int>(mapped_y) };
|
||||
}
|
||||
|
||||
template<>
|
||||
@ -174,8 +174,8 @@ template<>
|
||||
IntSize AffineTransform::map(IntSize const& size) const
|
||||
{
|
||||
return {
|
||||
roundf(static_cast<float>(size.width()) * x_scale()),
|
||||
roundf(static_cast<float>(size.height()) * y_scale()),
|
||||
round_to<int>(static_cast<float>(size.width()) * x_scale()),
|
||||
round_to<int>(static_cast<float>(size.height()) * y_scale()),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -200,10 +200,10 @@ public:
|
||||
|
||||
Color interpolate(Color const& other, float weight) const noexcept
|
||||
{
|
||||
u8 r = red() + roundf(static_cast<float>(other.red() - red()) * weight);
|
||||
u8 g = green() + roundf(static_cast<float>(other.green() - green()) * weight);
|
||||
u8 b = blue() + roundf(static_cast<float>(other.blue() - blue()) * weight);
|
||||
u8 a = alpha() + roundf(static_cast<float>(other.alpha() - alpha()) * weight);
|
||||
u8 r = red() + round_to<u8>(static_cast<float>(other.red() - red()) * weight);
|
||||
u8 g = green() + round_to<u8>(static_cast<float>(other.green() - green()) * weight);
|
||||
u8 b = blue() + round_to<u8>(static_cast<float>(other.blue() - blue()) * weight);
|
||||
u8 a = alpha() + round_to<u8>(static_cast<float>(other.alpha() - alpha()) * weight);
|
||||
return Color(r, g, b, a);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user