mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Clean up and document the send_display_list
interface
This moves more members to the CompositorDisplayListInfo struct, which now holds all miscellaneous, non-WebRender data when sending display lists. It also documents what each things sent with a display list does.
This commit is contained in:
parent
0377a1853a
commit
4d3625ec80
8 changed files with 85 additions and 79 deletions
|
@ -7,7 +7,7 @@
|
|||
use embedder_traits::Cursor;
|
||||
use webrender_api::{
|
||||
units::{LayoutSize, LayoutVector2D},
|
||||
ExternalScrollId, ScrollLocation, ScrollSensitivity, SpatialId,
|
||||
Epoch, ExternalScrollId, PipelineId, ScrollLocation, ScrollSensitivity, SpatialId,
|
||||
};
|
||||
|
||||
/// Information that Servo keeps alongside WebRender display items
|
||||
|
@ -213,6 +213,15 @@ impl ScrollTree {
|
|||
/// display lists sent to the compositor.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct CompositorDisplayListInfo {
|
||||
/// The WebRender [PipelineId] of this display list.
|
||||
pub pipeline_id: PipelineId,
|
||||
|
||||
/// The size of the viewport that this display list renders into.
|
||||
pub viewport_size: LayoutSize,
|
||||
|
||||
/// The epoch of the display list.
|
||||
pub epoch: Epoch,
|
||||
|
||||
/// An array of `HitTestInfo` which is used to store information
|
||||
/// to assist the compositor to take various actions (set the cursor,
|
||||
/// scroll without layout) using a WebRender hit test result.
|
||||
|
@ -237,7 +246,8 @@ impl CompositorDisplayListInfo {
|
|||
pub fn new(
|
||||
viewport_size: LayoutSize,
|
||||
content_size: LayoutSize,
|
||||
pipeline_id: webrender_api::PipelineId,
|
||||
pipeline_id: PipelineId,
|
||||
epoch: Epoch,
|
||||
) -> Self {
|
||||
let mut scroll_tree = ScrollTree::default();
|
||||
let root_reference_frame_id = scroll_tree.add_scroll_tree_node(
|
||||
|
@ -257,6 +267,9 @@ impl CompositorDisplayListInfo {
|
|||
);
|
||||
|
||||
CompositorDisplayListInfo {
|
||||
pipeline_id,
|
||||
viewport_size,
|
||||
epoch,
|
||||
hit_test_info: Default::default(),
|
||||
scroll_tree,
|
||||
root_reference_frame_id,
|
||||
|
|
|
@ -1132,15 +1132,16 @@ pub enum WebrenderMsg {
|
|||
/// Perform a scroll operation.
|
||||
SendScrollNode(LayoutPoint, ExternalScrollId, ScrollClamping),
|
||||
/// Inform WebRender of a new display list for the given pipeline.
|
||||
SendDisplayList(
|
||||
webrender_api::Epoch,
|
||||
LayoutSize,
|
||||
webrender_api::PipelineId,
|
||||
LayoutSize,
|
||||
ipc::IpcBytesReceiver,
|
||||
BuiltDisplayListDescriptor,
|
||||
CompositorDisplayListInfo,
|
||||
),
|
||||
SendDisplayList {
|
||||
/// The [CompositorDisplayListInfo] that describes the display list being sent.
|
||||
display_list_info: CompositorDisplayListInfo,
|
||||
/// The content size of this display list as calculated by WebRender.
|
||||
content_size: LayoutSize,
|
||||
/// A descriptor of this display list used to construct this display list from raw data.
|
||||
display_list_descriptor: BuiltDisplayListDescriptor,
|
||||
/// An [ipc::IpcBytesReceiver] used to send the raw data of the display list.
|
||||
display_list_receiver: ipc::IpcBytesReceiver,
|
||||
},
|
||||
/// Perform a hit test operation. The result will be returned via
|
||||
/// the provided channel sender.
|
||||
HitTest(
|
||||
|
@ -1191,26 +1192,21 @@ impl WebrenderIpcSender {
|
|||
/// Inform WebRender of a new display list for the given pipeline.
|
||||
pub fn send_display_list(
|
||||
&self,
|
||||
epoch: Epoch,
|
||||
size: LayoutSize,
|
||||
display_list_info: CompositorDisplayListInfo,
|
||||
(pipeline, size2, list): (webrender_api::PipelineId, LayoutSize, BuiltDisplayList),
|
||||
(_, content_size, list): (webrender_api::PipelineId, LayoutSize, BuiltDisplayList),
|
||||
) {
|
||||
let (data, descriptor) = list.into_data();
|
||||
let (sender, receiver) = ipc::bytes_channel().unwrap();
|
||||
if let Err(e) = self.0.send(WebrenderMsg::SendDisplayList(
|
||||
webrender_api::Epoch(epoch.0),
|
||||
size,
|
||||
pipeline,
|
||||
size2,
|
||||
receiver,
|
||||
descriptor,
|
||||
let (display_list_data, display_list_descriptor) = list.into_data();
|
||||
let (display_list_sender, display_list_receiver) = ipc::bytes_channel().unwrap();
|
||||
if let Err(e) = self.0.send(WebrenderMsg::SendDisplayList {
|
||||
display_list_info,
|
||||
)) {
|
||||
content_size,
|
||||
display_list_descriptor,
|
||||
display_list_receiver,
|
||||
}) {
|
||||
warn!("Error sending display list: {}", e);
|
||||
}
|
||||
|
||||
if let Err(e) = sender.send(&data) {
|
||||
if let Err(e) = display_list_sender.send(&display_list_data) {
|
||||
warn!("Error sending display data: {}", e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue