aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Kuehn <tkuehn@cmu.edu>2013-06-14 18:56:48 -0700
committerTim Kuehn <tkuehn@cmu.edu>2013-06-17 12:37:02 -0700
commit577a410f806d991f48c9f350a060aa1aca72eab8 (patch)
tree3d040da92e94ac90afaa2eaaeee493c6ce16d3bb
parent496069dad4beb0b8e395f36ee78c177af5429d6b (diff)
downloadservo-577a410f806d991f48c9f350a060aa1aca72eab8.tar.gz
servo-577a410f806d991f48c9f350a060aa1aca72eab8.zip
refactor compositor interfaces \--> RenderListener + ScriptListener; AttachCompositorMsg added to render_task::Msg
updated to reflect comments
-rw-r--r--src/components/gfx/compositor.rs2
-rw-r--r--src/components/gfx/render_task.rs33
-rw-r--r--src/components/main/compositing/mod.rs2
-rw-r--r--src/components/main/engine.rs12
-rw-r--r--src/components/main/layout/layout_task.rs7
-rw-r--r--src/components/main/platform/common/glut_windowing.rs1
-rwxr-xr-xsrc/components/main/servo.rc4
-rw-r--r--src/components/script/compositor_interface.rs2
-rw-r--r--src/components/util/time.rs2
m---------src/support/css/rust-css0
m---------src/support/glut/rust-glut0
11 files changed, 36 insertions, 29 deletions
diff --git a/src/components/gfx/compositor.rs b/src/components/gfx/compositor.rs
index b0f599c1f4d..46e09800685 100644
--- a/src/components/gfx/compositor.rs
+++ b/src/components/gfx/compositor.rs
@@ -32,7 +32,7 @@ pub enum RenderState {
RenderingRenderState,
}
-/// The interface used to by the renderer to acquire draw targets for each rendered frame and
+/// The interface used by the renderer to acquire draw targets for each rendered frame and
/// submit them to be drawn to the display.
pub trait RenderListener {
fn get_gl_context(&self) -> AzGLContext;
diff --git a/src/components/gfx/render_task.rs b/src/components/gfx/render_task.rs
index 41341554e27..8cb63f885f1 100644
--- a/src/components/gfx/render_task.rs
+++ b/src/components/gfx/render_task.rs
@@ -22,31 +22,39 @@ use servo_net::util::spawn_listener;
use servo_util::time::{ProfilerChan, profile};
use servo_util::time;
-pub enum Msg {
+pub enum Msg<C> {
+ AttachCompositorMsg(C),
RenderMsg(RenderLayer),
ExitMsg(Chan<()>),
}
-#[deriving(Clone)]
-pub struct RenderChan {
- chan: SharedChan<Msg>,
+pub struct RenderChan<C> {
+ chan: SharedChan<Msg<C>>,
}
-impl RenderChan {
- pub fn new(chan: Chan<Msg>) -> RenderChan {
+impl<C: RenderListener + Owned> Clone for RenderChan<C> {
+ pub fn clone(&self) -> RenderChan<C> {
+ RenderChan {
+ chan: self.chan.clone(),
+ }
+ }
+}
+
+impl<C: RenderListener + Owned> RenderChan<C> {
+ pub fn new(chan: Chan<Msg<C>>) -> RenderChan<C> {
RenderChan {
chan: SharedChan::new(chan),
}
}
- pub fn send(&self, msg: Msg) {
+ pub fn send(&self, msg: Msg<C>) {
self.chan.send(msg);
}
}
-pub fn create_render_task<C: RenderListener + Owned>(port: Port<Msg>,
- compositor: C,
- opts: Opts,
- profiler_chan: ProfilerChan) {
+pub fn create_render_task<C: RenderListener + Owned>(port: Port<Msg<C>>,
+ compositor: C,
+ opts: Opts,
+ profiler_chan: ProfilerChan) {
let compositor_cell = Cell(compositor);
let opts_cell = Cell(opts);
let port = Cell(port);
@@ -103,7 +111,7 @@ priv struct ThreadRenderContext {
}
priv struct Renderer<C> {
- port: Port<Msg>,
+ port: Port<Msg<C>>,
compositor: C,
thread_pool: TaskPool<ThreadRenderContext>,
opts: Opts,
@@ -120,6 +128,7 @@ impl<C: RenderListener + Owned> Renderer<C> {
loop {
match self.port.recv() {
+ AttachCompositorMsg(compositor) => self.compositor = compositor,
RenderMsg(render_layer) => self.render(render_layer),
ExitMsg(response_ch) => {
response_ch.send(());
diff --git a/src/components/main/compositing/mod.rs b/src/components/main/compositing/mod.rs
index cf42af2a6b9..ba32b706c41 100644
--- a/src/components/main/compositing/mod.rs
+++ b/src/components/main/compositing/mod.rs
@@ -132,7 +132,7 @@ impl CompositorTask {
}
/// Starts the compositor, which listens for messages on the specified port.
- pub fn create_compositor_task(port: Port<Msg>,
+ pub fn create(port: Port<Msg>,
profiler_chan: ProfilerChan,
shutdown_chan: Chan<()>) {
let port = Cell(port);
diff --git a/src/components/main/engine.rs b/src/components/main/engine.rs
index 8a8b30dc226..1abc00537c4 100644
--- a/src/components/main/engine.rs
+++ b/src/components/main/engine.rs
@@ -24,7 +24,7 @@ use servo_util::time::{ProfilerChan};
pub struct Engine {
request_port: Port<Msg>,
compositor_chan: CompositorChan,
- render_chan: RenderChan,
+ render_chan: RenderChan<CompositorChan>,
resource_task: ResourceTask,
image_cache_task: ImageCacheTask,
layout_chan: LayoutChan,
@@ -32,12 +32,6 @@ pub struct Engine {
profiler_chan: ProfilerChan,
}
-impl Drop for Engine {
- fn finalize(&self) {
- //self.profiler_chan.send(ForcePrintMsg);
- }
-}
-
impl Engine {
pub fn start(compositor_chan: CompositorChan,
opts: &Opts,
@@ -63,7 +57,9 @@ impl Engine {
// Create the layout port and channel.
let (layout_port, layout_chan) = closure_stream!(layout_interface::Msg, LayoutChan);
- let (render_port, render_chan) = closure_stream!(render_task::Msg, RenderChan);
+ let (render_port, render_chan) = comm::stream::<render_task::Msg<CompositorChan>>();
+ let (render_port, render_chan) = (Cell(render_port), RenderChan::new(render_chan));
+
compositor_chan.send(SetLayoutChan(layout_chan.clone()));
let compositor_chan = Cell(compositor_chan);
diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs
index 506f1d20769..fcdc8cc6b24 100644
--- a/src/components/main/layout/layout_task.rs
+++ b/src/components/main/layout/layout_task.rs
@@ -5,6 +5,7 @@
//! The layout task. Performs layout on the DOM, builds display lists and sends them to be
/// rendered.
+use compositing::CompositorChan;
use css::matching::MatchMethods;
use css::select::new_css_select_ctx;
use layout::aux::{LayoutData, LayoutAuxMethods};
@@ -47,7 +48,7 @@ use std::net::url::Url;
pub fn create_layout_task(port: Port<Msg>,
script_chan: ScriptChan,
- render_chan: RenderChan,
+ render_chan: RenderChan<CompositorChan>,
img_cache_task: ImageCacheTask,
opts: Opts,
profiler_chan: ProfilerChan) {
@@ -66,7 +67,7 @@ pub fn create_layout_task(port: Port<Msg>,
struct Layout {
port: Port<Msg>,
script_chan: ScriptChan,
- render_chan: RenderChan,
+ render_chan: RenderChan<CompositorChan>,
image_cache_task: ImageCacheTask,
local_image_cache: @mut LocalImageCache,
font_ctx: @mut FontContext,
@@ -83,7 +84,7 @@ struct Layout {
impl Layout {
fn new(port: Port<Msg>,
script_chan: ScriptChan,
- render_chan: RenderChan,
+ render_chan: RenderChan<CompositorChan>,
image_cache_task: ImageCacheTask,
opts: &Opts,
profiler_chan: ProfilerChan)
diff --git a/src/components/main/platform/common/glut_windowing.rs b/src/components/main/platform/common/glut_windowing.rs
index a6ee264437c..50e67d6e541 100644
--- a/src/components/main/platform/common/glut_windowing.rs
+++ b/src/components/main/platform/common/glut_windowing.rs
@@ -12,7 +12,6 @@ use windowing::{ResizeCallback, ScrollCallback, WindowMethods, WindowMouseEvent,
use windowing::{WindowMouseDownEvent, WindowMouseUpEvent, ZoomCallback};
use alert::{Alert, AlertMethods};
-use core::cell::Cell;
use core::libc::c_int;
use geom::point::Point2D;
use geom::size::Size2D;
diff --git a/src/components/main/servo.rc b/src/components/main/servo.rc
index 072d718b824..8357d4136d1 100755
--- a/src/components/main/servo.rc
+++ b/src/components/main/servo.rc
@@ -93,7 +93,7 @@ fn run(opts: &Opts) {
// Create the profiler channel.
let (profiler_port, profiler_chan) = comm::stream();
let profiler_chan = ProfilerChan::new(profiler_chan);
- Profiler::create_profiler(profiler_port);
+ Profiler::create(profiler_port);
do opts.profiler_period.map |period| {
let profiler_chan = profiler_chan.clone();
let period = *period;
@@ -109,7 +109,7 @@ fn run(opts: &Opts) {
// Create the compositor.
let (compositor_port, compositor_chan) = comm::stream();
let compositor_chan = CompositorChan::new(compositor_chan);
- CompositorTask::create_compositor_task(compositor_port, profiler_chan.clone(), shutdown_chan);
+ CompositorTask::create(compositor_port, profiler_chan.clone(), shutdown_chan);
// Create a Servo instance.
diff --git a/src/components/script/compositor_interface.rs b/src/components/script/compositor_interface.rs
index 1f8462f5463..b0041e49298 100644
--- a/src/components/script/compositor_interface.rs
+++ b/src/components/script/compositor_interface.rs
@@ -14,6 +14,8 @@ pub enum ReadyState {
FinishedLoading,
}
+/// The interface used by the script task to tell the compositor to update its ready state,
+/// which is used in displaying the appropriate message in the window's title.
pub trait ScriptListener : Clone {
fn set_ready_state(&self, ReadyState);
}
diff --git a/src/components/util/time.rs b/src/components/util/time.rs
index 8d1cdfc7091..95bdc207e34 100644
--- a/src/components/util/time.rs
+++ b/src/components/util/time.rs
@@ -110,7 +110,7 @@ impl ProfilerCategory {
}
impl Profiler {
- pub fn create_profiler(port: Port<ProfilerMsg>) {
+ pub fn create(port: Port<ProfilerMsg>) {
let port = Cell(port);
do spawn {
let mut profiler = Profiler::new(port.take());
diff --git a/src/support/css/rust-css b/src/support/css/rust-css
-Subproject 09d2db847c11bcab7f1832d5daf5947a7c1384e
+Subproject 865f539114383a021822583801e8362faf91669
diff --git a/src/support/glut/rust-glut b/src/support/glut/rust-glut
-Subproject 6f6b6fa95914fa6322f3277c803fd4921601cb9
+Subproject 453bf81e021008f5eba29b135f07f4529e6c8b2