mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Remove concept of Layers from Servo
Layers were a feature of the legacy drawing path. If we re-add them at some point, it probably makes more sense to make them a product of display list inspection. This change also remove a bunch of dead painting code.
This commit is contained in:
parent
e667e62f0c
commit
ccb7ab926a
21 changed files with 57 additions and 745 deletions
|
@ -51,12 +51,12 @@ use euclid::rect::Rect;
|
|||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::Size2D;
|
||||
use fnv::FnvHasher;
|
||||
use gfx::display_list::{ClippingRegion, DisplayList, LayerInfo, OpaqueNode};
|
||||
use gfx::display_list::{ClippingRegion, DisplayList, OpaqueNode};
|
||||
use gfx::display_list::{StackingContext, StackingContextType, WebRenderImageInfo};
|
||||
use gfx::font;
|
||||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use gfx::font_context;
|
||||
use gfx_traits::{Epoch, FragmentType, LayerId, ScrollPolicy, StackingContextId, color};
|
||||
use gfx_traits::{Epoch, FragmentType, ScrollPolicy, StackingContextId, color};
|
||||
use heapsize::HeapSizeOf;
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
|
@ -71,7 +71,7 @@ use layout::layout_debug;
|
|||
use layout::parallel;
|
||||
use layout::query::{LayoutRPCImpl, LayoutThreadData, process_content_box_request, process_content_boxes_request};
|
||||
use layout::query::{process_margin_style_query, process_node_overflow_request, process_resolved_style_request};
|
||||
use layout::query::{process_node_geometry_request, process_node_layer_id_request, process_node_scroll_area_request};
|
||||
use layout::query::{process_node_geometry_request, process_node_scroll_area_request};
|
||||
use layout::query::process_offset_parent_query;
|
||||
use layout::sequential;
|
||||
use layout::traversal::{ComputeAbsolutePositions, RecalcStyleAndConstructFlows};
|
||||
|
@ -124,9 +124,6 @@ use util::prefs::PREFS;
|
|||
use util::resource_files::read_resource_file;
|
||||
use util::thread;
|
||||
|
||||
/// The number of screens we have to traverse before we decide to generate new display lists.
|
||||
const DISPLAY_PORT_THRESHOLD_SIZE_FACTOR: i32 = 4;
|
||||
|
||||
/// Information needed by the layout thread.
|
||||
pub struct LayoutThread {
|
||||
/// The ID of the pipeline that we belong to.
|
||||
|
@ -197,10 +194,6 @@ pub struct LayoutThread {
|
|||
/// The root of the flow tree.
|
||||
root_flow: Option<FlowRef>,
|
||||
|
||||
/// The position and size of the visible rect for each layer. We do not build display lists
|
||||
/// for any areas more than `DISPLAY_PORT_SIZE_FACTOR` screens away from this area.
|
||||
visible_rects: Arc<HashMap<LayerId, Rect<Au>, BuildHasherDefault<FnvHasher>>>,
|
||||
|
||||
/// The list of currently-running animations.
|
||||
running_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
|
||||
|
||||
|
@ -446,7 +439,6 @@ impl LayoutThread {
|
|||
new_animations_receiver: new_animations_receiver,
|
||||
outstanding_web_fonts: outstanding_web_fonts_counter,
|
||||
root_flow: None,
|
||||
visible_rects: Arc::new(HashMap::with_hasher(Default::default())),
|
||||
running_animations: Arc::new(RwLock::new(HashMap::new())),
|
||||
expired_animations: Arc::new(RwLock::new(HashMap::new())),
|
||||
epoch: Epoch(0),
|
||||
|
@ -460,7 +452,6 @@ impl LayoutThread {
|
|||
content_box_response: Rect::zero(),
|
||||
content_boxes_response: Vec::new(),
|
||||
client_rect_response: Rect::zero(),
|
||||
layer_id_response: None,
|
||||
hit_test_response: (None, false),
|
||||
scroll_area_response: Rect::zero(),
|
||||
overflow_response: NodeOverflowResponse(None),
|
||||
|
@ -523,7 +514,6 @@ impl LayoutThread {
|
|||
image_cache_thread: self.image_cache_thread.clone(),
|
||||
image_cache_sender: Mutex::new(self.image_cache_sender.clone()),
|
||||
font_cache_thread: Mutex::new(self.font_cache_thread.clone()),
|
||||
visible_rects: self.visible_rects.clone(),
|
||||
webrender_image_cache: self.webrender_image_cache.clone(),
|
||||
}
|
||||
}
|
||||
|
@ -561,10 +551,6 @@ impl LayoutThread {
|
|||
};
|
||||
|
||||
match request {
|
||||
Request::FromPipeline(LayoutControlMsg::SetVisibleRects(new_visible_rects)) => {
|
||||
self.handle_request_helper(Msg::SetVisibleRects(new_visible_rects),
|
||||
possibly_locked_rw_data)
|
||||
},
|
||||
Request::FromPipeline(LayoutControlMsg::SetStackingContextScrollStates(
|
||||
new_scroll_states)) => {
|
||||
self.handle_request_helper(Msg::SetStackingContextScrollStates(new_scroll_states),
|
||||
|
@ -654,9 +640,6 @@ impl LayoutThread {
|
|||
Msg::ReflowWithNewlyLoadedWebFont => {
|
||||
self.reflow_with_newly_loaded_web_font(possibly_locked_rw_data)
|
||||
}
|
||||
Msg::SetVisibleRects(new_visible_rects) => {
|
||||
self.set_visible_rects(new_visible_rects, possibly_locked_rw_data);
|
||||
}
|
||||
Msg::SetStackingContextScrollStates(new_scroll_states) => {
|
||||
self.set_stacking_context_scroll_states(new_scroll_states,
|
||||
possibly_locked_rw_data);
|
||||
|
@ -935,7 +918,7 @@ impl LayoutThread {
|
|||
Matrix4D::identity(),
|
||||
Matrix4D::identity(),
|
||||
true,
|
||||
None,
|
||||
ScrollPolicy::Scrollable,
|
||||
None);
|
||||
|
||||
let display_list_entries =
|
||||
|
@ -945,7 +928,6 @@ impl LayoutThread {
|
|||
|
||||
debug!("Done building display list.");
|
||||
|
||||
let root_background_color = get_root_flow_background_color(layout_root);
|
||||
let root_size = {
|
||||
let root_flow = flow::base(layout_root);
|
||||
if rw_data.stylist.viewport_constraints().is_some() {
|
||||
|
@ -958,11 +940,6 @@ impl LayoutThread {
|
|||
let origin = Rect::new(Point2D::new(Au(0), Au(0)), root_size);
|
||||
root_stacking_context.bounds = origin;
|
||||
root_stacking_context.overflow = origin;
|
||||
root_stacking_context.layer_info =
|
||||
Some(LayerInfo::new(layout_root.layer_id(),
|
||||
ScrollPolicy::Scrollable,
|
||||
None,
|
||||
root_background_color));
|
||||
|
||||
rw_data.display_list =
|
||||
Some(Arc::new(DisplayList::new(root_stacking_context,
|
||||
|
@ -1066,9 +1043,6 @@ impl LayoutThread {
|
|||
ReflowQueryType::NodeGeometryQuery(_) => {
|
||||
rw_data.client_rect_response = Rect::zero();
|
||||
},
|
||||
ReflowQueryType::NodeLayerIdQuery(_) => {
|
||||
rw_data.layer_id_response = None;
|
||||
},
|
||||
ReflowQueryType::NodeScrollGeometryQuery(_) => {
|
||||
rw_data.scroll_area_response = Rect::zero();
|
||||
},
|
||||
|
@ -1279,10 +1253,6 @@ impl LayoutThread {
|
|||
let node = unsafe { ServoLayoutNode::new(&node) };
|
||||
rw_data.overflow_response = process_node_overflow_request(node);
|
||||
},
|
||||
ReflowQueryType::NodeLayerIdQuery(node) => {
|
||||
let node = unsafe { ServoLayoutNode::new(&node) };
|
||||
rw_data.layer_id_response = Some(process_node_layer_id_request(node));
|
||||
},
|
||||
ReflowQueryType::ResolvedStyleQuery(node, ref pseudo, ref property) => {
|
||||
let node = unsafe { ServoLayoutNode::new(&node) };
|
||||
let layout_context = LayoutContext::new(&shared_layout_context);
|
||||
|
@ -1305,66 +1275,6 @@ impl LayoutThread {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_visible_rects<'a, 'b>(&mut self,
|
||||
new_visible_rects: Vec<(LayerId, Rect<Au>)>,
|
||||
possibly_locked_rw_data: &mut RwData<'a, 'b>)
|
||||
-> bool {
|
||||
let mut rw_data = possibly_locked_rw_data.lock();
|
||||
|
||||
// First, determine if we need to regenerate the display lists. This will happen if the
|
||||
// layers have moved more than `DISPLAY_PORT_THRESHOLD_SIZE_FACTOR` away from their last
|
||||
// positions.
|
||||
let mut must_regenerate_display_lists = false;
|
||||
let mut old_visible_rects = HashMap::with_hasher(Default::default());
|
||||
let inflation_amount =
|
||||
Size2D::new(self.viewport_size.width * DISPLAY_PORT_THRESHOLD_SIZE_FACTOR,
|
||||
self.viewport_size.height * DISPLAY_PORT_THRESHOLD_SIZE_FACTOR);
|
||||
for &(ref layer_id, ref new_visible_rect) in &new_visible_rects {
|
||||
match self.visible_rects.get(layer_id) {
|
||||
None => {
|
||||
old_visible_rects.insert(*layer_id, *new_visible_rect);
|
||||
}
|
||||
Some(old_visible_rect) => {
|
||||
old_visible_rects.insert(*layer_id, *old_visible_rect);
|
||||
|
||||
if !old_visible_rect.inflate(inflation_amount.width, inflation_amount.height)
|
||||
.intersects(new_visible_rect) {
|
||||
must_regenerate_display_lists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !must_regenerate_display_lists {
|
||||
// Update `visible_rects` in case there are new layers that were discovered.
|
||||
self.visible_rects = Arc::new(old_visible_rects);
|
||||
return true
|
||||
}
|
||||
|
||||
debug!("regenerating display lists!");
|
||||
for &(ref layer_id, ref new_visible_rect) in &new_visible_rects {
|
||||
old_visible_rects.insert(*layer_id, *new_visible_rect);
|
||||
}
|
||||
self.visible_rects = Arc::new(old_visible_rects);
|
||||
|
||||
// Regenerate the display lists.
|
||||
let reflow_info = Reflow {
|
||||
goal: ReflowGoal::ForDisplay,
|
||||
page_clip_rect: max_rect(),
|
||||
};
|
||||
|
||||
let mut layout_context = self.build_shared_layout_context(&*rw_data,
|
||||
false,
|
||||
reflow_info.goal);
|
||||
|
||||
self.perform_post_main_layout_passes(&reflow_info,
|
||||
None,
|
||||
None,
|
||||
&mut *rw_data,
|
||||
&mut layout_context);
|
||||
true
|
||||
}
|
||||
|
||||
fn set_stacking_context_scroll_states<'a, 'b>(
|
||||
&mut self,
|
||||
new_scroll_states: Vec<StackingContextScrollState>,
|
||||
|
@ -1670,9 +1580,9 @@ fn reflow_query_type_needs_display_list(query_type: &ReflowQueryType) -> bool {
|
|||
ReflowQueryType::HitTestQuery(..) => true,
|
||||
ReflowQueryType::ContentBoxQuery(_) | ReflowQueryType::ContentBoxesQuery(_) |
|
||||
ReflowQueryType::NodeGeometryQuery(_) | ReflowQueryType::NodeScrollGeometryQuery(_) |
|
||||
ReflowQueryType::NodeOverflowQuery(_) | ReflowQueryType::NodeLayerIdQuery(_) |
|
||||
ReflowQueryType::ResolvedStyleQuery(..) | ReflowQueryType::OffsetParentQuery(_) |
|
||||
ReflowQueryType::MarginStyleQuery(_) | ReflowQueryType::NoQuery => false,
|
||||
ReflowQueryType::NodeOverflowQuery(_) | ReflowQueryType::ResolvedStyleQuery(..) |
|
||||
ReflowQueryType::OffsetParentQuery(_) | ReflowQueryType::MarginStyleQuery(_) |
|
||||
ReflowQueryType::NoQuery => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue