From 7c4b0b03895be84dfbca7cf06ab920d97b79cf76 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 16 Aug 2023 20:29:31 -0400 Subject: [PATCH] LibGfx+Userland: Rename Size::scaled_by to Size::scaled Ignoring Size for a second, we currently have: Rect::scale_by Rect::scaled Point::scale_by Point::scaled In Size, before this patch, we have: Size::scale_by Size::scaled_by This aligns Size to use the same method name as Rect and Point. While subjectively providing API symmetry, this is mostly to allow using this method in templated helpers without caring what the exact underlying type is. --- Userland/Applications/DisplaySettings/MonitorWidget.cpp | 2 +- Userland/Libraries/LibGfx/Size.h | 6 +++--- Userland/Libraries/LibGfx/VectorGraphic.cpp | 2 +- Userland/Libraries/LibVideo/VP9/Decoder.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Userland/Applications/DisplaySettings/MonitorWidget.cpp b/Userland/Applications/DisplaySettings/MonitorWidget.cpp index 859d58525c..fbe319bc40 100644 --- a/Userland/Applications/DisplaySettings/MonitorWidget.cpp +++ b/Userland/Applications/DisplaySettings/MonitorWidget.cpp @@ -126,7 +126,7 @@ void MonitorWidget::redraw_desktop_if_needed() float sw = (float)m_desktop_bitmap->width() / (float)m_desktop_resolution.width(); float sh = (float)m_desktop_bitmap->height() / (float)m_desktop_resolution.height(); - auto scaled_size = m_wallpaper_bitmap->size().to_type().scaled_by(sw, sh).to_type(); + auto scaled_size = m_wallpaper_bitmap->size().to_type().scaled(sw, sh).to_type(); auto scaled_bitmap_or_error = m_wallpaper_bitmap->scaled(sw, sh); if (scaled_bitmap_or_error.is_error()) { GUI::MessageBox::show_error(window(), "There was an error updating the desktop preview"sv); diff --git a/Userland/Libraries/LibGfx/Size.h b/Userland/Libraries/LibGfx/Size.h index 04e876796b..4f24709106 100644 --- a/Userland/Libraries/LibGfx/Size.h +++ b/Userland/Libraries/LibGfx/Size.h @@ -58,21 +58,21 @@ public: ALWAYS_INLINE constexpr void scale_by(T dboth) { scale_by(dboth, dboth); } ALWAYS_INLINE constexpr void scale_by(Point const& s) { scale_by(s.x(), s.y()); } - [[nodiscard]] constexpr Size scaled_by(T dx, T dy) const + [[nodiscard]] constexpr Size scaled(T dx, T dy) const { Size size = *this; size.scale_by(dx, dy); return size; } - [[nodiscard]] constexpr Size scaled_by(T dboth) const + [[nodiscard]] constexpr Size scaled(T dboth) const { Size size = *this; size.scale_by(dboth); return size; } - [[nodiscard]] constexpr Size scaled_by(Point const& s) const + [[nodiscard]] constexpr Size scaled(Point const& s) const { Size size = *this; size.scale_by(s); diff --git a/Userland/Libraries/LibGfx/VectorGraphic.cpp b/Userland/Libraries/LibGfx/VectorGraphic.cpp index 4f94463c23..baae04a216 100644 --- a/Userland/Libraries/LibGfx/VectorGraphic.cpp +++ b/Userland/Libraries/LibGfx/VectorGraphic.cpp @@ -15,7 +15,7 @@ void VectorGraphic::draw_into(Painter& painter, IntRect const& dest, AffineTrans // This allows you to easily rotate or flip the image before painting. auto transformed_rect = transform.map(FloatRect { {}, size() }); auto scale = min(float(dest.width()) / transformed_rect.width(), float(dest.height()) / transformed_rect.height()); - auto centered = FloatRect { {}, transformed_rect.size().scaled_by(scale) }.centered_within(dest.to_type()); + auto centered = FloatRect { {}, transformed_rect.size().scaled(scale) }.centered_within(dest.to_type()); auto view_transform = AffineTransform {} .translate(centered.location()) .multiply(AffineTransform {}.scale(scale, scale)) diff --git a/Userland/Libraries/LibVideo/VP9/Decoder.cpp b/Userland/Libraries/LibVideo/VP9/Decoder.cpp index f8cbe64ef6..7619612f0b 100644 --- a/Userland/Libraries/LibVideo/VP9/Decoder.cpp +++ b/Userland/Libraries/LibVideo/VP9/Decoder.cpp @@ -787,10 +787,10 @@ DecoderErrorOr Decoder::prepare_referenced_frame(Gfx::Size frame_size // − FrameHeight <= 16 * RefFrameHeight[ refIdx ] if (!reference_frame.is_valid()) return DecoderError::format(DecoderErrorCategory::Corrupted, "Attempted to use reference frame {} that has not been saved", reference_frame_index); - auto double_frame_size = frame_size.scaled_by(2); + auto double_frame_size = frame_size.scaled(2); if (double_frame_size.width() < reference_frame.size.width() || double_frame_size.height() < reference_frame.size.height()) return DecoderError::format(DecoderErrorCategory::Corrupted, "Inter frame size is too small relative to reference frame {}", reference_frame_index); - if (!reference_frame.size.scaled_by(16).contains(frame_size)) + if (!reference_frame.size.scaled(16).contains(frame_size)) return DecoderError::format(DecoderErrorCategory::Corrupted, "Inter frame size is too large relative to reference frame {}", reference_frame_index); // FIXME: Convert all the operations in this function to vector operations supported by