mirror of
https://github.com/servo/servo.git
synced 2025-07-05 22:43:40 +01:00
Move RenderNotifier from compositing to servo
This commit is contained in:
parent
fd07be1cef
commit
0b8deed28a
3 changed files with 45 additions and 43 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue