mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-10-28 14:14:23 +00:00
refactor: egl cxt teardown
This commit is contained in:
parent
6621db62c8
commit
87fc46750c
1 changed files with 14 additions and 2 deletions
|
|
@ -26,8 +26,8 @@ use std::{
|
||||||
use wayland_client::backend::ObjectId;
|
use wayland_client::backend::ObjectId;
|
||||||
|
|
||||||
pub struct EGLContext {
|
pub struct EGLContext {
|
||||||
context: PossiblyCurrentContext,
|
|
||||||
surface: Surface<WindowSurface>,
|
surface: Surface<WindowSurface>,
|
||||||
|
context: PossiblyCurrentContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -105,7 +105,7 @@ impl EGLContextBuilder {
|
||||||
.make_current(&surface)
|
.make_current(&surface)
|
||||||
.map_err(|e| LayerShikaError::EGLContextCreation(format!("Unable to activate EGL context: {e}. This may indicate a problem with the graphics drivers.")))?;
|
.map_err(|e| LayerShikaError::EGLContextCreation(format!("Unable to activate EGL context: {e}. This may indicate a problem with the graphics drivers.")))?;
|
||||||
|
|
||||||
Ok(EGLContext { context, surface })
|
Ok(EGLContext { surface, context })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,6 +124,18 @@ impl EGLContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for EGLContext {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if self.context.is_current() {
|
||||||
|
if let Err(e) = self.context.make_not_current_in_place() {
|
||||||
|
log::error!("Failed to make EGL context not current during cleanup: {e}");
|
||||||
|
} else {
|
||||||
|
log::debug!("Successfully made EGL context not current during cleanup");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn create_wayland_display_handle(display_id: &ObjectId) -> Result<RawDisplayHandle> {
|
fn create_wayland_display_handle(display_id: &ObjectId) -> Result<RawDisplayHandle> {
|
||||||
let display = NonNull::new(display_id.as_ptr().cast::<c_void>()).ok_or_else(|| {
|
let display = NonNull::new(display_id.as_ptr().cast::<c_void>()).ok_or_else(|| {
|
||||||
LayerShikaError::InvalidInput("Failed to create NonNull pointer for display".into())
|
LayerShikaError::InvalidInput("Failed to create NonNull pointer for display".into())
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue