mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 18:17:34 +00:00
Meta+Userland: Pass Gfx::Color by value
Gfx::Color is always 4 bytes (it's just a wrapper over u32) it's less work just to pass the color directly. This also updates IPCCompiler to prevent from generating Gfx::Color const &, which makes replacement easier.
This commit is contained in:
parent
f76c7f3788
commit
bbc149ebb9
28 changed files with 65 additions and 54 deletions
|
@ -316,7 +316,7 @@ Optional<Color> Color::from_string(StringView string)
|
|||
return Color(r.value(), g.value(), b.value(), a.value());
|
||||
}
|
||||
|
||||
Color Color::mixed_with(Color const& other, float weight) const
|
||||
Color Color::mixed_with(Color other, float weight) const
|
||||
{
|
||||
if (alpha() == other.alpha() || with_alpha(0) == other.with_alpha(0)) {
|
||||
return Gfx::Color {
|
||||
|
@ -382,7 +382,7 @@ ErrorOr<void> IPC::decode(Decoder& decoder, Color& color)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> AK::Formatter<Gfx::Color>::format(FormatBuilder& builder, Gfx::Color const& value)
|
||||
ErrorOr<void> AK::Formatter<Gfx::Color>::format(FormatBuilder& builder, Gfx::Color value)
|
||||
{
|
||||
return Formatter<StringView>::format(builder, value.to_deprecated_string());
|
||||
}
|
||||
|
|
|
@ -236,9 +236,9 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
Color mixed_with(Color const& other, float weight) const;
|
||||
Color mixed_with(Color other, float weight) const;
|
||||
|
||||
Color interpolate(Color const& other, float weight) const noexcept
|
||||
Color interpolate(Color other, float weight) const noexcept
|
||||
{
|
||||
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);
|
||||
|
@ -247,7 +247,7 @@ public:
|
|||
return Color(r, g, b, a);
|
||||
}
|
||||
|
||||
constexpr Color multiply(Color const& other) const
|
||||
constexpr Color multiply(Color other) const
|
||||
{
|
||||
return Color(
|
||||
red() * other.red() / 255,
|
||||
|
@ -256,7 +256,7 @@ public:
|
|||
alpha() * other.alpha() / 255);
|
||||
}
|
||||
|
||||
constexpr float distance_squared_to(Color const& other) const
|
||||
constexpr float distance_squared_to(Color other) const
|
||||
{
|
||||
int delta_red = other.red() - red();
|
||||
int delta_green = other.green() - green();
|
||||
|
@ -271,7 +271,7 @@ public:
|
|||
return (red() * 0.2126f + green() * 0.7152f + blue() * 0.0722f);
|
||||
}
|
||||
|
||||
constexpr float contrast_ratio(Color const& other)
|
||||
constexpr float contrast_ratio(Color other)
|
||||
{
|
||||
auto l1 = luminosity();
|
||||
auto l2 = other.luminosity();
|
||||
|
@ -340,14 +340,14 @@ public:
|
|||
return Color(~red(), ~green(), ~blue(), alpha());
|
||||
}
|
||||
|
||||
constexpr Color xored(Color const& other) const
|
||||
constexpr Color xored(Color other) const
|
||||
{
|
||||
return Color(((other.m_value ^ m_value) & 0x00ffffff) | (m_value & 0xff000000));
|
||||
}
|
||||
|
||||
constexpr ARGB32 value() const { return m_value; }
|
||||
|
||||
constexpr bool operator==(Color const& other) const
|
||||
constexpr bool operator==(Color other) const
|
||||
{
|
||||
return m_value == other.m_value;
|
||||
}
|
||||
|
@ -566,7 +566,7 @@ namespace AK {
|
|||
|
||||
template<>
|
||||
struct Formatter<Gfx::Color> : public Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder&, Gfx::Color const&);
|
||||
ErrorOr<void> format(FormatBuilder&, Gfx::Color);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1856,7 +1856,7 @@ ErrorOr<NonnullRefPtr<Bitmap>> Painter::get_region_bitmap(IntRect const& region,
|
|||
return m_target->cropped(bitmap_region, format);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void Painter::set_physical_pixel_with_draw_op(u32& pixel, Color const& color)
|
||||
ALWAYS_INLINE void Painter::set_physical_pixel_with_draw_op(u32& pixel, Color color)
|
||||
{
|
||||
// This always sets a single physical pixel, independent of scale().
|
||||
// This should only be called by routines that already handle scale.
|
||||
|
@ -1874,7 +1874,7 @@ ALWAYS_INLINE void Painter::set_physical_pixel_with_draw_op(u32& pixel, Color co
|
|||
}
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void Painter::fill_physical_scanline_with_draw_op(int y, int x, int width, Color const& color)
|
||||
ALWAYS_INLINE void Painter::fill_physical_scanline_with_draw_op(int y, int x, int width, Color color)
|
||||
{
|
||||
// This always draws a single physical scanline, independent of scale().
|
||||
// This should only be called by routines that already handle scale.
|
||||
|
|
|
@ -163,8 +163,8 @@ public:
|
|||
protected:
|
||||
IntRect to_physical(IntRect const& r) const { return r.translated(translation()) * scale(); }
|
||||
IntPoint to_physical(IntPoint const& p) const { return p.translated(translation()) * scale(); }
|
||||
void set_physical_pixel_with_draw_op(u32& pixel, Color const&);
|
||||
void fill_physical_scanline_with_draw_op(int y, int x, int width, Color const& color);
|
||||
void set_physical_pixel_with_draw_op(u32& pixel, Color);
|
||||
void fill_physical_scanline_with_draw_op(int y, int x, int width, Color color);
|
||||
void fill_rect_with_draw_op(IntRect const&, Color);
|
||||
void blit_with_opacity(IntPoint const&, Gfx::Bitmap const&, IntRect const& src_rect, float opacity, bool apply_alpha = true);
|
||||
void draw_physical_pixel(IntPoint const&, Color, int thickness = 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue