mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 02:29:21 +00:00
LibGfx+LibWeb: Turn Gfx::Filter into a SkImageFilter wrapper
This commit is contained in:
parent
417f4edc46
commit
0fcb574041
Notes:
github-actions[bot]
2025-06-01 21:23:19 +00:00
Author: https://github.com/ananas-dev
Commit: 0fcb574041
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4692
Reviewed-by: https://github.com/kalenikaliaksandr ✅
Reviewed-by: https://github.com/konradekk
26 changed files with 412 additions and 256 deletions
|
@ -784,8 +784,8 @@ void DisplayListPlayerSkia::apply_backdrop_filter(ApplyBackdropFilter const& com
|
|||
canvas.clipRect(rect);
|
||||
ScopeGuard guard = [&] { canvas.restore(); };
|
||||
|
||||
for (auto const& filter : command.backdrop_filter) {
|
||||
auto image_filter = to_skia_image_filter(filter);
|
||||
if (command.backdrop_filter.has_value()) {
|
||||
auto image_filter = to_skia_image_filter(command.backdrop_filter.value());
|
||||
canvas.saveLayer(SkCanvas::SaveLayerRec(nullptr, nullptr, image_filter.get(), 0));
|
||||
canvas.restore();
|
||||
}
|
||||
|
@ -1036,23 +1036,9 @@ void DisplayListPlayerSkia::apply_composite_and_blending_operator(ApplyComposite
|
|||
canvas.saveLayer(nullptr, &paint);
|
||||
}
|
||||
|
||||
void DisplayListPlayerSkia::apply_filters(ApplyFilters const& command)
|
||||
void DisplayListPlayerSkia::apply_filters(ApplyFilter const& command)
|
||||
{
|
||||
if (command.filter.is_empty()) {
|
||||
return;
|
||||
}
|
||||
sk_sp<SkImageFilter> image_filter;
|
||||
auto append_filter = [&image_filter](auto new_filter) {
|
||||
if (image_filter)
|
||||
image_filter = SkImageFilters::Compose(new_filter, image_filter);
|
||||
else
|
||||
image_filter = new_filter;
|
||||
};
|
||||
|
||||
// Apply filters in order
|
||||
for (auto filter : command.filter) {
|
||||
append_filter(to_skia_image_filter(filter));
|
||||
}
|
||||
sk_sp<SkImageFilter> image_filter = to_skia_image_filter(command.filter);
|
||||
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(image_filter);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue