Skip to content

Commit

Permalink
Changes for sender reciever
Browse files Browse the repository at this point in the history
  • Loading branch information
maharsh312 committed May 10, 2019
1 parent 30cc087 commit 1de8ddd
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 13 deletions.
6 changes: 3 additions & 3 deletions components/canvas/canvas_data.rs
Expand Up @@ -176,7 +176,7 @@ pub struct CanvasData<'a> {

impl<'a> CanvasData<'a> {
pub fn new(
size: Size2D<u32>,
size: Size2D<u64>,
webrender_api_sender: webrender_api::RenderApiSender,
antialias: AntialiasMode,
canvas_id: CanvasId,
Expand Down Expand Up @@ -708,13 +708,13 @@ impl<'a> CanvasData<'a> {
.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?
DrawTarget::new(BackendType::Skia, size.to_i32(), SurfaceFormat::B8G8R8A8)
}

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.saved_states.clear();
// Webrender doesn't let images change size, so we clear the webrender image key.
Expand Down
2 changes: 1 addition & 1 deletion components/canvas/canvas_paint_thread.rs
Expand Up @@ -77,7 +77,7 @@ impl<'a> CanvasPaintThread<'a> {

pub fn create_canvas(
&mut self,
size: Size2D<u32>,
size: Size2D<u64>,
webrender_api_sender: webrender_api::RenderApiSender,
antialias: bool,
) -> CanvasId {
Expand Down
2 changes: 1 addition & 1 deletion components/canvas_traits/canvas.rs
Expand Up @@ -23,7 +23,7 @@ pub enum CanvasMsg {
Canvas2d(Canvas2dMsg, CanvasId),
Create(
IpcSender<CanvasId>,
Size2D<u32>,
Size2D<u64>,
webrender_api::RenderApiSender,
bool,
),
Expand Down
2 changes: 1 addition & 1 deletion components/constellation/constellation.rs
Expand Up @@ -3067,7 +3067,7 @@ where

fn handle_create_canvas_paint_thread_msg(
&mut self,
size: Size2D<u32>,
size: Size2D<u64>,
response_sender: IpcSender<(IpcSender<CanvasMsg>, CanvasId)>,
) {
let webrender_api = self.webrender_api_sender.clone();
Expand Down
31 changes: 26 additions & 5 deletions components/script/dom/canvasrenderingcontext2d.rs
Expand Up @@ -132,17 +132,38 @@ pub struct 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) =
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();
debug!("Done.");
CanvasState {
//reflector_: Reflector::new(),
ipc_renderer: ipc_renderer,
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 {
self.canvas_id.clone()
Expand Down Expand Up @@ -199,7 +220,7 @@ impl CanvasRenderingContext2D {
base_url: ServoUrl,
size: Size2D<u32>,
) -> CanvasRenderingContext2D {
debug!("Creating new canvas rendering context.");
/*debug!("Creating new canvas rendering context.");
let (sender, receiver) =
profiled_ipc::channel(global.time_profiler_chan().clone()).unwrap();
let script_to_constellation_chan = global.script_to_constellation_chan();
Expand All @@ -208,7 +229,7 @@ impl CanvasRenderingContext2D {
.send(ScriptMsg::CreateCanvasPaintThread(size, sender))
.unwrap();
//let (canvas_state.ipc_renderer, canvas_id) = receiver.recv().unwrap();
debug!("Done.");
debug!("Done.");*/
CanvasRenderingContext2D {
reflector_: Reflector::new(),
canvas: canvas.map(Dom::from_ref),
Expand All @@ -220,7 +241,7 @@ impl CanvasRenderingContext2D {
saved_states: DomRefCell::new(Vec::new()),
origin_clean: Cell::new(true),
//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))),
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/offscreencanvasrenderingcontext2d.rs
Expand Up @@ -29,7 +29,7 @@ impl OffscreenCanvasRenderingContext2D {
OffscreenCanvasRenderingContext2D {
reflector_: Reflector::new(),
canvas: canvas.map(Dom::from_ref),
canvas_state: DomRefCell::new(CanvasState::new(_global)),
canvas_state: DomRefCell::new(CanvasState::new(_global,_size)),
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/script_traits/script_msg.rs
Expand Up @@ -121,7 +121,7 @@ pub enum ScriptMsg {
ChangeRunningAnimationsState(AnimationState),
/// 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.)
CreateCanvasPaintThread(Size2D<u32>, IpcSender<(IpcSender<CanvasMsg>, CanvasId)>),
CreateCanvasPaintThread(Size2D<u64>, IpcSender<(IpcSender<CanvasMsg>, CanvasId)>),
/// Notifies the constellation that this frame has received focus.
Focus,
/// Requests that the constellation retrieve the current contents of the clipboard
Expand Down

0 comments on commit 1de8ddd

Please sign in to comment.