Skip to content

Commit

Permalink
LibWeb: Remove wrappers for gradient painting command recording
Browse files Browse the repository at this point in the history
These were adding unnecessary indirection, whereas recording painter
could be called directly.
  • Loading branch information
kalenikaliaksandr committed Mar 3, 2024
1 parent c6b484a commit ee1d8a5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ void ConicGradientStyleValue::resolve_for_size(Layout::NodeWithStyleAndBoxModelM
void ConicGradientStyleValue::paint(PaintContext& context, DevicePixelRect const& dest_rect, CSS::ImageRendering, Vector<Gfx::Path> const& clip_paths) const
{
VERIFY(m_resolved.has_value());
Painting::paint_conic_gradient(context, dest_rect, m_resolved->data, context.rounded_device_point(m_resolved->position), clip_paths);
auto destination_rect = dest_rect.to_type<int>();
auto position = context.rounded_device_point(m_resolved->position).to_type<int>();
context.recording_painter().fill_rect_with_conic_gradient(destination_rect, m_resolved->data, position, clip_paths);
}

bool ConicGradientStyleValue::equals(StyleValue const& other) const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void LinearGradientStyleValue::resolve_for_size(Layout::NodeWithStyleAndBoxModel
void LinearGradientStyleValue::paint(PaintContext& context, DevicePixelRect const& dest_rect, CSS::ImageRendering, Vector<Gfx::Path> const& clip_paths) const
{
VERIFY(m_resolved.has_value());
Painting::paint_linear_gradient(context, dest_rect, m_resolved->data, clip_paths);
context.recording_painter().fill_rect_with_linear_gradient(dest_rect.to_type<int>(), m_resolved->data, clip_paths);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,9 @@ bool RadialGradientStyleValue::equals(StyleValue const& other) const
void RadialGradientStyleValue::paint(PaintContext& context, DevicePixelRect const& dest_rect, CSS::ImageRendering, Vector<Gfx::Path> const& clip_paths) const
{
VERIFY(m_resolved.has_value());
Painting::paint_radial_gradient(context, dest_rect, m_resolved->data,
context.rounded_device_point(m_resolved->center),
context.rounded_device_size(m_resolved->gradient_size),
clip_paths);
auto center = context.rounded_device_point(m_resolved->center).to_type<int>();
auto size = context.rounded_device_size(m_resolved->gradient_size).to_type<int>();
context.recording_painter().fill_rect_with_radial_gradient(dest_rect.to_type<int>(), m_resolved->data, center, size, clip_paths);
}

}
15 changes: 0 additions & 15 deletions Userland/Libraries/LibWeb/Painting/GradientPainting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,4 @@ RadialGradientData resolve_radial_gradient_data(Layout::NodeWithStyleAndBoxModel
return { resolved_color_stops };
}

void paint_linear_gradient(PaintContext& context, DevicePixelRect const& gradient_rect, LinearGradientData const& data, Vector<Gfx::Path> const& clip_paths)
{
context.recording_painter().fill_rect_with_linear_gradient(gradient_rect.to_type<int>(), data, clip_paths);
}

void paint_conic_gradient(PaintContext& context, DevicePixelRect const& gradient_rect, ConicGradientData const& data, DevicePixelPoint position, Vector<Gfx::Path> const& clip_paths)
{
context.recording_painter().fill_rect_with_conic_gradient(gradient_rect.to_type<int>(), data, position.to_type<int>(), clip_paths);
}

void paint_radial_gradient(PaintContext& context, DevicePixelRect const& gradient_rect, RadialGradientData const& data, DevicePixelPoint center, DevicePixelSize size, Vector<Gfx::Path> const& clip_paths)
{
context.recording_painter().fill_rect_with_radial_gradient(gradient_rect.to_type<int>(), data, center.to_type<int>(), size.to_type<int>(), clip_paths);
}

}
4 changes: 0 additions & 4 deletions Userland/Libraries/LibWeb/Painting/GradientPainting.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,4 @@ LinearGradientData resolve_linear_gradient_data(Layout::NodeWithStyleAndBoxModel
ConicGradientData resolve_conic_gradient_data(Layout::NodeWithStyleAndBoxModelMetrics const&, CSS::ConicGradientStyleValue const&);
RadialGradientData resolve_radial_gradient_data(Layout::NodeWithStyleAndBoxModelMetrics const&, CSSPixelSize, CSS::RadialGradientStyleValue const&);

void paint_linear_gradient(PaintContext&, DevicePixelRect const&, LinearGradientData const&, Vector<Gfx::Path> const& clip_paths = {});
void paint_conic_gradient(PaintContext&, DevicePixelRect const&, ConicGradientData const&, DevicePixelPoint position, Vector<Gfx::Path> const& clip_paths = {});
void paint_radial_gradient(PaintContext&, DevicePixelRect const&, RadialGradientData const&, DevicePixelPoint position, DevicePixelSize size, Vector<Gfx::Path> const& clip_paths = {});

}

0 comments on commit ee1d8a5

Please sign in to comment.