Skip to content

Commit

Permalink
Auto merge of #23288 - paulrouget:glutin-21, r=<try>
Browse files Browse the repository at this point in the history
Glutin 0.21

Fix #23189

Depends on #23233

Dependencies update:
- servo/rust-webvr#73
- servo/skia#172
- servo/rust-glx#23
- servo/surfman#134

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23288)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed May 6, 2019
2 parents 64c8489 + f3ae99e commit 9ba71d0
Show file tree
Hide file tree
Showing 17 changed files with 615 additions and 354 deletions.
786 changes: 488 additions & 298 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components/background_hang_monitor/Cargo.toml
Expand Up @@ -30,5 +30,5 @@ lazy_static = "1.0"
mach = "0.2.3"

[target.'cfg(all(target_os = "linux", not(any(target_arch = "arm", target_arch = "aarch64"))))'.dependencies]
nix = "~0.11.0"
nix = "0.13"
unwind-sys = "0.1.1"
2 changes: 1 addition & 1 deletion components/canvas/Cargo.toml
Expand Up @@ -21,7 +21,7 @@ compositing = {path = "../compositing"}
cssparser = "0.25"
euclid = "0.19"
fnv = "1.0"
gleam = "0.6.4"
gleam = "0.6.7"
half = "1"
ipc-channel = "0.11"
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion components/layout/Cargo.toml
Expand Up @@ -33,7 +33,7 @@ msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
num-traits = "0.2"
ordered-float = "1.0"
parking_lot = "0.6"
parking_lot = "0.7"
profile_traits = {path = "../profile_traits"}
range = {path = "../range"}
rayon = "1"
Expand Down
2 changes: 1 addition & 1 deletion components/layout_thread/Cargo.toml
Expand Up @@ -36,7 +36,7 @@ malloc_size_of = { path = "../malloc_size_of" }
metrics = {path = "../metrics"}
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
parking_lot = "0.6"
parking_lot = "0.7"
profile_traits = {path = "../profile_traits"}
range = {path = "../range"}
rayon = "1"
Expand Down
2 changes: 1 addition & 1 deletion components/script/Cargo.toml
Expand Up @@ -79,7 +79,7 @@ mime_guess = "2.0.0-alpha.6"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
num-traits = "0.2"
parking_lot = "0.6"
parking_lot = "0.7"
phf = "0.7.18"
pixels = {path = "../pixels"}
profile_traits = {path = "../profile_traits"}
Expand Down
2 changes: 1 addition & 1 deletion components/style/Cargo.toml
Expand Up @@ -53,7 +53,7 @@ num-traits = "0.2"
num-derive = "0.2"
ordered-float = "1.0"
owning_ref = "0.4"
parking_lot = "0.6"
parking_lot = "0.7"
precomputed-hash = "0.1.1"
rayon = "1"
selectors = { path = "../selectors" }
Expand Down
2 changes: 1 addition & 1 deletion components/webvr/Cargo.toml
Expand Up @@ -22,7 +22,7 @@ gleam = "0.6"
ipc-channel = "0.11"
log = "0.4"
msg = {path = "../msg"}
rust-webvr = {version = "0.10.2", features = ["openvr", "vrexternal"]}
rust-webvr = {version = "0.11", features = ["openvr", "vrexternal"]}
script_traits = {path = "../script_traits"}
servo_config = {path = "../config"}
webvr_traits = {path = "../webvr_traits" }
2 changes: 1 addition & 1 deletion components/webvr_traits/Cargo.toml
Expand Up @@ -13,5 +13,5 @@ path = "lib.rs"
[dependencies]
ipc-channel = "0.11"
msg = {path = "../msg"}
rust-webvr-api = {version = "0.10.3", features = ["ipc"]}
rust-webvr-api = {version = "0.11", features = ["ipc"]}
serde = "1.0"
4 changes: 2 additions & 2 deletions ports/glutin/Cargo.toml
Expand Up @@ -46,13 +46,13 @@ bitflags = "1.0"
crossbeam-channel = "0.3"
euclid = "0.19"
gleam = "0.6"
glutin = "0.19"
glutin = "0.21.0"
keyboard-types = "0.4.3"
lazy_static = "1"
libservo = {path = "../../components/servo"}
libc = "0.2"
log = "0.4"
rust-webvr = { version = "0.10.2", features = ["glwindow"] }
rust-webvr = { version = "0.11", features = ["glwindow"] }
tinyfiledialogs = "3.0"

[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]
Expand Down
65 changes: 65 additions & 0 deletions ports/glutin/context.rs
@@ -0,0 +1,65 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 glutin::{WindowedContext, NotCurrent, PossiblyCurrent};

pub enum GlContext {
Current(WindowedContext<PossiblyCurrent>),
NotCurrent(WindowedContext<NotCurrent>),
// Used a temporary value as we switch from Current to NotCurrent.
None,
}

impl GlContext {
pub fn window(&self) -> &glutin::Window {
match self {
GlContext::Current(c) => c.window(),
GlContext::NotCurrent(c) => c.window(),
GlContext::None => unreachable!(),
}
}
pub fn make_current(&mut self) {
*self = match std::mem::replace(self, GlContext::None) {
GlContext::Current(c) => {
warn!("Making an already current context current");
GlContext::Current(c)
},
GlContext::NotCurrent(c) => {
let c = unsafe {
c.make_current().expect("Couldn't make window current")
};
GlContext::Current(c)
}
GlContext::None => unreachable!(),
}
}
pub fn make_not_current(&mut self) {
*self = match std::mem::replace(self, GlContext::None) {
GlContext::Current(c) => {
let c = unsafe {
c.make_not_current().expect("Couldn't make window not current")
};
GlContext::NotCurrent(c)
},
GlContext::NotCurrent(c) => {
warn!("Making an already not current context not current");
GlContext::NotCurrent(c)
}
GlContext::None => unreachable!(),
}
}
pub fn swap_buffers(&self) {
match self {
GlContext::Current(c) => {
if let Err(err) = c.swap_buffers() {
warn!("Failed to swap window buffers ({}).", err);
}
},
GlContext::NotCurrent(_) => {
error!("Context is not current. Forgot to call prepare_for_composite?");
},
GlContext::None => unreachable!(),
};
}
}
12 changes: 5 additions & 7 deletions ports/glutin/embedder.rs
Expand Up @@ -9,7 +9,6 @@ use crate::events_loop::EventsLoop;
use gleam::gl;
use glutin;
use glutin::dpi::LogicalSize;
use glutin::{ContextBuilder, GlWindow};
use rust_webvr::GlWindowVRService;
use servo::compositing::windowing::EmbedderMethods;
use servo::embedder_traits::EventLoopWaker;
Expand Down Expand Up @@ -52,14 +51,13 @@ impl EmbedderMethods for EmbedderCallbacks {
.with_dimensions(size)
.with_visibility(false)
.with_multitouch();
let context_builder = ContextBuilder::new()
let context = glutin::ContextBuilder::new()
.with_gl(app::gl_version())
.with_vsync(false); // Assume the browser vsync is the same as the test VR window vsync
let gl_window =
GlWindow::new(window_builder, context_builder, &*self.events_loop.borrow().as_winit())
.expect("Failed to create window.");
.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, gl_window, gl);
let (service, heartbeat) = GlWindowVRService::new(name, context, gl);

services.register(Box::new(service));
heartbeats.push(Box::new(heartbeat));
Expand Down

0 comments on commit 9ba71d0

Please sign in to comment.