diff options
author | Niko Pen <42466421+nikopen@users.noreply.github.com> | 2019-01-17 05:07:30 +0100 |
---|---|---|
committer | Shanavas M <shanavas.m2@gmail.com> | 2019-02-28 19:53:54 +0530 |
commit | 0b8deed28ad61fc3ba3b933e96dd2829aadaf41e (patch) | |
tree | 85258841f14a15d43b2c5eab29648d58bb4072ba | |
parent | fd07be1cefa7c96ec15bcb16e21dbb0558627d3d (diff) | |
download | servo-0b8deed28ad61fc3ba3b933e96dd2829aadaf41e.tar.gz servo-0b8deed28ad61fc3ba3b933e96dd2829aadaf41e.zip |
Move RenderNotifier from compositing to servo
-rw-r--r-- | components/compositing/compositor.rs | 41 | ||||
-rw-r--r-- | components/compositing/lib.rs | 2 | ||||
-rw-r--r-- | components/servo/lib.rs | 45 |
3 files changed, 45 insertions, 43 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 89f185beadb..253fc1cb925 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -2,7 +2,7 @@ * 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::{CompositorProxy, CompositorReceiver}; +use crate::compositor_thread::CompositorReceiver; use crate::compositor_thread::{InitialCompositorState, Msg}; #[cfg(feature = "gl")] use crate::gl; @@ -249,45 +249,6 @@ enum CompositeTarget { PngFile, } -#[derive(Clone)] -pub struct RenderNotifier { - compositor_proxy: CompositorProxy, -} - -impl RenderNotifier { - pub fn new(compositor_proxy: CompositorProxy) -> RenderNotifier { - RenderNotifier { - compositor_proxy: compositor_proxy, - } - } -} - -impl webrender_api::RenderNotifier for RenderNotifier { - fn clone(&self) -> Box<dyn webrender_api::RenderNotifier> { - Box::new(RenderNotifier::new(self.compositor_proxy.clone())) - } - - fn wake_up(&self) { - self.compositor_proxy - .recomposite(CompositingReason::NewWebRenderFrame); - } - - fn new_frame_ready( - &self, - _document_id: webrender_api::DocumentId, - scrolled: bool, - composite_needed: bool, - _render_time_ns: Option<u64>, - ) { - if scrolled { - self.compositor_proxy - .send(Msg::NewScrollFrameReady(composite_needed)); - } else { - self.wake_up(); - } - } -} - impl<Window: WindowMethods> IOCompositor<Window> { fn new(window: Rc<Window>, state: InitialCompositorState) -> Self { let composite_target = match opts::get().output_file { diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs index 8ffbb9196b2..49b2ab7bf70 100644 --- a/components/compositing/lib.rs +++ b/components/compositing/lib.rs @@ -7,8 +7,8 @@ #[macro_use] extern crate log; +pub use crate::compositor::CompositingReason; pub use crate::compositor::IOCompositor; -pub use crate::compositor::RenderNotifier; pub use crate::compositor::ShutdownState; pub use crate::compositor_thread::CompositorProxy; use ipc_channel::ipc::IpcSender; diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 16fb675cfe4..0eed4aa6c1d 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -65,9 +65,11 @@ use bluetooth::BluetoothThreadFactory; use bluetooth_traits::BluetoothRequest; use canvas::gl_context::GLContextFactory; use canvas::webgl_thread::WebGLThreads; -use compositing::compositor_thread::{CompositorProxy, CompositorReceiver, InitialCompositorState}; +use compositing::compositor_thread::{ + CompositorProxy, CompositorReceiver, InitialCompositorState, Msg, +}; use compositing::windowing::{WindowEvent, WindowMethods}; -use compositing::{IOCompositor, RenderNotifier, ShutdownState}; +use compositing::{CompositingReason, IOCompositor, ShutdownState}; #[cfg(all( not(target_os = "windows"), not(target_os = "ios"), @@ -132,6 +134,45 @@ pub struct Servo<Window: WindowMethods + 'static> { embedder_events: Vec<(Option<BrowserId>, EmbedderMsg)>, } +#[derive(Clone)] +struct RenderNotifier { + compositor_proxy: CompositorProxy, +} + +impl RenderNotifier { + pub fn new(compositor_proxy: CompositorProxy) -> RenderNotifier { + RenderNotifier { + compositor_proxy: compositor_proxy, + } + } +} + +impl webrender_api::RenderNotifier for RenderNotifier { + fn clone(&self) -> Box<dyn webrender_api::RenderNotifier> { + Box::new(RenderNotifier::new(self.compositor_proxy.clone())) + } + + fn wake_up(&self) { + self.compositor_proxy + .recomposite(CompositingReason::NewWebRenderFrame); + } + + fn new_frame_ready( + &self, + _document_id: webrender_api::DocumentId, + scrolled: bool, + composite_needed: bool, + _render_time_ns: Option<u64>, + ) { + if scrolled { + self.compositor_proxy + .send(Msg::NewScrollFrameReady(composite_needed)); + } else { + self.wake_up(); + } + } +} + impl<Window> Servo<Window> where Window: WindowMethods + 'static, |