Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] 0.21 Api changes. #1129

Merged
merged 18 commits into from
Apr 2, 2019
16 changes: 13 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# Unreleased

- **Breaking**: Split `ContextTrait` into `ContextTrait` and `PossiblyCurrentContextTrait`.
- **Breaking**: Changed `WindowedContext` and `RawContext` into typedefs of
`ContextWrapper`.
- **Breaking**: Removed `new_windowed` and `new_headless` from `WindowedContext`
and `Context`, respectiveness.
- **Breaking**: Added two new types, `NotCurrentContext` and `PossiblyCurrentContext`,
which `RawContext`, `WindowedContext`, `ContextBuilder` and `Context` are now
generic over.
- Added `make_not_current` into `ContextTrait`.
- Added `treat_as_not_current` into `ContextTrait`.
- We now load `libGL.so` instead of `libGLX.so`.
- **Breaking**: Added `DisplayLost` variant to `ContextError`.
- Fixed bug where we drop the hidden window belonging to a headless context on
on X11 and/or Wayland before the actual context.
- "Fixed" bug where we will close `EGLDisplay`s while they are still in use by
others. Angry and/or salty rant can be found in `glutin/src/api/egl/mod.rs`,
- "Fixed" bug where we will close `EGLDisplay`s while they are still in use by
others. Angry and/or salty rant can be found in `glutin/src/api/egl/mod.rs`,
you can't miss it.

# Version 0.20.0 (2019-03-09)
Expand All @@ -22,7 +32,7 @@ OsMesa contexts via a separate extension.
- Added `ContextBuilder::build_{windowed,headless}` methods.
- **Breaking:** Renamed `Context::new` to `Context::new_headless`. `new_headless` now accepts dimensions for the off-screen surface backing it.
- **Breaking:** Renamed `GlWindow::new` to `WindowedContext::new_windowed`.
- On X11 and Wayland, you can now use shared contexts, however, one limitation
- On X11 and Wayland, you can now use shared contexts, however, one limitation
of the Wayland backend is that all shared contexts must use the same events
pool as each other.
- Added context sharing support to windows.
Expand Down
7 changes: 1 addition & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,5 @@ members = [
"glutin_glx_sys",
"glutin_wgl_sys",
"glutin_gles2_sys",
"glutin_emscripten_sys",
]

