mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
canvas: Make 2D context state creation failable and use dom_canvas_backend
pref for backend selection (#38310)
Before script just crashed in those cases because IPCSender was dropped, now we send `None` to tell script about the failure and fail getContext or registerPainter accordingly. This PR also unifies `dom_canvas_{backends}_enabled` prefs into `dom_canvas_backend` which is more flexible in multi-backends scenarios. Reviewable per commit. Testing: Added servo specific WPT test. --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
93d234d270
commit
ae69646371
17 changed files with 116 additions and 61 deletions
|
@ -221,7 +221,7 @@ pub(crate) struct CanvasState {
|
|||
}
|
||||
|
||||
impl CanvasState {
|
||||
pub(crate) fn new(global: &GlobalScope, size: Size2D<u64>) -> CanvasState {
|
||||
pub(crate) fn new(global: &GlobalScope, size: Size2D<u64>) -> Option<CanvasState> {
|
||||
debug!("Creating new canvas rendering context.");
|
||||
let (sender, receiver) =
|
||||
profiled_ipc::channel(global.time_profiler_chan().clone()).unwrap();
|
||||
|
@ -233,7 +233,7 @@ impl CanvasState {
|
|||
size, sender,
|
||||
))
|
||||
.unwrap();
|
||||
let (ipc_renderer, canvas_id, image_key) = receiver.recv().unwrap();
|
||||
let (ipc_renderer, canvas_id, image_key) = receiver.recv().ok()??;
|
||||
debug!("Done.");
|
||||
// Worklets always receive a unique origin. This messes with fetching
|
||||
// cached images in the case of paint worklets, since the image cache
|
||||
|
@ -243,7 +243,7 @@ impl CanvasState {
|
|||
} else {
|
||||
global.origin().immutable().clone()
|
||||
};
|
||||
CanvasState {
|
||||
Some(CanvasState {
|
||||
ipc_renderer,
|
||||
canvas_id,
|
||||
size: Cell::new(size),
|
||||
|
@ -256,7 +256,7 @@ impl CanvasState {
|
|||
image_key,
|
||||
origin,
|
||||
current_default_path: DomRefCell::new(Path::new()),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn get_ipc_renderer(&self) -> &IpcSender<CanvasMsg> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue