imagebitmap: Use snapshot::Snapshot as bitmap data (#37131)

Replace the holder of actual pixel data of the ImageBitmap interface
([[BitmapData]] slot) from Vec<u8> to snapshot::Snapshot (image bitmap
with metadata).
https://html.spec.whatwg.org/multipage/#the-imagebitmap-interface

It will allow to have all required information (e.g. size, pixel format,
alpha mode)
for further drawing processing to/from canvas2D output bitmap.

Testing: No required tests
Fixes: https://github.com/servo/servo/issues/34112

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
This commit is contained in:
Andrei Volykhin 2025-05-27 09:41:25 +03:00 committed by GitHub
parent d76b4a14df
commit 86b3b16b4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 50 additions and 47 deletions

View file

@ -2983,9 +2983,7 @@ impl GlobalScope {
}
if let Some(snapshot) = canvas.get_image_data() {
let size = snapshot.size().cast();
let image_bitmap = ImageBitmap::new(self, size.width, size.height, can_gc);
image_bitmap.set_bitmap_data(snapshot.to_vec());
let image_bitmap = ImageBitmap::new(self, snapshot, can_gc);
image_bitmap.set_origin_clean(canvas.origin_is_clean());
p.resolve_native(&(image_bitmap), can_gc);
}
@ -2999,9 +2997,7 @@ impl GlobalScope {
}
if let Some(snapshot) = canvas.get_image_data() {
let size = snapshot.size().cast();
let image_bitmap = ImageBitmap::new(self, size.width, size.height, can_gc);
image_bitmap.set_bitmap_data(snapshot.to_vec());
let image_bitmap = ImageBitmap::new(self, snapshot, can_gc);
image_bitmap.set_origin_clean(canvas.origin_is_clean());
p.resolve_native(&(image_bitmap), can_gc);
}