1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-10 15:04:32 +03:00
This commit is contained in:
Wez Furlong 2019-10-12 08:51:48 -07:00
parent 41e392fc79
commit bfc09299d8
2 changed files with 9 additions and 8 deletions

View File

@ -8,7 +8,8 @@ use ::window::*;
use failure::Fallible;
use promise::{BasicExecutor, Executor, SpawnFunc};
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
mod termwindow;
@ -17,16 +18,16 @@ pub struct SoftwareFrontEnd {
}
lazy_static::lazy_static! {
static ref USE_OPENGL: Mutex<bool> = Mutex::new(true);
static ref USE_OPENGL: AtomicBool = AtomicBool::new(true);
}
pub fn is_opengl_enabled() -> bool {
*USE_OPENGL.lock().unwrap()
USE_OPENGL.load(Ordering::Acquire)
}
impl SoftwareFrontEnd {
pub fn try_new_no_opengl(mux: &Rc<Mux>) -> Fallible<Rc<dyn FrontEnd>> {
*USE_OPENGL.lock().unwrap() = false;
USE_OPENGL.store(false, Ordering::Release);
Self::try_new(mux)
}

View File

@ -395,13 +395,13 @@ impl RenderState {
) -> Fallible<()> {
match self {
RenderState::Software(software) => {
let size = size.unwrap_or(software.glyph_cache.borrow().atlas.size());
let size = size.unwrap_or_else(|| software.glyph_cache.borrow().atlas.size());
let mut glyph_cache = GlyphCache::new(fonts, size);
software.util_sprites = UtilSprites::new(&mut glyph_cache, metrics)?;
*software.glyph_cache.borrow_mut() = glyph_cache;
}
RenderState::GL(gl) => {
let size = size.unwrap_or(gl.glyph_cache.borrow().atlas.size());
let size = size.unwrap_or_else(|| gl.glyph_cache.borrow().atlas.size());
let mut glyph_cache = GlyphCache::new_gl(&gl.context, fonts, size)?;
gl.util_sprites = UtilSprites::new(&mut glyph_cache, metrics)?;
*gl.glyph_cache.borrow_mut() = glyph_cache;
@ -720,7 +720,7 @@ impl TermWindow {
window.show();
if super::is_opengl_enabled() {
window.enable_opengl(|any, window, maybe_ctx| {
window.enable_opengl(|any, _window, maybe_ctx| {
let termwindow = any.downcast_ref::<TermWindow>().expect("to be TermWindow");
log::error!("I should use opengl");
@ -732,7 +732,7 @@ impl TermWindow {
&termwindow.render_metrics,
ATLAS_SIZE,
) {
Ok(gl) => {
Ok(_) => {
log::error!("OpenGL initialized!");
}
Err(err) => {