1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-03 05:32:13 +00:00

LibWeb: Make CSS background image painting respect destination origin and transparency

It was previously using draw_tiled_bitmap, which always aligns the
tiles with the global origin and does not respect the alpha of the
source. Switch to a new Painter::blit_tiled helper which uses
Painter::blit under the hood, which has more correct behavior.
This commit is contained in:
Mihai Parparita 2021-03-05 16:42:50 -08:00 committed by Andreas Kling
parent e97865e982
commit c2f3d3afe1
3 changed files with 28 additions and 4 deletions

View file

@ -46,10 +46,11 @@ void Box::paint(PaintContext& context, PaintPhase phase)
auto padded_rect = this->padded_rect();
if (phase == PaintPhase::Background && !is_body()) {
context.painter().fill_rect(enclosing_int_rect(padded_rect), computed_values().background_color());
if (background_image() && background_image()->bitmap())
context.painter().draw_tiled_bitmap(enclosing_int_rect(padded_rect), *background_image()->bitmap());
auto background_rect = enclosing_int_rect(padded_rect);
context.painter().fill_rect(background_rect, computed_values().background_color());
if (background_image() && background_image()->bitmap()) {
context.painter().blit_tiled(background_rect, *background_image()->bitmap(), background_image()->bitmap()->rect());
}
}
if (phase == PaintPhase::Border) {