mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
canvas: Make OffscreenCanvas transferable (without placeholder) (#37872)
Follow the specification and make OffscreenCanvas objects are transferable, but not in case if there are a weak reference to placeholder canvas element. To handle it properly need to implement dedicated frame provider/dispatcher between canvas element (script thread) and offscreen canvas (dedicated worker thread). https://html.spec.whatwg.org/multipage/#the-offscreencanvas-interface:transferable-objects Testing: Improvements in the following tests - html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.detachedcanvas.html - html/canvas/offscreen/manual/convert-to-blob/offscreencanvas.convert.to.blob* - html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transfer* - html/infrastructure/safe-passing-of-structured-data/transfer-errors.window.js Part of #24276 Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
This commit is contained in:
parent
c3f441d7ab
commit
4054f9a5a0
17 changed files with 159 additions and 60 deletions
|
@ -28,6 +28,8 @@ pub enum Transferrable {
|
|||
ImageBitmap,
|
||||
/// The `MessagePort` interface.
|
||||
MessagePort,
|
||||
/// The `OffscreenCanvas` interface.
|
||||
OffscreenCanvas,
|
||||
/// The `ReadableStream` interface.
|
||||
ReadableStream,
|
||||
/// The `WritableStream` interface.
|
||||
|
@ -185,3 +187,12 @@ impl MessagePortImpl {
|
|||
self.state = MessagePortState::Detached;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, MallocSizeOf, Serialize)]
|
||||
/// A struct supporting the transfer of OffscreenCanvas, which loosely
|
||||
/// corresponds to the dataHolder in
|
||||
/// <https://html.spec.whatwg.org/multipage/#the-offscreencanvas-interface:offscreencanvas-16>
|
||||
pub struct TransferableOffscreenCanvas {
|
||||
pub width: u64,
|
||||
pub height: u64,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue