canvas: Make GetImageData simple and only IPC message to obtain pixels (#38274)

Currently we had `GetImageData` and `SendPixels` to obtain pixels from
script thread. This PR unifies those into single `GetImageData` that
does not need canvas size and has optional rect (for obtaining sub
image).

Testing: Existing WPT tests

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
sagudev 2025-07-26 04:28:52 +02:00 committed by GitHub
parent 77f85f390e
commit 8b2a5fca54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 26 additions and 63 deletions

View file

@ -449,7 +449,6 @@ pub struct TextOptions {
#[derive(Debug, Deserialize, Serialize)]
pub enum CanvasMsg {
Canvas2d(Canvas2dMsg, CanvasId),
FromScript(FromScriptMsg, CanvasId),
Recreate(Option<Size2D<u64>>, CanvasId),
Close(CanvasId),
}
@ -475,7 +474,6 @@ pub enum Canvas2dMsg {
),
DrawImageInOther(
CanvasId,
Size2D<u32>,
Rect<f64>,
Rect<f64>,
bool,
@ -512,7 +510,7 @@ pub enum Canvas2dMsg {
CompositionOptions,
Transform2D<f32>,
),
GetImageData(Rect<u32>, Size2D<u32>, IpcSender<IpcSnapshot>),
GetImageData(Option<Rect<u32>>, IpcSender<IpcSnapshot>),
MeasureText(String, IpcSender<TextMetrics>, TextOptions),
PutImageData(Rect<u32>, IpcSnapshot),
StrokeRect(
@ -534,11 +532,6 @@ pub enum Canvas2dMsg {
UpdateImage(IpcSender<()>),
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum FromScriptMsg {
SendPixels(IpcSender<IpcSnapshot>),
}
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
pub struct CanvasGradientStop {
pub offset: f64,