Replace almost "render" to "paint" in compositing crate.

This doesn't touch some "render" words which are used as general means.
This commit is contained in:
Tetsuharu OHZEKI 2014-12-08 14:51:49 +09:00
parent f04c64f500
commit 8cee554898
5 changed files with 63 additions and 63 deletions

View file

@ -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 paint 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,
@ -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());
@ -207,7 +207,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
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,
} }
} }
@ -263,7 +263,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
} }
(PaintMsgDiscarded, 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()
} }
@ -378,32 +378,32 @@ impl<Window: WindowMethods> IOCompositor<Window> {
return self.paint_states.values().all(|&value| value == IdlePaintState); 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 PaintMsg'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");
} }
} }
@ -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");
} }
@ -856,7 +856,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
} }
}; };
// 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();
@ -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(PaintMsg(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,7 +944,7 @@ 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;
} }
@ -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

@ -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
@ -217,8 +217,8 @@ 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()
@ -229,7 +229,7 @@ impl CompositorLayer for Layer<CompositorData> {
} }
/// 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

@ -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.
/// ///
@ -184,9 +184,9 @@ pub enum Msg {
ChangeReadyState(PipelineId, ReadyState), ChangeReadyState(PipelineId, ReadyState),
/// Alerts the compositor to the current status of painting. /// Alerts the compositor to the current status of painting.
ChangePaintState(PipelineId, PaintState), ChangePaintState(PipelineId, PaintState),
/// Alerts the compositor that the RenderMsg has been discarded. /// Alerts the compositor that the PaintMsg has been discarded.
PaintMsgDiscarded, 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<()>),

View file

@ -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.
PainterReadyMsg(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");
@ -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

@ -19,7 +19,7 @@ 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>,
@ -27,7 +27,7 @@ pub struct Pipeline {
pub layout_chan: LayoutControlChan, pub layout_chan: LayoutControlChan,
pub paint_chan: PaintChan, 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,
} }
@ -41,7 +41,7 @@ pub struct CompositionPipeline {
} }
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, paint_chan) = PaintChan::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();
@ -103,13 +103,13 @@ impl Pipeline {
}; };
PaintTask::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,
@ -131,7 +131,7 @@ impl Pipeline {
LayoutControlChan(pipeline_chan), LayoutControlChan(pipeline_chan),
paint_chan, paint_chan,
layout_shutdown_port, layout_shutdown_port,
render_shutdown_port, paint_shutdown_port,
load_data) load_data)
} }
@ -141,7 +141,7 @@ impl Pipeline {
layout_chan: LayoutControlChan, layout_chan: LayoutControlChan,
paint_chan: PaintChan, 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 {
@ -151,7 +151,7 @@ impl Pipeline {
layout_chan: layout_chan, layout_chan: layout_chan,
paint_chan: paint_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,
} }
} }
@ -166,20 +166,20 @@ impl Pipeline {
} }
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.paint_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();
} }
} }