diff options
Diffstat (limited to 'components/layout_thread_2020/lib.rs')
-rw-r--r-- | components/layout_thread_2020/lib.rs | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs index e8fdb1cfccd..3e94c535775 100644 --- a/components/layout_thread_2020/lib.rs +++ b/components/layout_thread_2020/lib.rs @@ -64,9 +64,9 @@ use script_layout_interface::message::{LayoutThreadInit, Msg, NodesFromPointQuer use script_layout_interface::message::{QueryMsg, ReflowComplete, ReflowGoal, ScriptReflow}; use script_layout_interface::rpc::TextIndexResponse; use script_layout_interface::rpc::{LayoutRPC, OffsetParentResponse, StyleResponse}; -use script_traits::Painter; use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg}; use script_traits::{DrawAPaintImageResult, PaintWorkletError}; +use script_traits::{Painter, WebrenderIpcSender}; use script_traits::{ScrollState, UntrustedNodeAddress, WindowSizeData}; use selectors::Element; use servo_arc::Arc as ServoArc; @@ -193,7 +193,7 @@ pub struct LayoutThread { registered_painters: RegisteredPaintersImpl, /// Webrender interface. - webrender_api: webrender_api::RenderApi, + webrender_api: WebrenderIpcSender, /// Webrender document. webrender_document: webrender_api::DocumentId, @@ -233,7 +233,7 @@ impl LayoutThreadFactory for LayoutThread { font_cache_thread: FontCacheThread, time_profiler_chan: profile_time::ProfilerChan, mem_profiler_chan: profile_mem::ProfilerChan, - webrender_api_sender: webrender_api::RenderApiSender, + webrender_api_sender: WebrenderIpcSender, webrender_document: webrender_api::DocumentId, paint_time_metrics: PaintTimeMetrics, busy: Arc<AtomicBool>, @@ -442,7 +442,7 @@ impl LayoutThread { font_cache_thread: FontCacheThread, time_profiler_chan: profile_time::ProfilerChan, mem_profiler_chan: profile_mem::ProfilerChan, - webrender_api_sender: webrender_api::RenderApiSender, + webrender_api_sender: WebrenderIpcSender, webrender_document: webrender_api::DocumentId, paint_time_metrics: PaintTimeMetrics, busy: Arc<AtomicBool>, @@ -451,18 +451,7 @@ impl LayoutThread { relayout_event: bool, ) -> LayoutThread { // Let webrender know about this pipeline by sending an empty display list. - let mut epoch = Epoch(0); - let webrender_api = webrender_api_sender.create_api(); - let mut txn = webrender_api::Transaction::new(); - txn.set_display_list( - webrender_api::Epoch(epoch.0), - None, - Default::default(), - (id.to_webrender(), Default::default(), Default::default()), - false, - ); - webrender_api.send_transaction(webrender_document, txn); - epoch.next(); + webrender_api_sender.send_initial_transaction(webrender_document, id.to_webrender()); // The device pixel ratio is incorrect (it does not have the hidpi value), // but it will be set correctly when the initial reflow takes place. @@ -506,9 +495,10 @@ impl LayoutThread { box_tree_root: Default::default(), fragment_tree_root: Default::default(), document_shared_lock: None, - epoch: Cell::new(Epoch(0)), + // Epoch starts at 1 because of the initial display list for epoch 0 that we send to WR + epoch: Cell::new(Epoch(1)), viewport_size: Size2D::new(Au(0), Au(0)), - webrender_api: webrender_api_sender.create_api(), + webrender_api: webrender_api_sender, webrender_document, stylist: Stylist::new(device, QuirksMode::NoQuirks), rw_data: Arc::new(Mutex::new(LayoutThreadData { @@ -719,14 +709,12 @@ impl LayoutThread { .insert(state.scroll_id, state.scroll_offset); let point = Point2D::new(-state.scroll_offset.x, -state.scroll_offset.y); - let mut txn = webrender_api::Transaction::new(); - txn.scroll_node_with_id( + self.webrender_api.send_scroll_node( + self.webrender_document, webrender_api::units::LayoutPoint::from_untyped(point), state.scroll_id, webrender_api::ScrollClamping::ToContentBounds, ); - self.webrender_api - .send_transaction(self.webrender_document, txn); }, Msg::ReapStyleAndLayoutData(dead_data) => unsafe { drop_style_and_layout_data(dead_data) @@ -816,7 +804,7 @@ impl LayoutThread { self.font_cache_thread.clone(), self.time_profiler_chan.clone(), self.mem_profiler_chan.clone(), - self.webrender_api.clone_sender(), + self.webrender_api.clone(), self.webrender_document, info.paint_time_metrics, info.layout_is_busy, @@ -1308,17 +1296,12 @@ impl LayoutThread { self.paint_time_metrics .maybe_observe_paint_time(self, epoch, is_contentful.0); - let mut txn = webrender_api::Transaction::new(); - txn.set_display_list( - webrender_api::Epoch(epoch.0), - None, + self.webrender_api.send_display_list( + self.webrender_document, + epoch, viewport_size, display_list.wr.finalize(), - true, ); - txn.generate_frame(); - self.webrender_api - .send_transaction(self.webrender_document, txn); self.generation.set(self.generation.get() + 1); } |