diff options
author | Daniel Bertalan <dani@danielbertalan.dev> | 2021-07-05 18:56:06 +0200 |
---|---|---|
committer | Gunnar Beutner <gunnar@beutner.name> | 2021-07-08 10:11:00 +0200 |
commit | f14a4994b0496191bd202099b620723cb0e497f7 (patch) | |
tree | d9234f1bc38d0189c513a7b7ca3ba995aa3183ad /Userland/Libraries/LibGfx | |
parent | 01a0aa6e0b059b8bf7d258d5025109cc31fd004b (diff) | |
download | serenity-f14a4994b0496191bd202099b620723cb0e497f7.zip |
Everywhere: Don't promote float to double where not needed
The `float => double => float` round trip seen in a couple of places
might pessimize the code. Even if it's truncated to an int in the end,
it's weird not to use the functions with the `f` suffixes when working
with single precision floats.
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r-- | Userland/Libraries/LibGfx/AffineTransform.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Bitmap.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Painter.cpp | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibGfx/AffineTransform.cpp b/Userland/Libraries/LibGfx/AffineTransform.cpp index 2b02f1bac5..f0c9df2382 100644 --- a/Userland/Libraries/LibGfx/AffineTransform.cpp +++ b/Userland/Libraries/LibGfx/AffineTransform.cpp @@ -18,7 +18,7 @@ bool AffineTransform::is_identity() const static float hypotenuse(float x, float y) { // FIXME: This won't handle overflow :( - return sqrt(x * x + y * y); + return sqrtf(x * x + y * y); } float AffineTransform::x_scale() const diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index ac86b6dd56..52d3b30900 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -420,8 +420,8 @@ RefPtr<Gfx::Bitmap> Bitmap::scaled(float sx, float sy) const auto p = static_cast<float>(x) * static_cast<float>(old_width - 1) / static_cast<float>(new_width - 1); auto q = static_cast<float>(y) * static_cast<float>(old_height - 1) / static_cast<float>(new_height - 1); - int i = floor(p); - int j = floor(q); + int i = floorf(p); + int j = floorf(q); float u = p - static_cast<float>(i); float v = q - static_cast<float>(j); @@ -443,7 +443,7 @@ RefPtr<Gfx::Bitmap> Bitmap::scaled(float sx, float sy) const for (int x = 0; x < new_width - 1; x++) { auto p = static_cast<float>(x) * static_cast<float>(old_width - 1) / static_cast<float>(new_width - 1); - int i = floor(p); + int i = floorf(p); float u = p - static_cast<float>(i); auto a = get_pixel(i, old_bottom_y); @@ -458,7 +458,7 @@ RefPtr<Gfx::Bitmap> Bitmap::scaled(float sx, float sy) const for (int y = 0; y < new_height - 1; y++) { auto q = static_cast<float>(y) * static_cast<float>(old_height - 1) / static_cast<float>(new_height - 1); - int j = floor(q); + int j = floorf(q); float v = q - static_cast<float>(j); auto c = get_pixel(old_right_x, j); diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index 5985a4aa3c..d3bf8cb921 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -1902,7 +1902,7 @@ void Painter::for_each_line_segment_on_elliptical_arc(const FloatPoint& p1, cons if (theta_delta < 0) { swap(start, end); theta_1 = theta_1 + theta_delta; - theta_delta = fabs(theta_delta); + theta_delta = fabsf(theta_delta); } auto relative_start = start - center; |