LibWeb+LibGfx: Replace usage of Gfx::PaintStyle in fill{stoke}_commands

...with a struct defined in LibWeb. This is a step towards uncoupling
LibWeb from LibGfx, so we can try third-party libraries for painting.
This commit is contained in:
Aliaksandr Kalenik 2024-06-13 15:22:46 +03:00 committed by Alexander Kalenik
commit 7a04a95c8a
Notes: sideshowbarker 2024-07-16 18:06:41 +09:00
16 changed files with 242 additions and 42 deletions

View file

@ -6,6 +6,7 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/SVGRadialGradientElementPrototype.h>
#include <LibWeb/Painting/PaintStyle.h>
#include <LibWeb/SVG/AttributeNames.h>
#include <LibWeb/SVG/SVGRadialGradientElement.h>
@ -160,7 +161,7 @@ NumberPercentage SVGRadialGradientElement::end_circle_radius_impl(HashTable<SVGG
return NumberPercentage::create_percentage(50);
}
Optional<Gfx::PaintStyle const&> SVGRadialGradientElement::to_gfx_paint_style(SVGPaintContext const& paint_context) const
Optional<Painting::PaintStyle> SVGRadialGradientElement::to_gfx_paint_style(SVGPaintContext const& paint_context) const
{
auto units = gradient_units();
Gfx::FloatPoint start_center;
@ -200,8 +201,7 @@ Optional<Gfx::PaintStyle const&> SVGRadialGradientElement::to_gfx_paint_style(SV
}
if (!m_paint_style) {
m_paint_style = Gfx::SVGRadialGradientPaintStyle::create(start_center, start_radius, end_center, end_radius)
.release_value_but_fixme_should_propagate_errors();
m_paint_style = Painting::SVGRadialGradientPaintStyle::create(start_center, start_radius, end_center, end_radius);
// FIXME: Update stops in DOM changes:
add_color_stops(*m_paint_style);
} else {
@ -211,7 +211,7 @@ Optional<Gfx::PaintStyle const&> SVGRadialGradientElement::to_gfx_paint_style(SV
m_paint_style->set_end_radius(end_radius);
}
m_paint_style->set_gradient_transform(gradient_paint_transform(paint_context));
m_paint_style->set_spread_method(to_gfx_spread_method(spread_method()));
m_paint_style->set_spread_method(to_painting_spread_method(spread_method()));
return *m_paint_style;
}