aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ports/glutin/app.rs24
-rw-r--r--ports/glutin/embedder.rs23
-rw-r--r--ports/glutin/headed_window.rs12
-rw-r--r--ports/glutin/main2.rs2
-rw-r--r--ports/libsimpleservo/api/src/lib.rs1
5 files changed, 46 insertions, 16 deletions
diff --git a/ports/glutin/app.rs b/ports/glutin/app.rs
index 77bd3eb41dc..d5371bf1e93 100644
--- a/ports/glutin/app.rs
+++ b/ports/glutin/app.rs
@@ -6,8 +6,8 @@
use crate::browser::Browser;
use crate::embedder::EmbedderCallbacks;
-use crate::window_trait::WindowPortsMethods;
use crate::events_loop::EventsLoop;
+use crate::window_trait::WindowPortsMethods;
use crate::{headed_window, headless_window};
use glutin::WindowId;
use servo::compositing::windowing::WindowEvent;
@@ -34,14 +34,20 @@ pub struct App {
}
impl App {
- pub fn run() {
+ pub fn run(angle: bool, enable_vsync: bool) {
let events_loop = EventsLoop::new(opts::get().headless);
// Implements window methods, used by compositor.
let window = if opts::get().headless {
headless_window::Window::new(opts::get().initial_window_size)
} else {
- Rc::new(headed_window::Window::new(opts::get().initial_window_size, None, events_loop.clone()))
+ Rc::new(headed_window::Window::new(
+ opts::get().initial_window_size,
+ None,
+ events_loop.clone(),
+ angle,
+ enable_vsync,
+ ))
};
// Implements embedder methods, used by libservo and constellation.
@@ -49,6 +55,7 @@ impl App {
window.clone(),
events_loop.clone(),
window.gl(),
+ angle,
));
// Handle browser state.
@@ -110,7 +117,7 @@ impl App {
};
window.winit_event_to_servo_event(event);
return cont;
- }
+ },
}
});
},
@@ -121,7 +128,10 @@ impl App {
fn run_loop(self) {
loop {
let animating = WINDOWS.with(|windows| {
- windows.borrow().iter().any(|(_, window)| window.is_animating())
+ windows
+ .borrow()
+ .iter()
+ .any(|(_, window)| window.is_animating())
});
if !animating || self.suspended.get() {
// If there's no animations running then we block on the window event loop.
@@ -219,8 +229,8 @@ pub fn register_window(window: Rc<dyn WindowPortsMethods>) {
});
}
-pub fn gl_version() -> glutin::GlRequest {
- if opts::get().angle {
+pub fn gl_version(angle: bool) -> glutin::GlRequest {
+ if angle {
glutin::GlRequest::Specific(glutin::Api::OpenGlEs, (3, 0))
} else {
glutin::GlRequest::GlThenGles {
diff --git a/ports/glutin/embedder.rs b/ports/glutin/embedder.rs
index fcebdd4d859..678ecdd8064 100644
--- a/ports/glutin/embedder.rs
+++ b/ports/glutin/embedder.rs
@@ -9,8 +9,8 @@ use crate::events_loop::EventsLoop;
use crate::window_trait::WindowPortsMethods;
use gleam::gl;
use glutin;
-use glutin::EventsLoopClosed;
use glutin::dpi::LogicalSize;
+use glutin::EventsLoopClosed;
use rust_webvr::GlWindowVRService;
use servo::compositing::windowing::EmbedderMethods;
use servo::embedder_traits::EventLoopWaker;
@@ -24,15 +24,22 @@ pub struct EmbedderCallbacks {
window: Rc<dyn WindowPortsMethods>,
events_loop: Rc<RefCell<EventsLoop>>,
gl: Rc<dyn gl::Gl>,
+ angle: bool,
}
impl EmbedderCallbacks {
pub fn new(
window: Rc<dyn WindowPortsMethods>,
events_loop: Rc<RefCell<EventsLoop>>,
- gl: Rc<dyn gl::Gl>
+ gl: Rc<dyn gl::Gl>,
+ angle: bool,
) -> EmbedderCallbacks {
- EmbedderCallbacks { window, events_loop, gl }
+ EmbedderCallbacks {
+ window,
+ events_loop,
+ gl,
+ angle,
+ }
}
}
@@ -55,7 +62,10 @@ impl EmbedderMethods for EmbedderCallbacks {
let size = LogicalSize::new(size.width, size.height);
let events_loop_clone = self.events_loop.clone();
let events_loop_factory = Box::new(move || {
- events_loop_clone.borrow_mut().take().ok_or(EventsLoopClosed)
+ events_loop_clone
+ .borrow_mut()
+ .take()
+ .ok_or(EventsLoopClosed)
});
let window_builder = glutin::WindowBuilder::new()
.with_title(name.clone())
@@ -63,12 +73,13 @@ impl EmbedderMethods for EmbedderCallbacks {
.with_visibility(false)
.with_multitouch();
let context = glutin::ContextBuilder::new()
- .with_gl(app::gl_version())
+ .with_gl(app::gl_version(self.angle))
.with_vsync(false) // Assume the browser vsync is the same as the test VR window vsync
.build_windowed(window_builder, &*self.events_loop.borrow().as_winit())
.expect("Failed to create window.");
let gl = self.gl.clone();
- let (service, heartbeat) = GlWindowVRService::new(name, context, events_loop_factory, gl);
+ let (service, heartbeat) =
+ GlWindowVRService::new(name, context, events_loop_factory, gl);
services.register(Box::new(service));
heartbeats.push(Box::new(heartbeat));
diff --git a/ports/glutin/headed_window.rs b/ports/glutin/headed_window.rs
index f8e54149863..37af152a2a2 100644
--- a/ports/glutin/headed_window.rs
+++ b/ports/glutin/headed_window.rs
@@ -71,6 +71,8 @@ pub struct Window {
fullscreen: Cell<bool>,
gl: Rc<dyn gl::Gl>,
xr_rotation: Cell<Rotation3D<f32, UnknownUnit, UnknownUnit>>,
+ angle: bool,
+ enable_vsync: bool,
}
#[cfg(not(target_os = "windows"))]
@@ -90,6 +92,8 @@ impl Window {
win_size: Size2D<u32, DeviceIndependentPixel>,
sharing: Option<&Window>,
events_loop: Rc<RefCell<EventsLoop>>,
+ angle: bool,
+ enable_vsync: bool,
) -> Window {
let opts = opts::get();
@@ -114,8 +118,8 @@ impl Window {
window_builder = builder_with_platform_options(window_builder);
let mut context_builder = glutin::ContextBuilder::new()
- .with_gl(app::gl_version())
- .with_vsync(opts.enable_vsync);
+ .with_gl(app::gl_version(angle))
+ .with_vsync(enable_vsync);
if opts.use_msaa {
context_builder = context_builder.with_multisampling(MULTISAMPLES)
@@ -198,6 +202,8 @@ impl Window {
primary_monitor,
screen_size,
xr_rotation: Cell::new(Rotation3D::identity()),
+ angle,
+ enable_vsync,
};
window.present();
@@ -545,6 +551,8 @@ impl webxr::glwindow::GlWindow for Window {
self.inner_size.get(),
Some(self),
self.events_loop.clone(),
+ self.angle,
+ self.enable_vsync,
));
app::register_window(window.clone());
Ok(window)
diff --git a/ports/glutin/main2.rs b/ports/glutin/main2.rs
index 579c97d3a23..733a16036e6 100644
--- a/ports/glutin/main2.rs
+++ b/ports/glutin/main2.rs
@@ -128,7 +128,7 @@ pub fn main() {
process::exit(0);
}
- App::run();
+ App::run(opts::get().angle, opts::get().enable_vsync);
platform::deinit()
}
diff --git a/ports/libsimpleservo/api/src/lib.rs b/ports/libsimpleservo/api/src/lib.rs
index a68cea55dbc..8f4d314932b 100644
--- a/ports/libsimpleservo/api/src/lib.rs
+++ b/ports/libsimpleservo/api/src/lib.rs
@@ -9,6 +9,7 @@ pub mod gl_glue;
pub use servo::script_traits::MouseButton;
+use getopts::Options;
use servo::compositing::windowing::{
AnimationState, EmbedderCoordinates, EmbedderMethods, MouseWindowEvent, WindowEvent,
WindowMethods,