mirror of
https://github.com/RGBCube/serenity
synced 2025-07-29 08:57:47 +00:00
LibWeb+LibGfx: Allow filling with a paint style and opacity
This commit is contained in:
parent
8bd68198d6
commit
eb4a58528e
8 changed files with 32 additions and 12 deletions
|
@ -34,7 +34,7 @@ public:
|
|||
}
|
||||
|
||||
void fill_path(Path const&, Color, Painter::WindingRule rule = Painter::WindingRule::Nonzero);
|
||||
void fill_path(Path const&, PaintStyle const& paint_style, Painter::WindingRule rule = Painter::WindingRule::Nonzero);
|
||||
void fill_path(Path const&, PaintStyle const& paint_style, float opacity = 1.0f, Painter::WindingRule rule = Painter::WindingRule::Nonzero);
|
||||
|
||||
void stroke_path(Path const&, Color, float thickness);
|
||||
void stroke_path(Path const&, PaintStyle const& paint_style, float thickness);
|
||||
|
|
|
@ -81,10 +81,19 @@ void EdgeFlagPathRasterizer<SamplesPerPixel>::fill(Painter& painter, Path const&
|
|||
}
|
||||
|
||||
template<unsigned SamplesPerPixel>
|
||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::fill(Painter& painter, Path const& path, PaintStyle const& style, Painter::WindingRule winding_rule, FloatPoint offset)
|
||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::fill(Painter& painter, Path const& path, PaintStyle const& style, float opacity, Painter::WindingRule winding_rule, FloatPoint offset)
|
||||
{
|
||||
style.paint(enclosing_int_rect(path.bounding_box()), [&](PaintStyle::SamplerFunction sampler) {
|
||||
fill_internal(painter, path, move(sampler), winding_rule, offset);
|
||||
if (opacity == 0.0f)
|
||||
return;
|
||||
if (opacity != 1.0f) {
|
||||
return fill_internal(
|
||||
painter, path, [=, sampler = move(sampler)](IntPoint point) {
|
||||
return sampler(point).with_opacity(opacity);
|
||||
},
|
||||
winding_rule, offset);
|
||||
}
|
||||
return fill_internal(painter, path, move(sampler), winding_rule, offset);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -321,10 +330,10 @@ void Painter::fill_path(Path const& path, Color color, WindingRule winding_rule)
|
|||
rasterizer.fill(*this, path, color, winding_rule);
|
||||
}
|
||||
|
||||
void Painter::fill_path(Path const& path, PaintStyle const& paint_style, Painter::WindingRule winding_rule)
|
||||
void Painter::fill_path(Path const& path, PaintStyle const& paint_style, float opacity, Painter::WindingRule winding_rule)
|
||||
{
|
||||
EdgeFlagPathRasterizer<8> rasterizer(path_bounds(path));
|
||||
rasterizer.fill(*this, path, paint_style, winding_rule);
|
||||
rasterizer.fill(*this, path, paint_style, opacity, winding_rule);
|
||||
}
|
||||
|
||||
void AntiAliasingPainter::fill_path(Path const& path, Color color, Painter::WindingRule winding_rule)
|
||||
|
@ -333,10 +342,10 @@ void AntiAliasingPainter::fill_path(Path const& path, Color color, Painter::Wind
|
|||
rasterizer.fill(m_underlying_painter, path, color, winding_rule, m_transform.translation());
|
||||
}
|
||||
|
||||
void AntiAliasingPainter::fill_path(Path const& path, PaintStyle const& paint_style, Painter::WindingRule winding_rule)
|
||||
void AntiAliasingPainter::fill_path(Path const& path, PaintStyle const& paint_style, float opacity, Painter::WindingRule winding_rule)
|
||||
{
|
||||
EdgeFlagPathRasterizer<32> rasterizer(path_bounds(path));
|
||||
rasterizer.fill(m_underlying_painter, path, paint_style, winding_rule, m_transform.translation());
|
||||
rasterizer.fill(m_underlying_painter, path, paint_style, opacity, winding_rule, m_transform.translation());
|
||||
}
|
||||
|
||||
template class EdgeFlagPathRasterizer<8>;
|
||||
|
|
|
@ -146,7 +146,7 @@ public:
|
|||
EdgeFlagPathRasterizer(IntSize);
|
||||
|
||||
void fill(Painter&, Path const&, Color, Painter::WindingRule, FloatPoint offset = {});
|
||||
void fill(Painter&, Path const&, PaintStyle const&, Painter::WindingRule, FloatPoint offset = {});
|
||||
void fill(Painter&, Path const&, PaintStyle const&, float opacity, Painter::WindingRule, FloatPoint offset = {});
|
||||
|
||||
private:
|
||||
using SubpixelSample = Detail::Sample<SamplesPerPixel>;
|
||||
|
|
|
@ -145,7 +145,7 @@ public:
|
|||
};
|
||||
|
||||
void fill_path(Path const&, Color, WindingRule rule = WindingRule::Nonzero);
|
||||
void fill_path(Path const&, PaintStyle const& paint_style, WindingRule rule = WindingRule::Nonzero);
|
||||
void fill_path(Path const&, PaintStyle const& paint_style, float opacity = 1.0f, WindingRule rule = WindingRule::Nonzero);
|
||||
|
||||
Font const& font() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue