window+gui: migrate prefer_egl to WindowConfiguration

This commit is contained in:
Wez Furlong committed 2020-12-27 22:06:04 -08:00
1 parent 228356105e
commit cd997cbe48
6 files changed
+13 -19

No files matched your search

-4
View File
@@ -38,10 +38,6 @@ impl GuiFrontEnd {
}
pub fn try_new() -> anyhow::Result<Rc<GuiFrontEnd>> {
let config = config::configuration();
prefer_egl(config.prefer_egl);
#[cfg(windows)]
{
if is_running_in_rdp_session() {
+4
View File
@@ -15,4 +15,8 @@ impl WindowConfiguration for ConfigBridge {
fn enable_wayland(&self) -> bool {
configuration().enable_wayland
}
fn prefer_egl(&self) -> bool {
configuration().prefer_egl
}
}
+4
View File
@@ -12,6 +12,10 @@ pub trait WindowConfiguration {
fn enable_wayland(&self) -> bool {
true
}
fn prefer_egl(&self) -> bool {
true
}
}
lazy_static::lazy_static! {
-9
View File
@@ -301,7 +301,6 @@ pub trait WindowOpsMut {
}
static PREFER_SWRAST: AtomicBool = AtomicBool::new(false);
static PREFER_EGL: AtomicBool = AtomicBool::new(true);
pub fn prefer_swrast() {
PREFER_SWRAST.store(true, Ordering::Release);
@@ -310,11 +309,3 @@ pub fn prefer_swrast() {
pub fn is_swrast_preferred() -> bool {
PREFER_SWRAST.load(Ordering::Acquire)
}
pub fn prefer_egl(value: bool) {
PREFER_EGL.store(value, Ordering::Release);
}
pub fn is_egl_preferred() -> bool {
PREFER_EGL.load(Ordering::Acquire)
}
+4 -5
View File
@@ -6,10 +6,9 @@ use crate::bitmaps::Image;
use crate::connection::ConnectionOps;
use crate::os::macos::bitmap::BitmapRef;
use crate::{
config, is_egl_preferred, BitmapImage, Clipboard, Color, Connection, Dimensions, KeyCode,
KeyEvent, Modifiers, MouseButtons, MouseCursor, MouseEvent, MouseEventKind, MousePress,
Operator, PaintContext, Point, Rect, ScreenPoint, Size, WindowCallbacks, WindowOps,
WindowOpsMut,
config, BitmapImage, Clipboard, Color, Connection, Dimensions, KeyCode, KeyEvent, Modifiers,
MouseButtons, MouseCursor, MouseEvent, MouseEventKind, MousePress, Operator, PaintContext,
Point, Rect, ScreenPoint, Size, WindowCallbacks, WindowOps, WindowOpsMut,
};
use anyhow::{anyhow, bail, ensure};
use cocoa::appkit::{
@@ -132,7 +131,7 @@ mod opengl {
};
// Let's first try to initialize EGL...
let (context, backend) = match if is_egl_preferred() {
let (context, backend) = match if config().prefer_egl() {
// ANGLE wants a layer, so tell the view to create one.
// Importantly, we must set its scale to 1.0 prior to initializing
// EGL to prevent undesirable scaling.
+1 -1
View File
@@ -128,7 +128,7 @@ impl WindowInner {
let window = Window(self.hwnd);
let conn = Connection::get().unwrap();
let gl_state = if crate::is_egl_preferred() {
let gl_state = if config().prefer_egl() {
match conn.gl_connection.borrow().as_ref() {
None => crate::egl::GlState::create(None, self.hwnd.0),
Some(glconn) => {