Commit graph

4 commits

Author SHA1 Message Date
sagudev
e1a891ea96
canvas: Use snapshot in canvas backends (#37863)
This removes assumption about pixel format from backend abstraction to
actual backend implementation. This is important for vello.

Testing: WPT tests

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-04 20:22:20 +00:00
Andrei Volykhin
6ba54e4d79
canvas: Add OffscreenCanvas 'convertToBlob' method (#37786)
Follow the HTML speficication and add missing 'convertToBlob' method
to OffscreenCanvas interface.

https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-converttoblob

Testing: Improvements in the following tests
-
html/canvas/offscreen/manual/convert-to-blob/offscreencanvas.convert.to.blob*
-
html/canvas/offscreen/manual/wide-gamut-canvas/2d.color.space.p3.convertToBlobp3.canvas.html

Fixes: #24272

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-07-04 06:58:12 +00:00
sagudev
a631b42e60
pixels: Ensure expected formats when accesing bytes of snapshot (#37767)
I introduced snapshot in #36119 to pack raw bytes and metadata together,
now we take the next step and require for user to always specify what
kind of byte data they want when calling `as_bytes` or `to_vec`
(basically joining transform and data). There are also valid usages when
one might require just one property of bytes (textures can generally
handle both RGBA and BGRA). There are also valid usages of using just
raw bytes (when cropping). This PR tries to make such usages more
obvious.

This will make it easier to fix stuff around 2d canvas (we do not want
to assume any bytes properties in abstraction).

Testing: Code is covered by WPT tests.

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-07-03 15:02:41 +00:00
Martin Robinson
309485d2db
pixels: Move Snapshot and related data structures to pixels (#37590)
1. The `shared` directory is for the "_traits" crates, which will likely
   be moved out of this directly at some point and renamed "_api". These
   crates expose the API of crates to avoid circular dependencies.
   `Snapshot` isn't really this.
2. `Snapshot` is essentially a specialied kind of `Image` so it makes
   sense that it is grouped with other image-related things in `pixels`.

Testing: This should not change any behavior so is covered by existing
tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-06-20 14:47:06 +00:00
Renamed from components/shared/snapshot/lib.rs (Browse further)