diff --git a/Userland/Libraries/LibGfx/Filters/StackBlurFilter.cpp b/Userland/Libraries/LibGfx/Filters/StackBlurFilter.cpp index 785b9dc134e..c7ff7885cdb 100644 --- a/Userland/Libraries/LibGfx/Filters/StackBlurFilter.cpp +++ b/Userland/Libraries/LibGfx/Filters/StackBlurFilter.cpp @@ -96,14 +96,14 @@ private: // This is an implementation of StackBlur by Mario Klingemann (https://observablehq.com/@jobleonard/mario-klingemans-stackblur) // (Link is to a secondary source as the original site is now down) -FLATTEN void StackBlurFilter::process_rgba(u8 radius) +FLATTEN void StackBlurFilter::process_rgba(u8 radius, Color fill_color) { // TODO: Implement a plain RGB version of this (if required) if (radius == 0) return; - constexpr auto transparent_white = Color(Color::White).with_alpha(0); + fill_color = fill_color.with_alpha(0); uint width = m_bitmap.width(); uint height = m_bitmap.height(); @@ -115,7 +115,7 @@ FLATTEN void StackBlurFilter::process_rgba(u8 radius) auto get_pixel = [&](int x, int y) { auto color = m_bitmap.get_pixel(x, y); if (color.alpha() == 0) - return transparent_white; + return fill_color; return color; }; @@ -179,7 +179,7 @@ FLATTEN void StackBlurFilter::process_rgba(u8 radius) if (alpha != 0) set_pixel(x, y, Color((red_sum * sum_mult) >> sum_shift, (green_sum * sum_mult) >> sum_shift, (blue_sum * sum_mult) >> sum_shift, alpha)); else - set_pixel(x, y, transparent_white); + set_pixel(x, y, fill_color); red_sum -= red_out_sum; green_sum -= green_out_sum; @@ -266,7 +266,7 @@ FLATTEN void StackBlurFilter::process_rgba(u8 radius) if (alpha != 0) set_pixel(x, y, Color((red_sum * sum_mult) >> sum_shift, (green_sum * sum_mult) >> sum_shift, (blue_sum * sum_mult) >> sum_shift, alpha)); else - set_pixel(x, y, transparent_white); + set_pixel(x, y, fill_color); red_sum -= red_out_sum; green_sum -= green_out_sum; diff --git a/Userland/Libraries/LibGfx/Filters/StackBlurFilter.h b/Userland/Libraries/LibGfx/Filters/StackBlurFilter.h index 12381d38099..d6cedbbb1c2 100644 --- a/Userland/Libraries/LibGfx/Filters/StackBlurFilter.h +++ b/Userland/Libraries/LibGfx/Filters/StackBlurFilter.h @@ -18,7 +18,7 @@ public: } // Note: The radius is a u8 for reason! This implementation can only handle radii from 0 to 255. - void process_rgba(u8 radius); + void process_rgba(u8 radius, Color fill_color = Color::NamedColor::White); private: Bitmap& m_bitmap; diff --git a/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp b/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp index b4bc87d257b..ad3b91f07b0 100644 --- a/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp @@ -147,7 +147,7 @@ void paint_box_shadow(PaintContext& context, Gfx::IntRect const& content_rect, B aa_corner_painter.fill_rect_with_rounded_corners(shadow_bitmap_rect.shrunken(double_radius, double_radius, double_radius, double_radius), box_shadow_data.color, top_left_shadow_corner, top_right_shadow_corner, bottom_right_shadow_corner, bottom_left_shadow_corner); Gfx::StackBlurFilter filter(*shadow_bitmap); - filter.process_rgba(box_shadow_data.blur_radius); + filter.process_rgba(box_shadow_data.blur_radius, box_shadow_data.color); auto paint_shadow_infill = [&] { if (!border_radii.has_any_radius()) @@ -342,7 +342,7 @@ void paint_text_shadow(PaintContext& context, Layout::LineBoxFragment const& fra // Blur Gfx::StackBlurFilter filter(*shadow_bitmap); - filter.process_rgba(layer.blur_radius); + filter.process_rgba(layer.blur_radius, layer.color); auto draw_rect = Gfx::enclosing_int_rect(fragment.absolute_rect()); Gfx::IntPoint draw_location {