LibWeb: Implement <feComposite> SVG filter

This commit is contained in:
Tim Ledbetter 2025-08-06 13:27:50 +01:00 committed by Tim Ledbetter
parent bbfc3a0f5e
commit a00e7cb20b
Notes: github-actions[bot] 2025-09-30 21:34:29 +00:00
15 changed files with 303 additions and 0 deletions

View file

@ -9,6 +9,7 @@
#include <LibGfx/SkiaUtils.h>
#include <core/SkBlendMode.h>
#include <core/SkColorFilter.h>
#include <core/SkScalar.h>
#include <effects/SkColorMatrix.h>
#include <effects/SkImageFilters.h>
@ -41,6 +42,16 @@ FilterImpl const& Filter::impl() const
return *m_impl;
}
Filter Filter::arithmetic(Optional<Filter const&> background, Optional<Filter const&> foreground, float k1, float k2, float k3, float k4)
{
sk_sp<SkImageFilter> background_skia = background.has_value() ? background->m_impl->filter : nullptr;
sk_sp<SkImageFilter> foreground_skia = foreground.has_value() ? foreground->m_impl->filter : nullptr;
auto filter = SkImageFilters::Arithmetic(
SkFloatToScalar(k1), SkFloatToScalar(k2), SkFloatToScalar(k3), SkFloatToScalar(k4), false, move(background_skia), move(foreground_skia));
return Filter(Impl::create(filter));
}
Filter Filter::compose(Filter const& outer, Filter const& inner)
{
auto inner_skia = inner.m_impl->filter;