mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Changes for sender reciever
This commit is contained in:
parent
30cc087526
commit
1de8ddd89c
7 changed files with 34 additions and 13 deletions
|
@ -176,7 +176,7 @@ pub struct CanvasData<'a> {
|
||||||
|
|
||||||
impl<'a> CanvasData<'a> {
|
impl<'a> CanvasData<'a> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
size: Size2D<u32>,
|
size: Size2D<u64>,
|
||||||
webrender_api_sender: webrender_api::RenderApiSender,
|
webrender_api_sender: webrender_api::RenderApiSender,
|
||||||
antialias: AntialiasMode,
|
antialias: AntialiasMode,
|
||||||
canvas_id: CanvasId,
|
canvas_id: CanvasId,
|
||||||
|
@ -708,13 +708,13 @@ impl<'a> CanvasData<'a> {
|
||||||
.set_composition_op(op.to_azure_style());
|
.set_composition_op(op.to_azure_style());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(size: Size2D<u32>) -> DrawTarget {
|
pub fn create(size: Size2D<u64>) -> DrawTarget {
|
||||||
// FIXME(nox): Why is the size made of i32 values?
|
// FIXME(nox): Why is the size made of i32 values?
|
||||||
DrawTarget::new(BackendType::Skia, size.to_i32(), SurfaceFormat::B8G8R8A8)
|
DrawTarget::new(BackendType::Skia, size.to_i32(), SurfaceFormat::B8G8R8A8)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn recreate(&mut self, size: Size2D<u32>) {
|
pub fn recreate(&mut self, size: Size2D<u32>) {
|
||||||
self.drawtarget = CanvasData::create(size);
|
self.drawtarget = CanvasData::create(Size2D::new(size.width as u64, size.height as u64));
|
||||||
self.state = CanvasPaintState::new(self.state.draw_options.antialias);
|
self.state = CanvasPaintState::new(self.state.draw_options.antialias);
|
||||||
self.saved_states.clear();
|
self.saved_states.clear();
|
||||||
// Webrender doesn't let images change size, so we clear the webrender image key.
|
// Webrender doesn't let images change size, so we clear the webrender image key.
|
||||||
|
|
|
@ -77,7 +77,7 @@ impl<'a> CanvasPaintThread<'a> {
|
||||||
|
|
||||||
pub fn create_canvas(
|
pub fn create_canvas(
|
||||||
&mut self,
|
&mut self,
|
||||||
size: Size2D<u32>,
|
size: Size2D<u64>,
|
||||||
webrender_api_sender: webrender_api::RenderApiSender,
|
webrender_api_sender: webrender_api::RenderApiSender,
|
||||||
antialias: bool,
|
antialias: bool,
|
||||||
) -> CanvasId {
|
) -> CanvasId {
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub enum CanvasMsg {
|
||||||
Canvas2d(Canvas2dMsg, CanvasId),
|
Canvas2d(Canvas2dMsg, CanvasId),
|
||||||
Create(
|
Create(
|
||||||
IpcSender<CanvasId>,
|
IpcSender<CanvasId>,
|
||||||
Size2D<u32>,
|
Size2D<u64>,
|
||||||
webrender_api::RenderApiSender,
|
webrender_api::RenderApiSender,
|
||||||
bool,
|
bool,
|
||||||
),
|
),
|
||||||
|
|
|
@ -3067,7 +3067,7 @@ where
|
||||||
|
|
||||||
fn handle_create_canvas_paint_thread_msg(
|
fn handle_create_canvas_paint_thread_msg(
|
||||||
&mut self,
|
&mut self,
|
||||||
size: Size2D<u32>,
|
size: Size2D<u64>,
|
||||||
response_sender: IpcSender<(IpcSender<CanvasMsg>, CanvasId)>,
|
response_sender: IpcSender<(IpcSender<CanvasMsg>, CanvasId)>,
|
||||||
) {
|
) {
|
||||||
let webrender_api = self.webrender_api_sender.clone();
|
let webrender_api = self.webrender_api_sender.clone();
|
||||||
|
|
|
@ -132,17 +132,38 @@ pub struct CanvasState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CanvasState {
|
impl CanvasState {
|
||||||
pub fn new(global: &GlobalScope) -> CanvasState {
|
pub fn new(
|
||||||
|
global: &GlobalScope,
|
||||||
|
size: Size2D<u64>,
|
||||||
|
) -> CanvasState {
|
||||||
|
debug!("Creating new canvas rendering context.");
|
||||||
let (sender, receiver) =
|
let (sender, receiver) =
|
||||||
profiled_ipc::channel(global.time_profiler_chan().clone()).unwrap();
|
profiled_ipc::channel(global.time_profiler_chan().clone()).unwrap();
|
||||||
|
let script_to_constellation_chan = global.script_to_constellation_chan();
|
||||||
|
debug!("Asking constellation to create new canvas thread.");
|
||||||
|
script_to_constellation_chan
|
||||||
|
.send(ScriptMsg::CreateCanvasPaintThread(size, sender))
|
||||||
|
.unwrap();
|
||||||
let (ipc_renderer, canvas_id) = receiver.recv().unwrap();
|
let (ipc_renderer, canvas_id) = receiver.recv().unwrap();
|
||||||
debug!("Done.");
|
debug!("Done.");
|
||||||
CanvasState {
|
CanvasState {
|
||||||
//reflector_: Reflector::new(),
|
|
||||||
ipc_renderer: ipc_renderer,
|
ipc_renderer: ipc_renderer,
|
||||||
canvas_id: canvas_id,
|
canvas_id: canvas_id,
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*pub fn new(
|
||||||
|
global: &GlobalScope,
|
||||||
|
size: Size2D<u32>,
|
||||||
|
) -> CanvasState {
|
||||||
|
|
||||||
|
/*let boxed = Box::new(CanvasState::new_inherited(
|
||||||
|
global,
|
||||||
|
size,
|
||||||
|
));
|
||||||
|
|
||||||
|
reflect_dom_object(boxed, global, CanvasState)*/
|
||||||
|
}*/
|
||||||
|
|
||||||
pub fn get_canvas_id(&self) -> CanvasId {
|
pub fn get_canvas_id(&self) -> CanvasId {
|
||||||
self.canvas_id.clone()
|
self.canvas_id.clone()
|
||||||
|
@ -199,7 +220,7 @@ impl CanvasRenderingContext2D {
|
||||||
base_url: ServoUrl,
|
base_url: ServoUrl,
|
||||||
size: Size2D<u32>,
|
size: Size2D<u32>,
|
||||||
) -> CanvasRenderingContext2D {
|
) -> CanvasRenderingContext2D {
|
||||||
debug!("Creating new canvas rendering context.");
|
/*debug!("Creating new canvas rendering context.");
|
||||||
let (sender, receiver) =
|
let (sender, receiver) =
|
||||||
profiled_ipc::channel(global.time_profiler_chan().clone()).unwrap();
|
profiled_ipc::channel(global.time_profiler_chan().clone()).unwrap();
|
||||||
let script_to_constellation_chan = global.script_to_constellation_chan();
|
let script_to_constellation_chan = global.script_to_constellation_chan();
|
||||||
|
@ -208,7 +229,7 @@ impl CanvasRenderingContext2D {
|
||||||
.send(ScriptMsg::CreateCanvasPaintThread(size, sender))
|
.send(ScriptMsg::CreateCanvasPaintThread(size, sender))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
//let (canvas_state.ipc_renderer, canvas_id) = receiver.recv().unwrap();
|
//let (canvas_state.ipc_renderer, canvas_id) = receiver.recv().unwrap();
|
||||||
debug!("Done.");
|
debug!("Done.");*/
|
||||||
CanvasRenderingContext2D {
|
CanvasRenderingContext2D {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
canvas: canvas.map(Dom::from_ref),
|
canvas: canvas.map(Dom::from_ref),
|
||||||
|
@ -220,7 +241,7 @@ impl CanvasRenderingContext2D {
|
||||||
saved_states: DomRefCell::new(Vec::new()),
|
saved_states: DomRefCell::new(Vec::new()),
|
||||||
origin_clean: Cell::new(true),
|
origin_clean: Cell::new(true),
|
||||||
//canvas_id: canvas_id,
|
//canvas_id: canvas_id,
|
||||||
canvas_state: DomRefCell::new(CanvasState::new(global)),
|
canvas_state: DomRefCell::new(CanvasState::new(global,Size2D::new(size.width as u64, size.height as u64))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl OffscreenCanvasRenderingContext2D {
|
||||||
OffscreenCanvasRenderingContext2D {
|
OffscreenCanvasRenderingContext2D {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
canvas: canvas.map(Dom::from_ref),
|
canvas: canvas.map(Dom::from_ref),
|
||||||
canvas_state: DomRefCell::new(CanvasState::new(_global)),
|
canvas_state: DomRefCell::new(CanvasState::new(_global,_size)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ pub enum ScriptMsg {
|
||||||
ChangeRunningAnimationsState(AnimationState),
|
ChangeRunningAnimationsState(AnimationState),
|
||||||
/// Requests that a new 2D canvas thread be created. (This is done in the constellation because
|
/// Requests that a new 2D canvas thread be created. (This is done in the constellation because
|
||||||
/// 2D canvases may use the GPU and we don't want to give untrusted content access to the GPU.)
|
/// 2D canvases may use the GPU and we don't want to give untrusted content access to the GPU.)
|
||||||
CreateCanvasPaintThread(Size2D<u32>, IpcSender<(IpcSender<CanvasMsg>, CanvasId)>),
|
CreateCanvasPaintThread(Size2D<u64>, IpcSender<(IpcSender<CanvasMsg>, CanvasId)>),
|
||||||
/// Notifies the constellation that this frame has received focus.
|
/// Notifies the constellation that this frame has received focus.
|
||||||
Focus,
|
Focus,
|
||||||
/// Requests that the constellation retrieve the current contents of the clipboard
|
/// Requests that the constellation retrieve the current contents of the clipboard
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue