From c409881b5f86f8b353098757c0ef2dcf731f31ff Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Sun, 5 Jun 2022 18:00:33 +0200 Subject: LibGfx: Pass scaling mode as an enum in do_draw_scaled_bitmap --- Userland/Libraries/LibGfx/Painter.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Userland') diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index 418f216dbb..d6945795b5 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -1092,7 +1092,7 @@ ALWAYS_INLINE static void do_draw_integer_scaled_bitmap(Gfx::Bitmap& target, Int } } -template +template ALWAYS_INLINE static void do_draw_scaled_bitmap(Gfx::Bitmap& target, IntRect const& dst_rect, IntRect const& clipped_rect, Gfx::Bitmap const& source, FloatRect const& src_rect, GetPixel get_pixel, float opacity) { auto int_src_rect = enclosing_int_rect(src_rect); @@ -1100,7 +1100,7 @@ ALWAYS_INLINE static void do_draw_scaled_bitmap(Gfx::Bitmap& target, IntRect con if (clipped_src_rect.is_empty()) return; - if constexpr (!do_bilinear_blend) { + if constexpr (scaling_mode == Painter::ScalingMode::NearestNeighbor) { if (dst_rect == clipped_rect && int_src_rect == src_rect && !(dst_rect.width() % int_src_rect.width()) && !(dst_rect.height() % int_src_rect.height())) { int hfactor = dst_rect.width() / int_src_rect.width(); int vfactor = dst_rect.height() / int_src_rect.height(); @@ -1137,7 +1137,7 @@ ALWAYS_INLINE static void do_draw_scaled_bitmap(Gfx::Bitmap& target, IntRect con continue; Color src_pixel; - if constexpr (do_bilinear_blend) { + if constexpr (scaling_mode == Painter::ScalingMode::BilinearBlend) { auto scaled_x0 = clamp((desired_x - half_pixel) >> 32, clipped_src_rect.left(), clipped_src_rect.right()); auto scaled_x1 = clamp((desired_x + half_pixel) >> 32, clipped_src_rect.left(), clipped_src_rect.right()); auto scaled_y0 = clamp((desired_y - half_pixel) >> 32, clipped_src_rect.top(), clipped_src_rect.bottom()); @@ -1177,10 +1177,10 @@ ALWAYS_INLINE static void do_draw_scaled_bitmap(Gfx::Bitmap& target, IntRect con { switch (scaling_mode) { case Painter::ScalingMode::NearestNeighbor: - do_draw_scaled_bitmap(target, dst_rect, clipped_rect, source, src_rect, get_pixel, opacity); + do_draw_scaled_bitmap(target, dst_rect, clipped_rect, source, src_rect, get_pixel, opacity); break; case Painter::ScalingMode::BilinearBlend: - do_draw_scaled_bitmap(target, dst_rect, clipped_rect, source, src_rect, get_pixel, opacity); + do_draw_scaled_bitmap(target, dst_rect, clipped_rect, source, src_rect, get_pixel, opacity); break; } } -- cgit v1.2.3