macOS crash fix attempt
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -82,7 +82,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "baseview"
|
name = "baseview"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/RustAudio/baseview#f7326ceab58c8dd75f3e10bc815ecf7d098e2efc"
|
source = "git+https://github.com/RustAudio/baseview?rev=237d323c729f3aa99476ba3efa50129c5e86cad3#237d323c729f3aa99476ba3efa50129c5e86cad3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa",
|
"cocoa",
|
||||||
"core-foundation",
|
"core-foundation",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ crate-type = ["cdylib"]
|
|||||||
ebu-dsp = { version = "0.1.0", path = "ebu-dsp" }
|
ebu-dsp = { version = "0.1.0", path = "ebu-dsp" }
|
||||||
nih_plug = { git = "https://github.com/robbert-vdh/nih-plug", version = "0.0.0", default-features = false }
|
nih_plug = { git = "https://github.com/robbert-vdh/nih-plug", version = "0.0.0", default-features = false }
|
||||||
parking_lot = "0.12.5"
|
parking_lot = "0.12.5"
|
||||||
baseview = { git = "https://github.com/RustAudio/baseview", version = "0.1.0", features = ["opengl"]}
|
baseview = { git = "https://github.com/RustAudio/baseview", rev = "237d323c729f3aa99476ba3efa50129c5e86cad3", features = ["opengl"]}
|
||||||
crossbeam = "0.8.4"
|
crossbeam = "0.8.4"
|
||||||
femtovg = "0.18.1"
|
femtovg = "0.18.1"
|
||||||
serde = { version = "1.0.228", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
|
|||||||
50
src/gui.rs
50
src/gui.rs
@@ -9,8 +9,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
const FRESHENER_IMAGE: &'static [u8] = include_bytes!("../assets/AirFreshener/sheet.png");
|
const FRESHENER_IMAGE: &'static [u8] = include_bytes!("../assets/AirFreshener/sheet.png");
|
||||||
const NOT_SO_FRESH_BG_IMAGE: &'static [u8] = include_bytes!("../assets/AirFreshener/bg0.png");
|
const NOT_SO_FRESH_BG_IMAGE: &'static [u8] = include_bytes!("../assets/AirFreshener/bg0.png");
|
||||||
const FRESH_DUMBLEDORE_BG_IMAGE: &'static [u8] =
|
const FRESH_DUMBLEDORE_BG_IMAGE: &'static [u8] = include_bytes!("../assets/AirFreshener/bg1.png");
|
||||||
include_bytes!("../assets/AirFreshener/bg1.png");
|
|
||||||
const FRESHENER_FRAMES: u32 = 256;
|
const FRESHENER_FRAMES: u32 = 256;
|
||||||
const FRESHENER_FRAMES_X: u32 = 20;
|
const FRESHENER_FRAMES_X: u32 = 20;
|
||||||
const FRESHENER_FRAMES_Y: u32 = 13;
|
const FRESHENER_FRAMES_Y: u32 = 13;
|
||||||
@@ -43,36 +42,33 @@ impl PluginGui {
|
|||||||
gui_context: Arc<dyn GuiContext>,
|
gui_context: Arc<dyn GuiContext>,
|
||||||
params: Arc<PluginParams>,
|
params: Arc<PluginParams>,
|
||||||
scaling_factor: f32,
|
scaling_factor: f32,
|
||||||
) -> Self {
|
) -> Result<Self, &'static str> {
|
||||||
let context = window
|
let context = window
|
||||||
.gl_context()
|
.gl_context()
|
||||||
.expect("Failed to get window OpenGL context");
|
.ok_or("Failed to get window OpenGL context")?;
|
||||||
unsafe {
|
unsafe {
|
||||||
context.make_current();
|
context.make_current();
|
||||||
}
|
}
|
||||||
let renderer = unsafe { OpenGl::new_from_function(|s| context.get_proc_address(s)) }
|
let renderer = unsafe { OpenGl::new_from_function(|s| context.get_proc_address(s)) }
|
||||||
.expect("Failed to create femtovg renderer");
|
.map_err(|_| "Failed to create femtovg renderer")?;
|
||||||
let mut canvas = Canvas::new(renderer).expect("Failed to create femtovg canvas");
|
let mut canvas = Canvas::new(renderer).map_err(|_| "Failed to create femtovg canvas")?;
|
||||||
let (width, height) = params.editor_state.size();
|
let (width, height) = params.editor_state.size();
|
||||||
|
|
||||||
canvas.set_size(width, height, scaling_factor);
|
canvas.set_size(width, height, scaling_factor);
|
||||||
let le_fresh = canvas
|
let le_fresh = canvas
|
||||||
.load_image_mem(FRESHENER_IMAGE, ImageFlags::empty())
|
.load_image_mem(FRESHENER_IMAGE, ImageFlags::empty())
|
||||||
.expect("Failed to load le fresh");
|
.map_err(|_| "Failed to load le fresh")?;
|
||||||
let not_so_fresh_image = canvas
|
let not_so_fresh_image = canvas
|
||||||
.load_image_mem(NOT_SO_FRESH_BG_IMAGE, ImageFlags::empty())
|
.load_image_mem(NOT_SO_FRESH_BG_IMAGE, ImageFlags::empty())
|
||||||
.expect("Failed to load not so fresh");
|
.map_err(|_| "Failed to load not so fresh")?;
|
||||||
let fresh_dumbledore_image = canvas
|
let fresh_dumbledore_image = canvas
|
||||||
.load_image_mem(FRESH_DUMBLEDORE_BG_IMAGE, ImageFlags::empty())
|
.load_image_mem(FRESH_DUMBLEDORE_BG_IMAGE, ImageFlags::empty())
|
||||||
.expect("Failed to load fresh dumbledore");
|
.map_err(|_| "Failed to load fresh dumbledore")?;
|
||||||
//let font = canvas
|
|
||||||
// .add_font_mem(DROID_SANS_FONT)
|
|
||||||
// .expect("Failed to load font");
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
context.make_not_current();
|
context.make_not_current();
|
||||||
}
|
}
|
||||||
Self {
|
Ok(Self {
|
||||||
//font,
|
//font,
|
||||||
params,
|
params,
|
||||||
canvas,
|
canvas,
|
||||||
@@ -92,7 +88,7 @@ impl PluginGui {
|
|||||||
width: FRESHENER_FRAME_WIDTH,
|
width: FRESHENER_FRAME_WIDTH,
|
||||||
height: FRESHENER_FRAME_HEIGHT,
|
height: FRESHENER_FRAME_HEIGHT,
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,9 +101,13 @@ impl WindowHandler for PluginGui {
|
|||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let context = window
|
let context = match window.gl_context() {
|
||||||
.gl_context()
|
None => {
|
||||||
.expect("Failed to get window OpenGL context");
|
nih_error!("No OpenGL context");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Some(ctx) => ctx,
|
||||||
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
context.make_current();
|
context.make_current();
|
||||||
}
|
}
|
||||||
@@ -177,22 +177,6 @@ impl WindowHandler for PluginGui {
|
|||||||
1.0,
|
1.0,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
/*
|
|
||||||
let debug = format!("{:#?}", self.params.comp_state.load());
|
|
||||||
for (i, line) in debug.split('\n').enumerate() {
|
|
||||||
self.canvas
|
|
||||||
.fill_text(
|
|
||||||
10.0,
|
|
||||||
10.0 + i as f32 * 12.5,
|
|
||||||
line,
|
|
||||||
&Paint::color(Color::rgbf(1.0, 1.0, 1.0))
|
|
||||||
.with_font(&[self.font])
|
|
||||||
.with_font_size(12.5)
|
|
||||||
.with_text_baseline(femtovg::Baseline::Top),
|
|
||||||
)
|
|
||||||
.expect("Failed to render font");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
self.canvas.flush();
|
self.canvas.flush();
|
||||||
context.swap_buffers();
|
context.swap_buffers();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::sync::{Arc, atomic::Ordering};
|
use std::sync::{Arc, atomic::Ordering};
|
||||||
use baseview::{Window, WindowOpenOptions, WindowScalePolicy, gl::GlConfig};
|
use baseview::{Window, WindowOpenOptions, WindowScalePolicy, gl::GlConfig};
|
||||||
use crossbeam::atomic::AtomicCell;
|
use crossbeam::atomic::AtomicCell;
|
||||||
use nih_plug::{editor::Editor, plugin::Plugin};
|
use nih_plug::{editor::Editor, nih_error, plugin::Plugin};
|
||||||
use crate::{AirFreshener, editor::EditorHandle, parameters::PluginParams, gui::PluginGui};
|
use crate::{AirFreshener, editor::EditorHandle, parameters::PluginParams, gui::PluginGui};
|
||||||
|
|
||||||
pub struct EditorWindow {
|
pub struct EditorWindow {
|
||||||
@@ -49,7 +49,10 @@ impl Editor for EditorWindow {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
}, move |window: &mut baseview::Window<'_>| -> PluginGui {
|
}, move |window: &mut baseview::Window<'_>| -> PluginGui {
|
||||||
PluginGui::new(window, gui_context, params, scaling_factor.unwrap_or(1.0))
|
match PluginGui::new(window, gui_context, params, scaling_factor.unwrap_or(1.0)) {
|
||||||
|
Err(err) => { nih_error!("Failed to create plugin: {err}"); panic!("{err}"); }
|
||||||
|
Ok(plug) => plug
|
||||||
|
}
|
||||||
});
|
});
|
||||||
self.params.editor_state.open.store(true, Ordering::Release);
|
self.params.editor_state.open.store(true, Ordering::Release);
|
||||||
Box::new(EditorHandle {
|
Box::new(EditorHandle {
|
||||||
|
|||||||
Reference in New Issue
Block a user