canvas: Update the image as part of update the rendering (#35996)

* Create `update_rendering` in `CanvasState` instead of manually updating in layout

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Mark as dirty and do flushes

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* fixup rebase

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Update components/script/dom/htmlcanvaselement.rs

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
sagudev 2025-03-25 07:38:02 +01:00 committed by GitHub
parent ed995e61a6
commit 62737b3830
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 72 additions and 51 deletions

View file

@ -4,10 +4,8 @@
use std::cell::Cell;
use canvas_traits::canvas::{CanvasId, CanvasMsg, FromLayoutMsg};
use dom_struct::dom_struct;
use euclid::{Scale, Size2D};
use ipc_channel::ipc;
use script_bindings::reflector::Reflector;
use servo_url::ServoUrl;
use style_traits::CSSPixel;
@ -61,16 +59,9 @@ impl PaintRenderingContext2D {
)
}
pub(crate) fn get_canvas_id(&self) -> CanvasId {
self.canvas_state.get_canvas_id()
}
/// Send update to canvas paint thread and returns [`ImageKey`]
pub(crate) fn image_key(&self) -> ImageKey {
let (sender, receiver) = ipc::channel().unwrap();
let msg = CanvasMsg::FromLayout(FromLayoutMsg::UpdateImage(sender), self.get_canvas_id());
let _ = self.canvas_state.get_ipc_renderer().send(msg);
receiver.recv().unwrap();
self.canvas_state.update_rendering();
self.canvas_state.image_key()
}