mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 18:37:35 +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
|
@ -26,7 +26,7 @@ public:
|
|||
update();
|
||||
}
|
||||
|
||||
void set_color(Gfx::Color const& color)
|
||||
void set_color(Gfx::Color color)
|
||||
{
|
||||
m_color = color;
|
||||
update();
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
on_color_change(dialog->color());
|
||||
}
|
||||
|
||||
void set_background_color(Color const& color)
|
||||
void set_background_color(Color color)
|
||||
{
|
||||
auto pal = palette();
|
||||
pal.set_color(ColorRole::Background, color);
|
||||
|
@ -86,7 +86,7 @@ public:
|
|||
m_color = color;
|
||||
}
|
||||
|
||||
Function<void(Color const&)> on_color_change;
|
||||
Function<void(Color)> on_color_change;
|
||||
Color m_color = Color::White;
|
||||
|
||||
private:
|
||||
|
@ -103,14 +103,14 @@ PaletteWidget::PaletteWidget()
|
|||
set_fixed_height(35);
|
||||
|
||||
m_secondary_color_widget = add<SelectedColorWidget>();
|
||||
m_secondary_color_widget->on_color_change = [&](auto& color) {
|
||||
m_secondary_color_widget->on_color_change = [&](auto color) {
|
||||
set_secondary_color(color);
|
||||
};
|
||||
m_secondary_color_widget->set_relative_rect({ 0, 2, 60, 33 });
|
||||
m_secondary_color_widget->set_fill_with_background_color(true);
|
||||
|
||||
m_primary_color_widget = add<SelectedColorWidget>();
|
||||
m_primary_color_widget->on_color_change = [&](auto& color) {
|
||||
m_primary_color_widget->on_color_change = [&](auto color) {
|
||||
set_primary_color(color);
|
||||
};
|
||||
auto rect = Gfx::IntRect(0, 0, 35, 17).centered_within(m_secondary_color_widget->relative_rect());
|
||||
|
|
|
@ -84,7 +84,7 @@ Color BrushTool::color_for(GUI::MouseEvent const& event)
|
|||
return m_editor->color_for(event);
|
||||
}
|
||||
|
||||
void BrushTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point)
|
||||
void BrushTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point)
|
||||
{
|
||||
constexpr auto flow_scale = 10;
|
||||
for (int y = point.y() - size(); y < point.y() + size(); y++) {
|
||||
|
@ -103,7 +103,7 @@ void BrushTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::In
|
|||
}
|
||||
}
|
||||
|
||||
void BrushTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end)
|
||||
void BrushTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& start, Gfx::IntPoint const& end)
|
||||
{
|
||||
int length_x = end.x() - start.x();
|
||||
int length_y = end.y() - start.y();
|
||||
|
|
|
@ -46,8 +46,8 @@ protected:
|
|||
virtual StringView tool_name() const override { return "Brush Tool"sv; }
|
||||
|
||||
virtual Color color_for(GUI::MouseEvent const& event);
|
||||
virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point);
|
||||
virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end);
|
||||
virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point);
|
||||
virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& start, Gfx::IntPoint const& end);
|
||||
virtual NonnullRefPtr<Gfx::Bitmap> build_cursor();
|
||||
void refresh_editor_cursor();
|
||||
float m_scale_last_created_cursor = 0;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
namespace PixelPaint {
|
||||
|
||||
void CloneTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const&, Gfx::IntPoint const& point)
|
||||
void CloneTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color, Gfx::IntPoint const& point)
|
||||
{
|
||||
if (!m_sample_location.has_value())
|
||||
return;
|
||||
|
@ -45,7 +45,7 @@ void CloneTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const&, Gfx::IntPoint
|
|||
}
|
||||
}
|
||||
|
||||
void CloneTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end)
|
||||
void CloneTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& start, Gfx::IntPoint const& end)
|
||||
{
|
||||
if (!m_sample_location.has_value())
|
||||
return;
|
||||
|
|
|
@ -21,8 +21,8 @@ public:
|
|||
virtual bool is_overriding_alt() override { return true; }
|
||||
|
||||
protected:
|
||||
virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point) override;
|
||||
virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) override;
|
||||
virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point) override;
|
||||
virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) override;
|
||||
|
||||
virtual void on_mousedown(Layer*, MouseEvent&) override;
|
||||
virtual void on_mousemove(Layer*, MouseEvent&) override;
|
||||
|
|
|
@ -28,7 +28,7 @@ Color EraseTool::color_for(GUI::MouseEvent const&)
|
|||
return Color(255, 255, 255, 0);
|
||||
}
|
||||
|
||||
void EraseTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point)
|
||||
void EraseTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point)
|
||||
{
|
||||
if (m_draw_mode == DrawMode::Pencil) {
|
||||
int radius = size() / 2;
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual Color color_for(GUI::MouseEvent const& event) override;
|
||||
virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point) override;
|
||||
virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point) override;
|
||||
virtual NonnullRefPtr<Gfx::Bitmap> build_cursor() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -23,13 +23,13 @@ PenTool::PenTool()
|
|||
set_size(1);
|
||||
}
|
||||
|
||||
void PenTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point)
|
||||
void PenTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point)
|
||||
{
|
||||
GUI::Painter painter(bitmap);
|
||||
painter.draw_line(point, point, color, size());
|
||||
}
|
||||
|
||||
void PenTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end)
|
||||
void PenTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& start, Gfx::IntPoint const& end)
|
||||
{
|
||||
GUI::Painter painter(bitmap);
|
||||
painter.draw_line(start, end, color, size());
|
||||
|
|
|
@ -22,8 +22,8 @@ public:
|
|||
virtual GUI::Widget* get_properties_widget() override;
|
||||
|
||||
protected:
|
||||
virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point) override;
|
||||
virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) override;
|
||||
virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point) override;
|
||||
virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) override;
|
||||
|
||||
private:
|
||||
virtual StringView tool_name() const override { return "Pen Tool"sv; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue