script: Always provide canvas epoch on update_rendering (#39024)

We never not provided it.

Testing: Existing tests.

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Sam 2025-08-29 18:30:47 +02:00 committed by GitHub
parent b44b461a76
commit 95adb6f673
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 11 deletions

View file

@ -70,9 +70,9 @@ pub(crate) trait CanvasContext {
/// The WebRender [`ImageKey`] of this [`CanvasContext`] if any.
fn image_key(&self) -> Option<ImageKey>;
/// Request that the [`CanvasContext`] update the rendering of its contents, returning
/// the new [`Epoch`] of the image produced, if one was.
fn update_rendering(&self, _canvas_epoch: Option<Epoch>) -> bool {
/// Request that the [`CanvasContext`] update the rendering of its contents,
/// returning `true` if new image was produced.
fn update_rendering(&self, _canvas_epoch: Epoch) -> bool {
false
}
@ -250,7 +250,7 @@ impl CanvasContext for RenderingContext {
}
}
fn update_rendering(&self, canvas_epoch: Option<Epoch>) -> bool {
fn update_rendering(&self, canvas_epoch: Epoch) -> bool {
match self {
RenderingContext::Placeholder(offscreen_canvas) => offscreen_canvas
.context()
@ -357,7 +357,7 @@ impl CanvasContext for OffscreenRenderingContext {
None
}
fn update_rendering(&self, canvas_epoch: Option<Epoch>) -> bool {
fn update_rendering(&self, canvas_epoch: Epoch) -> bool {
match self {
OffscreenRenderingContext::Context2d(context) => context.update_rendering(canvas_epoch),
OffscreenRenderingContext::BitmapRenderer(context) => {

View file

@ -123,11 +123,11 @@ impl CanvasContext for CanvasRenderingContext2D {
Some(self.canvas.clone())
}
fn update_rendering(&self, canvas_epoch: Option<Epoch>) -> bool {
fn update_rendering(&self, canvas_epoch: Epoch) -> bool {
if !self.onscreen() {
return false;
}
self.canvas_state.update_rendering(canvas_epoch)
self.canvas_state.update_rendering(Some(canvas_epoch))
}
fn resize(&self) {

View file

@ -2690,7 +2690,7 @@ impl Document {
.borrow_mut()
.iter()
.filter_map(|(_, context)| context.root())
.filter(|context| context.update_rendering(Some(canvas_epoch)))
.filter(|context| context.update_rendering(canvas_epoch))
.map(|context| context.image_key()),
);
@ -2698,7 +2698,7 @@ impl Document {
self.dirty_2d_contexts
.borrow_mut()
.drain()
.filter(|(_, context)| context.update_rendering(Some(canvas_epoch)))
.filter(|(_, context)| context.update_rendering(canvas_epoch))
.map(|(_, context)| context.image_key()),
);

View file

@ -278,13 +278,13 @@ impl CanvasContext for GPUCanvasContext {
}
/// <https://gpuweb.github.io/gpuweb/#abstract-opdef-updating-the-rendering-of-a-webgpu-canvas>
fn update_rendering(&self, canvas_epoch: Option<Epoch>) -> bool {
fn update_rendering(&self, canvas_epoch: Epoch) -> bool {
if !self.onscreen() {
return false;
}
// Step 1: Expire the current texture of context.
self.expire_current_texture(canvas_epoch)
self.expire_current_texture(Some(canvas_epoch))
// Step 2: Set context.[[lastPresentedImage]] to context.[[drawingBuffer]].
// TODO: Implement this.
}