auto merge of #4279 : saneyuki/servo/rename, r=jdm

#4275 

* This changeset rename "render"/"rendering" to "paint"/"painting" under `components/`.
* This does not rename words which are used as general browser's working.
  * So this doesn't change `reftest.rs`.
This commit is contained in:
bors-servo 2014-12-08 10:28:10 -07:00
commit 0b486b1210
30 changed files with 353 additions and 353 deletions

View file

@ -103,7 +103,7 @@ cp servobuild.example .servobuild
- `-p INTERVAL` turns on the profiler and dumps info to the console every - `-p INTERVAL` turns on the profiler and dumps info to the console every
`INTERVAL` seconds `INTERVAL` seconds
- `-s SIZE` sets the tile size for rendering; defaults to 512 - `-s SIZE` sets the tile size for painting; defaults to 512
- `-z` disables all graphical output; useful for running JS / layout tests - `-z` disables all graphical output; useful for running JS / layout tests
### Keyboard Shortcuts ### Keyboard Shortcuts

View file

@ -18,17 +18,17 @@ pub enum CanvasMsg {
Close, Close,
} }
pub struct CanvasRenderTask { pub struct CanvasPaintTask {
drawtarget: DrawTarget, drawtarget: DrawTarget,
fill_color: ColorPattern, fill_color: ColorPattern,
stroke_color: ColorPattern, stroke_color: ColorPattern,
stroke_opts: StrokeOptions, stroke_opts: StrokeOptions,
} }
impl CanvasRenderTask { impl CanvasPaintTask {
fn new(size: Size2D<i32>) -> CanvasRenderTask { fn new(size: Size2D<i32>) -> CanvasPaintTask {
CanvasRenderTask { CanvasPaintTask {
drawtarget: CanvasRenderTask::create(size), drawtarget: CanvasPaintTask::create(size),
fill_color: ColorPattern::new(Color::new(0., 0., 0., 1.)), fill_color: ColorPattern::new(Color::new(0., 0., 0., 1.)),
stroke_color: ColorPattern::new(Color::new(0., 0., 0., 1.)), stroke_color: ColorPattern::new(Color::new(0., 0., 0., 1.)),
stroke_opts: StrokeOptions::new(1.0, 1.0), stroke_opts: StrokeOptions::new(1.0, 1.0),
@ -38,14 +38,14 @@ impl CanvasRenderTask {
pub fn start(size: Size2D<i32>) -> Sender<CanvasMsg> { pub fn start(size: Size2D<i32>) -> Sender<CanvasMsg> {
let (chan, port) = comm::channel::<CanvasMsg>(); let (chan, port) = comm::channel::<CanvasMsg>();
spawn_named("CanvasTask", proc() { spawn_named("CanvasTask", proc() {
let mut renderer = CanvasRenderTask::new(size); let mut painter = CanvasPaintTask::new(size);
loop { loop {
match port.recv() { match port.recv() {
FillRect(ref rect) => renderer.fill_rect(rect), FillRect(ref rect) => painter.fill_rect(rect),
StrokeRect(ref rect) => renderer.stroke_rect(rect), StrokeRect(ref rect) => painter.stroke_rect(rect),
ClearRect(ref rect) => renderer.clear_rect(rect), ClearRect(ref rect) => painter.clear_rect(rect),
Recreate(size) => renderer.recreate(size), Recreate(size) => painter.recreate(size),
Close => break, Close => break,
} }
} }
@ -72,6 +72,6 @@ impl CanvasRenderTask {
} }
fn recreate(&mut self, size: Size2D<i32>) { fn recreate(&mut self, size: Size2D<i32>) {
self.drawtarget = CanvasRenderTask::create(size); self.drawtarget = CanvasPaintTask::create(size);
} }
} }

View file

@ -9,4 +9,4 @@ extern crate azure;
extern crate geom; extern crate geom;
extern crate "util" as servo_util; extern crate "util" as servo_util;
pub mod canvas_render_task; pub mod canvas_paint_task;

View file

@ -4,11 +4,11 @@
use compositor_layer::{CompositorData, CompositorLayer, DoesntWantScrollEvents}; use compositor_layer::{CompositorData, CompositorLayer, DoesntWantScrollEvents};
use compositor_layer::WantsScrollEvents; use compositor_layer::WantsScrollEvents;
use compositor_task::{ChangeReadyState, ChangeRenderState, CompositorEventListener}; use compositor_task::{ChangeReadyState, ChangePaintState, CompositorEventListener};
use compositor_task::{CompositorProxy, CompositorReceiver, CompositorTask}; use compositor_task::{CompositorProxy, CompositorReceiver, CompositorTask};
use compositor_task::{CreateOrUpdateDescendantLayer, CreateOrUpdateRootLayer, Exit}; use compositor_task::{CreateOrUpdateDescendantLayer, CreateOrUpdateRootLayer, Exit};
use compositor_task::{FrameTreeUpdateMsg, GetGraphicsMetadata, LayerProperties}; use compositor_task::{FrameTreeUpdateMsg, GetGraphicsMetadata, LayerProperties};
use compositor_task::{LoadComplete, Msg, Paint, RenderMsgDiscarded, ScrollFragmentPoint}; use compositor_task::{LoadComplete, Msg, Paint, PaintMsgDiscarded, ScrollFragmentPoint};
use compositor_task::{ScrollTimeout, SetIds, SetLayerOrigin, ShutdownComplete}; use compositor_task::{ScrollTimeout, SetIds, SetLayerOrigin, ShutdownComplete};
use constellation::{SendableFrameTree, FrameTreeDiff}; use constellation::{SendableFrameTree, FrameTreeDiff};
use pipeline::CompositionPipeline; use pipeline::CompositionPipeline;
@ -29,7 +29,7 @@ use geom::point::{Point2D, TypedPoint2D};
use geom::rect::{Rect, TypedRect}; use geom::rect::{Rect, TypedRect};
use geom::size::TypedSize2D; use geom::size::TypedSize2D;
use geom::scale_factor::ScaleFactor; use geom::scale_factor::ScaleFactor;
use gfx::render_task::{RenderChan, RenderMsg, RenderRequest, UnusedBufferMsg}; use gfx::paint_task::{PaintChan, PaintMsg, PaintRequest, UnusedBufferMsg};
use layers::geometry::{DevicePixel, LayerPixel}; use layers::geometry::{DevicePixel, LayerPixel};
use layers::layers::{BufferRequest, Layer, LayerBufferSet}; use layers::layers::{BufferRequest, Layer, LayerBufferSet};
use layers::rendergl; use layers::rendergl;
@ -39,8 +39,8 @@ use png;
use gleam::gl::types::{GLint, GLsizei}; use gleam::gl::types::{GLint, GLsizei};
use gleam::gl; use gleam::gl;
use script_traits::{ViewportMsg, ScriptControlChan}; use script_traits::{ViewportMsg, ScriptControlChan};
use servo_msg::compositor_msg::{Blank, Epoch, FinishedLoading, IdleRenderState, LayerId}; use servo_msg::compositor_msg::{Blank, Epoch, FinishedLoading, IdlePaintState, LayerId};
use servo_msg::compositor_msg::{ReadyState, RenderingRenderState, RenderState, Scrollable}; use servo_msg::compositor_msg::{ReadyState, PaintingPaintState, PaintState, Scrollable};
use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, LoadUrlMsg}; use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, LoadUrlMsg};
use servo_msg::constellation_msg::{NavigateMsg, LoadData, PipelineId, ResizedWindowMsg}; use servo_msg::constellation_msg::{NavigateMsg, LoadData, PipelineId, ResizedWindowMsg};
use servo_msg::constellation_msg::{WindowSizeData, KeyState, Key, KeyModifiers}; use servo_msg::constellation_msg::{WindowSizeData, KeyState, Key, KeyModifiers};
@ -97,8 +97,8 @@ pub struct IOCompositor<Window: WindowMethods> {
/// the compositor. /// the compositor.
shutdown_state: ShutdownState, shutdown_state: ShutdownState,
/// Tracks outstanding render_msg's sent to the render tasks. /// Tracks outstanding paint_msg's sent to the paint tasks.
outstanding_render_msgs: uint, outstanding_paint_msgs: uint,
/// Tracks the last composite time. /// Tracks the last composite time.
last_composite_time: u64, last_composite_time: u64,
@ -112,8 +112,8 @@ pub struct IOCompositor<Window: WindowMethods> {
/// Current display/reflow status of each pipeline. /// Current display/reflow status of each pipeline.
ready_states: HashMap<PipelineId, ReadyState>, ready_states: HashMap<PipelineId, ReadyState>,
/// Current render status of each pipeline. /// Current paint status of each pipeline.
render_states: HashMap<PipelineId, RenderState>, paint_states: HashMap<PipelineId, PaintState>,
/// Whether the page being rendered has loaded completely. /// Whether the page being rendered has loaded completely.
/// Differs from ReadyState because we can finish loading (ready) /// Differs from ReadyState because we can finish loading (ready)
@ -173,8 +173,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
-> IOCompositor<Window> { -> IOCompositor<Window> {
// Create an initial layer tree. // Create an initial layer tree.
// //
// TODO: There should be no initial layer tree until the renderer creates one from the // TODO: There should be no initial layer tree until the painter creates one from the
// display list. This is only here because we don't have that logic in the renderer yet. // display list. This is only here because we don't have that logic in the painter yet.
let window_size = window.framebuffer_size(); let window_size = window.framebuffer_size();
let hidpi_factor = window.hidpi_factor(); let hidpi_factor = window.hidpi_factor();
let context = CompositorTask::create_graphics_context(&window.native_metadata()); let context = CompositorTask::create_graphics_context(&window.native_metadata());
@ -200,14 +200,14 @@ impl<Window: WindowMethods> IOCompositor<Window> {
zoom_action: false, zoom_action: false,
zoom_time: 0f64, zoom_time: 0f64,
ready_states: HashMap::new(), ready_states: HashMap::new(),
render_states: HashMap::new(), paint_states: HashMap::new(),
got_load_complete_message: false, got_load_complete_message: false,
got_set_ids_message: false, got_set_ids_message: false,
constellation_chan: constellation_chan, constellation_chan: constellation_chan,
time_profiler_chan: time_profiler_chan, time_profiler_chan: time_profiler_chan,
memory_profiler_chan: memory_profiler_chan, memory_profiler_chan: memory_profiler_chan,
fragment_point: None, fragment_point: None,
outstanding_render_msgs: 0, outstanding_paint_msgs: 0,
last_composite_time: 0, last_composite_time: 0,
} }
} }
@ -258,12 +258,12 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.change_ready_state(pipeline_id, ready_state); self.change_ready_state(pipeline_id, ready_state);
} }
(ChangeRenderState(pipeline_id, render_state), NotShuttingDown) => { (ChangePaintState(pipeline_id, paint_state), NotShuttingDown) => {
self.change_render_state(pipeline_id, render_state); self.change_paint_state(pipeline_id, paint_state);
} }
(RenderMsgDiscarded, NotShuttingDown) => { (PaintMsgDiscarded, NotShuttingDown) => {
self.remove_outstanding_render_msg(); self.remove_outstanding_paint_msg();
} }
(SetIds(frame_tree, response_chan, new_constellation_chan), NotShuttingDown) => { (SetIds(frame_tree, response_chan, new_constellation_chan), NotShuttingDown) => {
@ -298,7 +298,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
for (layer_id, new_layer_buffer_set) in replies.into_iter() { for (layer_id, new_layer_buffer_set) in replies.into_iter() {
self.paint(pipeline_id, layer_id, new_layer_buffer_set, epoch); self.paint(pipeline_id, layer_id, new_layer_buffer_set, epoch);
} }
self.remove_outstanding_render_msg(); self.remove_outstanding_paint_msg();
} }
(ScrollFragmentPoint(pipeline_id, layer_id, point), NotShuttingDown) => { (ScrollFragmentPoint(pipeline_id, layer_id, point), NotShuttingDown) => {
@ -308,14 +308,14 @@ impl<Window: WindowMethods> IOCompositor<Window> {
(LoadComplete(..), NotShuttingDown) => { (LoadComplete(..), NotShuttingDown) => {
self.got_load_complete_message = true; self.got_load_complete_message = true;
// If we're rendering in headless mode, schedule a recomposite. // If we're painting in headless mode, schedule a recomposite.
if opts::get().output_file.is_some() { if opts::get().output_file.is_some() {
self.composite_if_necessary(); self.composite_if_necessary();
} }
} }
(ScrollTimeout(timestamp), NotShuttingDown) => { (ScrollTimeout(timestamp), NotShuttingDown) => {
debug!("scroll timeout, drawing unrendered content!"); debug!("scroll timeout, drawing unpainted content!");
match self.composition_request { match self.composition_request {
CompositeOnScrollTimeout(this_timestamp) if timestamp == this_timestamp => { CompositeOnScrollTimeout(this_timestamp) if timestamp == this_timestamp => {
self.composition_request = CompositeNow self.composition_request = CompositeNow
@ -344,7 +344,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
} }
self.window.set_ready_state(self.get_earliest_pipeline_ready_state()); self.window.set_ready_state(self.get_earliest_pipeline_ready_state());
// If we're rendering in headless mode, schedule a recomposite. // If we're painting in headless mode, schedule a recomposite.
if opts::get().output_file.is_some() { if opts::get().output_file.is_some() {
self.composite_if_necessary() self.composite_if_necessary()
} }
@ -358,52 +358,52 @@ impl<Window: WindowMethods> IOCompositor<Window> {
} }
fn change_render_state(&mut self, pipeline_id: PipelineId, render_state: RenderState) { fn change_paint_state(&mut self, pipeline_id: PipelineId, paint_state: PaintState) {
match self.render_states.entry(pipeline_id) { match self.paint_states.entry(pipeline_id) {
Occupied(entry) => { Occupied(entry) => {
*entry.into_mut() = render_state; *entry.into_mut() = paint_state;
} }
Vacant(entry) => { Vacant(entry) => {
entry.set(render_state); entry.set(paint_state);
} }
} }
self.window.set_render_state(render_state); self.window.set_paint_state(paint_state);
} }
fn all_pipelines_in_idle_render_state(&self) -> bool { fn all_pipelines_in_idle_paint_state(&self) -> bool {
if self.ready_states.len() == 0 { if self.ready_states.len() == 0 {
return false; return false;
} }
return self.render_states.values().all(|&value| value == IdleRenderState); return self.paint_states.values().all(|&value| value == IdlePaintState);
} }
fn has_render_msg_tracking(&self) -> bool { fn has_paint_msg_tracking(&self) -> bool {
// only track RenderMsg's if the compositor outputs to a file. // only track PaintMsg's if the compositor outputs to a file.
opts::get().output_file.is_some() opts::get().output_file.is_some()
} }
fn has_outstanding_render_msgs(&self) -> bool { fn has_outstanding_paint_msgs(&self) -> bool {
self.has_render_msg_tracking() && self.outstanding_render_msgs > 0 self.has_paint_msg_tracking() && self.outstanding_paint_msgs > 0
} }
fn add_outstanding_render_msg(&mut self, count: uint) { fn add_outstanding_paint_msg(&mut self, count: uint) {
// return early if not tracking render_msg's // return early if not tracking paint_msg's
if !self.has_render_msg_tracking() { if !self.has_paint_msg_tracking() {
return; return;
} }
debug!("add_outstanding_render_msg {}", self.outstanding_render_msgs); debug!("add_outstanding_paint_msg {}", self.outstanding_paint_msgs);
self.outstanding_render_msgs += count; self.outstanding_paint_msgs += count;
} }
fn remove_outstanding_render_msg(&mut self) { fn remove_outstanding_paint_msg(&mut self) {
if !self.has_render_msg_tracking() { if !self.has_paint_msg_tracking() {
return; return;
} }
if self.outstanding_render_msgs > 0 { if self.outstanding_paint_msgs > 0 {
self.outstanding_render_msgs -= 1; self.outstanding_paint_msgs -= 1;
} else { } else {
debug!("too many rerender msgs completed"); debug!("too many repaint msgs completed");
} }
} }
@ -435,9 +435,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
frame_tree: &SendableFrameTree, frame_tree: &SendableFrameTree,
frame_rect: Option<TypedRect<PagePx, f32>>) frame_rect: Option<TypedRect<PagePx, f32>>)
-> Rc<Layer<CompositorData>> { -> Rc<Layer<CompositorData>> {
// Initialize the ReadyState and RenderState for this pipeline. // Initialize the ReadyState and PaintState for this pipeline.
self.ready_states.insert(frame_tree.pipeline.id, Blank); self.ready_states.insert(frame_tree.pipeline.id, Blank);
self.render_states.insert(frame_tree.pipeline.id, RenderingRenderState); self.paint_states.insert(frame_tree.pipeline.id, PaintingPaintState);
let root_layer = create_root_layer_for_pipeline_and_rect(&frame_tree.pipeline, frame_rect); let root_layer = create_root_layer_for_pipeline_and_rect(&frame_tree.pipeline, frame_rect);
for kid in frame_tree.children.iter() { for kid in frame_tree.children.iter() {
@ -483,7 +483,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
opts::get().tile_size); opts::get().tile_size);
// Add the first child / base layer to the front of the child list, so that // Add the first child / base layer to the front of the child list, so that
// child iframe layers are rendered on top of the base layer. These iframe // child iframe layers are painted on top of the base layer. These iframe
// layers were added previously when creating the layer tree skeleton in // layers were added previously when creating the layer tree skeleton in
// create_frame_tree_root_layers. // create_frame_tree_root_layers.
root_layer.children().insert(0, first_child); root_layer.children().insert(0, first_child);
@ -604,7 +604,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
} }
None => { None => {
// FIXME: This may potentially be triggered by a race condition where a // FIXME: This may potentially be triggered by a race condition where a
// buffers are being rendered but the layer is removed before rendering // buffers are being painted but the layer is removed before painting
// completes. // completes.
panic!("compositor given paint command for non-existent layer"); panic!("compositor given paint command for non-existent layer");
} }
@ -837,32 +837,32 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn convert_buffer_requests_to_pipeline_requests_map(&self, fn convert_buffer_requests_to_pipeline_requests_map(&self,
requests: Vec<(Rc<Layer<CompositorData>>, requests: Vec<(Rc<Layer<CompositorData>>,
Vec<BufferRequest>)>) -> Vec<BufferRequest>)>) ->
HashMap<PipelineId, (RenderChan, HashMap<PipelineId, (PaintChan,
Vec<RenderRequest>)> { Vec<PaintRequest>)> {
let scale = self.device_pixels_per_page_px(); let scale = self.device_pixels_per_page_px();
let mut results: let mut results:
HashMap<PipelineId, (RenderChan, Vec<RenderRequest>)> = HashMap::new(); HashMap<PipelineId, (PaintChan, Vec<PaintRequest>)> = HashMap::new();
for (layer, mut layer_requests) in requests.into_iter() { for (layer, mut layer_requests) in requests.into_iter() {
let &(_, ref mut vec) = let &(_, ref mut vec) =
match results.entry(layer.extra_data.borrow().pipeline.id) { match results.entry(layer.extra_data.borrow().pipeline.id) {
Occupied(mut entry) => { Occupied(mut entry) => {
*entry.get_mut() = *entry.get_mut() =
(layer.extra_data.borrow().pipeline.render_chan.clone(), vec!()); (layer.extra_data.borrow().pipeline.paint_chan.clone(), vec!());
entry.into_mut() entry.into_mut()
} }
Vacant(entry) => { Vacant(entry) => {
entry.set((layer.extra_data.borrow().pipeline.render_chan.clone(), vec!())) entry.set((layer.extra_data.borrow().pipeline.paint_chan.clone(), vec!()))
} }
}; };
// All the BufferRequests are in layer/device coordinates, but the render task // All the BufferRequests are in layer/device coordinates, but the paint task
// wants to know the page coordinates. We scale them before sending them. // wants to know the page coordinates. We scale them before sending them.
for request in layer_requests.iter_mut() { for request in layer_requests.iter_mut() {
request.page_rect = request.page_rect / scale.get(); request.page_rect = request.page_rect / scale.get();
} }
vec.push(RenderRequest { vec.push(PaintRequest {
buffer_requests: layer_requests, buffer_requests: layer_requests,
scale: scale.get(), scale: scale.get(),
layer_id: layer.extra_data.borrow().id, layer_id: layer.extra_data.borrow().id,
@ -879,7 +879,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let unused_buffers = self.scene.collect_unused_buffers(); let unused_buffers = self.scene.collect_unused_buffers();
if unused_buffers.len() != 0 { if unused_buffers.len() != 0 {
let message = UnusedBufferMsg(unused_buffers); let message = UnusedBufferMsg(unused_buffers);
let _ = pipeline.render_chan.send_opt(message); let _ = pipeline.paint_chan.send_opt(message);
} }
}, },
None => {} None => {}
@ -925,17 +925,17 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let pipeline_requests = let pipeline_requests =
self.convert_buffer_requests_to_pipeline_requests_map(layers_and_requests); self.convert_buffer_requests_to_pipeline_requests_map(layers_and_requests);
let mut num_render_msgs_sent = 0; let mut num_paint_msgs_sent = 0;
for (_pipeline_id, (chan, requests)) in pipeline_requests.into_iter() { for (_pipeline_id, (chan, requests)) in pipeline_requests.into_iter() {
num_render_msgs_sent += 1; num_paint_msgs_sent += 1;
let _ = chan.send_opt(RenderMsg(requests)); let _ = chan.send_opt(PaintMsg(requests));
} }
self.add_outstanding_render_msg(num_render_msgs_sent); self.add_outstanding_paint_msg(num_paint_msgs_sent);
true true
} }
fn is_ready_to_render_image_output(&self) -> bool { fn is_ready_to_paint_image_output(&self) -> bool {
if !self.got_load_complete_message { if !self.got_load_complete_message {
return false; return false;
} }
@ -944,11 +944,11 @@ impl<Window: WindowMethods> IOCompositor<Window> {
return false; return false;
} }
if self.has_outstanding_render_msgs() { if self.has_outstanding_paint_msgs() {
return false; return false;
} }
if !self.all_pipelines_in_idle_render_state() { if !self.all_pipelines_in_idle_paint_state() {
return false; return false;
} }
@ -961,7 +961,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn composite(&mut self) { fn composite(&mut self) {
let output_image = opts::get().output_file.is_some() && let output_image = opts::get().output_file.is_some() &&
self.is_ready_to_render_image_output(); self.is_ready_to_paint_image_output();
let mut framebuffer_ids = vec!(); let mut framebuffer_ids = vec!();
let mut texture_ids = vec!(); let mut texture_ids = vec!();
@ -992,7 +992,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
origin: Zero::zero(), origin: Zero::zero(),
size: self.window_size.as_f32(), size: self.window_size.as_f32(),
}; };
// Render the scene. // paint the scene.
match self.scene.root { match self.scene.root {
Some(ref layer) => { Some(ref layer) => {
rendergl::render_scene(layer.clone(), self.context, &self.scene); rendergl::render_scene(layer.clone(), self.context, &self.scene);

View file

@ -14,7 +14,7 @@ use geom::matrix::identity;
use geom::point::{Point2D, TypedPoint2D}; use geom::point::{Point2D, TypedPoint2D};
use geom::size::{Size2D, TypedSize2D}; use geom::size::{Size2D, TypedSize2D};
use geom::rect::Rect; use geom::rect::Rect;
use gfx::render_task::UnusedBufferMsg; use gfx::paint_task::UnusedBufferMsg;
use layers::color::Color; use layers::color::Color;
use layers::geometry::LayerPixel; use layers::geometry::LayerPixel;
use layers::layers::{Layer, LayerBufferSet}; use layers::layers::{Layer, LayerBufferSet};
@ -75,19 +75,19 @@ pub trait CompositorLayer {
fn add_buffers(&self, new_buffers: Box<LayerBufferSet>, epoch: Epoch) -> bool; fn add_buffers(&self, new_buffers: Box<LayerBufferSet>, epoch: Epoch) -> bool;
/// Destroys all layer tiles, sending the buffers back to the renderer to be destroyed or /// Destroys all layer tiles, sending the buffers back to the painter to be destroyed or
/// reused. /// reused.
fn clear(&self); fn clear(&self);
/// Destroys tiles for this layer and all descendent layers, sending the buffers back to the /// Destroys tiles for this layer and all descendent layers, sending the buffers back to the
/// renderer to be destroyed or reused. /// painter to be destroyed or reused.
fn clear_all_tiles(&self); fn clear_all_tiles(&self);
/// Destroys all tiles of all layers, including children, *without* sending them back to the /// Destroys all tiles of all layers, including children, *without* sending them back to the
/// renderer. You must call this only when the render task is destined to be going down; /// painter. You must call this only when the paint task is destined to be going down;
/// otherwise, you will leak tiles. /// otherwise, you will leak tiles.
/// ///
/// This is used during shutdown, when we know the render task is going away. /// This is used during shutdown, when we know the paint task is going away.
fn forget_all_tiles(&self); fn forget_all_tiles(&self);
/// Move the layer's descendants that don't want scroll events and scroll by a relative /// Move the layer's descendants that don't want scroll events and scroll by a relative
@ -194,7 +194,7 @@ impl CompositorLayer for Layer<CompositorData> {
epoch, epoch,
self.extra_data.borrow().pipeline.id); self.extra_data.borrow().pipeline.id);
let msg = UnusedBufferMsg(new_buffers.buffers); let msg = UnusedBufferMsg(new_buffers.buffers);
let _ = self.extra_data.borrow().pipeline.render_chan.send_opt(msg); let _ = self.extra_data.borrow().pipeline.paint_chan.send_opt(msg);
return false; return false;
} }
@ -206,7 +206,7 @@ impl CompositorLayer for Layer<CompositorData> {
let unused_buffers = self.collect_unused_buffers(); let unused_buffers = self.collect_unused_buffers();
if !unused_buffers.is_empty() { // send back unused buffers if !unused_buffers.is_empty() { // send back unused buffers
let msg = UnusedBufferMsg(unused_buffers); let msg = UnusedBufferMsg(unused_buffers);
let _ = self.extra_data.borrow().pipeline.render_chan.send_opt(msg); let _ = self.extra_data.borrow().pipeline.paint_chan.send_opt(msg);
} }
} }
@ -217,19 +217,19 @@ impl CompositorLayer for Layer<CompositorData> {
let mut buffers = self.collect_buffers(); let mut buffers = self.collect_buffers();
if !buffers.is_empty() { if !buffers.is_empty() {
// We have no way of knowing without a race whether the render task is even up and // We have no way of knowing without a race whether the paint task is even up and
// running, but mark the buffers as not leaking. If the render task died, then the // running, but mark the buffers as not leaking. If the paint task died, then the
// buffers are going to be cleaned up. // buffers are going to be cleaned up.
for buffer in buffers.iter_mut() { for buffer in buffers.iter_mut() {
buffer.mark_wont_leak() buffer.mark_wont_leak()
} }
let _ = self.extra_data.borrow().pipeline.render_chan.send_opt(UnusedBufferMsg(buffers)); let _ = self.extra_data.borrow().pipeline.paint_chan.send_opt(UnusedBufferMsg(buffers));
} }
} }
/// Destroys tiles for this layer and all descendent layers, sending the buffers back to the /// Destroys tiles for this layer and all descendent layers, sending the buffers back to the
/// renderer to be destroyed or reused. /// painter to be destroyed or reused.
fn clear_all_tiles(&self) { fn clear_all_tiles(&self) {
self.clear(); self.clear();
for kid in self.children().iter() { for kid in self.children().iter() {
@ -238,10 +238,10 @@ impl CompositorLayer for Layer<CompositorData> {
} }
/// Destroys all tiles of all layers, including children, *without* sending them back to the /// Destroys all tiles of all layers, including children, *without* sending them back to the
/// renderer. You must call this only when the render task is destined to be going down; /// painter. You must call this only when the paint task is destined to be going down;
/// otherwise, you will leak tiles. /// otherwise, you will leak tiles.
/// ///
/// This is used during shutdown, when we know the render task is going away. /// This is used during shutdown, when we know the paint task is going away.
fn forget_all_tiles(&self) { fn forget_all_tiles(&self) {
let tiles = self.collect_buffers(); let tiles = self.collect_buffers();
for tile in tiles.into_iter() { for tile in tiles.into_iter() {

View file

@ -18,7 +18,7 @@ use geom::size::Size2D;
use layers::platform::surface::{NativeCompositingGraphicsContext, NativeGraphicsMetadata}; use layers::platform::surface::{NativeCompositingGraphicsContext, NativeGraphicsMetadata};
use layers::layers::LayerBufferSet; use layers::layers::LayerBufferSet;
use servo_msg::compositor_msg::{Epoch, LayerId, LayerMetadata, ReadyState}; use servo_msg::compositor_msg::{Epoch, LayerId, LayerMetadata, ReadyState};
use servo_msg::compositor_msg::{RenderListener, RenderState, ScriptListener, ScrollPolicy}; use servo_msg::compositor_msg::{PaintListener, PaintState, ScriptListener, ScrollPolicy};
use servo_msg::constellation_msg::{ConstellationChan, PipelineId}; use servo_msg::constellation_msg::{ConstellationChan, PipelineId};
use servo_util::memory::MemoryProfilerChan; use servo_util::memory::MemoryProfilerChan;
use servo_util::time::TimeProfilerChan; use servo_util::time::TimeProfilerChan;
@ -108,8 +108,8 @@ impl LayerProperties {
} }
} }
/// Implementation of the abstract `RenderListener` interface. /// Implementation of the abstract `PaintListener` interface.
impl RenderListener for Box<CompositorProxy+'static+Send> { impl PaintListener for Box<CompositorProxy+'static+Send> {
fn get_graphics_metadata(&mut self) -> Option<NativeGraphicsMetadata> { fn get_graphics_metadata(&mut self) -> Option<NativeGraphicsMetadata> {
let (chan, port) = channel(); let (chan, port) = channel();
self.send(GetGraphicsMetadata(chan)); self.send(GetGraphicsMetadata(chan));
@ -142,12 +142,12 @@ impl RenderListener for Box<CompositorProxy+'static+Send> {
} }
} }
fn render_msg_discarded(&mut self) { fn paint_msg_discarded(&mut self) {
self.send(RenderMsgDiscarded); self.send(PaintMsgDiscarded);
} }
fn set_render_state(&mut self, pipeline_id: PipelineId, render_state: RenderState) { fn set_paint_state(&mut self, pipeline_id: PipelineId, paint_state: PaintState) {
self.send(ChangeRenderState(pipeline_id, render_state)) self.send(ChangePaintState(pipeline_id, paint_state))
} }
} }
@ -161,7 +161,7 @@ pub enum Msg {
/// at the time that we send it an ExitMsg. /// at the time that we send it an ExitMsg.
ShutdownComplete, ShutdownComplete,
/// Requests the compositor's graphics metadata. Graphics metadata is what the renderer needs /// Requests the compositor's graphics metadata. Graphics metadata is what the painter needs
/// to create surfaces that the compositor can see. On Linux this is the X display; on Mac this /// to create surfaces that the compositor can see. On Linux this is the X display; on Mac this
/// is the pixel format. /// is the pixel format.
/// ///
@ -182,11 +182,11 @@ pub enum Msg {
Paint(PipelineId, Epoch, Vec<(LayerId, Box<LayerBufferSet>)>), Paint(PipelineId, Epoch, Vec<(LayerId, Box<LayerBufferSet>)>),
/// Alerts the compositor to the current status of page loading. /// Alerts the compositor to the current status of page loading.
ChangeReadyState(PipelineId, ReadyState), ChangeReadyState(PipelineId, ReadyState),
/// Alerts the compositor to the current status of rendering. /// Alerts the compositor to the current status of painting.
ChangeRenderState(PipelineId, RenderState), ChangePaintState(PipelineId, PaintState),
/// Alerts the compositor that the RenderMsg has been discarded. /// Alerts the compositor that the PaintMsg has been discarded.
RenderMsgDiscarded, PaintMsgDiscarded,
/// Sets the channel to the current layout and render tasks, along with their id /// Sets the channel to the current layout and paint tasks, along with their id
SetIds(SendableFrameTree, Sender<()>, ConstellationChan), SetIds(SendableFrameTree, Sender<()>, ConstellationChan),
/// Sends an updated version of the frame tree. /// Sends an updated version of the frame tree.
FrameTreeUpdateMsg(FrameTreeDiff, Sender<()>), FrameTreeUpdateMsg(FrameTreeDiff, Sender<()>),
@ -209,8 +209,8 @@ impl Show for Msg {
ScrollFragmentPoint(..) => write!(f, "ScrollFragmentPoint"), ScrollFragmentPoint(..) => write!(f, "ScrollFragmentPoint"),
Paint(..) => write!(f, "Paint"), Paint(..) => write!(f, "Paint"),
ChangeReadyState(..) => write!(f, "ChangeReadyState"), ChangeReadyState(..) => write!(f, "ChangeReadyState"),
ChangeRenderState(..) => write!(f, "ChangeRenderState"), ChangePaintState(..) => write!(f, "ChangePaintState"),
RenderMsgDiscarded(..) => write!(f, "RenderMsgDiscarded"), PaintMsgDiscarded(..) => write!(f, "PaintMsgDiscarded"),
SetIds(..) => write!(f, "SetIds"), SetIds(..) => write!(f, "SetIds"),
FrameTreeUpdateMsg(..) => write!(f, "FrameTreeUpdateMsg"), FrameTreeUpdateMsg(..) => write!(f, "FrameTreeUpdateMsg"),
LoadComplete => write!(f, "LoadComplete"), LoadComplete => write!(f, "LoadComplete"),

View file

@ -10,7 +10,7 @@ use devtools_traits::DevtoolsControlChan;
use geom::rect::{Rect, TypedRect}; use geom::rect::{Rect, TypedRect};
use geom::scale_factor::ScaleFactor; use geom::scale_factor::ScaleFactor;
use gfx::font_cache_task::FontCacheTask; use gfx::font_cache_task::FontCacheTask;
use gfx::render_task; use gfx::paint_task;
use layers::geometry::DevicePixel; use layers::geometry::DevicePixel;
use layout_traits::{LayoutControlChan, LayoutTaskFactory, ExitNowMsg}; use layout_traits::{LayoutControlChan, LayoutTaskFactory, ExitNowMsg};
use libc; use libc;
@ -21,7 +21,7 @@ use servo_msg::compositor_msg::LayerId;
use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, FailureMsg, Failure, FrameRectMsg}; use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, FailureMsg, Failure, FrameRectMsg};
use servo_msg::constellation_msg::{IFrameSandboxState, IFrameUnsandboxed, InitLoadUrlMsg}; use servo_msg::constellation_msg::{IFrameSandboxState, IFrameUnsandboxed, InitLoadUrlMsg};
use servo_msg::constellation_msg::{LoadCompleteMsg, LoadUrlMsg, LoadData, Msg, NavigateMsg}; use servo_msg::constellation_msg::{LoadCompleteMsg, LoadUrlMsg, LoadData, Msg, NavigateMsg};
use servo_msg::constellation_msg::{NavigationType, PipelineId, RendererReadyMsg, ResizedWindowMsg}; use servo_msg::constellation_msg::{NavigationType, PipelineId, PainterReadyMsg, ResizedWindowMsg};
use servo_msg::constellation_msg::{ScriptLoadedURLInIFrameMsg, SubpageId, WindowSizeData}; use servo_msg::constellation_msg::{ScriptLoadedURLInIFrameMsg, SubpageId, WindowSizeData};
use servo_msg::constellation_msg::{KeyEvent, Key, KeyState, KeyModifiers}; use servo_msg::constellation_msg::{KeyEvent, Key, KeyState, KeyModifiers};
use servo_msg::constellation_msg; use servo_msg::constellation_msg;
@ -452,10 +452,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
debug!("constellation got navigation message"); debug!("constellation got navigation message");
self.handle_navigate_msg(direction); self.handle_navigate_msg(direction);
} }
// Notification that rendering has finished and is requesting permission to paint. // Notification that painting has finished and is requesting permission to paint.
RendererReadyMsg(pipeline_id) => { PainterReadyMsg(pipeline_id) => {
debug!("constellation got renderer ready message"); debug!("constellation got painter ready message");
self.handle_renderer_ready_msg(pipeline_id); self.handle_painter_ready_msg(pipeline_id);
} }
ResizedWindowMsg(new_size) => { ResizedWindowMsg(new_size) => {
debug!("constellation got window resize message"); debug!("constellation got window resize message");
@ -506,7 +506,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
fn force_pipeline_exit(old_pipeline: &Rc<Pipeline>) { fn force_pipeline_exit(old_pipeline: &Rc<Pipeline>) {
let ScriptControlChan(ref old_script) = old_pipeline.script_chan; let ScriptControlChan(ref old_script) = old_pipeline.script_chan;
let _ = old_script.send_opt(ExitPipelineMsg(old_pipeline.id)); let _ = old_script.send_opt(ExitPipelineMsg(old_pipeline.id));
let _ = old_pipeline.render_chan.send_opt(render_task::ExitMsg(None)); let _ = old_pipeline.paint_chan.send_opt(paint_task::ExitMsg(None));
let LayoutControlChan(ref old_layout) = old_pipeline.layout_chan; let LayoutControlChan(ref old_layout) = old_pipeline.layout_chan;
let _ = old_layout.send_opt(ExitNowMsg); let _ = old_layout.send_opt(ExitNowMsg);
} }
@ -787,8 +787,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}); });
} }
fn handle_renderer_ready_msg(&mut self, pipeline_id: PipelineId) { fn handle_painter_ready_msg(&mut self, pipeline_id: PipelineId) {
debug!("Renderer {} ready to send paint msg", pipeline_id); debug!("Painter {} ready to send paint msg", pipeline_id);
// This message could originate from a pipeline in the navigation context or // This message could originate from a pipeline in the navigation context or
// from a pending frame. The only time that we will grant paint permission is // from a pending frame. The only time that we will grant paint permission is
// when the message originates from a pending frame or the current frame. // when the message originates from a pending frame or the current frame.

View file

@ -4,7 +4,7 @@
use compositor_task::{GetGraphicsMetadata, CreateOrUpdateRootLayer, CreateOrUpdateDescendantLayer}; use compositor_task::{GetGraphicsMetadata, CreateOrUpdateRootLayer, CreateOrUpdateDescendantLayer};
use compositor_task::{Exit, ChangeReadyState, LoadComplete, Paint, ScrollFragmentPoint, SetIds}; use compositor_task::{Exit, ChangeReadyState, LoadComplete, Paint, ScrollFragmentPoint, SetIds};
use compositor_task::{SetLayerOrigin, ShutdownComplete, ChangeRenderState, RenderMsgDiscarded}; use compositor_task::{SetLayerOrigin, ShutdownComplete, ChangePaintState, PaintMsgDiscarded};
use compositor_task::{CompositorEventListener, CompositorReceiver, ScrollTimeout, FrameTreeUpdateMsg}; use compositor_task::{CompositorEventListener, CompositorReceiver, ScrollTimeout, FrameTreeUpdateMsg};
use windowing::WindowEvent; use windowing::WindowEvent;
@ -103,8 +103,8 @@ impl CompositorEventListener for NullCompositor {
CreateOrUpdateRootLayer(..) | CreateOrUpdateRootLayer(..) |
CreateOrUpdateDescendantLayer(..) | CreateOrUpdateDescendantLayer(..) |
SetLayerOrigin(..) | Paint(..) | SetLayerOrigin(..) | Paint(..) |
ChangeReadyState(..) | ChangeRenderState(..) | ScrollFragmentPoint(..) | ChangeReadyState(..) | ChangePaintState(..) | ScrollFragmentPoint(..) |
LoadComplete | RenderMsgDiscarded(..) | ScrollTimeout(..) => () LoadComplete | PaintMsgDiscarded(..) | ScrollTimeout(..) => ()
} }
true true
} }

View file

@ -8,8 +8,8 @@ use script_traits::{ScriptControlChan, ScriptTaskFactory};
use script_traits::{AttachLayoutMsg, LoadMsg, NewLayoutInfo, ExitPipelineMsg}; use script_traits::{AttachLayoutMsg, LoadMsg, NewLayoutInfo, ExitPipelineMsg};
use devtools_traits::DevtoolsControlChan; use devtools_traits::DevtoolsControlChan;
use gfx::render_task::{PaintPermissionGranted, PaintPermissionRevoked}; use gfx::paint_task::{PaintPermissionGranted, PaintPermissionRevoked};
use gfx::render_task::{RenderChan, RenderTask}; use gfx::paint_task::{PaintChan, PaintTask};
use servo_msg::constellation_msg::{ConstellationChan, Failure, PipelineId, SubpageId}; use servo_msg::constellation_msg::{ConstellationChan, Failure, PipelineId, SubpageId};
use servo_msg::constellation_msg::{LoadData, WindowSizeData}; use servo_msg::constellation_msg::{LoadData, WindowSizeData};
use servo_net::image_cache_task::ImageCacheTask; use servo_net::image_cache_task::ImageCacheTask;
@ -19,15 +19,15 @@ use servo_net::storage_task::StorageTask;
use servo_util::time::TimeProfilerChan; use servo_util::time::TimeProfilerChan;
use std::rc::Rc; use std::rc::Rc;
/// A uniquely-identifiable pipeline of script task, layout task, and render task. /// A uniquely-identifiable pipeline of script task, layout task, and paint task.
pub struct Pipeline { pub struct Pipeline {
pub id: PipelineId, pub id: PipelineId,
pub subpage_id: Option<SubpageId>, pub subpage_id: Option<SubpageId>,
pub script_chan: ScriptControlChan, pub script_chan: ScriptControlChan,
pub layout_chan: LayoutControlChan, pub layout_chan: LayoutControlChan,
pub render_chan: RenderChan, pub paint_chan: PaintChan,
pub layout_shutdown_port: Receiver<()>, pub layout_shutdown_port: Receiver<()>,
pub render_shutdown_port: Receiver<()>, pub paint_shutdown_port: Receiver<()>,
/// The most recently loaded page /// The most recently loaded page
pub load_data: LoadData, pub load_data: LoadData,
} }
@ -37,11 +37,11 @@ pub struct Pipeline {
pub struct CompositionPipeline { pub struct CompositionPipeline {
pub id: PipelineId, pub id: PipelineId,
pub script_chan: ScriptControlChan, pub script_chan: ScriptControlChan,
pub render_chan: RenderChan, pub paint_chan: PaintChan,
} }
impl Pipeline { impl Pipeline {
/// Starts a render task, layout task, and possibly a script task. /// Starts a paint task, layout task, and possibly a script task.
/// Returns the channels wrapped in a struct. /// Returns the channels wrapped in a struct.
/// If script_pipeline is not None, then subpage_id must also be not None. /// If script_pipeline is not None, then subpage_id must also be not None.
pub fn create<LTF:LayoutTaskFactory, STF:ScriptTaskFactory>( pub fn create<LTF:LayoutTaskFactory, STF:ScriptTaskFactory>(
@ -60,8 +60,8 @@ impl Pipeline {
load_data: LoadData) load_data: LoadData)
-> Pipeline { -> Pipeline {
let layout_pair = ScriptTaskFactory::create_layout_channel(None::<&mut STF>); let layout_pair = ScriptTaskFactory::create_layout_channel(None::<&mut STF>);
let (render_port, render_chan) = RenderChan::new(); let (paint_port, paint_chan) = PaintChan::new();
let (render_shutdown_chan, render_shutdown_port) = channel(); let (paint_shutdown_chan, paint_shutdown_port) = channel();
let (layout_shutdown_chan, layout_shutdown_port) = channel(); let (layout_shutdown_chan, layout_shutdown_port) = channel();
let (pipeline_chan, pipeline_port) = channel(); let (pipeline_chan, pipeline_port) = channel();
@ -102,14 +102,14 @@ impl Pipeline {
} }
}; };
RenderTask::create(id, PaintTask::create(id,
render_port, paint_port,
compositor_proxy, compositor_proxy,
constellation_chan.clone(), constellation_chan.clone(),
font_cache_task.clone(), font_cache_task.clone(),
failure.clone(), failure.clone(),
time_profiler_chan.clone(), time_profiler_chan.clone(),
render_shutdown_chan); paint_shutdown_chan);
LayoutTaskFactory::create(None::<&mut LTF>, LayoutTaskFactory::create(None::<&mut LTF>,
id, id,
@ -118,7 +118,7 @@ impl Pipeline {
constellation_chan, constellation_chan,
failure, failure,
script_chan.clone(), script_chan.clone(),
render_chan.clone(), paint_chan.clone(),
resource_task, resource_task,
image_cache_task, image_cache_task,
font_cache_task, font_cache_task,
@ -129,9 +129,9 @@ impl Pipeline {
subpage_id, subpage_id,
script_chan, script_chan,
LayoutControlChan(pipeline_chan), LayoutControlChan(pipeline_chan),
render_chan, paint_chan,
layout_shutdown_port, layout_shutdown_port,
render_shutdown_port, paint_shutdown_port,
load_data) load_data)
} }
@ -139,9 +139,9 @@ impl Pipeline {
subpage_id: Option<SubpageId>, subpage_id: Option<SubpageId>,
script_chan: ScriptControlChan, script_chan: ScriptControlChan,
layout_chan: LayoutControlChan, layout_chan: LayoutControlChan,
render_chan: RenderChan, paint_chan: PaintChan,
layout_shutdown_port: Receiver<()>, layout_shutdown_port: Receiver<()>,
render_shutdown_port: Receiver<()>, paint_shutdown_port: Receiver<()>,
load_data: LoadData) load_data: LoadData)
-> Pipeline { -> Pipeline {
Pipeline { Pipeline {
@ -149,9 +149,9 @@ impl Pipeline {
subpage_id: subpage_id, subpage_id: subpage_id,
script_chan: script_chan, script_chan: script_chan,
layout_chan: layout_chan, layout_chan: layout_chan,
render_chan: render_chan, paint_chan: paint_chan,
layout_shutdown_port: layout_shutdown_port, layout_shutdown_port: layout_shutdown_port,
render_shutdown_port: render_shutdown_port, paint_shutdown_port: paint_shutdown_port,
load_data: load_data, load_data: load_data,
} }
} }
@ -162,24 +162,24 @@ impl Pipeline {
} }
pub fn grant_paint_permission(&self) { pub fn grant_paint_permission(&self) {
let _ = self.render_chan.send_opt(PaintPermissionGranted); let _ = self.paint_chan.send_opt(PaintPermissionGranted);
} }
pub fn revoke_paint_permission(&self) { pub fn revoke_paint_permission(&self) {
debug!("pipeline revoking render channel paint permission"); debug!("pipeline revoking paint channel paint permission");
let _ = self.render_chan.send_opt(PaintPermissionRevoked); let _ = self.paint_chan.send_opt(PaintPermissionRevoked);
} }
pub fn exit(&self) { pub fn exit(&self) {
debug!("pipeline {} exiting", self.id); debug!("pipeline {} exiting", self.id);
// Script task handles shutting down layout, and layout handles shutting down the renderer. // Script task handles shutting down layout, and layout handles shutting down the painter.
// For now, if the script task has failed, we give up on clean shutdown. // For now, if the script task has failed, we give up on clean shutdown.
let ScriptControlChan(ref chan) = self.script_chan; let ScriptControlChan(ref chan) = self.script_chan;
if chan.send_opt(ExitPipelineMsg(self.id)).is_ok() { if chan.send_opt(ExitPipelineMsg(self.id)).is_ok() {
// Wait until all slave tasks have terminated and run destructors // Wait until all slave tasks have terminated and run destructors
// NOTE: We don't wait for script task as we don't always own it // NOTE: We don't wait for script task as we don't always own it
let _ = self.render_shutdown_port.recv_opt(); let _ = self.paint_shutdown_port.recv_opt();
let _ = self.layout_shutdown_port.recv_opt(); let _ = self.layout_shutdown_port.recv_opt();
} }
} }
@ -188,7 +188,7 @@ impl Pipeline {
CompositionPipeline { CompositionPipeline {
id: self.id.clone(), id: self.id.clone(),
script_chan: self.script_chan.clone(), script_chan: self.script_chan.clone(),
render_chan: self.render_chan.clone(), paint_chan: self.paint_chan.clone(),
} }
} }
} }

View file

@ -12,7 +12,7 @@ use geom::size::TypedSize2D;
use layers::geometry::DevicePixel; use layers::geometry::DevicePixel;
use layers::platform::surface::NativeGraphicsMetadata; use layers::platform::surface::NativeGraphicsMetadata;
use servo_msg::constellation_msg::{Key, KeyState, KeyModifiers}; use servo_msg::constellation_msg::{Key, KeyState, KeyModifiers};
use servo_msg::compositor_msg::{ReadyState, RenderState}; use servo_msg::compositor_msg::{ReadyState, PaintState};
use servo_util::geometry::ScreenPx; use servo_util::geometry::ScreenPx;
use std::fmt::{FormatError, Formatter, Show}; use std::fmt::{FormatError, Formatter, Show};
use std::rc::Rc; use std::rc::Rc;
@ -90,8 +90,8 @@ pub trait WindowMethods {
/// Sets the ready state of the current page. /// Sets the ready state of the current page.
fn set_ready_state(&self, ready_state: ReadyState); fn set_ready_state(&self, ready_state: ReadyState);
/// Sets the render state of the current page. /// Sets the paint state of the current page.
fn set_render_state(&self, render_state: RenderState); fn set_paint_state(&self, paint_state: PaintState);
/// Returns the hidpi factor of the monitor. /// Returns the hidpi factor of the monitor.
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32>; fn hidpi_factor(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32>;

View file

@ -12,7 +12,7 @@ use std::hash::sip::SipState;
use std::mem; use std::mem;
/// This is a struct used to store buffers when they are not in use. /// This is a struct used to store buffers when they are not in use.
/// The render task can quickly query for a particular size of buffer when it /// The paint task can quickly query for a particular size of buffer when it
/// needs it. /// needs it.
pub struct BufferMap { pub struct BufferMap {
/// A HashMap that stores the Buffers. /// A HashMap that stores the Buffers.

View file

@ -2,12 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Servo heavily uses display lists, which are retained-mode lists of rendering commands to //! Servo heavily uses display lists, which are retained-mode lists of painting commands to
//! perform. Using a list instead of rendering elements in immediate mode allows transforms, hit //! perform. Using a list instead of painting elements in immediate mode allows transforms, hit
//! testing, and invalidation to be performed using the same primitives as painting. It also allows //! testing, and invalidation to be performed using the same primitives as painting. It also allows
//! Servo to aggressively cull invisible and out-of-bounds rendering elements, to reduce overdraw. //! Servo to aggressively cull invisible and out-of-bounds painting elements, to reduce overdraw.
//! Finally, display lists allow tiles to be farmed out onto multiple CPUs and rendered in //! Finally, display lists allow tiles to be farmed out onto multiple CPUs and painted in
//! parallel (although this benefit does not apply to GPU-based rendering). //! parallel (although this benefit does not apply to GPU-based painting).
//! //!
//! Display items describe relatively high-level drawing operations (for example, entire borders //! Display items describe relatively high-level drawing operations (for example, entire borders
//! and shadows instead of lines and blur operations), to reduce the amount of allocation required. //! and shadows instead of lines and blur operations), to reduce the amount of allocation required.
@ -16,7 +16,7 @@
use color::Color; use color::Color;
use display_list::optimizer::DisplayListOptimizer; use display_list::optimizer::DisplayListOptimizer;
use render_context::{RenderContext, ToAzureRect}; use paint_context::{PaintContext, ToAzureRect};
use text::glyph::CharIndex; use text::glyph::CharIndex;
use text::TextRun; use text::TextRun;
@ -24,7 +24,7 @@ use azure::azure::AzFloat;
use collections::dlist::{mod, DList}; use collections::dlist::{mod, DList};
use geom::{Point2D, Rect, SideOffsets2D, Size2D, Matrix2D}; use geom::{Point2D, Rect, SideOffsets2D, Size2D, Matrix2D};
use libc::uintptr_t; use libc::uintptr_t;
use render_task::RenderLayer; use paint_task::PaintLayer;
use script_traits::UntrustedNodeAddress; use script_traits::UntrustedNodeAddress;
use servo_msg::compositor_msg::LayerId; use servo_msg::compositor_msg::LayerId;
use servo_net::image::base::Image; use servo_net::image::base::Image;
@ -138,7 +138,7 @@ pub struct StackingContext {
/// The display items that make up this stacking context. /// The display items that make up this stacking context.
pub display_list: Box<DisplayList>, pub display_list: Box<DisplayList>,
/// The layer for this stacking context, if there is one. /// The layer for this stacking context, if there is one.
pub layer: Option<Arc<RenderLayer>>, pub layer: Option<Arc<PaintLayer>>,
/// The position and size of this stacking context. /// The position and size of this stacking context.
pub bounds: Rect<Au>, pub bounds: Rect<Au>,
/// The clipping rect for this stacking context, in the coordinate system of the *parent* /// The clipping rect for this stacking context, in the coordinate system of the *parent*
@ -160,7 +160,7 @@ impl StackingContext {
bounds: Rect<Au>, bounds: Rect<Au>,
z_index: i32, z_index: i32,
opacity: AzFloat, opacity: AzFloat,
layer: Option<Arc<RenderLayer>>) layer: Option<Arc<PaintLayer>>)
-> StackingContext { -> StackingContext {
StackingContext { StackingContext {
display_list: display_list, display_list: display_list,
@ -174,19 +174,19 @@ impl StackingContext {
/// Draws the stacking context in the proper order according to the steps in CSS 2.1 § E.2. /// Draws the stacking context in the proper order according to the steps in CSS 2.1 § E.2.
pub fn optimize_and_draw_into_context(&self, pub fn optimize_and_draw_into_context(&self,
render_context: &mut RenderContext, paint_context: &mut PaintContext,
tile_bounds: &Rect<AzFloat>, tile_bounds: &Rect<AzFloat>,
current_transform: &Matrix2D<AzFloat>, current_transform: &Matrix2D<AzFloat>,
current_clip_stack: &mut Vec<Rect<Au>>) { current_clip_stack: &mut Vec<Rect<Au>>) {
let temporary_draw_target = let temporary_draw_target =
render_context.get_or_create_temporary_draw_target(self.opacity); paint_context.get_or_create_temporary_draw_target(self.opacity);
{ {
let mut render_subcontext = RenderContext { let mut paint_subcontext = PaintContext {
draw_target: temporary_draw_target.clone(), draw_target: temporary_draw_target.clone(),
font_ctx: &mut *render_context.font_ctx, font_ctx: &mut *paint_context.font_ctx,
page_rect: render_context.page_rect, page_rect: paint_context.page_rect,
screen_rect: render_context.screen_rect, screen_rect: paint_context.screen_rect,
..*render_context ..*paint_context
}; };
// Optimize the display list to throw out out-of-bounds display items and so forth. // Optimize the display list to throw out out-of-bounds display items and so forth.
@ -203,7 +203,7 @@ impl StackingContext {
// Steps 1 and 2: Borders and background for the root. // Steps 1 and 2: Borders and background for the root.
for display_item in display_list.background_and_borders.iter() { for display_item in display_list.background_and_borders.iter() {
display_item.draw_into_context(&mut render_subcontext, display_item.draw_into_context(&mut paint_subcontext,
current_transform, current_transform,
current_clip_stack) current_clip_stack)
} }
@ -222,7 +222,7 @@ impl StackingContext {
let new_tile_rect = let new_tile_rect =
self.compute_tile_rect_for_child_stacking_context(tile_bounds, self.compute_tile_rect_for_child_stacking_context(tile_bounds,
&**positioned_kid); &**positioned_kid);
positioned_kid.optimize_and_draw_into_context(&mut render_subcontext, positioned_kid.optimize_and_draw_into_context(&mut paint_subcontext,
&new_tile_rect, &new_tile_rect,
&new_transform, &new_transform,
current_clip_stack); current_clip_stack);
@ -231,14 +231,14 @@ impl StackingContext {
// Step 4: Block backgrounds and borders. // Step 4: Block backgrounds and borders.
for display_item in display_list.block_backgrounds_and_borders.iter() { for display_item in display_list.block_backgrounds_and_borders.iter() {
display_item.draw_into_context(&mut render_subcontext, display_item.draw_into_context(&mut paint_subcontext,
current_transform, current_transform,
current_clip_stack) current_clip_stack)
} }
// Step 5: Floats. // Step 5: Floats.
for display_item in display_list.floats.iter() { for display_item in display_list.floats.iter() {
display_item.draw_into_context(&mut render_subcontext, display_item.draw_into_context(&mut paint_subcontext,
current_transform, current_transform,
current_clip_stack) current_clip_stack)
} }
@ -247,7 +247,7 @@ impl StackingContext {
// Step 7: Content. // Step 7: Content.
for display_item in display_list.content.iter() { for display_item in display_list.content.iter() {
display_item.draw_into_context(&mut render_subcontext, display_item.draw_into_context(&mut paint_subcontext,
current_transform, current_transform,
current_clip_stack) current_clip_stack)
} }
@ -267,7 +267,7 @@ impl StackingContext {
let new_tile_rect = let new_tile_rect =
self.compute_tile_rect_for_child_stacking_context(tile_bounds, self.compute_tile_rect_for_child_stacking_context(tile_bounds,
&**positioned_kid); &**positioned_kid);
positioned_kid.optimize_and_draw_into_context(&mut render_subcontext, positioned_kid.optimize_and_draw_into_context(&mut paint_subcontext,
&new_tile_rect, &new_tile_rect,
&new_transform, &new_transform,
current_clip_stack); current_clip_stack);
@ -277,7 +277,7 @@ impl StackingContext {
// TODO(pcwalton): Step 10: Outlines. // TODO(pcwalton): Step 10: Outlines.
} }
render_context.draw_temporary_draw_target_if_necessary(&temporary_draw_target, paint_context.draw_temporary_draw_target_if_necessary(&temporary_draw_target,
self.opacity) self.opacity)
} }
@ -439,14 +439,14 @@ impl BaseDisplayItem {
} }
} }
/// Renders a solid color. /// Paints a solid color.
#[deriving(Clone)] #[deriving(Clone)]
pub struct SolidColorDisplayItem { pub struct SolidColorDisplayItem {
pub base: BaseDisplayItem, pub base: BaseDisplayItem,
pub color: Color, pub color: Color,
} }
/// Renders text. /// Paints text.
#[deriving(Clone)] #[deriving(Clone)]
pub struct TextDisplayItem { pub struct TextDisplayItem {
/// Fields common to all display items. /// Fields common to all display items.
@ -472,7 +472,7 @@ pub enum TextOrientation {
SidewaysRight, SidewaysRight,
} }
/// Renders an image. /// Paints an image.
#[deriving(Clone)] #[deriving(Clone)]
pub struct ImageDisplayItem { pub struct ImageDisplayItem {
pub base: BaseDisplayItem, pub base: BaseDisplayItem,
@ -500,7 +500,7 @@ pub struct GradientDisplayItem {
pub stops: Vec<GradientStop>, pub stops: Vec<GradientStop>,
} }
/// Renders a border. /// Paints a border.
#[deriving(Clone)] #[deriving(Clone)]
pub struct BorderDisplayItem { pub struct BorderDisplayItem {
/// Fields common to all display items. /// Fields common to all display items.
@ -532,7 +532,7 @@ pub struct BorderRadii<T> {
pub bottom_left: T, pub bottom_left: T,
} }
/// Renders a line segment. /// Paints a line segment.
#[deriving(Clone)] #[deriving(Clone)]
pub struct LineDisplayItem { pub struct LineDisplayItem {
pub base: BaseDisplayItem, pub base: BaseDisplayItem,
@ -560,32 +560,32 @@ impl<'a> Iterator<&'a DisplayItem> for DisplayItemIterator<'a> {
} }
impl DisplayItem { impl DisplayItem {
/// Renders this display item into the given render context. /// Paints this display item into the given paint context.
fn draw_into_context(&self, fn draw_into_context(&self,
render_context: &mut RenderContext, paint_context: &mut PaintContext,
current_transform: &Matrix2D<AzFloat>, current_transform: &Matrix2D<AzFloat>,
current_clip_stack: &mut Vec<Rect<Au>>) { current_clip_stack: &mut Vec<Rect<Au>>) {
// TODO(pcwalton): This will need some tweaking to deal with more complex clipping regions. // TODO(pcwalton): This will need some tweaking to deal with more complex clipping regions.
let clip_rect = &self.base().clip_rect; let clip_rect = &self.base().clip_rect;
if current_clip_stack.len() == 0 || current_clip_stack.last().unwrap() != clip_rect { if current_clip_stack.len() == 0 || current_clip_stack.last().unwrap() != clip_rect {
while current_clip_stack.len() != 0 { while current_clip_stack.len() != 0 {
render_context.draw_pop_clip(); paint_context.draw_pop_clip();
drop(current_clip_stack.pop()); drop(current_clip_stack.pop());
} }
render_context.draw_push_clip(clip_rect); paint_context.draw_push_clip(clip_rect);
current_clip_stack.push(*clip_rect); current_clip_stack.push(*clip_rect);
} }
render_context.draw_target.set_transform(current_transform); paint_context.draw_target.set_transform(current_transform);
match *self { match *self {
SolidColorDisplayItemClass(ref solid_color) => { SolidColorDisplayItemClass(ref solid_color) => {
render_context.draw_solid_color(&solid_color.base.bounds, solid_color.color) paint_context.draw_solid_color(&solid_color.base.bounds, solid_color.color)
} }
TextDisplayItemClass(ref text) => { TextDisplayItemClass(ref text) => {
debug!("Drawing text at {}.", text.base.bounds); debug!("Drawing text at {}.", text.base.bounds);
render_context.draw_text(&**text, current_transform); paint_context.draw_text(&**text, current_transform);
} }
ImageDisplayItemClass(ref image_item) => { ImageDisplayItemClass(ref image_item) => {
@ -600,7 +600,7 @@ impl DisplayItem {
bounds.origin.y = bounds.origin.y + y_offset; bounds.origin.y = bounds.origin.y + y_offset;
bounds.size = image_item.stretch_size; bounds.size = image_item.stretch_size;
render_context.draw_image(bounds, image_item.image.clone()); paint_context.draw_image(bounds, image_item.image.clone());
x_offset = x_offset + image_item.stretch_size.width; x_offset = x_offset + image_item.stretch_size.width;
} }
@ -610,7 +610,7 @@ impl DisplayItem {
} }
BorderDisplayItemClass(ref border) => { BorderDisplayItemClass(ref border) => {
render_context.draw_border(&border.base.bounds, paint_context.draw_border(&border.base.bounds,
border.border_widths, border.border_widths,
&border.radius, &border.radius,
border.color, border.color,
@ -618,14 +618,14 @@ impl DisplayItem {
} }
GradientDisplayItemClass(ref gradient) => { GradientDisplayItemClass(ref gradient) => {
render_context.draw_linear_gradient(&gradient.base.bounds, paint_context.draw_linear_gradient(&gradient.base.bounds,
&gradient.start_point, &gradient.start_point,
&gradient.end_point, &gradient.end_point,
gradient.stops.as_slice()); gradient.stops.as_slice());
} }
LineDisplayItemClass(ref line) => { LineDisplayItemClass(ref line) => {
render_context.draw_line(&line.base.bounds, paint_context.draw_line(&line.base.bounds,
line.color, line.color,
line.style) line.style)
} }

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Transforms a display list to produce a visually-equivalent, but cheaper-to-render, one. //! Transforms a display list to produce a visually-equivalent, but cheaper-to-paint, one.
use display_list::{DisplayItem, DisplayList, StackingContext}; use display_list::{DisplayItem, DisplayList, StackingContext};
@ -11,7 +11,7 @@ use geom::rect::Rect;
use servo_util::geometry::{mod, Au}; use servo_util::geometry::{mod, Au};
use sync::Arc; use sync::Arc;
/// Transforms a display list to produce a visually-equivalent, but cheaper-to-render, one. /// Transforms a display list to produce a visually-equivalent, but cheaper-to-paint, one.
pub struct DisplayListOptimizer { pub struct DisplayListOptimizer {
/// The visible rect in page coordinates. /// The visible rect in page coordinates.
visible_rect: Rect<Au>, visible_rect: Rect<Au>,

View file

@ -50,9 +50,9 @@ struct FallbackFontCacheEntry {
font: Rc<RefCell<Font>>, font: Rc<RefCell<Font>>,
} }
/// A cached azure font (per render task) that /// A cached azure font (per paint task) that
/// can be shared by multiple text runs. /// can be shared by multiple text runs.
struct RenderFontCacheEntry { struct PaintFontCacheEntry {
pt_size: Au, pt_size: Au,
identifier: String, identifier: String,
font: Rc<RefCell<ScaledFont>>, font: Rc<RefCell<ScaledFont>>,
@ -60,7 +60,7 @@ struct RenderFontCacheEntry {
/// The FontContext represents the per-thread/task state necessary for /// The FontContext represents the per-thread/task state necessary for
/// working with fonts. It is the public API used by the layout and /// working with fonts. It is the public API used by the layout and
/// render code. It talks directly to the font cache task where /// paint code. It talks directly to the font cache task where
/// required. /// required.
pub struct FontContext { pub struct FontContext {
platform_handle: FontContextHandle, platform_handle: FontContextHandle,
@ -70,9 +70,9 @@ pub struct FontContext {
layout_font_cache: Vec<LayoutFontCacheEntry>, layout_font_cache: Vec<LayoutFontCacheEntry>,
fallback_font_cache: Vec<FallbackFontCacheEntry>, fallback_font_cache: Vec<FallbackFontCacheEntry>,
/// Strong reference as the render FontContext is (for now) recycled /// Strong reference as the paint FontContext is (for now) recycled
/// per frame. TODO: Make this weak when incremental redraw is done. /// per frame. TODO: Make this weak when incremental redraw is done.
render_font_cache: Vec<RenderFontCacheEntry>, paint_font_cache: Vec<PaintFontCacheEntry>,
last_style: Option<Arc<SpecifiedFontStyle>>, last_style: Option<Arc<SpecifiedFontStyle>>,
last_fontgroup: Option<Rc<FontGroup>>, last_fontgroup: Option<Rc<FontGroup>>,
@ -86,7 +86,7 @@ impl FontContext {
font_cache_task: font_cache_task, font_cache_task: font_cache_task,
layout_font_cache: vec!(), layout_font_cache: vec!(),
fallback_font_cache: vec!(), fallback_font_cache: vec!(),
render_font_cache: vec!(), paint_font_cache: vec!(),
last_style: None, last_style: None,
last_fontgroup: None, last_fontgroup: None,
} }
@ -97,7 +97,7 @@ impl FontContext {
descriptor: FontTemplateDescriptor, pt_size: Au, descriptor: FontTemplateDescriptor, pt_size: Au,
variant: font_variant::T) -> Font { variant: font_variant::T) -> Font {
// TODO: (Bug #3463): Currently we only support fake small-caps // TODO: (Bug #3463): Currently we only support fake small-caps
// rendering. We should also support true small-caps (where the // painting. We should also support true small-caps (where the
// font supports it) in the future. // font supports it) in the future.
let actual_pt_size = match variant { let actual_pt_size = match variant {
font_variant::small_caps => pt_size.scale_by(SMALL_CAPS_SCALE_FACTOR), font_variant::small_caps => pt_size.scale_by(SMALL_CAPS_SCALE_FACTOR),
@ -227,26 +227,26 @@ impl FontContext {
font_group font_group
} }
/// Create a render font for use with azure. May return a cached /// Create a paint font for use with azure. May return a cached
/// reference if already used by this font context. /// reference if already used by this font context.
pub fn get_render_font_from_template(&mut self, pub fn get_paint_font_from_template(&mut self,
template: &Arc<FontTemplateData>, template: &Arc<FontTemplateData>,
pt_size: Au) pt_size: Au)
-> Rc<RefCell<ScaledFont>> { -> Rc<RefCell<ScaledFont>> {
for cached_font in self.render_font_cache.iter() { for cached_font in self.paint_font_cache.iter() {
if cached_font.pt_size == pt_size && if cached_font.pt_size == pt_size &&
cached_font.identifier == template.identifier { cached_font.identifier == template.identifier {
return cached_font.font.clone(); return cached_font.font.clone();
} }
} }
let render_font = Rc::new(RefCell::new(create_scaled_font(template, pt_size))); let paint_font = Rc::new(RefCell::new(create_scaled_font(template, pt_size)));
self.render_font_cache.push(RenderFontCacheEntry{ self.paint_font_cache.push(PaintFontCacheEntry{
font: render_font.clone(), font: paint_font.clone(),
pt_size: pt_size, pt_size: pt_size,
identifier: template.identifier.clone(), identifier: template.identifier.clone(),
}); });
render_font paint_font
} }
/// Returns a reference to the font cache task. /// Returns a reference to the font cache task.

View file

@ -50,16 +50,16 @@ extern crate freetype;
#[cfg(target_os="macos")] extern crate core_graphics; #[cfg(target_os="macos")] extern crate core_graphics;
#[cfg(target_os="macos")] extern crate core_text; #[cfg(target_os="macos")] extern crate core_text;
pub use render_context::RenderContext; pub use paint_context::PaintContext;
// Private rendering modules // Private painting modules
mod render_context; mod paint_context;
// Rendering // Painting
pub mod color; pub mod color;
#[path="display_list/mod.rs"] #[path="display_list/mod.rs"]
pub mod display_list; pub mod display_list;
pub mod render_task; pub mod paint_task;
// Fonts // Fonts
pub mod font; pub mod font;

View file

@ -33,7 +33,7 @@ use sync::Arc;
use text::TextRun; use text::TextRun;
use text::glyph::CharIndex; use text::glyph::CharIndex;
pub struct RenderContext<'a> { pub struct PaintContext<'a> {
pub draw_target: DrawTarget, pub draw_target: DrawTarget,
pub font_ctx: &'a mut Box<FontContext>, pub font_ctx: &'a mut Box<FontContext>,
/// The rectangle that this context encompasses in page coordinates. /// The rectangle that this context encompasses in page coordinates.
@ -54,7 +54,7 @@ enum DashSize {
DashedBorder = 3 DashedBorder = 3
} }
impl<'a> RenderContext<'a> { impl<'a> PaintContext<'a> {
pub fn get_draw_target(&self) -> &DrawTarget { pub fn get_draw_target(&self) -> &DrawTarget {
&self.draw_target &self.draw_target
} }
@ -657,7 +657,7 @@ impl<'a> RenderContext<'a> {
}; };
self.font_ctx self.font_ctx
.get_render_font_from_template(&text.text_run.font_template, .get_paint_font_from_template(&text.text_run.font_template,
text.text_run.actual_pt_size) text.text_run.actual_pt_size)
.borrow() .borrow()
.draw_text_into_context(self, .draw_text_into_context(self,
@ -717,7 +717,7 @@ impl<'a> RenderContext<'a> {
temporary_draw_target: &DrawTarget, temporary_draw_target: &DrawTarget,
opacity: AzFloat) { opacity: AzFloat) {
if (*temporary_draw_target) == self.draw_target { if (*temporary_draw_target) == self.draw_target {
// We're directly rendering to the surface; nothing to do. // We're directly painting to the surface; nothing to do.
return return
} }
@ -803,7 +803,7 @@ impl ToRadiiPx for BorderRadii<Au> {
trait ScaledFontExtensionMethods { trait ScaledFontExtensionMethods {
fn draw_text_into_context(&self, fn draw_text_into_context(&self,
rctx: &RenderContext, rctx: &PaintContext,
run: &Box<TextRun>, run: &Box<TextRun>,
range: &Range<CharIndex>, range: &Range<CharIndex>,
baseline_origin: Point2D<Au>, baseline_origin: Point2D<Au>,
@ -813,7 +813,7 @@ trait ScaledFontExtensionMethods {
impl ScaledFontExtensionMethods for ScaledFont { impl ScaledFontExtensionMethods for ScaledFont {
fn draw_text_into_context(&self, fn draw_text_into_context(&self,
rctx: &RenderContext, rctx: &PaintContext,
run: &Box<TextRun>, run: &Box<TextRun>,
range: &Range<CharIndex>, range: &Range<CharIndex>,
baseline_origin: Point2D<Au>, baseline_origin: Point2D<Au>,

View file

@ -2,13 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! The task that handles all rendering/painting. //! The task that handles all painting.
use buffer_map::BufferMap; use buffer_map::BufferMap;
use display_list::{mod, StackingContext}; use display_list::{mod, StackingContext};
use font_cache_task::FontCacheTask; use font_cache_task::FontCacheTask;
use font_context::FontContext; use font_context::FontContext;
use render_context::RenderContext; use paint_context::PaintContext;
use azure::azure_hl::{B8G8R8A8, Color, DrawTarget, SkiaBackend, StolenGLResources}; use azure::azure_hl::{B8G8R8A8, Color, DrawTarget, SkiaBackend, StolenGLResources};
use azure::AzFloat; use azure::AzFloat;
@ -21,10 +21,10 @@ use layers::platform::surface::{NativeSurface, NativeSurfaceMethods};
use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet}; use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet};
use layers; use layers;
use native::task::NativeTaskBuilder; use native::task::NativeTaskBuilder;
use servo_msg::compositor_msg::{Epoch, IdleRenderState, LayerId}; use servo_msg::compositor_msg::{Epoch, IdlePaintState, LayerId};
use servo_msg::compositor_msg::{LayerMetadata, RenderListener, RenderingRenderState, ScrollPolicy}; use servo_msg::compositor_msg::{LayerMetadata, PaintListener, PaintingPaintState, ScrollPolicy};
use servo_msg::constellation_msg::{ConstellationChan, Failure, FailureMsg, PipelineId}; use servo_msg::constellation_msg::{ConstellationChan, Failure, FailureMsg, PipelineId};
use servo_msg::constellation_msg::{RendererReadyMsg}; use servo_msg::constellation_msg::{PainterReadyMsg};
use servo_msg::platform::surface::NativeSurfaceAzureMethods; use servo_msg::platform::surface::NativeSurfaceAzureMethods;
use servo_util::geometry::{Au, ZERO_POINT}; use servo_util::geometry::{Au, ZERO_POINT};
use servo_util::opts; use servo_util::opts;
@ -40,19 +40,19 @@ use sync::Arc;
/// Information about a hardware graphics layer that layout sends to the painting task. /// Information about a hardware graphics layer that layout sends to the painting task.
#[deriving(Clone)] #[deriving(Clone)]
pub struct RenderLayer { pub struct PaintLayer {
/// A per-pipeline ID describing this layer that should be stable across reflows. /// A per-pipeline ID describing this layer that should be stable across reflows.
pub id: LayerId, pub id: LayerId,
/// The color of the background in this layer. Used for unrendered content. /// The color of the background in this layer. Used for unpainted content.
pub background_color: Color, pub background_color: Color,
/// The scrolling policy of this layer. /// The scrolling policy of this layer.
pub scroll_policy: ScrollPolicy, pub scroll_policy: ScrollPolicy,
} }
impl RenderLayer { impl PaintLayer {
/// Creates a new `RenderLayer`. /// Creates a new `PaintLayer`.
pub fn new(id: LayerId, background_color: Color, scroll_policy: ScrollPolicy) -> RenderLayer { pub fn new(id: LayerId, background_color: Color, scroll_policy: ScrollPolicy) -> PaintLayer {
RenderLayer { PaintLayer {
id: id, id: id,
background_color: background_color, background_color: background_color,
scroll_policy: scroll_policy, scroll_policy: scroll_policy,
@ -60,7 +60,7 @@ impl RenderLayer {
} }
} }
pub struct RenderRequest { pub struct PaintRequest {
pub buffer_requests: Vec<BufferRequest>, pub buffer_requests: Vec<BufferRequest>,
pub scale: f32, pub scale: f32,
pub layer_id: LayerId, pub layer_id: LayerId,
@ -68,8 +68,8 @@ pub struct RenderRequest {
} }
pub enum Msg { pub enum Msg {
RenderInitMsg(Arc<StackingContext>), PaintInitMsg(Arc<StackingContext>),
RenderMsg(Vec<RenderRequest>), PaintMsg(Vec<PaintRequest>),
UnusedBufferMsg(Vec<Box<LayerBuffer>>), UnusedBufferMsg(Vec<Box<LayerBuffer>>),
PaintPermissionGranted, PaintPermissionGranted,
PaintPermissionRevoked, PaintPermissionRevoked,
@ -77,26 +77,26 @@ pub enum Msg {
} }
#[deriving(Clone)] #[deriving(Clone)]
pub struct RenderChan(Sender<Msg>); pub struct PaintChan(Sender<Msg>);
impl RenderChan { impl PaintChan {
pub fn new() -> (Receiver<Msg>, RenderChan) { pub fn new() -> (Receiver<Msg>, PaintChan) {
let (chan, port) = channel(); let (chan, port) = channel();
(port, RenderChan(chan)) (port, PaintChan(chan))
} }
pub fn send(&self, msg: Msg) { pub fn send(&self, msg: Msg) {
let &RenderChan(ref chan) = self; let &PaintChan(ref chan) = self;
assert!(chan.send_opt(msg).is_ok(), "RenderChan.send: render port closed") assert!(chan.send_opt(msg).is_ok(), "PaintChan.send: paint port closed")
} }
pub fn send_opt(&self, msg: Msg) -> Result<(), Msg> { pub fn send_opt(&self, msg: Msg) -> Result<(), Msg> {
let &RenderChan(ref chan) = self; let &PaintChan(ref chan) = self;
chan.send_opt(msg) chan.send_opt(msg)
} }
} }
pub struct RenderTask<C> { pub struct PaintTask<C> {
id: PipelineId, id: PipelineId,
port: Receiver<Msg>, port: Receiver<Msg>,
compositor: C, compositor: C,
@ -125,10 +125,10 @@ pub struct RenderTask<C> {
} }
// If we implement this as a function, we get borrowck errors from borrowing // If we implement this as a function, we get borrowck errors from borrowing
// the whole RenderTask struct. // the whole PaintTask struct.
macro_rules! native_graphics_context( macro_rules! native_graphics_context(
($task:expr) => ( ($task:expr) => (
$task.native_graphics_context.as_ref().expect("Need a graphics context to do rendering") $task.native_graphics_context.as_ref().expect("Need a graphics context to do painting")
) )
) )
@ -136,7 +136,7 @@ fn initialize_layers<C>(compositor: &mut C,
pipeline_id: PipelineId, pipeline_id: PipelineId,
epoch: Epoch, epoch: Epoch,
root_stacking_context: &StackingContext) root_stacking_context: &StackingContext)
where C: RenderListener { where C: PaintListener {
let mut metadata = Vec::new(); let mut metadata = Vec::new();
build(&mut metadata, root_stacking_context, &ZERO_POINT); build(&mut metadata, root_stacking_context, &ZERO_POINT);
compositor.initialize_layers_for_pipeline(pipeline_id, metadata, epoch); compositor.initialize_layers_for_pipeline(pipeline_id, metadata, epoch);
@ -147,16 +147,16 @@ fn initialize_layers<C>(compositor: &mut C,
let page_position = stacking_context.bounds.origin + *page_position; let page_position = stacking_context.bounds.origin + *page_position;
match stacking_context.layer { match stacking_context.layer {
None => {} None => {}
Some(ref render_layer) => { Some(ref paint_layer) => {
metadata.push(LayerMetadata { metadata.push(LayerMetadata {
id: render_layer.id, id: paint_layer.id,
position: position:
Rect(Point2D(page_position.x.to_nearest_px() as uint, Rect(Point2D(page_position.x.to_nearest_px() as uint,
page_position.y.to_nearest_px() as uint), page_position.y.to_nearest_px() as uint),
Size2D(stacking_context.bounds.size.width.to_nearest_px() as uint, Size2D(stacking_context.bounds.size.width.to_nearest_px() as uint,
stacking_context.bounds.size.height.to_nearest_px() as uint)), stacking_context.bounds.size.height.to_nearest_px() as uint)),
background_color: render_layer.background_color, background_color: paint_layer.background_color,
scroll_policy: render_layer.scroll_policy, scroll_policy: paint_layer.scroll_policy,
}) })
} }
} }
@ -167,7 +167,7 @@ fn initialize_layers<C>(compositor: &mut C,
} }
} }
impl<C> RenderTask<C> where C: RenderListener + Send { impl<C> PaintTask<C> where C: PaintListener + Send {
pub fn create(id: PipelineId, pub fn create(id: PipelineId,
port: Receiver<Msg>, port: Receiver<Msg>,
compositor: C, compositor: C,
@ -177,9 +177,9 @@ impl<C> RenderTask<C> where C: RenderListener + Send {
time_profiler_chan: TimeProfilerChan, time_profiler_chan: TimeProfilerChan,
shutdown_chan: Sender<()>) { shutdown_chan: Sender<()>) {
let ConstellationChan(c) = constellation_chan.clone(); let ConstellationChan(c) = constellation_chan.clone();
spawn_named_with_send_on_failure("RenderTask", task_state::RENDER, proc() { spawn_named_with_send_on_failure("PaintTask", task_state::PAINT, proc() {
{ {
// Ensures that the render task and graphics context are destroyed before the // Ensures that the paint task and graphics context are destroyed before the
// shutdown message. // shutdown message.
let mut compositor = compositor; let mut compositor = compositor;
let native_graphics_context = compositor.get_graphics_metadata().map( let native_graphics_context = compositor.get_graphics_metadata().map(
@ -189,7 +189,7 @@ impl<C> RenderTask<C> where C: RenderListener + Send {
time_profiler_chan.clone()); time_profiler_chan.clone());
// FIXME: rust/#5967 // FIXME: rust/#5967
let mut render_task = RenderTask { let mut paint_task = PaintTask {
id: id, id: id,
port: port, port: port,
compositor: compositor, compositor: compositor,
@ -203,38 +203,38 @@ impl<C> RenderTask<C> where C: RenderListener + Send {
worker_threads: worker_threads, worker_threads: worker_threads,
}; };
render_task.start(); paint_task.start();
// Destroy all the buffers. // Destroy all the buffers.
match render_task.native_graphics_context.as_ref() { match paint_task.native_graphics_context.as_ref() {
Some(ctx) => render_task.buffer_map.clear(ctx), Some(ctx) => paint_task.buffer_map.clear(ctx),
None => (), None => (),
} }
// Tell all the worker threads to shut down. // Tell all the worker threads to shut down.
for worker_thread in render_task.worker_threads.iter_mut() { for worker_thread in paint_task.worker_threads.iter_mut() {
worker_thread.exit() worker_thread.exit()
} }
} }
debug!("render_task: shutdown_chan send"); debug!("paint_task: shutdown_chan send");
shutdown_chan.send(()); shutdown_chan.send(());
}, FailureMsg(failure_msg), c, true); }, FailureMsg(failure_msg), c, true);
} }
fn start(&mut self) { fn start(&mut self) {
debug!("render_task: beginning rendering loop"); debug!("paint_task: beginning painting loop");
loop { loop {
match self.port.recv() { match self.port.recv() {
RenderInitMsg(stacking_context) => { PaintInitMsg(stacking_context) => {
self.epoch.next(); self.epoch.next();
self.root_stacking_context = Some(stacking_context.clone()); self.root_stacking_context = Some(stacking_context.clone());
if !self.paint_permission { if !self.paint_permission {
debug!("render_task: render ready msg"); debug!("paint_task: paint ready msg");
let ConstellationChan(ref mut c) = self.constellation_chan; let ConstellationChan(ref mut c) = self.constellation_chan;
c.send(RendererReadyMsg(self.id)); c.send(PainterReadyMsg(self.id));
continue; continue;
} }
@ -243,29 +243,29 @@ impl<C> RenderTask<C> where C: RenderListener + Send {
self.epoch, self.epoch,
&*stacking_context); &*stacking_context);
} }
RenderMsg(requests) => { PaintMsg(requests) => {
if !self.paint_permission { if !self.paint_permission {
debug!("render_task: render ready msg"); debug!("paint_task: paint ready msg");
let ConstellationChan(ref mut c) = self.constellation_chan; let ConstellationChan(ref mut c) = self.constellation_chan;
c.send(RendererReadyMsg(self.id)); c.send(PainterReadyMsg(self.id));
self.compositor.render_msg_discarded(); self.compositor.paint_msg_discarded();
continue; continue;
} }
let mut replies = Vec::new(); let mut replies = Vec::new();
self.compositor.set_render_state(self.id, RenderingRenderState); self.compositor.set_paint_state(self.id, PaintingPaintState);
for RenderRequest { buffer_requests, scale, layer_id, epoch } for PaintRequest { buffer_requests, scale, layer_id, epoch }
in requests.into_iter() { in requests.into_iter() {
if self.epoch == epoch { if self.epoch == epoch {
self.render(&mut replies, buffer_requests, scale, layer_id); self.paint(&mut replies, buffer_requests, scale, layer_id);
} else { } else {
debug!("renderer epoch mismatch: {} != {}", self.epoch, epoch); debug!("painter epoch mismatch: {} != {}", self.epoch, epoch);
} }
} }
self.compositor.set_render_state(self.id, IdleRenderState); self.compositor.set_paint_state(self.id, IdlePaintState);
debug!("render_task: returning surfaces"); debug!("paint_task: returning surfaces");
self.compositor.paint(self.id, self.epoch, replies); self.compositor.paint(self.id, self.epoch, replies);
} }
UnusedBufferMsg(unused_buffers) => { UnusedBufferMsg(unused_buffers) => {
@ -291,7 +291,7 @@ impl<C> RenderTask<C> where C: RenderListener + Send {
self.paint_permission = false; self.paint_permission = false;
} }
ExitMsg(response_ch) => { ExitMsg(response_ch) => {
debug!("render_task: exitmsg response send"); debug!("paint_task: exitmsg response send");
response_ch.map(|ch| ch.send(())); response_ch.map(|ch| ch.send(()));
break; break;
} }
@ -342,8 +342,8 @@ impl<C> RenderTask<C> where C: RenderListener + Send {
}) })
} }
/// Renders one layer and sends the tiles back to the layer. /// Paints one layer and sends the tiles back to the layer.
fn render(&mut self, fn paint(&mut self,
replies: &mut Vec<(LayerId, Box<LayerBufferSet>)>, replies: &mut Vec<(LayerId, Box<LayerBufferSet>)>,
mut tiles: Vec<BufferRequest>, mut tiles: Vec<BufferRequest>,
scale: f32, scale: f32,
@ -493,7 +493,7 @@ impl WorkerThread {
DrawTarget::new(SkiaBackend, size, B8G8R8A8) DrawTarget::new(SkiaBackend, size, B8G8R8A8)
} else { } else {
// FIXME(pcwalton): Cache the components of draw targets (texture color buffer, // FIXME(pcwalton): Cache the components of draw targets (texture color buffer,
// renderbuffers) instead of recreating them. // paintbuffers) instead of recreating them.
let draw_target = DrawTarget::new_with_fbo(SkiaBackend, let draw_target = DrawTarget::new_with_fbo(SkiaBackend,
native_graphics_context!(self), native_graphics_context!(self),
size, size,
@ -503,34 +503,34 @@ impl WorkerThread {
}; };
{ {
// Build the render context. // Build the paint context.
let mut render_context = RenderContext { let mut paint_context = PaintContext {
draw_target: draw_target.clone(), draw_target: draw_target.clone(),
font_ctx: &mut self.font_context, font_ctx: &mut self.font_context,
page_rect: tile.page_rect, page_rect: tile.page_rect,
screen_rect: tile.screen_rect, screen_rect: tile.screen_rect,
}; };
// Apply the translation to render the tile we want. // Apply the translation to paint the tile we want.
let tile_bounds = tile.page_rect; let tile_bounds = tile.page_rect;
let matrix: Matrix2D<AzFloat> = Matrix2D::identity(); let matrix: Matrix2D<AzFloat> = Matrix2D::identity();
let matrix = matrix.scale(scale as AzFloat, scale as AzFloat); let matrix = matrix.scale(scale as AzFloat, scale as AzFloat);
let matrix = matrix.translate(-tile_bounds.origin.x as AzFloat, let matrix = matrix.translate(-tile_bounds.origin.x as AzFloat,
-tile_bounds.origin.y as AzFloat); -tile_bounds.origin.y as AzFloat);
render_context.draw_target.set_transform(&matrix); paint_context.draw_target.set_transform(&matrix);
// Clear the buffer. // Clear the buffer.
render_context.clear(); paint_context.clear();
// Draw the display list. // Draw the display list.
profile(time::PaintingPerTileCategory, None, self.time_profiler_sender.clone(), || { profile(time::PaintingPerTileCategory, None, self.time_profiler_sender.clone(), || {
let mut clip_stack = Vec::new(); let mut clip_stack = Vec::new();
stacking_context.optimize_and_draw_into_context(&mut render_context, stacking_context.optimize_and_draw_into_context(&mut paint_context,
&tile.page_rect, &tile.page_rect,
&matrix, &matrix,
&mut clip_stack); &mut clip_stack);
render_context.draw_target.flush(); paint_context.draw_target.flush();
}); });
} }
@ -544,10 +544,10 @@ impl WorkerThread {
scale: f32) scale: f32)
-> Box<LayerBuffer> { -> Box<LayerBuffer> {
// Extract the texture from the draw target and place it into its slot in the buffer. If // Extract the texture from the draw target and place it into its slot in the buffer. If
// using CPU rendering, upload it first. // using CPU painting, upload it first.
// //
// FIXME(pcwalton): We should supply the texture and native surface *to* the draw target in // FIXME(pcwalton): We should supply the texture and native surface *to* the draw target in
// GPU rendering mode, so that it doesn't have to recreate it. // GPU painting mode, so that it doesn't have to recreate it.
if !opts::get().gpu_painting { if !opts::get().gpu_painting {
let mut buffer = layer_buffer.unwrap(); let mut buffer = layer_buffer.unwrap();
draw_target.snapshot().get_data_surface().with_data(|data| { draw_target.snapshot().get_data_surface().with_data(|data| {

View file

@ -10,7 +10,7 @@ use core_text;
/// Platform specific font representation for mac. /// Platform specific font representation for mac.
/// The identifier is a PostScript font name. The /// The identifier is a PostScript font name. The
/// CTFont object is cached here for use by the /// CTFont object is cached here for use by the
/// render functions that create CGFont references. /// paint functions that create CGFont references.
pub struct FontTemplateData { pub struct FontTemplateData {
pub ctfont: Option<CTFont>, pub ctfont: Option<CTFont>,
pub identifier: String, pub identifier: String,

View file

@ -198,7 +198,7 @@ impl Shaper {
} }
impl ShaperMethods for Shaper { impl ShaperMethods for Shaper {
/// Calculate the layout metrics associated with the given text when rendered in a specific /// Calculate the layout metrics associated with the given text when painted in a specific
/// font. /// font.
fn shape_text(&self, text: &str, glyphs: &mut GlyphStore) { fn shape_text(&self, text: &str, glyphs: &mut GlyphStore) {
unsafe { unsafe {

View file

@ -30,7 +30,7 @@ use gfx::display_list::{ImageDisplayItem, ImageDisplayItemClass, LineDisplayItem
use gfx::display_list::{LineDisplayItemClass, PseudoDisplayItemClass, SidewaysLeft, SidewaysRight}; use gfx::display_list::{LineDisplayItemClass, PseudoDisplayItemClass, SidewaysLeft, SidewaysRight};
use gfx::display_list::{SolidColorDisplayItem, SolidColorDisplayItemClass, StackingContext}; use gfx::display_list::{SolidColorDisplayItem, SolidColorDisplayItemClass, StackingContext};
use gfx::display_list::{TextDisplayItem, TextDisplayItemClass, Upright}; use gfx::display_list::{TextDisplayItem, TextDisplayItemClass, Upright};
use gfx::render_task::RenderLayer; use gfx::paint_task::PaintLayer;
use servo_msg::compositor_msg::{FixedPosition, Scrollable}; use servo_msg::compositor_msg::{FixedPosition, Scrollable};
use servo_msg::constellation_msg::{ConstellationChan, FrameRectMsg}; use servo_msg::constellation_msg::{ConstellationChan, FrameRectMsg};
use servo_net::image::holder::ImageHolder; use servo_net::image::holder::ImageHolder;
@ -812,7 +812,7 @@ pub trait BlockFlowDisplayListBuilding {
fn build_display_list_for_floating_block(&mut self, layout_context: &LayoutContext); fn build_display_list_for_floating_block(&mut self, layout_context: &LayoutContext);
fn create_stacking_context(&self, fn create_stacking_context(&self,
display_list: Box<DisplayList>, display_list: Box<DisplayList>,
layer: Option<Arc<RenderLayer>>) layer: Option<Arc<PaintLayer>>)
-> Arc<StackingContext>; -> Arc<StackingContext>;
} }
@ -875,7 +875,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
let transparent = color::rgba(1.0, 1.0, 1.0, 0.0); let transparent = color::rgba(1.0, 1.0, 1.0, 0.0);
let stacking_context = let stacking_context =
self.create_stacking_context(display_list, self.create_stacking_context(display_list,
Some(Arc::new(RenderLayer::new(self.layer_id(0), Some(Arc::new(PaintLayer::new(self.layer_id(0),
transparent, transparent,
scroll_policy)))); scroll_policy))));
self.base.display_list_building_result = StackingContextResult(stacking_context) self.base.display_list_building_result = StackingContextResult(stacking_context)
@ -897,7 +897,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
fn create_stacking_context(&self, fn create_stacking_context(&self,
display_list: Box<DisplayList>, display_list: Box<DisplayList>,
layer: Option<Arc<RenderLayer>>) layer: Option<Arc<PaintLayer>>)
-> Arc<StackingContext> { -> Arc<StackingContext> {
let bounds = Rect(self.base.stacking_relative_position, let bounds = Rect(self.base.stacking_relative_position,
self.base.overflow.size.to_physical(self.base.writing_mode)); self.base.overflow.size.to_physical(self.base.writing_mode));

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! The layout task. Performs layout on the DOM, builds display lists and sends them to be //! The layout task. Performs layout on the DOM, builds display lists and sends them to be
//! rendered. //! painted.
use css::node_style::StyledNode; use css::node_style::StyledNode;
use construct::FlowConstructionResult; use construct::FlowConstructionResult;
@ -28,7 +28,7 @@ use geom::scale_factor::ScaleFactor;
use gfx::color; use gfx::color;
use gfx::display_list::{DisplayList, OpaqueNode, StackingContext}; use gfx::display_list::{DisplayList, OpaqueNode, StackingContext};
use gfx::font_cache_task::FontCacheTask; use gfx::font_cache_task::FontCacheTask;
use gfx::render_task::{mod, RenderInitMsg, RenderChan, RenderLayer}; use gfx::paint_task::{mod, PaintInitMsg, PaintChan, PaintLayer};
use layout_traits; use layout_traits;
use layout_traits::{LayoutControlMsg, LayoutTaskFactory}; use layout_traits::{LayoutControlMsg, LayoutTaskFactory};
use log; use log;
@ -119,7 +119,7 @@ pub struct LayoutTask {
pub script_chan: ScriptControlChan, pub script_chan: ScriptControlChan,
/// The channel on which messages can be sent to the painting task. /// The channel on which messages can be sent to the painting task.
pub render_chan: RenderChan, pub paint_chan: PaintChan,
/// The channel on which messages can be sent to the time profiler. /// The channel on which messages can be sent to the time profiler.
pub time_profiler_chan: TimeProfilerChan, pub time_profiler_chan: TimeProfilerChan,
@ -173,7 +173,7 @@ impl LayoutTaskFactory for LayoutTask {
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan,
failure_msg: Failure, failure_msg: Failure,
script_chan: ScriptControlChan, script_chan: ScriptControlChan,
render_chan: RenderChan, paint_chan: PaintChan,
resource_task: ResourceTask, resource_task: ResourceTask,
img_cache_task: ImageCacheTask, img_cache_task: ImageCacheTask,
font_cache_task: FontCacheTask, font_cache_task: FontCacheTask,
@ -191,7 +191,7 @@ impl LayoutTaskFactory for LayoutTask {
pipeline_port, pipeline_port,
constellation_chan, constellation_chan,
script_chan, script_chan,
render_chan, paint_chan,
resource_task, resource_task,
img_cache_task, img_cache_task,
font_cache_task, font_cache_task,
@ -240,7 +240,7 @@ impl LayoutTask {
pipeline_port: Receiver<LayoutControlMsg>, pipeline_port: Receiver<LayoutControlMsg>,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan,
script_chan: ScriptControlChan, script_chan: ScriptControlChan,
render_chan: RenderChan, paint_chan: PaintChan,
resource_task: ResourceTask, resource_task: ResourceTask,
image_cache_task: ImageCacheTask, image_cache_task: ImageCacheTask,
font_cache_task: FontCacheTask, font_cache_task: FontCacheTask,
@ -264,7 +264,7 @@ impl LayoutTask {
chan: chan, chan: chan,
constellation_chan: constellation_chan, constellation_chan: constellation_chan,
script_chan: script_chan, script_chan: script_chan,
render_chan: render_chan, paint_chan: paint_chan,
time_profiler_chan: time_profiler_chan, time_profiler_chan: time_profiler_chan,
resource_task: resource_task, resource_task: resource_task,
image_cache_task: image_cache_task.clone(), image_cache_task: image_cache_task.clone(),
@ -463,7 +463,7 @@ impl LayoutTask {
LayoutTask::return_rw_data(possibly_locked_rw_data, rw_data); LayoutTask::return_rw_data(possibly_locked_rw_data, rw_data);
} }
self.render_chan.send(render_task::ExitMsg(Some(response_chan))); self.paint_chan.send(paint_task::ExitMsg(Some(response_chan)));
response_port.recv() response_port.recv()
} }
@ -676,7 +676,7 @@ impl LayoutTask {
let mut display_list = box DisplayList::new(); let mut display_list = box DisplayList::new();
flow::mut_base(layout_root.deref_mut()).display_list_building_result flow::mut_base(layout_root.deref_mut()).display_list_building_result
.add_to(&mut *display_list); .add_to(&mut *display_list);
let render_layer = Arc::new(RenderLayer::new(layout_root.layer_id(0), let paint_layer = Arc::new(PaintLayer::new(layout_root.layer_id(0),
color, color,
Scrollable)); Scrollable));
let origin = Rect(Point2D(Au(0), Au(0)), root_size); let origin = Rect(Point2D(Au(0), Au(0)), root_size);
@ -684,13 +684,13 @@ impl LayoutTask {
origin, origin,
0, 0,
1.0, 1.0,
Some(render_layer))); Some(paint_layer)));
rw_data.stacking_context = Some(stacking_context.clone()); rw_data.stacking_context = Some(stacking_context.clone());
debug!("Layout done!"); debug!("Layout done!");
self.render_chan.send(RenderInitMsg(stacking_context)); self.paint_chan.send(PaintInitMsg(stacking_context));
}); });
} }
@ -825,7 +825,7 @@ impl LayoutTask {
} }
}); });
// Build the display list if necessary, and send it to the renderer. // Build the display list if necessary, and send it to the painter.
if data.goal == ReflowForDisplay { if data.goal == ReflowForDisplay {
self.build_display_list_for_reflow(data, self.build_display_list_for_reflow(data,
node, node,

View file

@ -20,7 +20,7 @@ extern crate "util" as servo_util;
// that these modules won't have to depend on layout. // that these modules won't have to depend on layout.
use gfx::font_cache_task::FontCacheTask; use gfx::font_cache_task::FontCacheTask;
use gfx::render_task::RenderChan; use gfx::paint_task::PaintChan;
use servo_msg::constellation_msg::{ConstellationChan, PipelineId}; use servo_msg::constellation_msg::{ConstellationChan, PipelineId};
use servo_msg::constellation_msg::Failure; use servo_msg::constellation_msg::Failure;
use servo_net::image_cache_task::ImageCacheTask; use servo_net::image_cache_task::ImageCacheTask;
@ -48,7 +48,7 @@ pub trait LayoutTaskFactory {
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan,
failure_msg: Failure, failure_msg: Failure,
script_chan: ScriptControlChan, script_chan: ScriptControlChan,
render_chan: RenderChan, paint_chan: PaintChan,
resource_task: ResourceTask, resource_task: ResourceTask,
img_cache_task: ImageCacheTask, img_cache_task: ImageCacheTask,
font_cache_task: FontCacheTask, font_cache_task: FontCacheTask,

View file

@ -12,11 +12,11 @@ use std::fmt;
use constellation_msg::PipelineId; use constellation_msg::PipelineId;
/// The status of the renderer. /// The status of the painter.
#[deriving(PartialEq, Clone)] #[deriving(PartialEq, Clone)]
pub enum RenderState { pub enum PaintState {
IdleRenderState, IdlePaintState,
RenderingRenderState, PaintingPaintState,
} }
#[deriving(Eq, Ord, PartialEq, PartialOrd, Clone)] #[deriving(Eq, Ord, PartialEq, PartialOrd, Clone)]
@ -81,13 +81,13 @@ pub struct LayerMetadata {
pub scroll_policy: ScrollPolicy, pub scroll_policy: ScrollPolicy,
} }
/// The interface used by the renderer to acquire draw targets for each render frame and /// The interface used by the painter to acquire draw targets for each paint frame and
/// submit them to be drawn to the display. /// submit them to be drawn to the display.
pub trait RenderListener for Sized? { pub trait PaintListener for Sized? {
fn get_graphics_metadata(&mut self) -> Option<NativeGraphicsMetadata>; fn get_graphics_metadata(&mut self) -> Option<NativeGraphicsMetadata>;
/// Informs the compositor of the layers for the given pipeline. The compositor responds by /// Informs the compositor of the layers for the given pipeline. The compositor responds by
/// creating and/or destroying render layers as necessary. /// creating and/or destroying paint layers as necessary.
fn initialize_layers_for_pipeline(&mut self, fn initialize_layers_for_pipeline(&mut self,
pipeline_id: PipelineId, pipeline_id: PipelineId,
metadata: Vec<LayerMetadata>, metadata: Vec<LayerMetadata>,
@ -99,8 +99,8 @@ pub trait RenderListener for Sized? {
epoch: Epoch, epoch: Epoch,
replies: Vec<(LayerId, Box<LayerBufferSet>)>); replies: Vec<(LayerId, Box<LayerBufferSet>)>);
fn render_msg_discarded(&mut self); fn paint_msg_discarded(&mut self);
fn set_render_state(&mut self, PipelineId, RenderState); fn set_paint_state(&mut self, PipelineId, PaintState);
} }
/// The interface used by the script task to tell the compositor to update its ready state, /// The interface used by the script task to tell the compositor to update its ready state,

View file

@ -202,7 +202,7 @@ pub enum Msg {
LoadUrlMsg(PipelineId, LoadData), LoadUrlMsg(PipelineId, LoadData),
ScriptLoadedURLInIFrameMsg(Url, PipelineId, SubpageId, IFrameSandboxState), ScriptLoadedURLInIFrameMsg(Url, PipelineId, SubpageId, IFrameSandboxState),
NavigateMsg(NavigationDirection), NavigateMsg(NavigationDirection),
RendererReadyMsg(PipelineId), PainterReadyMsg(PipelineId),
ResizedWindowMsg(WindowSizeData), ResizedWindowMsg(WindowSizeData),
KeyEvent(Key, KeyState, KeyModifiers), KeyEvent(Key, KeyState, KeyModifiers),
} }

View file

@ -13,7 +13,7 @@ use geom::point::Point2D;
use geom::rect::Rect; use geom::rect::Rect;
use geom::size::Size2D; use geom::size::Size2D;
use canvas::canvas_render_task::{CanvasMsg, CanvasRenderTask, ClearRect, Close, FillRect, Recreate, StrokeRect}; use canvas::canvas_paint_task::{CanvasMsg, CanvasPaintTask, ClearRect, Close, FillRect, Recreate, StrokeRect};
#[dom_struct] #[dom_struct]
pub struct CanvasRenderingContext2D { pub struct CanvasRenderingContext2D {
@ -28,7 +28,7 @@ impl CanvasRenderingContext2D {
CanvasRenderingContext2D { CanvasRenderingContext2D {
reflector_: Reflector::new(), reflector_: Reflector::new(),
global: GlobalField::from_rooted(global), global: GlobalField::from_rooted(global),
renderer: CanvasRenderTask::start(size), renderer: CanvasPaintTask::start(size),
canvas: JS::from_rooted(canvas), canvas: JS::from_rooted(canvas),
} }
} }

View file

@ -31,10 +31,10 @@ pub struct Opts {
/// The initial URLs to load. /// The initial URLs to load.
pub urls: Vec<String>, pub urls: Vec<String>,
/// How many threads to use for CPU rendering (`-t`). /// How many threads to use for CPU painting (`-t`).
/// ///
/// FIXME(pcwalton): This is not currently used. All rendering is sequential. /// FIXME(pcwalton): This is not currently used. All painting is sequential.
pub n_render_threads: uint, pub n_paint_threads: uint,
/// True to use GPU painting via Skia-GL, false to use CPU painting via Skia (`-g`). Note that /// True to use GPU painting via Skia-GL, false to use CPU painting via Skia (`-g`). Note that
/// compositing is always done on the GPU. /// compositing is always done on the GPU.
@ -88,7 +88,7 @@ pub struct Opts {
/// True if each step of layout is traced to an external JSON file /// True if each step of layout is traced to an external JSON file
/// for debugging purposes. Settings this implies sequential layout /// for debugging purposes. Settings this implies sequential layout
/// and render. /// and paint.
pub trace_layout: bool, pub trace_layout: bool,
/// If true, instrument the runtime for each task created and dump /// If true, instrument the runtime for each task created and dump
@ -145,7 +145,7 @@ fn args_fail(msg: &str) {
os::set_exit_status(1); os::set_exit_status(1);
} }
// Always use CPU rendering on android. // Always use CPU painting on android.
#[cfg(target_os="android")] #[cfg(target_os="android")]
static FORCE_CPU_PAINTING: bool = true; static FORCE_CPU_PAINTING: bool = true;
@ -156,7 +156,7 @@ static FORCE_CPU_PAINTING: bool = false;
pub fn default_opts() -> Opts { pub fn default_opts() -> Opts {
Opts { Opts {
urls: vec!(), urls: vec!(),
n_render_threads: 1, n_paint_threads: 1,
gpu_painting: false, gpu_painting: false,
tile_size: 512, tile_size: 512,
device_pixels_per_px: None, device_pixels_per_px: None,
@ -194,7 +194,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
getopts::optopt("s", "size", "Size of tiles", "512"), getopts::optopt("s", "size", "Size of tiles", "512"),
getopts::optopt("", "device-pixel-ratio", "Device pixels per px", ""), getopts::optopt("", "device-pixel-ratio", "Device pixels per px", ""),
getopts::optflag("e", "experimental", "Enable experimental web features"), getopts::optflag("e", "experimental", "Enable experimental web features"),
getopts::optopt("t", "threads", "Number of render threads", "1"), getopts::optopt("t", "threads", "Number of paint threads", "1"),
getopts::optflagopt("p", "profile", "Profiler flag and output interval", "10"), getopts::optflagopt("p", "profile", "Profiler flag and output interval", "10"),
getopts::optflagopt("m", "memory-profile", "Memory profiler flag and output interval", "10"), getopts::optflagopt("m", "memory-profile", "Memory profiler flag and output interval", "10"),
getopts::optflag("x", "exit", "Exit after load flag"), getopts::optflag("x", "exit", "Exit after load flag"),
@ -253,8 +253,8 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
ScaleFactor(from_str(dppx_str.as_slice()).unwrap()) ScaleFactor(from_str(dppx_str.as_slice()).unwrap())
); );
let mut n_render_threads: uint = match opt_match.opt_str("t") { let mut n_paint_threads: uint = match opt_match.opt_str("t") {
Some(n_render_threads_str) => from_str(n_render_threads_str.as_slice()).unwrap(), Some(n_paint_threads_str) => from_str(n_paint_threads_str.as_slice()).unwrap(),
None => 1, // FIXME: Number of cores. None => 1, // FIXME: Number of cores.
}; };
@ -278,7 +278,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
let mut bubble_inline_sizes_separately = debug_options.contains(&"bubble-widths"); let mut bubble_inline_sizes_separately = debug_options.contains(&"bubble-widths");
let trace_layout = debug_options.contains(&"trace-layout"); let trace_layout = debug_options.contains(&"trace-layout");
if trace_layout { if trace_layout {
n_render_threads = 1; n_paint_threads = 1;
layout_threads = 1; layout_threads = 1;
bubble_inline_sizes_separately = true; bubble_inline_sizes_separately = true;
} }
@ -308,7 +308,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
let opts = Opts { let opts = Opts {
urls: urls, urls: urls,
n_render_threads: n_render_threads, n_paint_threads: n_paint_threads,
gpu_painting: gpu_painting, gpu_painting: gpu_painting,
tile_size: tile_size, tile_size: tile_size,
device_pixels_per_px: device_pixels_per_px, device_pixels_per_px: device_pixels_per_px,

View file

@ -15,7 +15,7 @@ bitflags! {
flags TaskState: u32 { flags TaskState: u32 {
const SCRIPT = 0x01, const SCRIPT = 0x01,
const LAYOUT = 0x02, const LAYOUT = 0x02,
const RENDER = 0x04, const PAINT = 0x04,
const IN_WORKER = 0x0100, const IN_WORKER = 0x0100,
const IN_GC = 0x0200, const IN_GC = 0x0200,
@ -40,7 +40,7 @@ macro_rules! task_types ( ( $( $fun:ident = $flag:ident ; )* ) => (
task_types! { task_types! {
is_script = SCRIPT; is_script = SCRIPT;
is_layout = LAYOUT; is_layout = LAYOUT;
is_render = RENDER; is_paint = PAINT;
} }
#[cfg(not(ndebug))] #[cfg(not(ndebug))]

View file

@ -19,7 +19,7 @@ use geom::scale_factor::ScaleFactor;
use geom::size::TypedSize2D; use geom::size::TypedSize2D;
use layers::geometry::DevicePixel; use layers::geometry::DevicePixel;
use layers::platform::surface::NativeGraphicsMetadata; use layers::platform::surface::NativeGraphicsMetadata;
use msg::compositor_msg::{IdleRenderState, RenderState}; use msg::compositor_msg::{IdlePaintState, PaintState};
use msg::compositor_msg::{Blank, ReadyState}; use msg::compositor_msg::{Blank, ReadyState};
use util::geometry::ScreenPx; use util::geometry::ScreenPx;
@ -41,7 +41,7 @@ pub struct Window {
pub mouse_down_point: Cell<Point2D<c_int>>, pub mouse_down_point: Cell<Point2D<c_int>>,
pub ready_state: Cell<ReadyState>, pub ready_state: Cell<ReadyState>,
pub render_state: Cell<RenderState>, pub paint_state: Cell<PaintState>,
pub throbber_frame: Cell<u8>, pub throbber_frame: Cell<u8>,
} }
@ -65,7 +65,7 @@ impl Window {
mouse_down_point: Cell::new(Point2D(0 as c_int, 0)), mouse_down_point: Cell::new(Point2D(0 as c_int, 0)),
ready_state: Cell::new(Blank), ready_state: Cell::new(Blank),
render_state: Cell::new(IdleRenderState), paint_state: Cell::new(IdlePaintState),
throbber_frame: Cell::new(0), throbber_frame: Cell::new(0),
}; };
@ -180,9 +180,9 @@ impl WindowMethods for Window {
//self.update_window_title() //self.update_window_title()
} }
/// Sets the render state. /// Sets the paint state.
fn set_render_state(&self, render_state: RenderState) { fn set_paint_state(&self, paint_state: PaintState) {
self.render_state.set(render_state); self.paint_state.set(paint_state);
//FIXME: set_window_title causes crash with Android version of freeGLUT. Temporarily blocked. //FIXME: set_window_title causes crash with Android version of freeGLUT. Temporarily blocked.
//self.update_window_title() //self.update_window_title()
} }
@ -215,11 +215,11 @@ impl Window {
// glut::set_window_title(self.glut_window, format!("{:c} Performing Layout . Servo", throbber)) // glut::set_window_title(self.glut_window, format!("{:c} Performing Layout . Servo", throbber))
// } // }
// FinishedLoading => { // FinishedLoading => {
// match self.render_state { // match self.paint_state {
// RenderingRenderState => { // PaintingPaintState => {
// glut::set_window_title(self.glut_window, format!("{:c} Rendering . Servo", throbber)) // glut::set_window_title(self.glut_window, format!("{:c} Rendering . Servo", throbber))
// } // }
// IdleRenderState => glut::set_window_title(self.glut_window, "Servo"), // IdlePaintState => glut::set_window_title(self.glut_window, "Servo"),
// } // }
// } // }
// } // }

View file

@ -24,7 +24,7 @@ use layers::geometry::DevicePixel;
use layers::platform::surface::NativeGraphicsMetadata; use layers::platform::surface::NativeGraphicsMetadata;
use libc::c_int; use libc::c_int;
use msg::compositor_msg::{FinishedLoading, Blank, Loading, PerformingLayout, ReadyState}; use msg::compositor_msg::{FinishedLoading, Blank, Loading, PerformingLayout, ReadyState};
use msg::compositor_msg::{IdleRenderState, RenderState, RenderingRenderState}; use msg::compositor_msg::{IdlePaintState, PaintState, PaintingPaintState};
use msg::constellation_msg; use msg::constellation_msg;
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
use std::comm::Receiver; use std::comm::Receiver;
@ -45,7 +45,7 @@ pub struct Window {
mouse_down_point: Cell<Point2D<c_int>>, mouse_down_point: Cell<Point2D<c_int>>,
ready_state: Cell<ReadyState>, ready_state: Cell<ReadyState>,
render_state: Cell<RenderState>, paint_state: Cell<PaintState>,
last_title_set_time: Cell<Timespec>, last_title_set_time: Cell<Timespec>,
} }
@ -78,7 +78,7 @@ impl Window {
mouse_down_point: Cell::new(Point2D(0 as c_int, 0)), mouse_down_point: Cell::new(Point2D(0 as c_int, 0)),
ready_state: Cell::new(Blank), ready_state: Cell::new(Blank),
render_state: Cell::new(IdleRenderState), paint_state: Cell::new(IdlePaintState),
last_title_set_time: Cell::new(Timespec::new(0, 0)), last_title_set_time: Cell::new(Timespec::new(0, 0)),
}; };
@ -159,9 +159,9 @@ impl WindowMethods for Window {
self.update_window_title() self.update_window_title()
} }
/// Sets the render state. /// Sets the paint state.
fn set_render_state(&self, render_state: RenderState) { fn set_paint_state(&self, paint_state: PaintState) {
self.render_state.set(render_state); self.paint_state.set(paint_state);
self.update_window_title() self.update_window_title()
} }
@ -302,11 +302,11 @@ impl Window {
self.glfw_window.set_title("Performing Layout — Servo [GLFW]") self.glfw_window.set_title("Performing Layout — Servo [GLFW]")
} }
FinishedLoading => { FinishedLoading => {
match self.render_state.get() { match self.paint_state.get() {
RenderingRenderState => { PaintingPaintState => {
self.glfw_window.set_title("Rendering — Servo [GLFW]") self.glfw_window.set_title("Rendering — Servo [GLFW]")
} }
IdleRenderState => { IdlePaintState => {
self.glfw_window.set_title("Servo [GLFW]") self.glfw_window.set_title("Servo [GLFW]")
} }
} }

View file

@ -18,7 +18,7 @@ use geom::size::TypedSize2D;
use gleam::gl; use gleam::gl;
use layers::geometry::DevicePixel; use layers::geometry::DevicePixel;
use layers::platform::surface::NativeGraphicsMetadata; use layers::platform::surface::NativeGraphicsMetadata;
use msg::compositor_msg::{IdleRenderState, RenderState, RenderingRenderState}; use msg::compositor_msg::{IdlePaintState, PaintState, PaintingPaintState};
use msg::compositor_msg::{FinishedLoading, Blank, Loading, PerformingLayout, ReadyState}; use msg::compositor_msg::{FinishedLoading, Blank, Loading, PerformingLayout, ReadyState};
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
use std::rc::Rc; use std::rc::Rc;
@ -66,7 +66,7 @@ pub struct Window {
mouse_pos: Cell<Point2D<int>>, mouse_pos: Cell<Point2D<int>>,
ready_state: Cell<ReadyState>, ready_state: Cell<ReadyState>,
render_state: Cell<RenderState>, paint_state: Cell<PaintState>,
key_modifiers: Cell<KeyModifiers>, key_modifiers: Cell<KeyModifiers>,
last_title_set_time: Cell<Timespec>, last_title_set_time: Cell<Timespec>,
@ -118,7 +118,7 @@ impl Window {
mouse_pos: Cell::new(Point2D(0, 0)), mouse_pos: Cell::new(Point2D(0, 0)),
ready_state: Cell::new(Blank), ready_state: Cell::new(Blank),
render_state: Cell::new(IdleRenderState), paint_state: Cell::new(IdlePaintState),
key_modifiers: Cell::new(KeyModifiers::empty()), key_modifiers: Cell::new(KeyModifiers::empty()),
last_title_set_time: Cell::new(Timespec::new(0, 0)), last_title_set_time: Cell::new(Timespec::new(0, 0)),
@ -173,9 +173,9 @@ impl WindowMethods for Window {
self.update_window_title() self.update_window_title()
} }
/// Sets the render state. /// Sets the paint state.
fn set_render_state(&self, render_state: RenderState) { fn set_paint_state(&self, paint_state: PaintState) {
self.render_state.set(render_state); self.paint_state.set(paint_state);
self.update_window_title() self.update_window_title()
} }
@ -233,11 +233,11 @@ impl Window {
window.set_title("Performing Layout - Servo [glutin]") window.set_title("Performing Layout - Servo [glutin]")
} }
FinishedLoading => { FinishedLoading => {
match self.render_state.get() { match self.paint_state.get() {
RenderingRenderState => { PaintingPaintState => {
window.set_title("Rendering - Servo [glutin]") window.set_title("Rendering - Servo [glutin]")
} }
IdleRenderState => { IdlePaintState => {
window.set_title("Servo [glutin]") window.set_title("Servo [glutin]")
} }
} }