mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +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
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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};
|
use crate::compositor_thread::{InitialCompositorState, Msg};
|
||||||
#[cfg(feature = "gl")]
|
#[cfg(feature = "gl")]
|
||||||
use crate::gl;
|
use crate::gl;
|
||||||
|
@ -249,45 +249,6 @@ enum CompositeTarget {
|
||||||
PngFile,
|
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> {
|
impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
fn new(window: Rc<Window>, state: InitialCompositorState) -> Self {
|
fn new(window: Rc<Window>, state: InitialCompositorState) -> Self {
|
||||||
let composite_target = match opts::get().output_file {
|
let composite_target = match opts::get().output_file {
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
|
pub use crate::compositor::CompositingReason;
|
||||||
pub use crate::compositor::IOCompositor;
|
pub use crate::compositor::IOCompositor;
|
||||||
pub use crate::compositor::RenderNotifier;
|
|
||||||
pub use crate::compositor::ShutdownState;
|
pub use crate::compositor::ShutdownState;
|
||||||
pub use crate::compositor_thread::CompositorProxy;
|
pub use crate::compositor_thread::CompositorProxy;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
|
|
|
@ -65,9 +65,11 @@ use bluetooth::BluetoothThreadFactory;
|
||||||
use bluetooth_traits::BluetoothRequest;
|
use bluetooth_traits::BluetoothRequest;
|
||||||
use canvas::gl_context::GLContextFactory;
|
use canvas::gl_context::GLContextFactory;
|
||||||
use canvas::webgl_thread::WebGLThreads;
|
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::windowing::{WindowEvent, WindowMethods};
|
||||||
use compositing::{IOCompositor, RenderNotifier, ShutdownState};
|
use compositing::{CompositingReason, IOCompositor, ShutdownState};
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
not(target_os = "windows"),
|
not(target_os = "windows"),
|
||||||
not(target_os = "ios"),
|
not(target_os = "ios"),
|
||||||
|
@ -132,6 +134,45 @@ pub struct Servo<Window: WindowMethods + 'static> {
|
||||||
embedder_events: Vec<(Option<BrowserId>, EmbedderMsg)>,
|
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>
|
impl<Window> Servo<Window>
|
||||||
where
|
where
|
||||||
Window: WindowMethods + 'static,
|
Window: WindowMethods + 'static,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue