mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Remove layout_2020::display_list, use WebRender display lists instead
This commit is contained in:
parent
e9f7079c70
commit
3e6489f543
9 changed files with 22 additions and 105 deletions
|
@ -1,17 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use euclid::Vector2D;
|
||||
use std::collections::HashMap;
|
||||
use std::f32;
|
||||
use webrender_api::units::LayoutPixel;
|
||||
use webrender_api::ExternalScrollId;
|
||||
|
||||
pub use style::dom::OpaqueNode;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct DisplayList {}
|
||||
|
||||
/// The type of the scroll offset list. This is only populated if WebRender is in use.
|
||||
pub type ScrollOffsetMap = HashMap<ExternalScrollId, Vector2D<f32, LayoutPixel>>;
|
|
@ -1,6 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
pub mod items;
|
||||
mod webrender_helpers;
|
|
@ -1,33 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::display_list::items::DisplayList;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use webrender_api::units::LayoutSize;
|
||||
use webrender_api::{self, DisplayListBuilder};
|
||||
|
||||
/// Contentful paint, for the purpose of
|
||||
/// https://w3c.github.io/paint-timing/#first-contentful-paint
|
||||
/// (i.e. the display list contains items of type text,
|
||||
/// image, non-white canvas or SVG). Used by metrics.
|
||||
pub struct IsContentful(pub bool);
|
||||
|
||||
impl DisplayList {
|
||||
pub fn convert_to_webrender(
|
||||
&mut self,
|
||||
pipeline_id: PipelineId,
|
||||
) -> (DisplayListBuilder, IsContentful) {
|
||||
let webrender_pipeline = pipeline_id.to_webrender();
|
||||
|
||||
let builder = DisplayListBuilder::with_capacity(
|
||||
webrender_pipeline,
|
||||
LayoutSize::zero(),
|
||||
1024 * 1024, // 1 MB of space
|
||||
);
|
||||
|
||||
let is_contentful = IsContentful(false);
|
||||
|
||||
(builder, is_contentful)
|
||||
}
|
||||
}
|
|
@ -5,11 +5,11 @@
|
|||
//! The `Fragment` type, which represents the leaves of the layout tree.
|
||||
|
||||
use crate::context::LayoutContext;
|
||||
use crate::display_list::items::OpaqueNode;
|
||||
use crate::ServoArc;
|
||||
use app_units::Au;
|
||||
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutNode};
|
||||
use serde::ser::{Serialize, SerializeStruct, Serializer};
|
||||
use style::dom::OpaqueNode;
|
||||
use style::logical_geometry::{LogicalMargin, LogicalRect};
|
||||
use style::properties::ComputedValues;
|
||||
use style::selector_parser::RestyleDamage;
|
||||
|
|
|
@ -4,12 +4,8 @@
|
|||
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde;
|
||||
|
||||
pub mod context;
|
||||
pub mod data;
|
||||
pub mod display_list;
|
||||
mod fragment;
|
||||
pub mod opaque_node;
|
||||
pub mod query;
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::display_list::items::OpaqueNode;
|
||||
use libc::c_void;
|
||||
use script_traits::UntrustedNodeAddress;
|
||||
use style::dom::OpaqueNode;
|
||||
|
||||
pub trait OpaqueNodeMethods {
|
||||
fn to_untrusted_node_address(&self) -> UntrustedNodeAddress;
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
//! Utilities for querying the layout, as needed by the layout thread.
|
||||
|
||||
use crate::context::LayoutContext;
|
||||
use crate::display_list::items::{DisplayList, OpaqueNode, ScrollOffsetMap};
|
||||
use app_units::Au;
|
||||
use euclid::default::{Point2D, Rect};
|
||||
use euclid::Vector2D;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use script_layout_interface::rpc::TextIndexResponse;
|
||||
|
@ -17,9 +17,12 @@ use script_layout_interface::rpc::{OffsetParentResponse, ResolvedStyleResponse,
|
|||
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
|
||||
use script_traits::LayoutMsg as ConstellationMsg;
|
||||
use script_traits::UntrustedNodeAddress;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use style::dom::OpaqueNode;
|
||||
use style::properties::PropertyId;
|
||||
use style::selector_parser::PseudoElement;
|
||||
use webrender_api::units::LayoutPixel;
|
||||
use webrender_api::ExternalScrollId;
|
||||
|
||||
/// Mutable data belonging to the LayoutThread.
|
||||
|
@ -30,7 +33,7 @@ pub struct LayoutThreadData {
|
|||
pub constellation_chan: IpcSender<ConstellationMsg>,
|
||||
|
||||
/// The root stacking context.
|
||||
pub display_list: Option<DisplayList>,
|
||||
pub display_list: Option<webrender_api::DisplayListBuilder>,
|
||||
|
||||
/// A queued response for the union of the content boxes of a node.
|
||||
pub content_box_response: Option<Rect<Au>>,
|
||||
|
@ -57,7 +60,7 @@ pub struct LayoutThreadData {
|
|||
pub style_response: StyleResponse,
|
||||
|
||||
/// Scroll offsets of scrolling regions.
|
||||
pub scroll_offsets: ScrollOffsetMap,
|
||||
pub scroll_offsets: HashMap<ExternalScrollId, Vector2D<f32, LayoutPixel>>,
|
||||
|
||||
/// Index in a text fragment. We need this do determine the insertion point.
|
||||
pub text_index_response: TextIndexResponse,
|
||||
|
|
|
@ -37,7 +37,6 @@ use histogram::Histogram;
|
|||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use layout::context::LayoutContext;
|
||||
use layout::display_list::items::DisplayList;
|
||||
use layout::query::{
|
||||
process_content_box_request, process_content_boxes_request, LayoutRPCImpl, LayoutThreadData,
|
||||
};
|
||||
|
@ -1337,36 +1336,35 @@ impl LayoutThread {
|
|||
document.will_paint();
|
||||
}
|
||||
|
||||
let mut display_list = DisplayList {};
|
||||
|
||||
debug!("Layout done!");
|
||||
|
||||
// TODO: Avoid the temporary conversion and build webrender sc/dl directly!
|
||||
let (builder, is_contentful) = display_list.convert_to_webrender(self.id);
|
||||
|
||||
let viewport_size = Size2D::new(
|
||||
self.viewport_size.width.to_f32_px(),
|
||||
self.viewport_size.height.to_f32_px(),
|
||||
);
|
||||
|
||||
let viewport_size = webrender_api::units::LayoutSize::from_untyped(viewport_size);
|
||||
|
||||
let display_list =
|
||||
webrender_api::DisplayListBuilder::new(self.id.to_webrender(), viewport_size);
|
||||
let is_contentful = false;
|
||||
|
||||
debug!("Layout done!");
|
||||
|
||||
let mut epoch = self.epoch.get();
|
||||
epoch.next();
|
||||
self.epoch.set(epoch);
|
||||
|
||||
let viewport_size = webrender_api::units::LayoutSize::from_untyped(viewport_size);
|
||||
|
||||
// Observe notifications about rendered frames if needed right before
|
||||
// sending the display list to WebRender in order to set time related
|
||||
// Progressive Web Metrics.
|
||||
self.paint_time_metrics
|
||||
.maybe_observe_paint_time(self, epoch, is_contentful.0);
|
||||
.maybe_observe_paint_time(self, epoch, is_contentful);
|
||||
|
||||
let mut txn = webrender_api::Transaction::new();
|
||||
txn.set_display_list(
|
||||
webrender_api::Epoch(epoch.0),
|
||||
None,
|
||||
viewport_size,
|
||||
builder.finalize(),
|
||||
display_list.finalize(),
|
||||
true,
|
||||
);
|
||||
txn.generate_frame();
|
||||
|
|
|
@ -4,13 +4,10 @@
|
|||
|
||||
use gfx_traits::Epoch;
|
||||
use ipc_channel::ipc;
|
||||
use layout::display_list::items::{BaseDisplayItem, CommonDisplayItem, DisplayItem, DisplayList};
|
||||
use metrics::{PaintTimeMetrics, ProfilerMetadataFactory, ProgressiveWebMetric};
|
||||
use msg::constellation_msg::TEST_PIPELINE_ID;
|
||||
use profile_traits::time::{ProfilerChan, TimerMetadata};
|
||||
use servo_url::ServoUrl;
|
||||
use webrender_api::units::{LayoutRect, LayoutSize};
|
||||
use webrender_api::{AlphaType, ColorF, ImageDisplayItem, ImageKey, ImageRendering};
|
||||
|
||||
struct DummyProfilerMetadataFactory {}
|
||||
impl ProfilerMetadataFactory for DummyProfilerMetadataFactory {
|
||||
|
@ -49,7 +46,7 @@ fn test_paint_metrics_construction() {
|
|||
);
|
||||
}
|
||||
|
||||
fn test_common(display_list: &DisplayList, epoch: Epoch) -> PaintTimeMetrics {
|
||||
fn test_common(display_list_is_contentful: bool, epoch: Epoch) -> PaintTimeMetrics {
|
||||
let (sender, _) = ipc::channel().unwrap();
|
||||
let profiler_chan = ProfilerChan(sender);
|
||||
let (layout_sender, _) = ipc::channel().unwrap();
|
||||
|
@ -66,7 +63,7 @@ fn test_common(display_list: &DisplayList, epoch: Epoch) -> PaintTimeMetrics {
|
|||
paint_time_metrics.maybe_observe_paint_time(
|
||||
&dummy_profiler_metadata_factory,
|
||||
epoch,
|
||||
&*display_list,
|
||||
display_list_is_contentful,
|
||||
);
|
||||
|
||||
// Should not set any metric until navigation start is set.
|
||||
|
@ -95,12 +92,8 @@ fn test_common(display_list: &DisplayList, epoch: Epoch) -> PaintTimeMetrics {
|
|||
|
||||
#[test]
|
||||
fn test_first_paint_setter() {
|
||||
let empty_display_list = DisplayList {
|
||||
list: Vec::new(),
|
||||
clip_scroll_nodes: Vec::new(),
|
||||
};
|
||||
let epoch = Epoch(0);
|
||||
let paint_time_metrics = test_common(&empty_display_list, epoch);
|
||||
let paint_time_metrics = test_common(false, epoch);
|
||||
let now = time::precise_time_ns();
|
||||
paint_time_metrics.maybe_set_metric(epoch, now);
|
||||
assert!(
|
||||
|
@ -116,25 +109,8 @@ fn test_first_paint_setter() {
|
|||
|
||||
#[test]
|
||||
fn test_first_contentful_paint_setter() {
|
||||
let image = DisplayItem::Image(CommonDisplayItem::new(
|
||||
BaseDisplayItem::empty(),
|
||||
ImageDisplayItem {
|
||||
bounds: LayoutRect::zero(),
|
||||
common: layout::display_list::items::empty_common_item_properties(),
|
||||
image_key: ImageKey::DUMMY,
|
||||
stretch_size: LayoutSize::zero(),
|
||||
tile_spacing: LayoutSize::zero(),
|
||||
image_rendering: ImageRendering::Auto,
|
||||
alpha_type: AlphaType::PremultipliedAlpha,
|
||||
color: ColorF::WHITE,
|
||||
},
|
||||
));
|
||||
let display_list = DisplayList {
|
||||
list: vec![image],
|
||||
clip_scroll_nodes: Vec::new(),
|
||||
};
|
||||
let epoch = Epoch(0);
|
||||
let paint_time_metrics = test_common(&display_list, epoch);
|
||||
let paint_time_metrics = test_common(true, epoch);
|
||||
let now = time::precise_time_ns();
|
||||
paint_time_metrics.maybe_set_metric(epoch, now);
|
||||
assert!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue