mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-26 09:59:43 +00:00
LibWeb: Account for paint style and global alpha when drawing shadows
This commit is contained in:
parent
553a7a9278
commit
b99c0c6a7f
Notes:
github-actions[bot]
2025-10-21 16:57:04 +00:00
Author: https://github.com/tcl3
Commit: b99c0c6a7f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6530
Reviewed-by: https://github.com/gmta ✅
15 changed files with 216 additions and 2 deletions
|
|
@ -1062,12 +1062,19 @@ void CanvasRenderingContext2D::paint_shadow_for_fill_internal(Gfx::Path const& p
|
|||
if (state.current_compositing_and_blending_operator == Gfx::CompositingAndBlendingOperator::Copy)
|
||||
return;
|
||||
|
||||
auto alpha = state.global_alpha * (state.shadow_color.alpha() / 255.0f);
|
||||
auto fill_style_color = state.fill_style.as_color();
|
||||
if (fill_style_color.has_value() && fill_style_color->alpha() > 0)
|
||||
alpha = (fill_style_color->alpha() / 255.0f) * state.global_alpha;
|
||||
if (alpha == 0.0f)
|
||||
return;
|
||||
|
||||
painter->save();
|
||||
|
||||
Gfx::AffineTransform transform;
|
||||
transform.translate(state.shadow_offset_x, state.shadow_offset_y);
|
||||
painter->set_transform(transform);
|
||||
painter->fill_path(path, state.shadow_color.with_opacity(state.global_alpha), winding_rule, state.shadow_blur, state.current_compositing_and_blending_operator);
|
||||
painter->fill_path(path, state.shadow_color.with_opacity(alpha), winding_rule, state.shadow_blur, state.current_compositing_and_blending_operator);
|
||||
|
||||
painter->restore();
|
||||
|
||||
|
|
@ -1085,12 +1092,19 @@ void CanvasRenderingContext2D::paint_shadow_for_stroke_internal(Gfx::Path const&
|
|||
if (state.current_compositing_and_blending_operator == Gfx::CompositingAndBlendingOperator::Copy)
|
||||
return;
|
||||
|
||||
auto alpha = state.global_alpha * (state.shadow_color.alpha() / 255.0f);
|
||||
auto fill_style_color = state.fill_style.as_color();
|
||||
if (fill_style_color.has_value() && fill_style_color->alpha() > 0)
|
||||
alpha = (fill_style_color->alpha() / 255.0f) * state.global_alpha;
|
||||
if (alpha == 0.0f)
|
||||
return;
|
||||
|
||||
painter->save();
|
||||
|
||||
Gfx::AffineTransform transform;
|
||||
transform.translate(state.shadow_offset_x, state.shadow_offset_y);
|
||||
painter->set_transform(transform);
|
||||
painter->stroke_path(path, state.shadow_color.with_opacity(state.global_alpha), state.line_width, state.shadow_blur, state.current_compositing_and_blending_operator);
|
||||
painter->stroke_path(path, state.shadow_color.with_opacity(alpha), state.line_width, state.shadow_blur, state.current_compositing_and_blending_operator);
|
||||
|
||||
painter->restore();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue