diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2012-08-16 19:38:46 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2012-08-16 19:38:46 -0700 |
commit | 160baa61be48674f843501b7b09e2a606fd4635d (patch) | |
tree | 3e367eb52a5cb603580dac71a68febbb8ed6e8ec | |
parent | 989302d6c30c4ce3fc032429a59a460371fdf5ed (diff) | |
download | servo-160baa61be48674f843501b7b09e2a606fd4635d.tar.gz servo-160baa61be48674f843501b7b09e2a606fd4635d.zip |
Use the high-level Azure API everywhere
m--------- | src/rust-azure | 0 | ||||
-rw-r--r-- | src/servo/gfx/pngsink.rs | 22 | ||||
-rw-r--r-- | src/servo/gfx/renderer.rs | 17 | ||||
-rw-r--r-- | src/servo/platform/osmain.rs | 16 |
4 files changed, 28 insertions, 27 deletions
diff --git a/src/rust-azure b/src/rust-azure -Subproject 9e604c78152cda2fa43f1e11427fcccf658dff6 +Subproject f47c170c826a5634c894097d1778062c42e2896 diff --git a/src/servo/gfx/pngsink.rs b/src/servo/gfx/pngsink.rs index 8973690b61c..25e6afc3eb7 100644 --- a/src/servo/gfx/pngsink.rs +++ b/src/servo/gfx/pngsink.rs @@ -8,7 +8,6 @@ Each time the renderer renders a frame the bufsink will output a export PngSink, Msg, Exit; import libc::{c_int, c_uint, c_void, c_uchar}; -import azure::AzDrawTargetRef; import azure_bg = azure::bindgen; import azure_bg::{AzCreateDrawTargetForCairoSurface, AzReleaseDrawTarget}; import azure::cairo; @@ -27,20 +26,21 @@ import ptr::addr_of; import dom::event::Event; import dvec::dvec; import layout::display_list::display_list; +import std::cell::Cell; type PngSink = Chan<Msg>; enum Msg { - BeginDrawing(pipes::chan<AzDrawTargetRef>), - Draw(pipes::chan<AzDrawTargetRef>, AzDrawTargetRef), + BeginDrawing(pipes::chan<DrawTarget>), + Draw(pipes::chan<DrawTarget>, DrawTarget), Exit } impl Chan<Msg> : Sink { - fn begin_drawing(+next_dt: pipes::chan<AzDrawTargetRef>) { + fn begin_drawing(+next_dt: pipes::chan<DrawTarget>) { self.send(BeginDrawing(next_dt)) } - fn draw(+next_dt: pipes::chan<AzDrawTargetRef>, draw_me: AzDrawTargetRef) { + fn draw(+next_dt: pipes::chan<DrawTarget>, +draw_me: DrawTarget) { self.send(Draw(next_dt, draw_me)) } fn add_event_listener(_listener: Chan<Event>) { @@ -51,17 +51,17 @@ impl Chan<Msg> : Sink { fn PngSink(output: Chan<~[u8]>) -> PngSink { do spawn_listener |po: Port<Msg>| { let cairo_surface = ImageSurface(CAIRO_FORMAT_ARGB32, 800, 600); - let draw_target = DrawTarget(cairo_surface); + let draw_target = Cell(DrawTarget(cairo_surface)); loop { match po.recv() { BeginDrawing(sender) => { debug!("pngsink: begin_drawing"); - sender.send(draw_target.azure_draw_target); + sender.send(draw_target.take()); } Draw(sender, dt) => { debug!("pngsink: draw"); - do_draw(sender, dt, output, cairo_surface); + do_draw(sender, dt.clone(), output, cairo_surface); } Exit => break } @@ -69,8 +69,8 @@ fn PngSink(output: Chan<~[u8]>) -> PngSink { } } -fn do_draw(sender: pipes::chan<AzDrawTargetRef>, - dt: AzDrawTargetRef, +fn do_draw(sender: pipes::chan<DrawTarget>, + +dt: DrawTarget, output: Chan<~[u8]>, cairo_surface: ImageSurface) { let buffer = io::mem_buffer(); @@ -79,7 +79,7 @@ fn do_draw(sender: pipes::chan<AzDrawTargetRef>, output.send(vec::from_mut(dvec::unwrap(move buffer))); // Send the next draw target to the renderer - sender.send(dt); + sender.send(move dt); } #[test] diff --git a/src/servo/gfx/renderer.rs b/src/servo/gfx/renderer.rs index ea47d3b3840..f4981a60cd8 100644 --- a/src/servo/gfx/renderer.rs +++ b/src/servo/gfx/renderer.rs @@ -17,6 +17,7 @@ import azure_hl::{DrawTarget, Linear}; import ptr::addr_of; import std::arc::arc; import azure::cairo::{cairo_font_face_t, cairo_scaled_font_t}; +import std::cell::Cell; import pipes::{port, chan}; @@ -34,8 +35,8 @@ each rendered frame and submit them to be drawn to the display FIXME: Change this name to Compositor. "] trait Sink { - fn begin_drawing(+next_dt: pipes::chan<AzDrawTargetRef>); - fn draw(+next_dt: pipes::chan<AzDrawTargetRef>, draw_me: AzDrawTargetRef); + fn begin_drawing(+next_dt: pipes::chan<DrawTarget>); + fn draw(+next_dt: pipes::chan<DrawTarget>, +draw_me: DrawTarget); fn add_event_listener(listener: comm::Chan<Event>); } @@ -53,7 +54,7 @@ fn Renderer<S: Sink send copy>(sink: S) -> comm::Chan<Msg> { match po.recv() { RenderMsg(display_list) => { #debug("renderer: got render request"); - let azure_draw_target = draw_target_po.recv(); + let draw_target = Cell(draw_target_po.recv()); let (ch, po) = pipes::stream(); let mut draw_target_ch_ = some(ch); draw_target_po = po; @@ -63,13 +64,13 @@ fn Renderer<S: Sink send copy>(sink: S) -> comm::Chan<Msg> { draw_target_ch_ <-> draw_target_ch; let draw_target_ch = option::unwrap(draw_target_ch); - let draw_target = - azure_hl::new_draw_target_from_azure_draw_target(azure_draw_target); - clear(&draw_target); - draw_display_list(&draw_target, display_list); + do draw_target.with_ref |draw_target| { + clear(draw_target); + draw_display_list(draw_target, display_list); + } #debug("renderer: returning surface"); - sink.draw(draw_target_ch, azure_draw_target); + sink.draw(draw_target_ch, draw_target.take()); } } ExitMsg(response_ch) => { diff --git a/src/servo/platform/osmain.rs b/src/servo/platform/osmain.rs index ab3ddb9b948..83ab0c0a7ef 100644 --- a/src/servo/platform/osmain.rs +++ b/src/servo/platform/osmain.rs @@ -23,8 +23,8 @@ import pipes::chan; type OSMain = comm::Chan<Msg>; enum Msg { - BeginDrawing(pipes::chan<AzDrawTargetRef>), - Draw(pipes::chan<AzDrawTargetRef>, AzDrawTargetRef), + BeginDrawing(pipes::chan<DrawTarget>), + Draw(pipes::chan<DrawTarget>, DrawTarget), AddKeyHandler(pipes::chan<()>), AddEventListener(comm::Chan<Event>), Exit @@ -125,10 +125,10 @@ Implementation to allow the osmain channel to be used as a graphics sink for the renderer "] impl OSMain : Sink { - fn begin_drawing(+next_dt: pipes::chan<AzDrawTargetRef>) { + fn begin_drawing(+next_dt: pipes::chan<DrawTarget>) { self.send(BeginDrawing(next_dt)) } - fn draw(+next_dt: pipes::chan<AzDrawTargetRef>, draw_me: AzDrawTargetRef) { + fn draw(+next_dt: pipes::chan<DrawTarget>, +draw_me: DrawTarget) { self.send(Draw(next_dt, draw_me)) } fn add_event_listener(listener: comm::Chan<Event>) { @@ -141,11 +141,11 @@ struct SurfaceSet { mut back: Surface; } -fn lend_surface(surfaces: SurfaceSet, receiver: pipes::chan<AzDrawTargetRef>) { +fn lend_surface(surfaces: SurfaceSet, receiver: pipes::chan<DrawTarget>) { // We are in a position to lend out the surface? assert surfaces.front.have; // Ok then take it - let draw_target = surfaces.front.draw_target.azure_draw_target; + let draw_target = azure_hl::clone_mutable_draw_target(&mut surfaces.front.draw_target); #debug("osmain: lending surface %?", draw_target); receiver.send(draw_target); // Now we don't have it @@ -156,14 +156,14 @@ fn lend_surface(surfaces: SurfaceSet, receiver: pipes::chan<AzDrawTargetRef>) { assert surfaces.front.have; } -fn return_surface(surfaces: SurfaceSet, draw_target: AzDrawTargetRef) { +fn return_surface(surfaces: SurfaceSet, draw_target: DrawTarget) { #debug("osmain: returning surface %?", draw_target); // We have room for a return assert surfaces.front.have; assert !surfaces.back.have; // FIXME: This is incompatible with page resizing. - assert surfaces.back.draw_target.azure_draw_target == draw_target; + assert surfaces.back.draw_target.azure_draw_target == draw_target.azure_draw_target; // Now we have it again surfaces.back.have = true; |