[replace]
"glutin_egl_sys:0.1.2" = { path = "glutin_egl_sys" }
"glutin_glx_sys:0.1.2" = { path = "glutin_glx_sys" }
"glutin_wgl_sys:0.1.2" = { path = "glutin_wgl_sys" }
"glutin_gles2_sys:0.1.2" = { path = "glutin_gles2_sys" }
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ See also [this documentation](https://kripken.github.io/emscripten-site/docs/api

### X11

The plan is that glutin tries to dynamically link-to and use wayland if possible. If it doesn't work, it will try xlib instead. If it doesn't work, it will try libcaca. This is work-in-progress.
The plan is that glutin tries to dynamically link-to and use wayland if possible. If it doesn't work, it will try xlib instead. This is work-in-progress.

### Wayland

Due to an issue with how mesa and Wayland play together, all shared contexts must use the same events pool as each other.
Expand Down
23 changes: 14 additions & 9 deletions glutin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ winit = "0.19"

[target.'cfg(target_os = "android")'.dependencies]
android_glue = "0.2"
glutin_egl_sys = "0.1.1"
glutin_egl_sys = { version = "0.1.2", path = "../glutin_egl_sys" }
parking_lot = "0.7"

[target.'cfg(target_os = "emscripten")'.dependencies]
glutin_emscripten_sys = { version = "0.1.0", path = "../glutin_emscripten_sys" }

[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
objc = "0.2"
glutin_gles2_sys = "0.1.1"
objc = "0.2.6"
glutin_gles2_sys = { version = "0.1.2", path = "../glutin_gles2_sys" }

[target.'cfg(target_os = "macos")'.dependencies]
cgl = "0.2"
Expand All @@ -46,15 +50,16 @@ features = [

[target.'cfg(target_os = "windows")'.dependencies]
libloading = "0.5"
glutin_wgl_sys = "0.1.1"
glutin_egl_sys = "0.1.1"
glutin_wgl_sys = { version = "0.1.2", path = "../glutin_wgl_sys" }
glutin_egl_sys = { version = "0.1.2", path = "../glutin_egl_sys" }
parking_lot = "0.7"

[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
osmesa-sys = "0.1"
wayland-client = { version = "0.21", features = ["egl", "dlopen"] }
libloading = "0.5"
shared_library = "0.1.1"
glutin_egl_sys = "0.1.1"
glutin_glx_sys = "0.1.1"
takeable-option = "0.3"
glutin_egl_sys = { version = "0.1.2", path = "../glutin_egl_sys" }
glutin_glx_sys = { version = "0.1.2", path = "../glutin_glx_sys" }
debug_stub_derive = "0.3"
takeable-option = "0.4"
parking_lot = "0.7"
30 changes: 23 additions & 7 deletions glutin/src/api/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ use glutin_egl_sys as ffi;
use winit;
use winit::dpi;
use winit::os::android::EventsLoopExt;
use parking_lot::Mutex;

use std::cell::Cell;
use std::sync::Arc;

#[derive(Debug)]
struct AndroidContext {
egl_context: EglContext,
stopped: Option<Cell<bool>>,
stopped: Option<Mutex<bool>>,
}

#[derive(Debug)]
Expand All @@ -37,7 +37,8 @@ impl android_glue::SyncEventHandler for AndroidSyncEventHandler {
// this situation. Set stop to true to prevent
// swap_buffer call race conditions.
android_glue::Event::TermWindow => {
self.0.stopped.as_ref().unwrap().set(true);
let mut stopped = self.0.stopped.as_ref().unwrap().lock();
*stopped = true;
}
_ => {
return;
Expand Down Expand Up @@ -65,15 +66,16 @@ impl Context {
.and_then(|p| p.finish(nwin as *const _))?;
let ctx = Arc::new(AndroidContext {
egl_context,
stopped: Some(Cell::new(false)),
stopped: Some(Mutex::new(false)),
});

let handler = Box::new(AndroidSyncEventHandler(ctx.clone()));
android_glue::add_sync_event_handler(handler);
let context = Context(ctx.clone());

el.set_suspend_callback(Some(Box::new(move |suspended| {
ctx.stopped.as_ref().unwrap().set(suspended);
let mut stopped = ctx.stopped.as_ref().unwrap().lock();
*stopped = suspended;
if suspended {
// Android has stopped the activity or sent it to background.
// Release the EGL surface and stop the animation loop.
Expand Down Expand Up @@ -114,14 +116,27 @@ impl Context {
#[inline]
pub unsafe fn make_current(&self) -> Result<(), ContextError> {
if let Some(ref stopped) = self.0.stopped {
if stopped.get() {
let stopped = stopped.lock();
if *stopped {
return Err(ContextError::ContextLost);
}
}

self.0.egl_context.make_current()
}

#[inline]
pub unsafe fn make_not_current(&self) -> Result<(), ContextError> {
if let Some(ref stopped) = self.0.stopped {
let stopped = stopped.lock();
if *stopped {
return Err(ContextError::ContextLost);
}
}

self.0.egl_context.make_not_current()
}

#[inline]
pub fn resize(&self, _: u32, _: u32) {}

Expand All @@ -138,7 +153,8 @@ impl Context {
#[inline]
pub fn swap_buffers(&self) -> Result<(), ContextError> {
if let Some(ref stopped) = self.0.stopped {
if stopped.get() {
let stopped = stopped.lock();
if *stopped {
return Err(ContextError::ContextLost);
}
}
Expand Down
23 changes: 0 additions & 23 deletions glutin/src/api/caca/ffi.rs

This file was deleted.

163 changes: 0 additions & 163 deletions glutin/src/api/caca/mod.rs

This file was deleted.

4 changes: 1 addition & 3 deletions glutin/src/api/egl/make_current_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ impl MakeCurrentGuard {

pub fn if_any_same_then_invalidate(
&mut self,
display: ffi::egl::types::EGLDisplay,
draw_surface: ffi::egl::types::EGLSurface,
read_surface: ffi::egl::types::EGLSurface,
context: ffi::egl::types::EGLContext,
) {
if self.possibly_invalid.is_some() {
let pi = self.possibly_invalid.as_ref().unwrap();
if self.old_display == display
|| pi.old_draw_surface == draw_surface
if pi.old_draw_surface == draw_surface
|| pi.old_read_surface == read_surface
|| pi.old_context == context
{
Expand Down
Loading