mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Update to latest rust-layers
This commit is contained in:
parent
52e55a2770
commit
07db2d3273
3 changed files with 62 additions and 65 deletions
|
@ -31,7 +31,7 @@ use layers::platform::surface::NativeCompositingGraphicsContext;
|
||||||
use layers::rendergl;
|
use layers::rendergl;
|
||||||
use layers::rendergl::RenderContext;
|
use layers::rendergl::RenderContext;
|
||||||
use layers::scene::Scene;
|
use layers::scene::Scene;
|
||||||
use layers::layers::ContainerLayer;
|
use layers::layers::Layer;
|
||||||
use opengles::gl2;
|
use opengles::gl2;
|
||||||
use png;
|
use png;
|
||||||
use servo_msg::compositor_msg::{Blank, Epoch, FinishedLoading, IdleRenderState};
|
use servo_msg::compositor_msg::{Blank, Epoch, FinishedLoading, IdleRenderState};
|
||||||
|
@ -375,8 +375,8 @@ impl IOCompositor {
|
||||||
|
|
||||||
if layer_id != root_layer_id {
|
if layer_id != root_layer_id {
|
||||||
let root_pipeline_id = root_pipeline.id;
|
let root_pipeline_id = root_pipeline.id;
|
||||||
let new_root = Rc::new(ContainerLayer::new(Some(size), self.opts.tile_size,
|
let new_root = Rc::new(Layer::new(size, self.opts.tile_size,
|
||||||
CompositorData::new_root(root_pipeline,
|
CompositorData::new_root(root_pipeline,
|
||||||
size, self.opts.cpu_painting)));
|
size, self.opts.cpu_painting)));
|
||||||
new_root.extra_data.borrow_mut().unrendered_color = unrendered_color;
|
new_root.extra_data.borrow_mut().unrendered_color = unrendered_color;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ use geom::rect::{Rect, TypedRect};
|
||||||
use geom::size::{Size2D, TypedSize2D};
|
use geom::size::{Size2D, TypedSize2D};
|
||||||
use gfx::render_task::{ReRenderMsg, UnusedBufferMsg};
|
use gfx::render_task::{ReRenderMsg, UnusedBufferMsg};
|
||||||
use gfx;
|
use gfx;
|
||||||
use layers::layers::{ContainerLayer, Flip, LayerBuffer, LayerBufferSet, NoFlip, TextureLayer};
|
use layers::layers::{Layer, Flip, LayerBuffer, LayerBufferSet, NoFlip, TextureLayer};
|
||||||
use layers::quadtree::{Tile, Normal, Hidden};
|
use layers::quadtree::{Tile, Normal, Hidden};
|
||||||
use layers::platform::surface::{NativeCompositingGraphicsContext, NativeSurfaceMethods};
|
use layers::platform::surface::{NativeCompositingGraphicsContext, NativeSurfaceMethods};
|
||||||
use layers::texturegl::{Texture, TextureTarget};
|
use layers::texturegl::{Texture, TextureTarget};
|
||||||
|
@ -139,8 +139,8 @@ impl CompositorData {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn id_of_first_child(layer: Rc<ContainerLayer<CompositorData>>) -> LayerId {
|
pub fn id_of_first_child(layer: Rc<Layer<CompositorData>>) -> LayerId {
|
||||||
layer.children().next().expect("no first child!").extra_data.borrow().id
|
layer.children().iter().next().expect("no first child!").extra_data.borrow().id
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a child layer to the layer with the given ID and the given pipeline, if it doesn't
|
/// Adds a child layer to the layer with the given ID and the given pipeline, if it doesn't
|
||||||
|
@ -152,7 +152,7 @@ impl CompositorData {
|
||||||
/// * True if the layer was not added because it already existed;
|
/// * True if the layer was not added because it already existed;
|
||||||
/// * False if the layer could not be added because no suitable parent layer with the given
|
/// * False if the layer could not be added because no suitable parent layer with the given
|
||||||
/// ID and pipeline could be found.
|
/// ID and pipeline could be found.
|
||||||
pub fn add_child_if_necessary(layer: Rc<ContainerLayer<CompositorData>>,
|
pub fn add_child_if_necessary(layer: Rc<Layer<CompositorData>>,
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
parent_layer_id: LayerId,
|
parent_layer_id: LayerId,
|
||||||
child_layer_id: LayerId,
|
child_layer_id: LayerId,
|
||||||
|
@ -161,8 +161,8 @@ impl CompositorData {
|
||||||
scroll_policy: ScrollPolicy) -> bool {
|
scroll_policy: ScrollPolicy) -> bool {
|
||||||
if layer.extra_data.borrow().pipeline.id != pipeline_id ||
|
if layer.extra_data.borrow().pipeline.id != pipeline_id ||
|
||||||
layer.extra_data.borrow().id != parent_layer_id {
|
layer.extra_data.borrow().id != parent_layer_id {
|
||||||
return layer.children().any(|kid| {
|
return layer.children().iter().any(|kid| {
|
||||||
CompositorData::add_child_if_necessary(kid,
|
CompositorData::add_child_if_necessary(kid.clone(),
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
parent_layer_id,
|
parent_layer_id,
|
||||||
child_layer_id,
|
child_layer_id,
|
||||||
|
@ -173,7 +173,7 @@ impl CompositorData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we've already made this child layer.
|
// See if we've already made this child layer.
|
||||||
if layer.children().any(|kid| {
|
if layer.children().iter().any(|kid| {
|
||||||
kid.extra_data.borrow().pipeline.id == pipeline_id &&
|
kid.extra_data.borrow().pipeline.id == pipeline_id &&
|
||||||
kid.extra_data.borrow().id == child_layer_id
|
kid.extra_data.borrow().id == child_layer_id
|
||||||
}) {
|
}) {
|
||||||
|
@ -188,15 +188,15 @@ impl CompositorData {
|
||||||
DoesntWantScrollEvents,
|
DoesntWantScrollEvents,
|
||||||
scroll_policy,
|
scroll_policy,
|
||||||
false);
|
false);
|
||||||
let new_kid = Rc::new(ContainerLayer::new(Some(page_size),
|
let new_kid = Rc::new(Layer::new(page_size,
|
||||||
ContainerLayer::tile_size(layer.clone()),
|
Layer::tile_size(layer.clone()),
|
||||||
new_compositor_data));
|
new_compositor_data));
|
||||||
|
|
||||||
new_kid.extra_data.borrow_mut().scissor = Some(rect);
|
new_kid.extra_data.borrow_mut().scissor = Some(rect);
|
||||||
new_kid.common.borrow_mut().origin = rect.origin;
|
*new_kid.origin.borrow_mut() = rect.origin;
|
||||||
|
|
||||||
// Place the kid's layer in the container passed in.
|
// Place the kid's layer in the container passed in.
|
||||||
ContainerLayer::add_child_end(layer.clone(), new_kid.clone());
|
Layer::add_child(layer.clone(), new_kid.clone());
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ impl CompositorData {
|
||||||
/// specified amount in page coordinates. This also takes in a cursor position to see if the
|
/// specified amount in page coordinates. This also takes in a cursor position to see if the
|
||||||
/// mouse is over child layers first. If a layer successfully scrolled, returns true; otherwise
|
/// mouse is over child layers first. If a layer successfully scrolled, returns true; otherwise
|
||||||
/// returns false, so a parent layer can scroll instead.
|
/// returns false, so a parent layer can scroll instead.
|
||||||
pub fn handle_scroll_event(layer: Rc<ContainerLayer<CompositorData>>,
|
pub fn handle_scroll_event(layer: Rc<Layer<CompositorData>>,
|
||||||
delta: TypedPoint2D<PagePx, f32>,
|
delta: TypedPoint2D<PagePx, f32>,
|
||||||
cursor: TypedPoint2D<PagePx, f32>,
|
cursor: TypedPoint2D<PagePx, f32>,
|
||||||
window_size: TypedSize2D<PagePx, f32>)
|
window_size: TypedSize2D<PagePx, f32>)
|
||||||
|
@ -223,7 +223,7 @@ impl CompositorData {
|
||||||
|
|
||||||
// Allow children to scroll.
|
// Allow children to scroll.
|
||||||
let cursor = cursor - layer.extra_data.borrow().scroll_offset;
|
let cursor = cursor - layer.extra_data.borrow().scroll_offset;
|
||||||
for child in layer.children() {
|
for child in layer.children().iter() {
|
||||||
match child.extra_data.borrow().scissor {
|
match child.extra_data.borrow().scissor {
|
||||||
None => {
|
None => {
|
||||||
error!("CompositorData: unable to perform cursor hit test for layer");
|
error!("CompositorData: unable to perform cursor hit test for layer");
|
||||||
|
@ -272,7 +272,7 @@ impl CompositorData {
|
||||||
|
|
||||||
/// Actually scrolls the descendants of a layer that scroll. This is called by
|
/// Actually scrolls the descendants of a layer that scroll. This is called by
|
||||||
/// `handle_scroll_event` above when it determines that a layer wants to scroll.
|
/// `handle_scroll_event` above when it determines that a layer wants to scroll.
|
||||||
fn scroll(layer: Rc<ContainerLayer<CompositorData>>,
|
fn scroll(layer: Rc<Layer<CompositorData>>,
|
||||||
scroll_offset: TypedPoint2D<PagePx, f32>)
|
scroll_offset: TypedPoint2D<PagePx, f32>)
|
||||||
-> bool {
|
-> bool {
|
||||||
let mut result = false;
|
let mut result = false;
|
||||||
|
@ -283,13 +283,12 @@ impl CompositorData {
|
||||||
layer.extra_data.borrow_mut().scroll_offset = scroll_offset;
|
layer.extra_data.borrow_mut().scroll_offset = scroll_offset;
|
||||||
|
|
||||||
let scroll_offset = layer.extra_data.borrow().scroll_offset.clone();
|
let scroll_offset = layer.extra_data.borrow().scroll_offset.clone();
|
||||||
layer.common.borrow_mut().set_transform(
|
*layer.transform.borrow_mut() = identity().translate(scroll_offset.x.get(), scroll_offset.y.get(), 0.0);
|
||||||
identity().translate(scroll_offset.x.get(), scroll_offset.y.get(), 0.0));
|
|
||||||
|
|
||||||
result = true
|
result = true
|
||||||
}
|
}
|
||||||
|
|
||||||
for child in layer.children() {
|
for child in layer.children().iter() {
|
||||||
result = CompositorData::scroll(child.clone(), scroll_offset) || result;
|
result = CompositorData::scroll(child.clone(), scroll_offset) || result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,10 +298,10 @@ impl CompositorData {
|
||||||
// Takes in a MouseWindowEvent, determines if it should be passed to children, and
|
// Takes in a MouseWindowEvent, determines if it should be passed to children, and
|
||||||
// sends the event off to the appropriate pipeline. NB: the cursor position is in
|
// sends the event off to the appropriate pipeline. NB: the cursor position is in
|
||||||
// page coordinates.
|
// page coordinates.
|
||||||
pub fn send_mouse_event(layer: Rc<ContainerLayer<CompositorData>>,
|
pub fn send_mouse_event(layer: Rc<Layer<CompositorData>>,
|
||||||
event: MouseWindowEvent, cursor: TypedPoint2D<PagePx, f32>) {
|
event: MouseWindowEvent, cursor: TypedPoint2D<PagePx, f32>) {
|
||||||
let cursor = cursor - layer.extra_data.borrow().scroll_offset;
|
let cursor = cursor - layer.extra_data.borrow().scroll_offset;
|
||||||
for child in layer.children() {
|
for child in layer.children().iter() {
|
||||||
if child.extra_data.borrow().hidden {
|
if child.extra_data.borrow().hidden {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +331,7 @@ impl CompositorData {
|
||||||
let _ = chan.send_opt(SendEventMsg(layer.extra_data.borrow().pipeline.id.clone(), message));
|
let _ = chan.send_opt(SendEventMsg(layer.extra_data.borrow().pipeline.id.clone(), message));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_mouse_move_event(layer: Rc<ContainerLayer<CompositorData>>,
|
pub fn send_mouse_move_event(layer: Rc<Layer<CompositorData>>,
|
||||||
cursor: TypedPoint2D<PagePx, f32>) {
|
cursor: TypedPoint2D<PagePx, f32>) {
|
||||||
let message = MouseMoveEvent(cursor.to_untyped());
|
let message = MouseMoveEvent(cursor.to_untyped());
|
||||||
let ScriptChan(ref chan) = layer.extra_data.borrow().pipeline.script_chan;
|
let ScriptChan(ref chan) = layer.extra_data.borrow().pipeline.script_chan;
|
||||||
|
@ -341,14 +340,12 @@ impl CompositorData {
|
||||||
|
|
||||||
// Given the current window size, determine which tiles need to be (re-)rendered and sends them
|
// Given the current window size, determine which tiles need to be (re-)rendered and sends them
|
||||||
// off the the appropriate renderer. Returns true if and only if the scene should be repainted.
|
// off the the appropriate renderer. Returns true if and only if the scene should be repainted.
|
||||||
pub fn get_buffer_request(layer: Rc<ContainerLayer<CompositorData>>,
|
pub fn get_buffer_request(layer: Rc<Layer<CompositorData>>,
|
||||||
graphics_context: &NativeCompositingGraphicsContext,
|
graphics_context: &NativeCompositingGraphicsContext,
|
||||||
window_rect: Rect<f32>,
|
window_rect: Rect<f32>,
|
||||||
scale: f32)
|
scale: f32)
|
||||||
-> bool {
|
-> bool {
|
||||||
let (request, unused) = ContainerLayer::get_tile_rects_page(layer.clone(),
|
let (request, unused) = Layer::get_tile_rects_page(layer.clone(), window_rect, scale);
|
||||||
window_rect,
|
|
||||||
scale);
|
|
||||||
let redisplay = !unused.is_empty();
|
let redisplay = !unused.is_empty();
|
||||||
if redisplay {
|
if redisplay {
|
||||||
// Send back unused tiles.
|
// Send back unused tiles.
|
||||||
|
@ -371,7 +368,7 @@ impl CompositorData {
|
||||||
CompositorData::build_layer_tree(layer.clone(), graphics_context);
|
CompositorData::build_layer_tree(layer.clone(), graphics_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
let get_child_buffer_request = |kid: Rc<ContainerLayer<CompositorData>>| -> bool {
|
let get_child_buffer_request = |kid: &Rc<Layer<CompositorData>>| -> bool {
|
||||||
match kid.extra_data.borrow().scissor {
|
match kid.extra_data.borrow().scissor {
|
||||||
Some(scissor) => {
|
Some(scissor) => {
|
||||||
let mut new_rect = window_rect;
|
let mut new_rect = window_rect;
|
||||||
|
@ -399,7 +396,7 @@ impl CompositorData {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
layer.children().filter(|x| !x.extra_data.borrow().hidden)
|
layer.children().iter().filter(|x| !x.extra_data.borrow().hidden)
|
||||||
.map(get_child_buffer_request)
|
.map(get_child_buffer_request)
|
||||||
.any(|b| b) || redisplay
|
.any(|b| b) || redisplay
|
||||||
}
|
}
|
||||||
|
@ -408,7 +405,7 @@ impl CompositorData {
|
||||||
// and clip the layer to the specified size in page coordinates.
|
// and clip the layer to the specified size in page coordinates.
|
||||||
// If the layer is hidden and has a defined page size, unhide it.
|
// If the layer is hidden and has a defined page size, unhide it.
|
||||||
// This method returns false if the specified layer is not found.
|
// This method returns false if the specified layer is not found.
|
||||||
pub fn set_clipping_rect(layer: Rc<ContainerLayer<CompositorData>>,
|
pub fn set_clipping_rect(layer: Rc<Layer<CompositorData>>,
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
layer_id: LayerId,
|
layer_id: LayerId,
|
||||||
new_rect: Rect<f32>)
|
new_rect: Rect<f32>)
|
||||||
|
@ -419,18 +416,18 @@ impl CompositorData {
|
||||||
layer_id) {
|
layer_id) {
|
||||||
Some(child_node) => {
|
Some(child_node) => {
|
||||||
debug!("compositor_data: node found for set_clipping_rect()");
|
debug!("compositor_data: node found for set_clipping_rect()");
|
||||||
child_node.common.borrow_mut().origin = new_rect.origin;
|
*child_node.origin.borrow_mut() = new_rect.origin;
|
||||||
let old_rect = child_node.extra_data.borrow().scissor.clone();
|
let old_rect = child_node.extra_data.borrow().scissor.clone();
|
||||||
child_node.extra_data.borrow_mut().scissor = Some(new_rect);
|
child_node.extra_data.borrow_mut().scissor = Some(new_rect);
|
||||||
match old_rect {
|
match old_rect {
|
||||||
Some(old_rect) => {
|
Some(old_rect) => {
|
||||||
// Rect is unhidden
|
// Rect is unhidden
|
||||||
ContainerLayer::set_status_page(layer.clone(), old_rect, Normal, false);
|
Layer::set_status_page(layer.clone(), old_rect, Normal, false);
|
||||||
}
|
}
|
||||||
None => {} // Nothing to do
|
None => {} // Nothing to do
|
||||||
}
|
}
|
||||||
// Hide the new rect
|
// Hide the new rect
|
||||||
ContainerLayer::set_status_page(layer.clone(), new_rect, Hidden, false);
|
Layer::set_status_page(layer.clone(), new_rect, Hidden, false);
|
||||||
|
|
||||||
// If possible, unhide child
|
// If possible, unhide child
|
||||||
let mut child_data = child_node.extra_data.borrow_mut();
|
let mut child_data = child_node.extra_data.borrow_mut();
|
||||||
|
@ -440,7 +437,7 @@ impl CompositorData {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
layer.children()
|
layer.children().iter()
|
||||||
.any(|kid| CompositorData::set_clipping_rect(kid.clone(),
|
.any(|kid| CompositorData::set_clipping_rect(kid.clone(),
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
layer_id,
|
layer_id,
|
||||||
|
@ -453,7 +450,7 @@ impl CompositorData {
|
||||||
// Set the layer's page size. This signals that the renderer is ready for BufferRequests.
|
// Set the layer's page size. This signals that the renderer is ready for BufferRequests.
|
||||||
// If the layer is hidden and has a defined clipping rect, unhide it.
|
// If the layer is hidden and has a defined clipping rect, unhide it.
|
||||||
// This method returns false if the specified layer is not found.
|
// This method returns false if the specified layer is not found.
|
||||||
pub fn resize(layer: Rc<ContainerLayer<CompositorData>>,
|
pub fn resize(layer: Rc<Layer<CompositorData>>,
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
layer_id: LayerId,
|
layer_id: LayerId,
|
||||||
new_size: Size2D<f32>,
|
new_size: Size2D<f32>,
|
||||||
|
@ -474,7 +471,7 @@ impl CompositorData {
|
||||||
layer.extra_data.borrow_mut().epoch = epoch;
|
layer.extra_data.borrow_mut().epoch = epoch;
|
||||||
layer.extra_data.borrow_mut().page_size = Some(new_size);
|
layer.extra_data.borrow_mut().page_size = Some(new_size);
|
||||||
|
|
||||||
let unused_buffers = ContainerLayer::resize(layer.clone(), new_size);
|
let unused_buffers = Layer::resize(layer.clone(), new_size);
|
||||||
if !unused_buffers.is_empty() {
|
if !unused_buffers.is_empty() {
|
||||||
let _ = layer.extra_data.borrow().pipeline
|
let _ = layer.extra_data.borrow().pipeline
|
||||||
.render_chan
|
.render_chan
|
||||||
|
@ -492,7 +489,7 @@ impl CompositorData {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn move(layer: Rc<ContainerLayer<CompositorData>>,
|
pub fn move(layer: Rc<Layer<CompositorData>>,
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
layer_id: LayerId,
|
layer_id: LayerId,
|
||||||
origin: Point2D<f32>,
|
origin: Point2D<f32>,
|
||||||
|
@ -501,7 +498,7 @@ impl CompositorData {
|
||||||
// Search children for the right layer to move.
|
// Search children for the right layer to move.
|
||||||
if layer.extra_data.borrow().pipeline.id != pipeline_id ||
|
if layer.extra_data.borrow().pipeline.id != pipeline_id ||
|
||||||
layer.extra_data.borrow().id != layer_id {
|
layer.extra_data.borrow().id != layer_id {
|
||||||
return layer.children().any(|kid| {
|
return layer.children().iter().any(|kid| {
|
||||||
CompositorData::move(kid.clone(), pipeline_id, layer_id, origin, window_size)
|
CompositorData::move(kid.clone(), pipeline_id, layer_id, origin, window_size)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -566,21 +563,21 @@ impl CompositorData {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn find_child_with_layer_and_pipeline_id(layer: Rc<ContainerLayer<CompositorData>>,
|
fn find_child_with_layer_and_pipeline_id(layer: Rc<Layer<CompositorData>>,
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
layer_id: LayerId)
|
layer_id: LayerId)
|
||||||
-> Option<Rc<ContainerLayer<CompositorData>>> {
|
-> Option<Rc<Layer<CompositorData>>> {
|
||||||
for kid in layer.children() {
|
for kid in layer.children().iter() {
|
||||||
if pipeline_id == kid.extra_data.borrow().pipeline.id &&
|
if pipeline_id == kid.extra_data.borrow().pipeline.id &&
|
||||||
layer_id == kid.extra_data.borrow().id {
|
layer_id == kid.extra_data.borrow().id {
|
||||||
return Some(kid);
|
return Some(kid.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return None
|
return None
|
||||||
}
|
}
|
||||||
|
|
||||||
// A helper method to resize sublayers.
|
// A helper method to resize sublayers.
|
||||||
fn resize_helper(layer: Rc<ContainerLayer<CompositorData>>,
|
fn resize_helper(layer: Rc<Layer<CompositorData>>,
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
layer_id: LayerId,
|
layer_id: LayerId,
|
||||||
new_size: Size2D<f32>,
|
new_size: Size2D<f32>,
|
||||||
|
@ -596,7 +593,7 @@ impl CompositorData {
|
||||||
child.extra_data.borrow_mut().epoch = epoch;
|
child.extra_data.borrow_mut().epoch = epoch;
|
||||||
child.extra_data.borrow_mut().page_size = Some(new_size);
|
child.extra_data.borrow_mut().page_size = Some(new_size);
|
||||||
|
|
||||||
let unused_buffers = ContainerLayer::resize(child.clone(), new_size);
|
let unused_buffers = Layer::resize(child.clone(), new_size);
|
||||||
if !unused_buffers.is_empty() {
|
if !unused_buffers.is_empty() {
|
||||||
let msg = UnusedBufferMsg(unused_buffers);
|
let msg = UnusedBufferMsg(unused_buffers);
|
||||||
let _ = child.extra_data.borrow().pipeline.render_chan.send_opt(msg);
|
let _ = child.extra_data.borrow().pipeline.render_chan.send_opt(msg);
|
||||||
|
@ -628,20 +625,20 @@ impl CompositorData {
|
||||||
|
|
||||||
// If we got here, the layer's ID does not match ours, so recurse on descendents (including
|
// If we got here, the layer's ID does not match ours, so recurse on descendents (including
|
||||||
// hidden children).
|
// hidden children).
|
||||||
layer.children().any(|kid| {
|
layer.children().iter().any(|kid| {
|
||||||
CompositorData::resize_helper(kid.clone(), pipeline_id, layer_id, new_size, epoch)
|
CompositorData::resize_helper(kid.clone(), pipeline_id, layer_id, new_size, epoch)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect buffers from the quadtree. This method IS NOT recursive, so child layers
|
// Collect buffers from the quadtree. This method IS NOT recursive, so child layers
|
||||||
// are not rebuilt directly from this method.
|
// are not rebuilt directly from this method.
|
||||||
pub fn build_layer_tree(layer: Rc<ContainerLayer<CompositorData>>,
|
pub fn build_layer_tree(layer: Rc<Layer<CompositorData>>,
|
||||||
graphics_context: &NativeCompositingGraphicsContext) {
|
graphics_context: &NativeCompositingGraphicsContext) {
|
||||||
// Clear all old textures.
|
// Clear all old textures.
|
||||||
layer.tiles.borrow_mut().clear();
|
layer.tiles.borrow_mut().clear();
|
||||||
|
|
||||||
// Add new tiles.
|
// Add new tiles.
|
||||||
ContainerLayer::do_for_all_tiles(layer.clone(), |buffer: &Box<LayerBuffer>| {
|
Layer::do_for_all_tiles(layer.clone(), |buffer: &Box<LayerBuffer>| {
|
||||||
debug!("osmain: compositing buffer rect {}", buffer.rect);
|
debug!("osmain: compositing buffer rect {}", buffer.rect);
|
||||||
|
|
||||||
let size = Size2D(buffer.screen_pos.size.width as int,
|
let size = Size2D(buffer.screen_pos.size.width as int,
|
||||||
|
@ -679,7 +676,7 @@ impl CompositorData {
|
||||||
//
|
//
|
||||||
// If the epoch of the message does not match the layer's epoch, the message is ignored, the
|
// If the epoch of the message does not match the layer's epoch, the message is ignored, the
|
||||||
// layer buffer set is consumed, and None is returned.
|
// layer buffer set is consumed, and None is returned.
|
||||||
pub fn add_buffers(layer: Rc<ContainerLayer<CompositorData>>,
|
pub fn add_buffers(layer: Rc<Layer<CompositorData>>,
|
||||||
graphics_context: &NativeCompositingGraphicsContext,
|
graphics_context: &NativeCompositingGraphicsContext,
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
layer_id: LayerId,
|
layer_id: LayerId,
|
||||||
|
@ -690,7 +687,7 @@ impl CompositorData {
|
||||||
if layer.extra_data.borrow().pipeline.id != pipeline_id ||
|
if layer.extra_data.borrow().pipeline.id != pipeline_id ||
|
||||||
layer.extra_data.borrow().id != layer_id {
|
layer.extra_data.borrow().id != layer_id {
|
||||||
// ID does not match ours, so recurse on descendents (including hidden children).
|
// ID does not match ours, so recurse on descendents (including hidden children).
|
||||||
for child_layer in layer.children() {
|
for child_layer in layer.children().iter() {
|
||||||
match CompositorData::add_buffers(child_layer.clone(),
|
match CompositorData::add_buffers(child_layer.clone(),
|
||||||
graphics_context,
|
graphics_context,
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
|
@ -721,7 +718,7 @@ impl CompositorData {
|
||||||
{
|
{
|
||||||
let mut unused_tiles = vec!();
|
let mut unused_tiles = vec!();
|
||||||
for buffer in new_buffers.buffers.move_iter().rev() {
|
for buffer in new_buffers.buffers.move_iter().rev() {
|
||||||
unused_tiles.push_all_move(ContainerLayer::add_tile_pixel(layer.clone(), buffer));
|
unused_tiles.push_all_move(Layer::add_tile_pixel(layer.clone(), buffer));
|
||||||
}
|
}
|
||||||
if !unused_tiles.is_empty() { // send back unused buffers
|
if !unused_tiles.is_empty() { // send back unused buffers
|
||||||
let msg = UnusedBufferMsg(unused_tiles);
|
let msg = UnusedBufferMsg(unused_tiles);
|
||||||
|
@ -735,19 +732,19 @@ impl CompositorData {
|
||||||
|
|
||||||
// Recursively sets occluded portions of quadtrees to Hidden, so that they do not ask for
|
// Recursively sets occluded portions of quadtrees to Hidden, so that they do not ask for
|
||||||
// tile requests. If layers are moved, resized, or deleted, these portions may be updated.
|
// tile requests. If layers are moved, resized, or deleted, these portions may be updated.
|
||||||
fn set_occlusions(layer: Rc<ContainerLayer<CompositorData>>) {
|
fn set_occlusions(layer: Rc<Layer<CompositorData>>) {
|
||||||
for kid in layer.children() {
|
for kid in layer.children().iter() {
|
||||||
if !kid.extra_data.borrow().hidden {
|
if !kid.extra_data.borrow().hidden {
|
||||||
match kid.extra_data.borrow().scissor {
|
match kid.extra_data.borrow().scissor {
|
||||||
None => {} // Nothing to do
|
None => {} // Nothing to do
|
||||||
Some(rect) => {
|
Some(rect) => {
|
||||||
ContainerLayer::set_status_page(layer.clone(), rect, Hidden, false);
|
Layer::set_status_page(layer.clone(), rect, Hidden, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for kid in layer.children() {
|
for kid in layer.children().iter() {
|
||||||
if !kid.extra_data.borrow().hidden {
|
if !kid.extra_data.borrow().hidden {
|
||||||
CompositorData::set_occlusions(kid.clone());
|
CompositorData::set_occlusions(kid.clone());
|
||||||
}
|
}
|
||||||
|
@ -756,8 +753,8 @@ impl CompositorData {
|
||||||
|
|
||||||
/// Destroys all quadtree tiles, sending the buffers back to the renderer to be destroyed or
|
/// Destroys all quadtree tiles, sending the buffers back to the renderer to be destroyed or
|
||||||
/// reused.
|
/// reused.
|
||||||
fn clear(layer: Rc<ContainerLayer<CompositorData>>) {
|
fn clear(layer: Rc<Layer<CompositorData>>) {
|
||||||
let mut tiles = ContainerLayer::collect_tiles(layer.clone());
|
let mut tiles = Layer::collect_tiles(layer.clone());
|
||||||
|
|
||||||
if !tiles.is_empty() {
|
if !tiles.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 render task is even up and
|
||||||
|
@ -773,9 +770,9 @@ impl 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.
|
/// renderer to be destroyed or reused.
|
||||||
pub fn clear_all_tiles(layer: Rc<ContainerLayer<CompositorData>>) {
|
pub fn clear_all_tiles(layer: Rc<Layer<CompositorData>>) {
|
||||||
CompositorData::clear(layer.clone());
|
CompositorData::clear(layer.clone());
|
||||||
for kid in layer.children() {
|
for kid in layer.children().iter() {
|
||||||
CompositorData::clear_all_tiles(kid.clone());
|
CompositorData::clear_all_tiles(kid.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -785,26 +782,26 @@ impl CompositorData {
|
||||||
/// 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 render task is going away.
|
||||||
pub fn forget_all_tiles(layer: Rc<ContainerLayer<CompositorData>>) {
|
pub fn forget_all_tiles(layer: Rc<Layer<CompositorData>>) {
|
||||||
let tiles = ContainerLayer::collect_tiles(layer.clone());
|
let tiles = Layer::collect_tiles(layer.clone());
|
||||||
for tile in tiles.move_iter() {
|
for tile in tiles.move_iter() {
|
||||||
let mut tile = tile;
|
let mut tile = tile;
|
||||||
tile.mark_wont_leak()
|
tile.mark_wont_leak()
|
||||||
}
|
}
|
||||||
|
|
||||||
for kid in layer.children() {
|
for kid in layer.children().iter() {
|
||||||
CompositorData::forget_all_tiles(kid.clone());
|
CompositorData::forget_all_tiles(kid.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_unrendered_color(layer: Rc<ContainerLayer<CompositorData>>,
|
pub fn set_unrendered_color(layer: Rc<Layer<CompositorData>>,
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
layer_id: LayerId,
|
layer_id: LayerId,
|
||||||
color: Color)
|
color: Color)
|
||||||
-> bool {
|
-> bool {
|
||||||
if layer.extra_data.borrow().pipeline.id != pipeline_id ||
|
if layer.extra_data.borrow().pipeline.id != pipeline_id ||
|
||||||
layer.extra_data.borrow().id != layer_id {
|
layer.extra_data.borrow().id != layer_id {
|
||||||
for child_layer in layer.children() {
|
for child_layer in layer.children().iter() {
|
||||||
if CompositorData::set_unrendered_color(child_layer.clone(),
|
if CompositorData::set_unrendered_color(child_layer.clone(),
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
layer_id,
|
layer_id,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5ff99f3ac797bd1bed205549d705264fc85d3099
|
Subproject commit ccd9bb5564be060efd83f54b6e0918fafb19d1c0
|
Loading…
Add table
Add a link
Reference in a new issue