1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:37:36 +00:00

LibWeb: Paint conic-gradient()s

This is a first pass at painting conic-gradient()s, I've yet to try to
optimize this much, but I feel like you could do better than atan2
in a loop.
This commit is contained in:
MacDue 2022-10-30 19:28:00 +01:00 committed by Linus Groh
parent 49497044de
commit fdcc73d4b1
4 changed files with 129 additions and 66 deletions

View file

@ -1976,12 +1976,17 @@ String ConicGradientStyleValue::to_string() const
return builder.to_string();
}
void ConicGradientStyleValue::resolve_for_size(Layout::Node const&, Gfx::FloatSize const&) const
void ConicGradientStyleValue::resolve_for_size(Layout::Node const& node, Gfx::FloatSize const& size) const
{
if (!m_resolved.has_value())
m_resolved = ResolvedData { Painting::resolve_conic_gradient_data(node, *this), {} };
m_resolved->position = m_position.resolved(node, Gfx::FloatRect { { 0, 0 }, size });
}
void ConicGradientStyleValue::paint(PaintContext&, Gfx::IntRect const&, CSS::ImageRendering) const
void ConicGradientStyleValue::paint(PaintContext& context, Gfx::IntRect const& dest_rect, CSS::ImageRendering) const
{
VERIFY(m_resolved.has_value());
Painting::paint_conic_gradient(context, dest_rect, m_resolved->data, m_resolved->position.to_rounded<int>());
}
bool ConicGradientStyleValue::equals(StyleValue const&) const

View file

@ -1233,6 +1233,13 @@ private:
Angle m_from_angle;
PositionValue m_position;
Vector<AngularColorStopListElement> m_color_stop_list;
struct ResolvedData {
Painting::ConicGradientData data;
Gfx::FloatPoint position;
};
mutable Optional<ResolvedData> m_resolved;
};
class LinearGradientStyleValue final : public AbstractImageStyleValue {