Add unique canvas IDs to all canvas operations.

This commit is contained in:
Brody Eastwood 2018-03-20 15:04:15 -04:00 committed by Brody-Eastwood
parent a69eceefc9
commit 8a1590efc6
13 changed files with 334 additions and 155 deletions

View file

@ -95,6 +95,7 @@ use browsingcontext::{BrowsingContext, SessionHistoryChange, SessionHistoryEntry
use browsingcontext::{FullyActiveBrowsingContextsIterator, AllBrowsingContextsIterator};
use canvas::canvas_paint_thread::CanvasPaintThread;
use canvas::webgl_thread::WebGLThreads;
use canvas_traits::canvas::CanvasId;
use canvas_traits::canvas::CanvasMsg;
use clipboard::{ClipboardContext, ClipboardProvider};
use compositing::SendableFrameTree;
@ -329,6 +330,9 @@ pub struct Constellation<Message, LTF, STF> {
/// A channel through which messages can be sent to the webvr thread.
webvr_chan: Option<IpcSender<WebVRMsg>>,
/// An Id for the next canvas to use.
canvas_id: CanvasId,
}
/// State needed to construct a constellation.
@ -626,6 +630,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}),
webgl_threads: state.webgl_threads,
webvr_chan: state.webvr_chan,
canvas_id: CanvasId(0),
};
constellation.run();
@ -2203,11 +2208,12 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
fn handle_create_canvas_paint_thread_msg(
&mut self,
size: &Size2D<i32>,
response_sender: IpcSender<IpcSender<CanvasMsg>>) {
response_sender: IpcSender<(IpcSender<CanvasMsg>, CanvasId)>) {
self.canvas_id.0 += 1;
let webrender_api = self.webrender_api_sender.clone();
let sender = CanvasPaintThread::start(*size, webrender_api,
opts::get().enable_canvas_antialiasing);
if let Err(e) = response_sender.send(sender) {
opts::get().enable_canvas_antialiasing, self.canvas_id.clone());
if let Err(e) = response_sender.send((sender, self.canvas_id.clone())) {
warn!("Create canvas paint thread response failed ({})", e);
}
}