mirror of
https://github.com/servo/servo.git
synced 2025-06-19 14:48:59 +01:00
refactor compositor interfaces \--> RenderListener + ScriptListener; AttachCompositorMsg added to render_task::Msg
updated to reflect comments
This commit is contained in:
parent
496069dad4
commit
577a410f80
11 changed files with 38 additions and 31 deletions
|
@ -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;
|
||||
|
|
|
@ -22,28 +22,36 @@ 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>,
|
||||
pub fn create_render_task<C: RenderListener + Owned>(port: Port<Msg<C>>,
|
||||
compositor: C,
|
||||
opts: Opts,
|
||||
profiler_chan: ProfilerChan) {
|
||||
|
@ -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(());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 09d2db847c11bcab7f1832d5daf5947a7c1384ee
|
||||
Subproject commit 865f539114383a021822583801e8362faf916699
|
|
@ -1 +1 @@
|
|||
Subproject commit 6f6b6fa95914fa6322f3277c803fd4921601cb90
|
||||
Subproject commit 453bf81e021008f5eba29b135f07f4529e6c8b2e
|
Loading…
Add table
Add a link
Reference in a new issue