mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
[NFC] compositing: extract types into new compositing_traits crate (#30125)
* [NFC] compositing: extract types into new compositing_traits crate * [NFC] compositing: move InitialCompositorState back to compositing * [NFC] compositing: rename Msg to CompositorMsg * [NFC] compositing: revert changes to Cargo.toml features section * [NFC] compositing: merge imports
This commit is contained in:
parent
0e7c958bd5
commit
b256a72448
16 changed files with 358 additions and 286 deletions
28
Cargo.lock
generated
28
Cargo.lock
generated
|
@ -915,6 +915,7 @@ name = "compositing"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"canvas",
|
||||
"compositing_traits",
|
||||
"crossbeam-channel",
|
||||
"embedder_traits",
|
||||
"euclid",
|
||||
|
@ -944,6 +945,28 @@ dependencies = [
|
|||
"webxr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "compositing_traits"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"canvas",
|
||||
"crossbeam-channel",
|
||||
"embedder_traits",
|
||||
"euclid",
|
||||
"gfx_traits",
|
||||
"ipc-channel",
|
||||
"keyboard-types",
|
||||
"log",
|
||||
"msg",
|
||||
"net_traits",
|
||||
"profile_traits",
|
||||
"script_traits",
|
||||
"servo_url",
|
||||
"style_traits",
|
||||
"webrender_api",
|
||||
"webrender_surfman",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "const-cstr"
|
||||
version = "0.3.0"
|
||||
|
@ -958,7 +981,7 @@ dependencies = [
|
|||
"backtrace",
|
||||
"bluetooth_traits",
|
||||
"canvas_traits",
|
||||
"compositing",
|
||||
"compositing_traits",
|
||||
"crossbeam-channel",
|
||||
"devtools_traits",
|
||||
"embedder_traits",
|
||||
|
@ -3437,6 +3460,7 @@ dependencies = [
|
|||
"canvas",
|
||||
"canvas_traits",
|
||||
"compositing",
|
||||
"compositing_traits",
|
||||
"constellation",
|
||||
"crossbeam-channel",
|
||||
"devtools",
|
||||
|
@ -7099,7 +7123,7 @@ name = "webdriver_server"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"base64 0.21.2",
|
||||
"compositing",
|
||||
"compositing_traits",
|
||||
"cookie 0.12.0",
|
||||
"crossbeam-channel",
|
||||
"euclid",
|
||||
|
|
|
@ -17,6 +17,7 @@ gl = ["gleam", "pixels"]
|
|||
|
||||
[dependencies]
|
||||
canvas = { path = "../canvas" }
|
||||
compositing_traits = { path = "../compositing_traits" }
|
||||
crossbeam-channel = { workspace = true }
|
||||
embedder_traits = { path = "../embedder_traits" }
|
||||
euclid = { workspace = true }
|
||||
|
|
|
@ -2,18 +2,18 @@
|
|||
* 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::compositor_thread::CompositorReceiver;
|
||||
use crate::compositor_thread::{
|
||||
InitialCompositorState, Msg, WebrenderCanvasMsg, WebrenderFontMsg, WebrenderMsg,
|
||||
};
|
||||
#[cfg(feature = "gl")]
|
||||
use crate::gl;
|
||||
use crate::touch::{TouchAction, TouchHandler};
|
||||
use crate::windowing::{
|
||||
self, EmbedderCoordinates, MouseWindowEvent, WebRenderDebugOption, WindowMethods,
|
||||
};
|
||||
use crate::{CompositionPipeline, ConstellationMsg, SendableFrameTree};
|
||||
use crate::InitialCompositorState;
|
||||
use canvas::canvas_paint_thread::ImageUpdate;
|
||||
use compositing_traits::{
|
||||
CompositingReason, CompositionPipeline, CompositorMsg, CompositorReceiver, ConstellationMsg,
|
||||
SendableFrameTree, WebrenderCanvasMsg, WebrenderFontMsg, WebrenderMsg,
|
||||
};
|
||||
use crossbeam_channel::Sender;
|
||||
use embedder_traits::Cursor;
|
||||
use euclid::{Point2D, Rect, Scale, Vector2D};
|
||||
|
@ -475,40 +475,40 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
self.shutdown_state = ShutdownState::FinishedShuttingDown;
|
||||
}
|
||||
|
||||
fn handle_browser_message(&mut self, msg: Msg) -> bool {
|
||||
fn handle_browser_message(&mut self, msg: CompositorMsg) -> bool {
|
||||
match (msg, self.shutdown_state) {
|
||||
(_, ShutdownState::FinishedShuttingDown) => {
|
||||
error!("compositor shouldn't be handling messages after shutting down");
|
||||
return false;
|
||||
},
|
||||
|
||||
(Msg::ShutdownComplete, _) => {
|
||||
(CompositorMsg::ShutdownComplete, _) => {
|
||||
self.finish_shutting_down();
|
||||
return false;
|
||||
},
|
||||
|
||||
(
|
||||
Msg::ChangeRunningAnimationsState(pipeline_id, animation_state),
|
||||
CompositorMsg::ChangeRunningAnimationsState(pipeline_id, animation_state),
|
||||
ShutdownState::NotShuttingDown,
|
||||
) => {
|
||||
self.change_running_animations_state(pipeline_id, animation_state);
|
||||
},
|
||||
|
||||
(Msg::SetFrameTree(frame_tree), ShutdownState::NotShuttingDown) => {
|
||||
(CompositorMsg::SetFrameTree(frame_tree), ShutdownState::NotShuttingDown) => {
|
||||
self.set_frame_tree(&frame_tree);
|
||||
self.send_scroll_positions_to_layout_for_pipeline(&frame_tree.pipeline.id);
|
||||
},
|
||||
|
||||
(Msg::Recomposite(reason), ShutdownState::NotShuttingDown) => {
|
||||
(CompositorMsg::Recomposite(reason), ShutdownState::NotShuttingDown) => {
|
||||
self.waiting_on_pending_frame = false;
|
||||
self.composition_request = CompositionRequest::CompositeNow(reason)
|
||||
},
|
||||
|
||||
(Msg::TouchEventProcessed(result), ShutdownState::NotShuttingDown) => {
|
||||
(CompositorMsg::TouchEventProcessed(result), ShutdownState::NotShuttingDown) => {
|
||||
self.touch_handler.on_event_processed(result);
|
||||
},
|
||||
|
||||
(Msg::CreatePng(rect, reply), ShutdownState::NotShuttingDown) => {
|
||||
(CompositorMsg::CreatePng(rect, reply), ShutdownState::NotShuttingDown) => {
|
||||
let res = self.composite_specific_target(CompositeTarget::WindowAndPng, rect);
|
||||
if let Err(ref e) = res {
|
||||
info!("Error retrieving PNG: {:?}", e);
|
||||
|
@ -519,7 +519,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
}
|
||||
},
|
||||
|
||||
(Msg::IsReadyToSaveImageReply(is_ready), ShutdownState::NotShuttingDown) => {
|
||||
(CompositorMsg::IsReadyToSaveImageReply(is_ready), ShutdownState::NotShuttingDown) => {
|
||||
assert_eq!(
|
||||
self.ready_to_save_state,
|
||||
ReadyState::WaitingForConstellationReply
|
||||
|
@ -540,20 +540,23 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
},
|
||||
|
||||
(
|
||||
Msg::PipelineVisibilityChanged(pipeline_id, visible),
|
||||
CompositorMsg::PipelineVisibilityChanged(pipeline_id, visible),
|
||||
ShutdownState::NotShuttingDown,
|
||||
) => {
|
||||
self.pipeline_details(pipeline_id).visible = visible;
|
||||
self.process_animations();
|
||||
},
|
||||
|
||||
(Msg::PipelineExited(pipeline_id, sender), _) => {
|
||||
(CompositorMsg::PipelineExited(pipeline_id, sender), _) => {
|
||||
debug!("Compositor got pipeline exited: {:?}", pipeline_id);
|
||||
self.remove_pipeline_root_layer(pipeline_id);
|
||||
let _ = sender.send(());
|
||||
},
|
||||
|
||||
(Msg::NewScrollFrameReady(recomposite_needed), ShutdownState::NotShuttingDown) => {
|
||||
(
|
||||
CompositorMsg::NewScrollFrameReady(recomposite_needed),
|
||||
ShutdownState::NotShuttingDown,
|
||||
) => {
|
||||
self.waiting_for_results_of_scroll = false;
|
||||
if let Some(result) = self.hit_test_at_device_point(self.cursor_pos) {
|
||||
self.update_cursor(result);
|
||||
|
@ -565,13 +568,13 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
}
|
||||
},
|
||||
|
||||
(Msg::Dispatch(func), ShutdownState::NotShuttingDown) => {
|
||||
(CompositorMsg::Dispatch(func), ShutdownState::NotShuttingDown) => {
|
||||
// The functions sent here right now are really dumb, so they can't panic.
|
||||
// But if we start running more complex code here, we should really catch panic here.
|
||||
func();
|
||||
},
|
||||
|
||||
(Msg::LoadComplete(_), ShutdownState::NotShuttingDown) => {
|
||||
(CompositorMsg::LoadComplete(_), ShutdownState::NotShuttingDown) => {
|
||||
// If we're painting in headless mode, schedule a recomposite.
|
||||
if self.output_file.is_some() || self.exit_after_load {
|
||||
self.composite_if_necessary(CompositingReason::Headless);
|
||||
|
@ -579,7 +582,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
},
|
||||
|
||||
(
|
||||
Msg::WebDriverMouseButtonEvent(mouse_event_type, mouse_button, x, y),
|
||||
CompositorMsg::WebDriverMouseButtonEvent(mouse_event_type, mouse_button, x, y),
|
||||
ShutdownState::NotShuttingDown,
|
||||
) => {
|
||||
let dppx = self.device_pixels_per_page_px();
|
||||
|
@ -591,29 +594,29 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
});
|
||||
},
|
||||
|
||||
(Msg::WebDriverMouseMoveEvent(x, y), ShutdownState::NotShuttingDown) => {
|
||||
(CompositorMsg::WebDriverMouseMoveEvent(x, y), ShutdownState::NotShuttingDown) => {
|
||||
let dppx = self.device_pixels_per_page_px();
|
||||
let point = dppx.transform_point(Point2D::new(x, y));
|
||||
self.on_mouse_window_move_event_class(DevicePoint::new(point.x, point.y));
|
||||
},
|
||||
|
||||
(Msg::PendingPaintMetric(pipeline_id, epoch), _) => {
|
||||
(CompositorMsg::PendingPaintMetric(pipeline_id, epoch), _) => {
|
||||
self.pending_paint_metrics.insert(pipeline_id, epoch);
|
||||
},
|
||||
|
||||
(Msg::GetClientWindow(req), ShutdownState::NotShuttingDown) => {
|
||||
(CompositorMsg::GetClientWindow(req), ShutdownState::NotShuttingDown) => {
|
||||
if let Err(e) = req.send(self.embedder_coordinates.window) {
|
||||
warn!("Sending response to get client window failed ({:?}).", e);
|
||||
}
|
||||
},
|
||||
|
||||
(Msg::GetScreenSize(req), ShutdownState::NotShuttingDown) => {
|
||||
(CompositorMsg::GetScreenSize(req), ShutdownState::NotShuttingDown) => {
|
||||
if let Err(e) = req.send(self.embedder_coordinates.screen) {
|
||||
warn!("Sending response to get screen size failed ({:?}).", e);
|
||||
}
|
||||
},
|
||||
|
||||
(Msg::GetScreenAvailSize(req), ShutdownState::NotShuttingDown) => {
|
||||
(CompositorMsg::GetScreenAvailSize(req), ShutdownState::NotShuttingDown) => {
|
||||
if let Err(e) = req.send(self.embedder_coordinates.screen_avail) {
|
||||
warn!(
|
||||
"Sending response to get screen avail size failed ({:?}).",
|
||||
|
@ -622,7 +625,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
}
|
||||
},
|
||||
|
||||
(Msg::Webrender(msg), ShutdownState::NotShuttingDown) => {
|
||||
(CompositorMsg::Webrender(msg), ShutdownState::NotShuttingDown) => {
|
||||
self.handle_webrender_message(msg);
|
||||
},
|
||||
|
||||
|
@ -1807,8 +1810,8 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
let mut found_recomposite_msg = false;
|
||||
while let Some(msg) = self.port.try_recv_compositor_msg() {
|
||||
match msg {
|
||||
Msg::Recomposite(_) if found_recomposite_msg => {},
|
||||
Msg::Recomposite(_) => {
|
||||
CompositorMsg::Recomposite(_) if found_recomposite_msg => {},
|
||||
CompositorMsg::Recomposite(_) => {
|
||||
found_recomposite_msg = true;
|
||||
compositor_messages.push(msg)
|
||||
},
|
||||
|
@ -1858,7 +1861,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
while self.shutdown_state != ShutdownState::ShuttingDown {
|
||||
let msg = self.port.recv_compositor_msg();
|
||||
let need_recomposite = match msg {
|
||||
Msg::Recomposite(_) => true,
|
||||
CompositorMsg::Recomposite(_) => true,
|
||||
_ => false,
|
||||
};
|
||||
let keep_going = self.handle_browser_message(msg);
|
||||
|
@ -1955,30 +1958,3 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
|||
self.external_present = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// Why we performed a composite. This is used for debugging.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum CompositingReason {
|
||||
/// We hit the delayed composition timeout. (See `delayed_composition.rs`.)
|
||||
DelayedCompositeTimeout,
|
||||
/// The window has been scrolled and we're starting the first recomposite.
|
||||
Scroll,
|
||||
/// A scroll has continued and we need to recomposite again.
|
||||
ContinueScroll,
|
||||
/// We're performing the single composite in headless mode.
|
||||
Headless,
|
||||
/// We're performing a composite to run an animation.
|
||||
Animation,
|
||||
/// A new frame tree has been loaded.
|
||||
NewFrameTree,
|
||||
/// New painted buffers have been received.
|
||||
NewPaintedBuffers,
|
||||
/// The window has been zoomed.
|
||||
Zoom,
|
||||
/// A new WebRender frame has arrived.
|
||||
NewWebRenderFrame,
|
||||
/// WebRender has processed a scroll event and has generated a new frame.
|
||||
NewWebRenderScrollFrame,
|
||||
/// The window has been resized and will need to be synchronously repainted.
|
||||
Resize,
|
||||
}
|
||||
|
|
|
@ -7,145 +7,41 @@
|
|||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
pub use crate::compositor::CompositingReason;
|
||||
pub use crate::compositor::IOCompositor;
|
||||
pub use crate::compositor::ShutdownState;
|
||||
pub use crate::compositor_thread::CompositorProxy;
|
||||
use embedder_traits::Cursor;
|
||||
use gfx_traits::Epoch;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use keyboard_types::KeyboardEvent;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use msg::constellation_msg::TopLevelBrowsingContextId;
|
||||
use msg::constellation_msg::{BrowsingContextId, TraversalDirection};
|
||||
use script_traits::{
|
||||
AnimationTickType, LogEntry, WebDriverCommandMsg, WindowSizeData, WindowSizeType,
|
||||
};
|
||||
use script_traits::{
|
||||
CompositorEvent, ConstellationControlMsg, LayoutControlMsg, MediaSessionActionType,
|
||||
};
|
||||
use servo_url::ServoUrl;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::time::Duration;
|
||||
|
||||
use compositing_traits::{CompositorProxy, CompositorReceiver, ConstellationMsg};
|
||||
use crossbeam_channel::Sender;
|
||||
use profile_traits::mem;
|
||||
use profile_traits::time;
|
||||
use std::rc::Rc;
|
||||
use webrender_api::DocumentId;
|
||||
use webrender_api::RenderApi;
|
||||
use webrender_surfman::WebrenderSurfman;
|
||||
|
||||
mod compositor;
|
||||
pub mod compositor_thread;
|
||||
#[cfg(feature = "gl")]
|
||||
mod gl;
|
||||
mod touch;
|
||||
pub mod windowing;
|
||||
|
||||
pub struct SendableFrameTree {
|
||||
pub pipeline: CompositionPipeline,
|
||||
pub children: Vec<SendableFrameTree>,
|
||||
}
|
||||
|
||||
/// The subset of the pipeline that is needed for layer composition.
|
||||
#[derive(Clone)]
|
||||
pub struct CompositionPipeline {
|
||||
pub id: PipelineId,
|
||||
pub top_level_browsing_context_id: TopLevelBrowsingContextId,
|
||||
pub script_chan: IpcSender<ConstellationControlMsg>,
|
||||
pub layout_chan: IpcSender<LayoutControlMsg>,
|
||||
}
|
||||
|
||||
/// Messages to the constellation.
|
||||
pub enum ConstellationMsg {
|
||||
/// Exit the constellation.
|
||||
Exit,
|
||||
/// Request that the constellation send the BrowsingContextId corresponding to the document
|
||||
/// with the provided pipeline id
|
||||
GetBrowsingContext(PipelineId, IpcSender<Option<BrowsingContextId>>),
|
||||
/// Request that the constellation send the current pipeline id for the provided
|
||||
/// browsing context id, over a provided channel.
|
||||
GetPipeline(BrowsingContextId, IpcSender<Option<PipelineId>>),
|
||||
/// Request that the constellation send the current focused top-level browsing context id,
|
||||
/// over a provided channel.
|
||||
GetFocusTopLevelBrowsingContext(IpcSender<Option<TopLevelBrowsingContextId>>),
|
||||
/// Query the constellation to see if the current compositor output is stable
|
||||
IsReadyToSaveImage(HashMap<PipelineId, Epoch>),
|
||||
/// Inform the constellation of a key event.
|
||||
Keyboard(KeyboardEvent),
|
||||
/// Whether to allow script to navigate.
|
||||
AllowNavigationResponse(PipelineId, bool),
|
||||
/// Request to load a page.
|
||||
LoadUrl(TopLevelBrowsingContextId, ServoUrl),
|
||||
/// Clear the network cache.
|
||||
ClearCache,
|
||||
/// Request to traverse the joint session history of the provided browsing context.
|
||||
TraverseHistory(TopLevelBrowsingContextId, TraversalDirection),
|
||||
/// Inform the constellation of a window being resized.
|
||||
WindowSize(TopLevelBrowsingContextId, WindowSizeData, WindowSizeType),
|
||||
/// Requests that the constellation instruct layout to begin a new tick of the animation.
|
||||
TickAnimation(PipelineId, AnimationTickType),
|
||||
/// Dispatch a webdriver command
|
||||
WebDriverCommand(WebDriverCommandMsg),
|
||||
/// Reload a top-level browsing context.
|
||||
Reload(TopLevelBrowsingContextId),
|
||||
/// A log entry, with the top-level browsing context id and thread name
|
||||
LogEntry(Option<TopLevelBrowsingContextId>, Option<String>, LogEntry),
|
||||
/// Create a new top level browsing context.
|
||||
NewBrowser(ServoUrl, TopLevelBrowsingContextId),
|
||||
/// Close a top level browsing context.
|
||||
CloseBrowser(TopLevelBrowsingContextId),
|
||||
/// Panic a top level browsing context.
|
||||
SendError(Option<TopLevelBrowsingContextId>, String),
|
||||
/// Make browser visible.
|
||||
SelectBrowser(TopLevelBrowsingContextId),
|
||||
/// Forward an event to the script task of the given pipeline.
|
||||
ForwardEvent(PipelineId, CompositorEvent),
|
||||
/// Requesting a change to the onscreen cursor.
|
||||
SetCursor(Cursor),
|
||||
/// Enable the sampling profiler, with a given sampling rate and max total sampling duration.
|
||||
EnableProfiler(Duration, Duration),
|
||||
/// Disable the sampling profiler.
|
||||
DisableProfiler,
|
||||
/// Request to exit from fullscreen mode
|
||||
ExitFullScreen(TopLevelBrowsingContextId),
|
||||
/// Media session action.
|
||||
MediaSessionAction(MediaSessionActionType),
|
||||
/// Toggle browser visibility.
|
||||
ChangeBrowserVisibility(TopLevelBrowsingContextId, bool),
|
||||
/// Virtual keyboard was dismissed
|
||||
IMEDismissed,
|
||||
/// Compositing done, but external code needs to present.
|
||||
ReadyToPresent(TopLevelBrowsingContextId),
|
||||
}
|
||||
|
||||
impl fmt::Debug for ConstellationMsg {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
use self::ConstellationMsg::*;
|
||||
let variant = match *self {
|
||||
Exit => "Exit",
|
||||
GetBrowsingContext(..) => "GetBrowsingContext",
|
||||
GetPipeline(..) => "GetPipeline",
|
||||
GetFocusTopLevelBrowsingContext(..) => "GetFocusTopLevelBrowsingContext",
|
||||
IsReadyToSaveImage(..) => "IsReadyToSaveImage",
|
||||
Keyboard(..) => "Keyboard",
|
||||
AllowNavigationResponse(..) => "AllowNavigationResponse",
|
||||
LoadUrl(..) => "LoadUrl",
|
||||
TraverseHistory(..) => "TraverseHistory",
|
||||
WindowSize(..) => "WindowSize",
|
||||
TickAnimation(..) => "TickAnimation",
|
||||
WebDriverCommand(..) => "WebDriverCommand",
|
||||
Reload(..) => "Reload",
|
||||
LogEntry(..) => "LogEntry",
|
||||
NewBrowser(..) => "NewBrowser",
|
||||
CloseBrowser(..) => "CloseBrowser",
|
||||
SendError(..) => "SendError",
|
||||
SelectBrowser(..) => "SelectBrowser",
|
||||
ForwardEvent(..) => "ForwardEvent",
|
||||
SetCursor(..) => "SetCursor",
|
||||
EnableProfiler(..) => "EnableProfiler",
|
||||
DisableProfiler => "DisableProfiler",
|
||||
ExitFullScreen(..) => "ExitFullScreen",
|
||||
MediaSessionAction(..) => "MediaSessionAction",
|
||||
ChangeBrowserVisibility(..) => "ChangeBrowserVisibility",
|
||||
IMEDismissed => "IMEDismissed",
|
||||
ClearCache => "ClearCache",
|
||||
ReadyToPresent(..) => "ReadyToPresent",
|
||||
};
|
||||
write!(formatter, "ConstellationMsg::{}", variant)
|
||||
}
|
||||
/// Data used to construct a compositor.
|
||||
pub struct InitialCompositorState {
|
||||
/// A channel to the compositor.
|
||||
pub sender: CompositorProxy,
|
||||
/// A port on which messages inbound to the compositor can be received.
|
||||
pub receiver: CompositorReceiver,
|
||||
/// A channel to the constellation.
|
||||
pub constellation_chan: Sender<ConstellationMsg>,
|
||||
/// A channel to the time profiler thread.
|
||||
pub time_profiler_chan: time::ProfilerChan,
|
||||
/// A channel to the memory profiler thread.
|
||||
pub mem_profiler_chan: mem::ProfilerChan,
|
||||
/// Instance of webrender API
|
||||
pub webrender: webrender::Renderer,
|
||||
pub webrender_document: DocumentId,
|
||||
pub webrender_api: RenderApi,
|
||||
pub webrender_surfman: WebrenderSurfman,
|
||||
pub webrender_gl: Rc<dyn gleam::gl::Gl>,
|
||||
pub webxr_main_thread: webxr::MainThreadRegistry,
|
||||
}
|
||||
|
|
29
components/compositing_traits/Cargo.toml
Normal file
29
components/compositing_traits/Cargo.toml
Normal file
|
@ -0,0 +1,29 @@
|
|||
[package]
|
||||
name = "compositing_traits"
|
||||
version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
license = "MPL-2.0"
|
||||
edition = "2018"
|
||||
publish = false
|
||||
|
||||
[lib]
|
||||
name = "compositing_traits"
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
canvas = { path = "../canvas" }
|
||||
crossbeam-channel = { workspace = true }
|
||||
embedder_traits = { path = "../embedder_traits" }
|
||||
euclid = { workspace = true }
|
||||
gfx_traits = { path = "../gfx_traits" }
|
||||
ipc-channel = { workspace = true }
|
||||
keyboard-types = { workspace = true }
|
||||
log = { workspace = true }
|
||||
msg = { path = "../msg" }
|
||||
net_traits = { path = "../net_traits" }
|
||||
profile_traits = { path = "../profile_traits" }
|
||||
script_traits = { path = "../script_traits" }
|
||||
servo_url = { path = "../url" }
|
||||
style_traits = { path = "../style_traits" }
|
||||
webrender_api = { workspace = true }
|
||||
webrender_surfman = { path = "../webrender_surfman" }
|
122
components/compositing_traits/constellation_msg.rs
Normal file
122
components/compositing_traits/constellation_msg.rs
Normal file
|
@ -0,0 +1,122 @@
|
|||
/* 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 embedder_traits::Cursor;
|
||||
use gfx_traits::Epoch;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use keyboard_types::KeyboardEvent;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use msg::constellation_msg::TopLevelBrowsingContextId;
|
||||
use msg::constellation_msg::{BrowsingContextId, TraversalDirection};
|
||||
use script_traits::AnimationTickType;
|
||||
use script_traits::CompositorEvent;
|
||||
use script_traits::LogEntry;
|
||||
use script_traits::MediaSessionActionType;
|
||||
use script_traits::WebDriverCommandMsg;
|
||||
use script_traits::WindowSizeData;
|
||||
use script_traits::WindowSizeType;
|
||||
use servo_url::ServoUrl;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::time::Duration;
|
||||
|
||||
/// Messages to the constellation.
|
||||
pub enum ConstellationMsg {
|
||||
/// Exit the constellation.
|
||||
Exit,
|
||||
/// Request that the constellation send the BrowsingContextId corresponding to the document
|
||||
/// with the provided pipeline id
|
||||
GetBrowsingContext(PipelineId, IpcSender<Option<BrowsingContextId>>),
|
||||
/// Request that the constellation send the current pipeline id for the provided
|
||||
/// browsing context id, over a provided channel.
|
||||
GetPipeline(BrowsingContextId, IpcSender<Option<PipelineId>>),
|
||||
/// Request that the constellation send the current focused top-level browsing context id,
|
||||
/// over a provided channel.
|
||||
GetFocusTopLevelBrowsingContext(IpcSender<Option<TopLevelBrowsingContextId>>),
|
||||
/// Query the constellation to see if the current compositor output is stable
|
||||
IsReadyToSaveImage(HashMap<PipelineId, Epoch>),
|
||||
/// Inform the constellation of a key event.
|
||||
Keyboard(KeyboardEvent),
|
||||
/// Whether to allow script to navigate.
|
||||
AllowNavigationResponse(PipelineId, bool),
|
||||
/// Request to load a page.
|
||||
LoadUrl(TopLevelBrowsingContextId, ServoUrl),
|
||||
/// Clear the network cache.
|
||||
ClearCache,
|
||||
/// Request to traverse the joint session history of the provided browsing context.
|
||||
TraverseHistory(TopLevelBrowsingContextId, TraversalDirection),
|
||||
/// Inform the constellation of a window being resized.
|
||||
WindowSize(TopLevelBrowsingContextId, WindowSizeData, WindowSizeType),
|
||||
/// Requests that the constellation instruct layout to begin a new tick of the animation.
|
||||
TickAnimation(PipelineId, AnimationTickType),
|
||||
/// Dispatch a webdriver command
|
||||
WebDriverCommand(WebDriverCommandMsg),
|
||||
/// Reload a top-level browsing context.
|
||||
Reload(TopLevelBrowsingContextId),
|
||||
/// A log entry, with the top-level browsing context id and thread name
|
||||
LogEntry(Option<TopLevelBrowsingContextId>, Option<String>, LogEntry),
|
||||
/// Create a new top level browsing context.
|
||||
NewBrowser(ServoUrl, TopLevelBrowsingContextId),
|
||||
/// Close a top level browsing context.
|
||||
CloseBrowser(TopLevelBrowsingContextId),
|
||||
/// Panic a top level browsing context.
|
||||
SendError(Option<TopLevelBrowsingContextId>, String),
|
||||
/// Make browser visible.
|
||||
SelectBrowser(TopLevelBrowsingContextId),
|
||||
/// Forward an event to the script task of the given pipeline.
|
||||
ForwardEvent(PipelineId, CompositorEvent),
|
||||
/// Requesting a change to the onscreen cursor.
|
||||
SetCursor(Cursor),
|
||||
/// Enable the sampling profiler, with a given sampling rate and max total sampling duration.
|
||||
EnableProfiler(Duration, Duration),
|
||||
/// Disable the sampling profiler.
|
||||
DisableProfiler,
|
||||
/// Request to exit from fullscreen mode
|
||||
ExitFullScreen(TopLevelBrowsingContextId),
|
||||
/// Media session action.
|
||||
MediaSessionAction(MediaSessionActionType),
|
||||
/// Toggle browser visibility.
|
||||
ChangeBrowserVisibility(TopLevelBrowsingContextId, bool),
|
||||
/// Virtual keyboard was dismissed
|
||||
IMEDismissed,
|
||||
/// Compositing done, but external code needs to present.
|
||||
ReadyToPresent(TopLevelBrowsingContextId),
|
||||
}
|
||||
|
||||
impl fmt::Debug for ConstellationMsg {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
use self::ConstellationMsg::*;
|
||||
let variant = match *self {
|
||||
Exit => "Exit",
|
||||
GetBrowsingContext(..) => "GetBrowsingContext",
|
||||
GetPipeline(..) => "GetPipeline",
|
||||
GetFocusTopLevelBrowsingContext(..) => "GetFocusTopLevelBrowsingContext",
|
||||
IsReadyToSaveImage(..) => "IsReadyToSaveImage",
|
||||
Keyboard(..) => "Keyboard",
|
||||
AllowNavigationResponse(..) => "AllowNavigationResponse",
|
||||
LoadUrl(..) => "LoadUrl",
|
||||
TraverseHistory(..) => "TraverseHistory",
|
||||
WindowSize(..) => "WindowSize",
|
||||
TickAnimation(..) => "TickAnimation",
|
||||
WebDriverCommand(..) => "WebDriverCommand",
|
||||
Reload(..) => "Reload",
|
||||
LogEntry(..) => "LogEntry",
|
||||
NewBrowser(..) => "NewBrowser",
|
||||
CloseBrowser(..) => "CloseBrowser",
|
||||
SendError(..) => "SendError",
|
||||
SelectBrowser(..) => "SelectBrowser",
|
||||
ForwardEvent(..) => "ForwardEvent",
|
||||
SetCursor(..) => "SetCursor",
|
||||
EnableProfiler(..) => "EnableProfiler",
|
||||
DisableProfiler => "DisableProfiler",
|
||||
ExitFullScreen(..) => "ExitFullScreen",
|
||||
MediaSessionAction(..) => "MediaSessionAction",
|
||||
ChangeBrowserVisibility(..) => "ChangeBrowserVisibility",
|
||||
IMEDismissed => "IMEDismissed",
|
||||
ClearCache => "ClearCache",
|
||||
ReadyToPresent(..) => "ReadyToPresent",
|
||||
};
|
||||
write!(formatter, "ConstellationMsg::{}", variant)
|
||||
}
|
||||
}
|
|
@ -4,8 +4,13 @@
|
|||
|
||||
//! Communication with the compositor thread.
|
||||
|
||||
use crate::compositor::CompositingReason;
|
||||
use crate::{ConstellationMsg, SendableFrameTree};
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
mod constellation_msg;
|
||||
|
||||
pub use constellation_msg::ConstellationMsg;
|
||||
|
||||
use canvas::canvas_paint_thread::ImageUpdate;
|
||||
use crossbeam_channel::{Receiver, Sender};
|
||||
use embedder_traits::EventLoopWaker;
|
||||
|
@ -14,24 +19,50 @@ use gfx_traits::Epoch;
|
|||
use ipc_channel::ipc::IpcSender;
|
||||
use msg::constellation_msg::{PipelineId, TopLevelBrowsingContextId};
|
||||
use net_traits::image::base::Image;
|
||||
use profile_traits::mem;
|
||||
use profile_traits::time;
|
||||
use script_traits::{AnimationState, EventResult, MouseButton, MouseEventType};
|
||||
use script_traits::{
|
||||
AnimationState, ConstellationControlMsg, EventResult, LayoutControlMsg, MouseButton,
|
||||
MouseEventType,
|
||||
};
|
||||
use std::fmt::{Debug, Error, Formatter};
|
||||
use std::rc::Rc;
|
||||
use style_traits::CSSPixel;
|
||||
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};
|
||||
use webrender_api::{self, DocumentId, FontInstanceKey, FontKey, ImageKey, RenderApi};
|
||||
use webrender_surfman::WebrenderSurfman;
|
||||
use webrender_api::{self, FontInstanceKey, FontKey, ImageKey};
|
||||
|
||||
/// Why we performed a composite. This is used for debugging.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum CompositingReason {
|
||||
/// We hit the delayed composition timeout. (See `delayed_composition.rs`.)
|
||||
DelayedCompositeTimeout,
|
||||
/// The window has been scrolled and we're starting the first recomposite.
|
||||
Scroll,
|
||||
/// A scroll has continued and we need to recomposite again.
|
||||
ContinueScroll,
|
||||
/// We're performing the single composite in headless mode.
|
||||
Headless,
|
||||
/// We're performing a composite to run an animation.
|
||||
Animation,
|
||||
/// A new frame tree has been loaded.
|
||||
NewFrameTree,
|
||||
/// New painted buffers have been received.
|
||||
NewPaintedBuffers,
|
||||
/// The window has been zoomed.
|
||||
Zoom,
|
||||
/// A new WebRender frame has arrived.
|
||||
NewWebRenderFrame,
|
||||
/// WebRender has processed a scroll event and has generated a new frame.
|
||||
NewWebRenderScrollFrame,
|
||||
/// The window has been resized and will need to be synchronously repainted.
|
||||
Resize,
|
||||
}
|
||||
|
||||
/// Sends messages to the compositor.
|
||||
pub struct CompositorProxy {
|
||||
pub sender: Sender<Msg>,
|
||||
pub sender: Sender<CompositorMsg>,
|
||||
pub event_loop_waker: Box<dyn EventLoopWaker>,
|
||||
}
|
||||
|
||||
impl CompositorProxy {
|
||||
pub fn send(&self, msg: Msg) {
|
||||
pub fn send(&self, msg: CompositorMsg) {
|
||||
if let Err(err) = self.sender.send(msg) {
|
||||
warn!("Failed to send response ({:?}).", err);
|
||||
}
|
||||
|
@ -50,26 +81,26 @@ impl Clone for CompositorProxy {
|
|||
|
||||
/// The port that the compositor receives messages on.
|
||||
pub struct CompositorReceiver {
|
||||
pub receiver: Receiver<Msg>,
|
||||
pub receiver: Receiver<CompositorMsg>,
|
||||
}
|
||||
|
||||
impl CompositorReceiver {
|
||||
pub fn try_recv_compositor_msg(&mut self) -> Option<Msg> {
|
||||
pub fn try_recv_compositor_msg(&mut self) -> Option<CompositorMsg> {
|
||||
self.receiver.try_recv().ok()
|
||||
}
|
||||
pub fn recv_compositor_msg(&mut self) -> Msg {
|
||||
pub fn recv_compositor_msg(&mut self) -> CompositorMsg {
|
||||
self.receiver.recv().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl CompositorProxy {
|
||||
pub fn recomposite(&self, reason: CompositingReason) {
|
||||
self.send(Msg::Recomposite(reason));
|
||||
self.send(CompositorMsg::Recomposite(reason));
|
||||
}
|
||||
}
|
||||
|
||||
/// Messages from the painting thread and the constellation thread to the compositor thread.
|
||||
pub enum Msg {
|
||||
/// Messages from (or via) the constellation thread to the compositor.
|
||||
pub enum CompositorMsg {
|
||||
/// Informs the compositor that the constellation has completed shutdown.
|
||||
/// Required because the constellation can have pending calls to make
|
||||
/// (e.g. SetFrameTree) at the time that we send it an ExitMsg.
|
||||
|
@ -123,6 +154,20 @@ pub enum Msg {
|
|||
Webrender(WebrenderMsg),
|
||||
}
|
||||
|
||||
pub struct SendableFrameTree {
|
||||
pub pipeline: CompositionPipeline,
|
||||
pub children: Vec<SendableFrameTree>,
|
||||
}
|
||||
|
||||
/// The subset of the pipeline that is needed for layer composition.
|
||||
#[derive(Clone)]
|
||||
pub struct CompositionPipeline {
|
||||
pub id: PipelineId,
|
||||
pub top_level_browsing_context_id: TopLevelBrowsingContextId,
|
||||
pub script_chan: IpcSender<ConstellationControlMsg>,
|
||||
pub layout_chan: IpcSender<LayoutControlMsg>,
|
||||
}
|
||||
|
||||
pub enum WebrenderFontMsg {
|
||||
AddFontInstance(FontKey, f32, Sender<FontInstanceKey>),
|
||||
AddFont(gfx_traits::FontData, Sender<FontKey>),
|
||||
|
@ -140,51 +185,30 @@ pub enum WebrenderMsg {
|
|||
Canvas(WebrenderCanvasMsg),
|
||||
}
|
||||
|
||||
impl Debug for Msg {
|
||||
impl Debug for CompositorMsg {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
|
||||
match *self {
|
||||
Msg::ShutdownComplete => write!(f, "ShutdownComplete"),
|
||||
Msg::ChangeRunningAnimationsState(_, state) => {
|
||||
CompositorMsg::ShutdownComplete => write!(f, "ShutdownComplete"),
|
||||
CompositorMsg::ChangeRunningAnimationsState(_, state) => {
|
||||
write!(f, "ChangeRunningAnimationsState({:?})", state)
|
||||
},
|
||||
Msg::SetFrameTree(..) => write!(f, "SetFrameTree"),
|
||||
Msg::Recomposite(..) => write!(f, "Recomposite"),
|
||||
Msg::TouchEventProcessed(..) => write!(f, "TouchEventProcessed"),
|
||||
Msg::CreatePng(..) => write!(f, "CreatePng"),
|
||||
Msg::IsReadyToSaveImageReply(..) => write!(f, "IsReadyToSaveImageReply"),
|
||||
Msg::PipelineVisibilityChanged(..) => write!(f, "PipelineVisibilityChanged"),
|
||||
Msg::PipelineExited(..) => write!(f, "PipelineExited"),
|
||||
Msg::NewScrollFrameReady(..) => write!(f, "NewScrollFrameReady"),
|
||||
Msg::Dispatch(..) => write!(f, "Dispatch"),
|
||||
Msg::PendingPaintMetric(..) => write!(f, "PendingPaintMetric"),
|
||||
Msg::LoadComplete(..) => write!(f, "LoadComplete"),
|
||||
Msg::WebDriverMouseButtonEvent(..) => write!(f, "WebDriverMouseButtonEvent"),
|
||||
Msg::WebDriverMouseMoveEvent(..) => write!(f, "WebDriverMouseMoveEvent"),
|
||||
Msg::GetClientWindow(..) => write!(f, "GetClientWindow"),
|
||||
Msg::GetScreenSize(..) => write!(f, "GetScreenSize"),
|
||||
Msg::GetScreenAvailSize(..) => write!(f, "GetScreenAvailSize"),
|
||||
Msg::Webrender(..) => write!(f, "Webrender"),
|
||||
CompositorMsg::SetFrameTree(..) => write!(f, "SetFrameTree"),
|
||||
CompositorMsg::Recomposite(..) => write!(f, "Recomposite"),
|
||||
CompositorMsg::TouchEventProcessed(..) => write!(f, "TouchEventProcessed"),
|
||||
CompositorMsg::CreatePng(..) => write!(f, "CreatePng"),
|
||||
CompositorMsg::IsReadyToSaveImageReply(..) => write!(f, "IsReadyToSaveImageReply"),
|
||||
CompositorMsg::PipelineVisibilityChanged(..) => write!(f, "PipelineVisibilityChanged"),
|
||||
CompositorMsg::PipelineExited(..) => write!(f, "PipelineExited"),
|
||||
CompositorMsg::NewScrollFrameReady(..) => write!(f, "NewScrollFrameReady"),
|
||||
CompositorMsg::Dispatch(..) => write!(f, "Dispatch"),
|
||||
CompositorMsg::PendingPaintMetric(..) => write!(f, "PendingPaintMetric"),
|
||||
CompositorMsg::LoadComplete(..) => write!(f, "LoadComplete"),
|
||||
CompositorMsg::WebDriverMouseButtonEvent(..) => write!(f, "WebDriverMouseButtonEvent"),
|
||||
CompositorMsg::WebDriverMouseMoveEvent(..) => write!(f, "WebDriverMouseMoveEvent"),
|
||||
CompositorMsg::GetClientWindow(..) => write!(f, "GetClientWindow"),
|
||||
CompositorMsg::GetScreenSize(..) => write!(f, "GetScreenSize"),
|
||||
CompositorMsg::GetScreenAvailSize(..) => write!(f, "GetScreenAvailSize"),
|
||||
CompositorMsg::Webrender(..) => write!(f, "Webrender"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Data used to construct a compositor.
|
||||
pub struct InitialCompositorState {
|
||||
/// A channel to the compositor.
|
||||
pub sender: CompositorProxy,
|
||||
/// A port on which messages inbound to the compositor can be received.
|
||||
pub receiver: CompositorReceiver,
|
||||
/// A channel to the constellation.
|
||||
pub constellation_chan: Sender<ConstellationMsg>,
|
||||
/// A channel to the time profiler thread.
|
||||
pub time_profiler_chan: time::ProfilerChan,
|
||||
/// A channel to the memory profiler thread.
|
||||
pub mem_profiler_chan: mem::ProfilerChan,
|
||||
/// Instance of webrender API
|
||||
pub webrender: webrender::Renderer,
|
||||
pub webrender_document: DocumentId,
|
||||
pub webrender_api: RenderApi,
|
||||
pub webrender_surfman: WebrenderSurfman,
|
||||
pub webrender_gl: Rc<dyn gleam::gl::Gl>,
|
||||
pub webxr_main_thread: webxr::MainThreadRegistry,
|
||||
}
|
|
@ -15,7 +15,7 @@ background_hang_monitor = { path = "../background_hang_monitor" }
|
|||
backtrace = { workspace = true }
|
||||
bluetooth_traits = { path = "../bluetooth_traits" }
|
||||
canvas_traits = { path = "../canvas_traits" }
|
||||
compositing = { path = "../compositing" }
|
||||
compositing_traits = { path = "../compositing_traits" }
|
||||
crossbeam-channel = { workspace = true }
|
||||
devtools_traits = { path = "../devtools_traits" }
|
||||
embedder_traits = { path = "../embedder_traits" }
|
||||
|
|
|
@ -106,10 +106,10 @@ use bluetooth_traits::BluetoothRequest;
|
|||
use canvas_traits::canvas::{CanvasId, CanvasMsg};
|
||||
use canvas_traits::webgl::WebGLThreads;
|
||||
use canvas_traits::ConstellationCanvasMsg;
|
||||
use compositing::compositor_thread::CompositorProxy;
|
||||
use compositing::compositor_thread::Msg as ToCompositorMsg;
|
||||
use compositing::compositor_thread::WebrenderMsg;
|
||||
use compositing::{ConstellationMsg as FromCompositorMsg, SendableFrameTree};
|
||||
use compositing_traits::{
|
||||
CompositorMsg, CompositorProxy, ConstellationMsg as FromCompositorMsg, SendableFrameTree,
|
||||
WebrenderMsg,
|
||||
};
|
||||
use crossbeam_channel::{after, never, unbounded, Receiver, Sender};
|
||||
use devtools_traits::{
|
||||
ChromeToDevtoolsControlMsg, DevtoolsControlMsg, DevtoolsPageInfo, NavigationState,
|
||||
|
@ -724,7 +724,7 @@ where
|
|||
ROUTER.add_route(
|
||||
webrender_ipc_receiver.to_opaque(),
|
||||
Box::new(move |message| {
|
||||
let _ = compositor_proxy.send(ToCompositorMsg::Webrender(
|
||||
let _ = compositor_proxy.send(CompositorMsg::Webrender(
|
||||
WebrenderMsg::Layout(message.to().expect("conversion failure")),
|
||||
));
|
||||
}),
|
||||
|
@ -734,9 +734,9 @@ where
|
|||
ROUTER.add_route(
|
||||
webrender_image_ipc_receiver.to_opaque(),
|
||||
Box::new(move |message| {
|
||||
let _ = compositor_proxy.send(ToCompositorMsg::Webrender(
|
||||
WebrenderMsg::Net(message.to().expect("conversion failure")),
|
||||
));
|
||||
let _ = compositor_proxy.send(CompositorMsg::Webrender(WebrenderMsg::Net(
|
||||
message.to().expect("conversion failure"),
|
||||
)));
|
||||
}),
|
||||
);
|
||||
|
||||
|
@ -1467,7 +1467,7 @@ where
|
|||
}
|
||||
let is_ready = is_ready == ReadyToSave::Ready;
|
||||
self.compositor_proxy
|
||||
.send(ToCompositorMsg::IsReadyToSaveImageReply(is_ready));
|
||||
.send(CompositorMsg::IsReadyToSaveImageReply(is_ready));
|
||||
if self.is_running_problem_test {
|
||||
println!("sent response");
|
||||
}
|
||||
|
@ -1735,22 +1735,22 @@ where
|
|||
},
|
||||
FromScriptMsg::GetClientWindow(response_sender) => {
|
||||
self.compositor_proxy
|
||||
.send(ToCompositorMsg::GetClientWindow(response_sender));
|
||||
.send(CompositorMsg::GetClientWindow(response_sender));
|
||||
},
|
||||
FromScriptMsg::GetScreenSize(response_sender) => {
|
||||
self.compositor_proxy
|
||||
.send(ToCompositorMsg::GetScreenSize(response_sender));
|
||||
.send(CompositorMsg::GetScreenSize(response_sender));
|
||||
},
|
||||
FromScriptMsg::GetScreenAvailSize(response_sender) => {
|
||||
self.compositor_proxy
|
||||
.send(ToCompositorMsg::GetScreenAvailSize(response_sender));
|
||||
.send(CompositorMsg::GetScreenAvailSize(response_sender));
|
||||
},
|
||||
FromScriptMsg::LogEntry(thread_name, entry) => {
|
||||
self.handle_log_entry(Some(source_top_ctx_id), thread_name, entry);
|
||||
},
|
||||
FromScriptMsg::TouchEventProcessed(result) => self
|
||||
.compositor_proxy
|
||||
.send(ToCompositorMsg::TouchEventProcessed(result)),
|
||||
.send(CompositorMsg::TouchEventProcessed(result)),
|
||||
FromScriptMsg::GetBrowsingContextInfo(pipeline_id, response_sender) => {
|
||||
let result = self
|
||||
.pipelines
|
||||
|
@ -2734,8 +2734,7 @@ where
|
|||
}
|
||||
|
||||
debug!("Asking compositor to complete shutdown.");
|
||||
self.compositor_proxy
|
||||
.send(ToCompositorMsg::ShutdownComplete);
|
||||
self.compositor_proxy.send(CompositorMsg::ShutdownComplete);
|
||||
|
||||
debug!("Shutting-down IPC router thread in constellation.");
|
||||
ROUTER.shutdown();
|
||||
|
@ -3344,7 +3343,7 @@ where
|
|||
|
||||
fn handle_pending_paint_metric(&self, pipeline_id: PipelineId, epoch: Epoch) {
|
||||
self.compositor_proxy
|
||||
.send(ToCompositorMsg::PendingPaintMetric(pipeline_id, epoch))
|
||||
.send(CompositorMsg::PendingPaintMetric(pipeline_id, epoch))
|
||||
}
|
||||
|
||||
fn handle_set_cursor_msg(&mut self, cursor: Cursor) {
|
||||
|
@ -3361,7 +3360,7 @@ where
|
|||
if pipeline.animation_state != animation_state {
|
||||
pipeline.animation_state = animation_state;
|
||||
self.compositor_proxy
|
||||
.send(ToCompositorMsg::ChangeRunningAnimationsState(
|
||||
.send(CompositorMsg::ChangeRunningAnimationsState(
|
||||
pipeline_id,
|
||||
animation_state,
|
||||
))
|
||||
|
@ -3598,7 +3597,7 @@ where
|
|||
if !current_top_level_pipeline_will_be_replaced {
|
||||
// Notify embedder and compositor top level document finished loading.
|
||||
self.compositor_proxy
|
||||
.send(ToCompositorMsg::LoadComplete(top_level_browsing_context_id));
|
||||
.send(CompositorMsg::LoadComplete(top_level_browsing_context_id));
|
||||
}
|
||||
} else {
|
||||
self.handle_subframe_loaded(pipeline_id);
|
||||
|
@ -4435,7 +4434,7 @@ where
|
|||
},
|
||||
WebDriverCommandMsg::MouseButtonAction(mouse_event_type, mouse_button, x, y) => {
|
||||
self.compositor_proxy
|
||||
.send(ToCompositorMsg::WebDriverMouseButtonEvent(
|
||||
.send(CompositorMsg::WebDriverMouseButtonEvent(
|
||||
mouse_event_type,
|
||||
mouse_button,
|
||||
x,
|
||||
|
@ -4444,11 +4443,11 @@ where
|
|||
},
|
||||
WebDriverCommandMsg::MouseMoveAction(x, y) => {
|
||||
self.compositor_proxy
|
||||
.send(ToCompositorMsg::WebDriverMouseMoveEvent(x, y));
|
||||
.send(CompositorMsg::WebDriverMouseMoveEvent(x, y));
|
||||
},
|
||||
WebDriverCommandMsg::TakeScreenshot(_, rect, response_sender) => {
|
||||
self.compositor_proxy
|
||||
.send(ToCompositorMsg::CreatePng(rect, response_sender));
|
||||
.send(CompositorMsg::CreatePng(rect, response_sender));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -5454,7 +5453,7 @@ where
|
|||
);
|
||||
self.active_browser_id = Some(top_level_browsing_context_id);
|
||||
self.compositor_proxy
|
||||
.send(ToCompositorMsg::SetFrameTree(frame_tree));
|
||||
.send(CompositorMsg::SetFrameTree(frame_tree));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use backtrace::Backtrace;
|
||||
use compositing::ConstellationMsg as FromCompositorMsg;
|
||||
use compositing_traits::ConstellationMsg as FromCompositorMsg;
|
||||
use crossbeam_channel::Sender;
|
||||
use log::{Level, LevelFilter, Log, Metadata, Record};
|
||||
use msg::constellation_msg::TopLevelBrowsingContextId;
|
||||
|
|
|
@ -7,9 +7,9 @@ use crate::sandboxing::{spawn_multiprocess, UnprivilegedContent};
|
|||
use background_hang_monitor::HangMonitorRegister;
|
||||
use bluetooth_traits::BluetoothRequest;
|
||||
use canvas_traits::webgl::WebGLPipeline;
|
||||
use compositing::compositor_thread::Msg as CompositorMsg;
|
||||
use compositing::CompositionPipeline;
|
||||
use compositing::CompositorProxy;
|
||||
use compositing_traits::CompositionPipeline;
|
||||
use compositing_traits::CompositorMsg;
|
||||
use compositing_traits::CompositorProxy;
|
||||
use crossbeam_channel::{unbounded, Sender};
|
||||
use devtools_traits::{DevtoolsControlMsg, ScriptToDevtoolsControlMsg};
|
||||
use embedder_traits::EventLoopWaker;
|
||||
|
|
|
@ -40,6 +40,7 @@ bluetooth_traits = { path = "../bluetooth_traits" }
|
|||
canvas = { path = "../canvas", default-features = false }
|
||||
canvas_traits = { path = "../canvas_traits" }
|
||||
compositing = { path = "../compositing", features = ["gl"] }
|
||||
compositing_traits = { path = "../compositing_traits" }
|
||||
constellation = { path = "../constellation" }
|
||||
crossbeam-channel = { workspace = true }
|
||||
devtools = { path = "../devtools" }
|
||||
|
|
|
@ -68,12 +68,12 @@ use bluetooth_traits::BluetoothRequest;
|
|||
use canvas::canvas_paint_thread::{self, CanvasPaintThread};
|
||||
use canvas::WebGLComm;
|
||||
use canvas_traits::webgl::WebGLThreads;
|
||||
use compositing::compositor_thread::{
|
||||
CompositorProxy, CompositorReceiver, InitialCompositorState, Msg, WebrenderCanvasMsg,
|
||||
WebrenderFontMsg, WebrenderMsg,
|
||||
};
|
||||
use compositing::windowing::{EmbedderEvent, EmbedderMethods, WindowMethods};
|
||||
use compositing::{CompositingReason, ConstellationMsg, IOCompositor, ShutdownState};
|
||||
use compositing::{IOCompositor, InitialCompositorState, ShutdownState};
|
||||
use compositing_traits::{
|
||||
CompositingReason, CompositorMsg, CompositorProxy, CompositorReceiver, ConstellationMsg,
|
||||
WebrenderCanvasMsg, WebrenderFontMsg, WebrenderMsg,
|
||||
};
|
||||
#[cfg(all(
|
||||
not(target_os = "windows"),
|
||||
not(target_os = "ios"),
|
||||
|
@ -234,7 +234,7 @@ impl webrender_api::RenderNotifier for RenderNotifier {
|
|||
) {
|
||||
if scrolled {
|
||||
self.compositor_proxy
|
||||
.send(Msg::NewScrollFrameReady(composite_needed));
|
||||
.send(CompositorMsg::NewScrollFrameReady(composite_needed));
|
||||
} else {
|
||||
self.wake_up();
|
||||
}
|
||||
|
@ -934,14 +934,14 @@ struct FontCacheWR(CompositorProxy);
|
|||
impl gfx_traits::WebrenderApi for FontCacheWR {
|
||||
fn add_font_instance(&self, font_key: FontKey, size: f32) -> FontInstanceKey {
|
||||
let (sender, receiver) = unbounded();
|
||||
let _ = self.0.send(Msg::Webrender(WebrenderMsg::Font(
|
||||
let _ = self.0.send(CompositorMsg::Webrender(WebrenderMsg::Font(
|
||||
WebrenderFontMsg::AddFontInstance(font_key, size, sender),
|
||||
)));
|
||||
receiver.recv().unwrap()
|
||||
}
|
||||
fn add_font(&self, data: gfx_traits::FontData) -> FontKey {
|
||||
let (sender, receiver) = unbounded();
|
||||
let _ = self.0.send(Msg::Webrender(WebrenderMsg::Font(
|
||||
let _ = self.0.send(CompositorMsg::Webrender(WebrenderMsg::Font(
|
||||
WebrenderFontMsg::AddFont(data, sender),
|
||||
)));
|
||||
receiver.recv().unwrap()
|
||||
|
@ -954,13 +954,13 @@ struct CanvasWebrenderApi(CompositorProxy);
|
|||
impl canvas_paint_thread::WebrenderApi for CanvasWebrenderApi {
|
||||
fn generate_key(&self) -> Result<ImageKey, ()> {
|
||||
let (sender, receiver) = unbounded();
|
||||
let _ = self.0.send(Msg::Webrender(WebrenderMsg::Canvas(
|
||||
let _ = self.0.send(CompositorMsg::Webrender(WebrenderMsg::Canvas(
|
||||
WebrenderCanvasMsg::GenerateKey(sender),
|
||||
)));
|
||||
receiver.recv().map_err(|_| ())
|
||||
}
|
||||
fn update_images(&self, updates: Vec<canvas_paint_thread::ImageUpdate>) {
|
||||
let _ = self.0.send(Msg::Webrender(WebrenderMsg::Canvas(
|
||||
let _ = self.0.send(CompositorMsg::Webrender(WebrenderMsg::Canvas(
|
||||
WebrenderCanvasMsg::UpdateImages(updates),
|
||||
)));
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ path = "lib.rs"
|
|||
|
||||
[dependencies]
|
||||
base64 = { workspace = true }
|
||||
compositing = { path = "../compositing" }
|
||||
compositing_traits = { path = "../compositing_traits" }
|
||||
cookie = { workspace = true }
|
||||
crossbeam-channel = { workspace = true }
|
||||
euclid = { workspace = true }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::Handler;
|
||||
use compositing::ConstellationMsg;
|
||||
use compositing_traits::ConstellationMsg;
|
||||
use ipc_channel::ipc;
|
||||
use keyboard_types::webdriver::KeyInputState;
|
||||
use script_traits::webdriver_msg::WebDriverScriptCommand;
|
||||
|
|
|
@ -19,7 +19,7 @@ mod capabilities;
|
|||
use crate::actions::{InputSourceState, PointerInputState};
|
||||
use base64::Engine;
|
||||
use capabilities::ServoCapabilities;
|
||||
use compositing::ConstellationMsg;
|
||||
use compositing_traits::ConstellationMsg;
|
||||
use crossbeam_channel::{after, unbounded, Receiver, Sender};
|
||||
use euclid::{Rect, Size2D};
|
||||
use http::method::Method;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue