Do not assume OffscreenCanvasContext to be 2d (#35629)

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2025-02-24 15:06:08 +01:00 committed by GitHub
parent 6062995636
commit e887e621f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 18 deletions

View file

@ -524,13 +524,19 @@ impl CanvasState {
));
},
CanvasContext::Placeholder(ref context) => {
context.send_canvas_2d_msg(Canvas2dMsg::DrawImageInOther(
self.get_canvas_id(),
image_size,
dest_rect,
source_rect,
smoothing_enabled,
));
let Some(context) = context.context() else {
return Err(Error::InvalidState);
};
match *context {
OffscreenCanvasContext::OffscreenContext2d(ref context) => context
.send_canvas_2d_msg(Canvas2dMsg::DrawImageInOther(
self.get_canvas_id(),
image_size,
dest_rect,
source_rect,
smoothing_enabled,
)),
}
},
_ => return Err(Error::InvalidState),
}