mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
compositor: Move WebRender-ish messages and types to webrender_traits
(#32315)
* Move WebRender related types to `webrender_traits` This refactor moves several WebRender related types from `compositing_traits`, `script_traits` and `net_traits` crates to the `webrender_traits` crate. This change also moves the `Image` type and associated function out of `net_traits` and into the `pixels` crate. Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com> * Move `script_traits::WebrenderIpcSender` to `webrender_traits::WebRenderScriptApi` --------- Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
c2076580f3
commit
2af6fe0b30
53 changed files with 666 additions and 617 deletions
|
@ -43,6 +43,7 @@ style_traits = { workspace = true }
|
|||
time = { workspace = true }
|
||||
webrender = { workspace = true }
|
||||
webrender_api = { workspace = true }
|
||||
webrender_traits = { workspace = true }
|
||||
webxr = { git = "https://github.com/servo/webxr" }
|
||||
|
||||
[build-dependencies]
|
||||
|
|
|
@ -13,10 +13,9 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
|||
|
||||
use base::id::{PipelineId, TopLevelBrowsingContextId, WebViewId};
|
||||
use base::{Epoch, WebRenderEpochToU16};
|
||||
use canvas::canvas_paint_thread::ImageUpdate;
|
||||
use compositing_traits::{
|
||||
CanvasToCompositorMsg, CompositionPipeline, CompositorMsg, CompositorReceiver,
|
||||
ConstellationMsg, FontToCompositorMsg, ForwardedToCompositorMsg, SendableFrameTree,
|
||||
CompositionPipeline, CompositorMsg, CompositorReceiver, ConstellationMsg,
|
||||
ForwardedToCompositorMsg, SendableFrameTree,
|
||||
};
|
||||
use crossbeam_channel::Sender;
|
||||
use embedder_traits::Cursor;
|
||||
|
@ -27,16 +26,13 @@ use image::{DynamicImage, ImageFormat};
|
|||
use ipc_channel::ipc;
|
||||
use libc::c_void;
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use net_traits::image::base::Image;
|
||||
use net_traits::image_cache::CorsStatus;
|
||||
use pixels::PixelFormat;
|
||||
use pixels::{CorsStatus, Image, PixelFormat};
|
||||
use profile_traits::time::{self as profile_time, profile, ProfilerCategory};
|
||||
use script_traits::compositor::{HitTestInfo, ScrollTree};
|
||||
use script_traits::CompositorEvent::{MouseButtonEvent, MouseMoveEvent, TouchEvent, WheelEvent};
|
||||
use script_traits::{
|
||||
AnimationState, AnimationTickType, CompositorHitTestResult, ConstellationControlMsg,
|
||||
LayoutControlMsg, MouseButton, MouseEventType, ScrollState, TouchEventType, TouchId,
|
||||
UntrustedNodeAddress, WheelDelta, WindowSizeData, WindowSizeType,
|
||||
AnimationState, AnimationTickType, ConstellationControlMsg, LayoutControlMsg, MouseButton,
|
||||
MouseEventType, ScrollState, TouchEventType, TouchId, WheelDelta, WindowSizeData,
|
||||
WindowSizeType,
|
||||
};
|
||||
use servo_geometry::{DeviceIndependentPixel, FramebufferUintLength};
|
||||
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
|
||||
|
@ -51,6 +47,11 @@ use webrender_api::{
|
|||
PropertyBinding, ReferenceFrameKind, RenderReasons, SampledScrollOffset, ScrollLocation,
|
||||
SpaceAndClipInfo, SpatialId, SpatialTreeItemKey, TransformStyle,
|
||||
};
|
||||
use webrender_traits::display_list::{HitTestInfo, ScrollTree};
|
||||
use webrender_traits::{
|
||||
CanvasToCompositorMsg, CompositorHitTestResult, FontToCompositorMsg, ImageUpdate,
|
||||
NetToCompositorMsg, ScriptToCompositorMsg, SerializedImageUpdate, UntrustedNodeAddress,
|
||||
};
|
||||
|
||||
use crate::gl::RenderTargetInfo;
|
||||
use crate::touch::{TouchAction, TouchHandler};
|
||||
|
@ -695,9 +696,9 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
/// instance in the parent process.
|
||||
fn handle_webrender_message(&mut self, msg: ForwardedToCompositorMsg) {
|
||||
match msg {
|
||||
ForwardedToCompositorMsg::Layout(
|
||||
script_traits::ScriptToCompositorMsg::SendInitialTransaction(pipeline),
|
||||
) => {
|
||||
ForwardedToCompositorMsg::Layout(ScriptToCompositorMsg::SendInitialTransaction(
|
||||
pipeline,
|
||||
)) => {
|
||||
let mut txn = Transaction::new();
|
||||
txn.set_display_list(WebRenderEpoch(0), (pipeline, Default::default()));
|
||||
self.generate_frame(&mut txn, RenderReasons::SCENE);
|
||||
|
@ -705,13 +706,11 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
.send_transaction(self.webrender_document, txn);
|
||||
},
|
||||
|
||||
ForwardedToCompositorMsg::Layout(
|
||||
script_traits::ScriptToCompositorMsg::SendScrollNode(
|
||||
pipeline_id,
|
||||
point,
|
||||
external_scroll_id,
|
||||
),
|
||||
) => {
|
||||
ForwardedToCompositorMsg::Layout(ScriptToCompositorMsg::SendScrollNode(
|
||||
pipeline_id,
|
||||
point,
|
||||
external_scroll_id,
|
||||
)) => {
|
||||
let pipeline_id = pipeline_id.into();
|
||||
let pipeline_details = match self.pipeline_details.get_mut(&pipeline_id) {
|
||||
Some(details) => details,
|
||||
|
@ -743,13 +742,11 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
.send_transaction(self.webrender_document, txn);
|
||||
},
|
||||
|
||||
ForwardedToCompositorMsg::Layout(
|
||||
script_traits::ScriptToCompositorMsg::SendDisplayList {
|
||||
display_list_info,
|
||||
display_list_descriptor,
|
||||
display_list_receiver,
|
||||
},
|
||||
) => {
|
||||
ForwardedToCompositorMsg::Layout(ScriptToCompositorMsg::SendDisplayList {
|
||||
display_list_info,
|
||||
display_list_descriptor,
|
||||
display_list_receiver,
|
||||
}) => {
|
||||
// This must match the order from the sender, currently in `shared/script/lib.rs`.
|
||||
let items_data = match display_list_receiver.recv() {
|
||||
Ok(display_list_data) => display_list_data,
|
||||
|
@ -799,7 +796,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
.send_transaction(self.webrender_document, transaction);
|
||||
},
|
||||
|
||||
ForwardedToCompositorMsg::Layout(script_traits::ScriptToCompositorMsg::HitTest(
|
||||
ForwardedToCompositorMsg::Layout(ScriptToCompositorMsg::HitTest(
|
||||
pipeline,
|
||||
point,
|
||||
flags,
|
||||
|
@ -821,31 +818,23 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
let _ = sender.send(result);
|
||||
},
|
||||
|
||||
ForwardedToCompositorMsg::Layout(
|
||||
script_traits::ScriptToCompositorMsg::GenerateImageKey(sender),
|
||||
) |
|
||||
ForwardedToCompositorMsg::Net(net_traits::NetToCompositorMsg::GenerateImageKey(
|
||||
sender,
|
||||
)) => {
|
||||
ForwardedToCompositorMsg::Layout(ScriptToCompositorMsg::GenerateImageKey(sender)) |
|
||||
ForwardedToCompositorMsg::Net(NetToCompositorMsg::GenerateImageKey(sender)) => {
|
||||
let _ = sender.send(self.webrender_api.generate_image_key());
|
||||
},
|
||||
|
||||
ForwardedToCompositorMsg::Layout(
|
||||
script_traits::ScriptToCompositorMsg::UpdateImages(updates),
|
||||
) => {
|
||||
ForwardedToCompositorMsg::Layout(ScriptToCompositorMsg::UpdateImages(updates)) => {
|
||||
let mut txn = Transaction::new();
|
||||
for update in updates {
|
||||
match update {
|
||||
script_traits::SerializedImageUpdate::AddImage(key, desc, data) => {
|
||||
SerializedImageUpdate::AddImage(key, desc, data) => {
|
||||
match data.to_image_data() {
|
||||
Ok(data) => txn.add_image(key, desc, data, None),
|
||||
Err(e) => warn!("error when sending image data: {:?}", e),
|
||||
}
|
||||
},
|
||||
script_traits::SerializedImageUpdate::DeleteImage(key) => {
|
||||
txn.delete_image(key)
|
||||
},
|
||||
script_traits::SerializedImageUpdate::UpdateImage(key, desc, data) => {
|
||||
SerializedImageUpdate::DeleteImage(key) => txn.delete_image(key),
|
||||
SerializedImageUpdate::UpdateImage(key, desc, data) => {
|
||||
match data.to_image_data() {
|
||||
Ok(data) => txn.update_image(key, desc, data, &DirtyRect::All),
|
||||
Err(e) => warn!("error when sending image data: {:?}", e),
|
||||
|
@ -857,11 +846,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
.send_transaction(self.webrender_document, txn);
|
||||
},
|
||||
|
||||
ForwardedToCompositorMsg::Net(net_traits::NetToCompositorMsg::AddImage(
|
||||
key,
|
||||
desc,
|
||||
data,
|
||||
)) => {
|
||||
ForwardedToCompositorMsg::Net(NetToCompositorMsg::AddImage(key, desc, data)) => {
|
||||
let mut txn = Transaction::new();
|
||||
txn.add_image(key, desc, data, None);
|
||||
self.webrender_api
|
||||
|
@ -929,13 +914,13 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
let mut txn = Transaction::new();
|
||||
for update in updates {
|
||||
match update {
|
||||
ImageUpdate::Add(key, descriptor, data) => {
|
||||
ImageUpdate::AddImage(key, descriptor, data) => {
|
||||
txn.add_image(key, descriptor, data, None)
|
||||
},
|
||||
ImageUpdate::Update(key, descriptor, data) => {
|
||||
ImageUpdate::UpdateImage(key, descriptor, data) => {
|
||||
txn.update_image(key, descriptor, data, &DirtyRect::All)
|
||||
},
|
||||
ImageUpdate::Delete(key) => txn.delete_image(key),
|
||||
ImageUpdate::DeleteImage(key) => txn.delete_image(key),
|
||||
}
|
||||
}
|
||||
self.webrender_api
|
||||
|
@ -1469,7 +1454,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
event_type,
|
||||
button,
|
||||
result.point_in_viewport.to_untyped(),
|
||||
Some(result.node),
|
||||
Some(result.node.into()),
|
||||
Some(result.point_relative_to_item),
|
||||
button as u16,
|
||||
);
|
||||
|
@ -1549,7 +1534,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
None => return,
|
||||
};
|
||||
|
||||
let event = MouseMoveEvent(result.point_in_viewport, Some(result.node), 0);
|
||||
let event = MouseMoveEvent(result.point_in_viewport, Some(result.node.into()), 0);
|
||||
let msg = ConstellationMsg::ForwardEvent(result.pipeline_id, event);
|
||||
if let Err(e) = self.constellation_chan.send(msg) {
|
||||
warn!("Sending event to constellation failed ({:?}).", e);
|
||||
|
@ -1568,7 +1553,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
event_type,
|
||||
identifier,
|
||||
result.point_in_viewport,
|
||||
Some(result.node),
|
||||
Some(result.node.into()),
|
||||
);
|
||||
let msg = ConstellationMsg::ForwardEvent(result.pipeline_id, event);
|
||||
if let Err(e) = self.constellation_chan.send(msg) {
|
||||
|
@ -1579,7 +1564,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
|
||||
pub fn send_wheel_event(&mut self, delta: WheelDelta, point: DevicePoint) {
|
||||
if let Some(result) = self.hit_test_at_point(point) {
|
||||
let event = WheelEvent(delta, result.point_in_viewport, Some(result.node));
|
||||
let event = WheelEvent(delta, result.point_in_viewport, Some(result.node.into()));
|
||||
let msg = ConstellationMsg::ForwardEvent(result.pipeline_id, event);
|
||||
if let Err(e) = self.constellation_chan.send(msg) {
|
||||
warn!("Sending event to constellation failed ({:?}).", e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue