mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +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
Notes:
sideshowbarker
2024-07-17 03:41:39 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/bbc149ebb9 Pull-request: https://github.com/SerenityOS/serenity/pull/16344
28 changed files with 65 additions and 54 deletions
|
@ -66,6 +66,17 @@ static bool is_primitive_type(DeprecatedString const& type)
|
||||||
return type.is_one_of("u8", "i8", "u16", "i16", "u32", "i32", "u64", "i64", "bool", "double", "float", "int", "unsigned", "unsigned int");
|
return type.is_one_of("u8", "i8", "u16", "i16", "u32", "i32", "u64", "i64", "bool", "double", "float", "int", "unsigned", "unsigned int");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_simple_type(DeprecatedString const& type)
|
||||||
|
{
|
||||||
|
// Small types that it makes sense just to pass by value.
|
||||||
|
return type.is_one_of("Gfx::Color");
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool is_primitive_or_simple_type(DeprecatedString const& type)
|
||||||
|
{
|
||||||
|
return is_primitive_type(type) || is_simple_type(type);
|
||||||
|
}
|
||||||
|
|
||||||
static DeprecatedString message_name(DeprecatedString const& endpoint, DeprecatedString const& message, bool is_response)
|
static DeprecatedString message_name(DeprecatedString const& endpoint, DeprecatedString const& message, bool is_response)
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
@ -477,7 +488,7 @@ void do_message_for_proxy(SourceGenerator message_generator, Endpoint const& end
|
||||||
auto const& parameter = parameters[i];
|
auto const& parameter = parameters[i];
|
||||||
auto argument_generator = message_generator.fork();
|
auto argument_generator = message_generator.fork();
|
||||||
argument_generator.set("argument.name", parameter.name);
|
argument_generator.set("argument.name", parameter.name);
|
||||||
if (is_primitive_type(parameters[i].type))
|
if (is_primitive_or_simple_type(parameters[i].type))
|
||||||
argument_generator.append("@argument.name@");
|
argument_generator.append("@argument.name@");
|
||||||
else
|
else
|
||||||
argument_generator.append("move(@argument.name@)");
|
argument_generator.append("move(@argument.name@)");
|
||||||
|
@ -734,7 +745,7 @@ public:
|
||||||
auto make_argument_type = [](DeprecatedString const& type) {
|
auto make_argument_type = [](DeprecatedString const& type) {
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
|
||||||
bool const_ref = !is_primitive_type(type);
|
bool const_ref = !is_primitive_or_simple_type(type);
|
||||||
|
|
||||||
builder.append(type);
|
builder.append(type);
|
||||||
if (const_ref)
|
if (const_ref)
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_color(Gfx::Color const& color)
|
void set_color(Gfx::Color color)
|
||||||
{
|
{
|
||||||
m_color = color;
|
m_color = color;
|
||||||
update();
|
update();
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
on_color_change(dialog->color());
|
on_color_change(dialog->color());
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_background_color(Color const& color)
|
void set_background_color(Color color)
|
||||||
{
|
{
|
||||||
auto pal = palette();
|
auto pal = palette();
|
||||||
pal.set_color(ColorRole::Background, color);
|
pal.set_color(ColorRole::Background, color);
|
||||||
|
@ -86,7 +86,7 @@ public:
|
||||||
m_color = color;
|
m_color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
Function<void(Color const&)> on_color_change;
|
Function<void(Color)> on_color_change;
|
||||||
Color m_color = Color::White;
|
Color m_color = Color::White;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -103,14 +103,14 @@ PaletteWidget::PaletteWidget()
|
||||||
set_fixed_height(35);
|
set_fixed_height(35);
|
||||||
|
|
||||||
m_secondary_color_widget = add<SelectedColorWidget>();
|
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);
|
set_secondary_color(color);
|
||||||
};
|
};
|
||||||
m_secondary_color_widget->set_relative_rect({ 0, 2, 60, 33 });
|
m_secondary_color_widget->set_relative_rect({ 0, 2, 60, 33 });
|
||||||
m_secondary_color_widget->set_fill_with_background_color(true);
|
m_secondary_color_widget->set_fill_with_background_color(true);
|
||||||
|
|
||||||
m_primary_color_widget = add<SelectedColorWidget>();
|
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);
|
set_primary_color(color);
|
||||||
};
|
};
|
||||||
auto rect = Gfx::IntRect(0, 0, 35, 17).centered_within(m_secondary_color_widget->relative_rect());
|
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);
|
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;
|
constexpr auto flow_scale = 10;
|
||||||
for (int y = point.y() - size(); y < point.y() + size(); y++) {
|
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_x = end.x() - start.x();
|
||||||
int length_y = end.y() - start.y();
|
int length_y = end.y() - start.y();
|
||||||
|
|
|
@ -46,8 +46,8 @@ protected:
|
||||||
virtual StringView tool_name() const override { return "Brush Tool"sv; }
|
virtual StringView tool_name() const override { return "Brush Tool"sv; }
|
||||||
|
|
||||||
virtual Color color_for(GUI::MouseEvent const& event);
|
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_point(Gfx::Bitmap& bitmap, Gfx::Color 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_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& start, Gfx::IntPoint const& end);
|
||||||
virtual NonnullRefPtr<Gfx::Bitmap> build_cursor();
|
virtual NonnullRefPtr<Gfx::Bitmap> build_cursor();
|
||||||
void refresh_editor_cursor();
|
void refresh_editor_cursor();
|
||||||
float m_scale_last_created_cursor = 0;
|
float m_scale_last_created_cursor = 0;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
namespace PixelPaint {
|
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())
|
if (!m_sample_location.has_value())
|
||||||
return;
|
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())
|
if (!m_sample_location.has_value())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -21,8 +21,8 @@ public:
|
||||||
virtual bool is_overriding_alt() override { return true; }
|
virtual bool is_overriding_alt() override { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
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 void draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) 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_mousedown(Layer*, MouseEvent&) override;
|
||||||
virtual void on_mousemove(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);
|
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) {
|
if (m_draw_mode == DrawMode::Pencil) {
|
||||||
int radius = size() / 2;
|
int radius = size() / 2;
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual Color color_for(GUI::MouseEvent const& event) override;
|
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;
|
virtual NonnullRefPtr<Gfx::Bitmap> build_cursor() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -23,13 +23,13 @@ PenTool::PenTool()
|
||||||
set_size(1);
|
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);
|
GUI::Painter painter(bitmap);
|
||||||
painter.draw_line(point, point, color, size());
|
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);
|
GUI::Painter painter(bitmap);
|
||||||
painter.draw_line(start, end, color, size());
|
painter.draw_line(start, end, color, size());
|
||||||
|
|
|
@ -22,8 +22,8 @@ public:
|
||||||
virtual GUI::Widget* get_properties_widget() override;
|
virtual GUI::Widget* get_properties_widget() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
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 void draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) override;
|
virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual StringView tool_name() const override { return "Pen Tool"sv; }
|
virtual StringView tool_name() const override { return "Pen Tool"sv; }
|
||||||
|
|
|
@ -32,7 +32,7 @@ void Card::paint(GUI::Painter& painter) const
|
||||||
painter.blit(position(), bitmap, bitmap->rect());
|
painter.blit(position(), bitmap, bitmap->rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Card::clear(GUI::Painter& painter, Color const& background_color) const
|
void Card::clear(GUI::Painter& painter, Color background_color) const
|
||||||
{
|
{
|
||||||
painter.fill_rect({ old_position(), { width, height } }, background_color);
|
painter.fill_rect({ old_position(), { width, height } }, background_color);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ void Card::save_old_position()
|
||||||
m_old_position_valid = true;
|
m_old_position_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Card::clear_and_paint(GUI::Painter& painter, Color const& background_color)
|
void Card::clear_and_paint(GUI::Painter& painter, Color background_color)
|
||||||
{
|
{
|
||||||
if (is_old_position_valid())
|
if (is_old_position_valid())
|
||||||
clear(painter, background_color);
|
clear(painter, background_color);
|
||||||
|
|
|
@ -108,8 +108,8 @@ public:
|
||||||
void save_old_position();
|
void save_old_position();
|
||||||
|
|
||||||
void paint(GUI::Painter&) const;
|
void paint(GUI::Painter&) const;
|
||||||
void clear(GUI::Painter&, Color const& background_color) const;
|
void clear(GUI::Painter&, Color background_color) const;
|
||||||
void clear_and_paint(GUI::Painter& painter, Color const& background_color);
|
void clear_and_paint(GUI::Painter& painter, Color background_color);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Card(Suit, Rank);
|
Card(Suit, Rank);
|
||||||
|
|
|
@ -121,7 +121,7 @@ Gfx::Color CardGame::background_color() const
|
||||||
return palette().color(background_role());
|
return palette().color(background_role());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardGame::set_background_color(Gfx::Color const& color)
|
void CardGame::set_background_color(Gfx::Color color)
|
||||||
{
|
{
|
||||||
auto new_palette = palette();
|
auto new_palette = palette();
|
||||||
new_palette.set_color(Gfx::ColorRole::Background, color);
|
new_palette.set_color(Gfx::ColorRole::Background, color);
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
virtual ~CardGame() = default;
|
virtual ~CardGame() = default;
|
||||||
|
|
||||||
Gfx::Color background_color() const;
|
Gfx::Color background_color() const;
|
||||||
void set_background_color(Gfx::Color const&);
|
void set_background_color(Gfx::Color);
|
||||||
|
|
||||||
NonnullRefPtrVector<CardStack>& stacks() { return m_stacks; }
|
NonnullRefPtrVector<CardStack>& stacks() { return m_stacks; }
|
||||||
NonnullRefPtrVector<CardStack> const& stacks() const { return m_stacks; }
|
NonnullRefPtrVector<CardStack> const& stacks() const { return m_stacks; }
|
||||||
|
|
|
@ -32,7 +32,7 @@ void CardStack::clear()
|
||||||
m_stack_positions.clear();
|
m_stack_positions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardStack::paint(GUI::Painter& painter, Gfx::Color const& background_color)
|
void CardStack::paint(GUI::Painter& painter, Gfx::Color background_color)
|
||||||
{
|
{
|
||||||
auto draw_background_if_empty = [&]() {
|
auto draw_background_if_empty = [&]() {
|
||||||
size_t number_of_moving_cards = 0;
|
size_t number_of_moving_cards = 0;
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
|
|
||||||
bool is_allowed_to_push(Card const&, size_t stack_size = 1, MovementRule movement_rule = MovementRule::Alternating) const;
|
bool is_allowed_to_push(Card const&, size_t stack_size = 1, MovementRule movement_rule = MovementRule::Alternating) const;
|
||||||
void add_all_grabbed_cards(Gfx::IntPoint const& click_location, NonnullRefPtrVector<Card>& grabbed, MovementRule movement_rule = MovementRule::Alternating);
|
void add_all_grabbed_cards(Gfx::IntPoint const& click_location, NonnullRefPtrVector<Card>& grabbed, MovementRule movement_rule = MovementRule::Alternating);
|
||||||
void paint(GUI::Painter&, Gfx::Color const& background_color);
|
void paint(GUI::Painter&, Gfx::Color background_color);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -316,7 +316,7 @@ Optional<Color> Color::from_string(StringView string)
|
||||||
return Color(r.value(), g.value(), b.value(), a.value());
|
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)) {
|
if (alpha() == other.alpha() || with_alpha(0) == other.with_alpha(0)) {
|
||||||
return Gfx::Color {
|
return Gfx::Color {
|
||||||
|
@ -382,7 +382,7 @@ ErrorOr<void> IPC::decode(Decoder& decoder, Color& color)
|
||||||
return {};
|
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());
|
return Formatter<StringView>::format(builder, value.to_deprecated_string());
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,9 +236,9 @@ public:
|
||||||
#endif
|
#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 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);
|
u8 g = green() + round_to<u8>(static_cast<float>(other.green() - green()) * weight);
|
||||||
|
@ -247,7 +247,7 @@ public:
|
||||||
return Color(r, g, b, a);
|
return Color(r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Color multiply(Color const& other) const
|
constexpr Color multiply(Color other) const
|
||||||
{
|
{
|
||||||
return Color(
|
return Color(
|
||||||
red() * other.red() / 255,
|
red() * other.red() / 255,
|
||||||
|
@ -256,7 +256,7 @@ public:
|
||||||
alpha() * other.alpha() / 255);
|
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_red = other.red() - red();
|
||||||
int delta_green = other.green() - green();
|
int delta_green = other.green() - green();
|
||||||
|
@ -271,7 +271,7 @@ public:
|
||||||
return (red() * 0.2126f + green() * 0.7152f + blue() * 0.0722f);
|
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 l1 = luminosity();
|
||||||
auto l2 = other.luminosity();
|
auto l2 = other.luminosity();
|
||||||
|
@ -340,14 +340,14 @@ public:
|
||||||
return Color(~red(), ~green(), ~blue(), alpha());
|
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));
|
return Color(((other.m_value ^ m_value) & 0x00ffffff) | (m_value & 0xff000000));
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr ARGB32 value() const { return m_value; }
|
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;
|
return m_value == other.m_value;
|
||||||
}
|
}
|
||||||
|
@ -566,7 +566,7 @@ namespace AK {
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct Formatter<Gfx::Color> : public Formatter<StringView> {
|
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);
|
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 always sets a single physical pixel, independent of scale().
|
||||||
// This should only be called by routines that already handle 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 always draws a single physical scanline, independent of scale().
|
||||||
// This should only be called by routines that already handle scale.
|
// This should only be called by routines that already handle scale.
|
||||||
|
|
|
@ -163,8 +163,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
IntRect to_physical(IntRect const& r) const { return r.translated(translation()) * scale(); }
|
IntRect to_physical(IntRect const& r) const { return r.translated(translation()) * scale(); }
|
||||||
IntPoint to_physical(IntPoint const& p) const { return p.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 set_physical_pixel_with_draw_op(u32& pixel, Color);
|
||||||
void fill_physical_scanline_with_draw_op(int y, int x, int width, Color const& 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 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 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);
|
void draw_physical_pixel(IntPoint const&, Color, int thickness = 1);
|
||||||
|
|
|
@ -327,13 +327,13 @@ public:
|
||||||
void set_font_size(float font_size) { m_inherited.font_size = font_size; }
|
void set_font_size(float font_size) { m_inherited.font_size = font_size; }
|
||||||
void set_font_weight(int font_weight) { m_inherited.font_weight = font_weight; }
|
void set_font_weight(int font_weight) { m_inherited.font_weight = font_weight; }
|
||||||
void set_font_variant(CSS::FontVariant font_variant) { m_inherited.font_variant = font_variant; }
|
void set_font_variant(CSS::FontVariant font_variant) { m_inherited.font_variant = font_variant; }
|
||||||
void set_color(Color const& color) { m_inherited.color = color; }
|
void set_color(Color color) { m_inherited.color = color; }
|
||||||
void set_clip(CSS::Clip const& clip) { m_noninherited.clip = clip; }
|
void set_clip(CSS::Clip const& clip) { m_noninherited.clip = clip; }
|
||||||
void set_content(ContentData const& content) { m_noninherited.content = content; }
|
void set_content(ContentData const& content) { m_noninherited.content = content; }
|
||||||
void set_cursor(CSS::Cursor cursor) { m_inherited.cursor = cursor; }
|
void set_cursor(CSS::Cursor cursor) { m_inherited.cursor = cursor; }
|
||||||
void set_image_rendering(CSS::ImageRendering value) { m_inherited.image_rendering = value; }
|
void set_image_rendering(CSS::ImageRendering value) { m_inherited.image_rendering = value; }
|
||||||
void set_pointer_events(CSS::PointerEvents value) { m_inherited.pointer_events = value; }
|
void set_pointer_events(CSS::PointerEvents value) { m_inherited.pointer_events = value; }
|
||||||
void set_background_color(Color const& color) { m_noninherited.background_color = color; }
|
void set_background_color(Color color) { m_noninherited.background_color = color; }
|
||||||
void set_background_layers(Vector<BackgroundLayerData>&& layers) { m_noninherited.background_layers = move(layers); }
|
void set_background_layers(Vector<BackgroundLayerData>&& layers) { m_noninherited.background_layers = move(layers); }
|
||||||
void set_float(CSS::Float value) { m_noninherited.float_ = value; }
|
void set_float(CSS::Float value) { m_noninherited.float_ = value; }
|
||||||
void set_clear(CSS::Clear value) { m_noninherited.clear = value; }
|
void set_clear(CSS::Clear value) { m_noninherited.clear = value; }
|
||||||
|
|
|
@ -1642,13 +1642,13 @@ private:
|
||||||
class ShadowStyleValue final : public StyleValue {
|
class ShadowStyleValue final : public StyleValue {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<ShadowStyleValue>
|
static NonnullRefPtr<ShadowStyleValue>
|
||||||
create(Color const& color, Length const& offset_x, Length const& offset_y, Length const& blur_radius, Length const& spread_distance, ShadowPlacement placement)
|
create(Color color, Length const& offset_x, Length const& offset_y, Length const& blur_radius, Length const& spread_distance, ShadowPlacement placement)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new ShadowStyleValue(color, offset_x, offset_y, blur_radius, spread_distance, placement));
|
return adopt_ref(*new ShadowStyleValue(color, offset_x, offset_y, blur_radius, spread_distance, placement));
|
||||||
}
|
}
|
||||||
virtual ~ShadowStyleValue() override = default;
|
virtual ~ShadowStyleValue() override = default;
|
||||||
|
|
||||||
Color const& color() const { return m_color; }
|
Color color() const { return m_color; }
|
||||||
Length const& offset_x() const { return m_offset_x; }
|
Length const& offset_x() const { return m_offset_x; }
|
||||||
Length const& offset_y() const { return m_offset_y; }
|
Length const& offset_y() const { return m_offset_y; }
|
||||||
Length const& blur_radius() const { return m_blur_radius; }
|
Length const& blur_radius() const { return m_blur_radius; }
|
||||||
|
@ -1659,7 +1659,7 @@ public:
|
||||||
virtual bool equals(StyleValue const& other) const override;
|
virtual bool equals(StyleValue const& other) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ShadowStyleValue(Color const& color, Length const& offset_x, Length const& offset_y, Length const& blur_radius, Length const& spread_distance, ShadowPlacement placement)
|
explicit ShadowStyleValue(Color color, Length const& offset_x, Length const& offset_y, Length const& blur_radius, Length const& spread_distance, ShadowPlacement placement)
|
||||||
: StyleValue(Type::Shadow)
|
: StyleValue(Type::Shadow)
|
||||||
, m_color(color)
|
, m_color(color)
|
||||||
, m_offset_x(offset_x)
|
, m_offset_x(offset_x)
|
||||||
|
|
|
@ -20,8 +20,8 @@ public:
|
||||||
m_states.append(State());
|
m_states.append(State());
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::Color const& fill_color() const { return state().fill_color; }
|
Gfx::Color fill_color() const { return state().fill_color; }
|
||||||
Gfx::Color const& stroke_color() const { return state().stroke_color; }
|
Gfx::Color stroke_color() const { return state().stroke_color; }
|
||||||
float stroke_width() const { return state().stroke_width; }
|
float stroke_width() const { return state().stroke_width; }
|
||||||
|
|
||||||
void set_fill_color(Gfx::Color color) { state().fill_color = color; }
|
void set_fill_color(Gfx::Color color) { state().fill_color = color; }
|
||||||
|
|
|
@ -912,7 +912,7 @@ Messages::WindowServer::GetCursorHighlightRadiusResponse ConnectionFromClient::g
|
||||||
return WindowManager::the().cursor_highlight_radius();
|
return WindowManager::the().cursor_highlight_radius();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionFromClient::set_cursor_highlight_color(Gfx::Color const& color)
|
void ConnectionFromClient::set_cursor_highlight_color(Gfx::Color color)
|
||||||
{
|
{
|
||||||
WindowManager::the().set_cursor_highlight_color(color);
|
WindowManager::the().set_cursor_highlight_color(color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ private:
|
||||||
virtual void apply_cursor_theme(DeprecatedString const&) override;
|
virtual void apply_cursor_theme(DeprecatedString const&) override;
|
||||||
virtual void set_cursor_highlight_radius(int radius) override;
|
virtual void set_cursor_highlight_radius(int radius) override;
|
||||||
virtual Messages::WindowServer::GetCursorHighlightRadiusResponse get_cursor_highlight_radius() override;
|
virtual Messages::WindowServer::GetCursorHighlightRadiusResponse get_cursor_highlight_radius() override;
|
||||||
virtual void set_cursor_highlight_color(Gfx::Color const& color) override;
|
virtual void set_cursor_highlight_color(Gfx::Color color) override;
|
||||||
virtual Messages::WindowServer::GetCursorHighlightColorResponse get_cursor_highlight_color() override;
|
virtual Messages::WindowServer::GetCursorHighlightColorResponse get_cursor_highlight_color() override;
|
||||||
virtual Messages::WindowServer::GetCursorThemeResponse get_cursor_theme() override;
|
virtual Messages::WindowServer::GetCursorThemeResponse get_cursor_theme() override;
|
||||||
virtual Messages::WindowServer::SetSystemFontsResponse set_system_fonts(DeprecatedString const&, DeprecatedString const&, DeprecatedString const&) override;
|
virtual Messages::WindowServer::SetSystemFontsResponse set_system_fonts(DeprecatedString const&, DeprecatedString const&, DeprecatedString const&) override;
|
||||||
|
|
|
@ -2277,7 +2277,7 @@ void WindowManager::set_cursor_highlight_radius(int radius)
|
||||||
sync_config_to_disk();
|
sync_config_to_disk();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::set_cursor_highlight_color(Gfx::Color const& color)
|
void WindowManager::set_cursor_highlight_color(Gfx::Color color)
|
||||||
{
|
{
|
||||||
m_cursor_highlight_color = color;
|
m_cursor_highlight_color = color;
|
||||||
Compositor::the().invalidate_cursor();
|
Compositor::the().invalidate_cursor();
|
||||||
|
|
|
@ -320,7 +320,7 @@ public:
|
||||||
void apply_cursor_theme(DeprecatedString const& name);
|
void apply_cursor_theme(DeprecatedString const& name);
|
||||||
|
|
||||||
void set_cursor_highlight_radius(int radius);
|
void set_cursor_highlight_radius(int radius);
|
||||||
void set_cursor_highlight_color(Gfx::Color const& color);
|
void set_cursor_highlight_color(Gfx::Color color);
|
||||||
|
|
||||||
bool is_cursor_highlight_enabled() const { return m_cursor_highlight_radius > 0 && m_cursor_highlight_enabled; }
|
bool is_cursor_highlight_enabled() const { return m_cursor_highlight_radius > 0 && m_cursor_highlight_enabled; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue