mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Refactoring of the Glutin port in preparation of the compositor refactoring.
This commit is contained in:
parent
d58ea974ba
commit
21ed7653f4
30 changed files with 1287 additions and 1067 deletions
|
@ -10,7 +10,8 @@ pub mod gl_glue;
|
|||
pub use servo::script_traits::MouseButton;
|
||||
|
||||
use servo::compositing::windowing::{
|
||||
AnimationState, EmbedderCoordinates, MouseWindowEvent, WindowEvent, WindowMethods,
|
||||
AnimationState, EmbedderCoordinates, EmbedderMethods, MouseWindowEvent, WindowEvent,
|
||||
WindowMethods,
|
||||
};
|
||||
use servo::embedder_traits::resources::{self, Resource, ResourceReaderMethods};
|
||||
use servo::embedder_traits::EmbedderMsg;
|
||||
|
@ -112,9 +113,9 @@ pub trait HostTrait {
|
|||
}
|
||||
|
||||
pub struct ServoGlue {
|
||||
servo: Servo<ServoCallbacks>,
|
||||
servo: Servo<ServoWindowCallbacks>,
|
||||
batch_mode: bool,
|
||||
callbacks: Rc<ServoCallbacks>,
|
||||
callbacks: Rc<ServoWindowCallbacks>,
|
||||
/// id of the top level browsing context. It is unique as tabs
|
||||
/// are not supported yet. None until created.
|
||||
browser_id: Option<BrowserId>,
|
||||
|
@ -169,22 +170,25 @@ pub fn init(
|
|||
gl.clear(gl::COLOR_BUFFER_BIT);
|
||||
gl.finish();
|
||||
|
||||
let callbacks = Rc::new(ServoCallbacks {
|
||||
let window_callbacks = Rc::new(ServoWindowCallbacks {
|
||||
gl: gl.clone(),
|
||||
host_callbacks: callbacks,
|
||||
coordinates: RefCell::new(init_opts.coordinates),
|
||||
density: init_opts.density,
|
||||
});
|
||||
|
||||
let embedder_callbacks = Box::new(ServoEmbedderCallbacks {
|
||||
vr_pointer: init_opts.vr_pointer,
|
||||
waker,
|
||||
});
|
||||
|
||||
let servo = Servo::new(callbacks.clone());
|
||||
let servo = Servo::new(embedder_callbacks, window_callbacks.clone());
|
||||
|
||||
SERVO.with(|s| {
|
||||
let mut servo_glue = ServoGlue {
|
||||
servo,
|
||||
batch_mode: false,
|
||||
callbacks,
|
||||
callbacks: window_callbacks,
|
||||
browser_id: None,
|
||||
browsers: vec![],
|
||||
events: vec![],
|
||||
|
@ -546,16 +550,37 @@ impl ServoGlue {
|
|||
}
|
||||
}
|
||||
|
||||
struct ServoCallbacks {
|
||||
struct ServoEmbedderCallbacks {
|
||||
waker: Box<dyn EventLoopWaker>,
|
||||
vr_pointer: Option<*mut c_void>,
|
||||
}
|
||||
|
||||
struct ServoWindowCallbacks {
|
||||
gl: Rc<dyn gl::Gl>,
|
||||
host_callbacks: Box<dyn HostTrait>,
|
||||
coordinates: RefCell<Coordinates>,
|
||||
density: f32,
|
||||
vr_pointer: Option<*mut c_void>,
|
||||
}
|
||||
|
||||
impl WindowMethods for ServoCallbacks {
|
||||
impl EmbedderMethods for ServoEmbedderCallbacks {
|
||||
fn register_vr_services(
|
||||
&self,
|
||||
services: &mut VRServiceManager,
|
||||
_: &mut Vec<Box<VRMainThreadHeartbeat>>,
|
||||
) {
|
||||
debug!("EmbedderMethods::register_vrexternal");
|
||||
if let Some(ptr) = self.vr_pointer {
|
||||
services.register_vrexternal(VRExternalShmemPtr::new(ptr));
|
||||
}
|
||||
}
|
||||
|
||||
fn create_event_loop_waker(&self) -> Box<dyn EventLoopWaker> {
|
||||
debug!("EmbedderMethods::create_event_loop_waker");
|
||||
self.waker.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl WindowMethods for ServoWindowCallbacks {
|
||||
fn prepare_for_composite(&self) -> bool {
|
||||
debug!("WindowMethods::prepare_for_composite");
|
||||
self.host_callbacks.make_current();
|
||||
|
@ -567,11 +592,6 @@ impl WindowMethods for ServoCallbacks {
|
|||
self.host_callbacks.flush();
|
||||
}
|
||||
|
||||
fn create_event_loop_waker(&self) -> Box<dyn EventLoopWaker> {
|
||||
debug!("WindowMethods::create_event_loop_waker");
|
||||
self.waker.clone()
|
||||
}
|
||||
|
||||
fn gl(&self) -> Rc<dyn gl::Gl> {
|
||||
debug!("WindowMethods::gl");
|
||||
self.gl.clone()
|
||||
|
@ -594,16 +614,6 @@ impl WindowMethods for ServoCallbacks {
|
|||
hidpi_factor: TypedScale::new(self.density),
|
||||
}
|
||||
}
|
||||
|
||||
fn register_vr_services(
|
||||
&self,
|
||||
services: &mut VRServiceManager,
|
||||
_: &mut Vec<Box<VRMainThreadHeartbeat>>,
|
||||
) {
|
||||
if let Some(ptr) = self.vr_pointer {
|
||||
services.register_vrexternal(VRExternalShmemPtr::new(ptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ResourceReaderInstance;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue