mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
LibGfx+LibWeb: Convert bitmap alpha type when creating ImmutableBitmaps
When decoding data into bitmaps, we end up with different alpha types (premultiplied vs. unpremultiplied color data). Unfortunately, Skia only seems to handle premultiplied color data well when scaling bitmaps with an alpha channel. This might be due to Skia historically only supporting premultiplied color blending, with unpremultiplied support having been added more recently. When using Skia to blend bitmaps, we need the color data to be premultiplied. ImmutableBitmap gains a new method to enforce the alpha type to be used, which is now used by SharedResourceRequest and CanvasRenderingContext2D to enforce the right alpha type. Our LibWeb tests actually had a couple of screenshot tests that exposed the graphical glitches caused by Skia; see the big smiley faces in the CSS backgrounds tests for example. The failing tests are now updated to accommodate the new behavior. Chromium and Firefox both seem to apply the same behavior; e.g. they actively decode PNGs (which are unpremultiplied in nature) to a premultiplied bitmap. Fixes #3691.
This commit is contained in:
parent
c6644c92e7
commit
bf517f9ac2
Notes:
github-actions[bot]
2025-03-22 16:50:33 +00:00
Author: https://github.com/gmta
Commit: bf517f9ac2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3705
14 changed files with 74 additions and 2 deletions
|
@ -161,7 +161,7 @@ void SharedResourceRequest::handle_successful_fetch(URL::URL const& url_string,
|
|||
Vector<AnimatedBitmapDecodedImageData::Frame> frames;
|
||||
for (auto& frame : result.frames) {
|
||||
frames.append(AnimatedBitmapDecodedImageData::Frame {
|
||||
.bitmap = Gfx::ImmutableBitmap::create(*frame.bitmap, result.color_space),
|
||||
.bitmap = Gfx::ImmutableBitmap::create(*frame.bitmap, Gfx::AlphaType::Premultiplied, result.color_space),
|
||||
.duration = static_cast<int>(frame.duration),
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue