diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-03-07 12:59:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-07 11:59:02 +0000 |
commit | 6005049d88766b415f38f62930d3edf79b8befe8 (patch) | |
tree | 2d4c322aa4101e155865ffba1142f545532785f9 /components/shared/compositing/lib.rs | |
parent | 3098c3d1215dddef50456e862a029e76237fa826 (diff) | |
download | servo-6005049d88766b415f38f62930d3edf79b8befe8.tar.gz servo-6005049d88766b415f38f62930d3edf79b8befe8.zip |
compositor: Improve the way we wait for frames (#31523)
* compositor: Improve the way we wait for frames
In the newest version of WebRender it will be harder to make the
distinction between frame queued for scrolling and other kinds of
pending frames. This change makes it so that we queue frames for both
kinds of changes the same way and keeps a counting of pending frames.
This is conceptually a lot simpler.
In addition, do queue a composite even when recomposite isn't necessary
for a WebRender frame when there are active requestAnimationFrame
callbacks. Doing a composite is what triggers the callbacks to actually
run in the script thread! I believe this was a bug, but the WebRender
upgrade made it much more obvious.
These changes are in preparation for the WebRender upgrade.
* Remove spurious println
Diffstat (limited to 'components/shared/compositing/lib.rs')
-rw-r--r-- | components/shared/compositing/lib.rs | 44 |
1 files changed, 4 insertions, 40 deletions
diff --git a/components/shared/compositing/lib.rs b/components/shared/compositing/lib.rs index b3810344439..a64f1a83eb3 100644 --- a/components/shared/compositing/lib.rs +++ b/components/shared/compositing/lib.rs @@ -27,33 +27,6 @@ use style_traits::CSSPixel; use webrender_api::units::{DeviceIntPoint, DeviceIntSize}; 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<CompositorMsg>, @@ -92,12 +65,6 @@ impl CompositorReceiver { } } -impl CompositorProxy { - pub fn recomposite(&self, reason: CompositingReason) { - self.send(CompositorMsg::Recomposite(reason)); - } -} - /// Messages from (or via) the constellation thread to the compositor. pub enum CompositorMsg { /// Informs the compositor that the constellation has completed shutdown. @@ -108,8 +75,6 @@ pub enum CompositorMsg { ChangeRunningAnimationsState(PipelineId, AnimationState), /// Replaces the current frame tree, typically called during main frame navigation. SetFrameTree(SendableFrameTree), - /// Composite. - Recomposite(CompositingReason), /// Script has handled a touch event, and either prevented or allowed default actions. TouchEventProcessed(EventResult), /// Composite to a PNG file and return the Image over a passed channel. @@ -118,9 +83,9 @@ pub enum CompositorMsg { IsReadyToSaveImageReply(bool), /// Pipeline visibility changed PipelineVisibilityChanged(PipelineId, bool), - /// WebRender has successfully processed a scroll. The boolean specifies whether a composite is - /// needed. - NewScrollFrameReady(bool), + /// WebRender has produced a new frame. This message informs the compositor that + /// the frame is ready, so that it may trigger a recomposite. + NewWebRenderFrameReady(bool /* composite_needed */), /// A pipeline was shut down. // This message acts as a synchronization point between the constellation, // when it shuts down a pipeline, to the compositor; when the compositor @@ -193,13 +158,12 @@ impl Debug for CompositorMsg { write!(f, "ChangeRunningAnimationsState({:?})", state) }, 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::NewWebRenderFrameReady(..) => write!(f, "NewWebRenderFrameReady"), CompositorMsg::Dispatch(..) => write!(f, "Dispatch"), CompositorMsg::PendingPaintMetric(..) => write!(f, "PendingPaintMetric"), CompositorMsg::LoadComplete(..) => write!(f, "LoadComplete"), |