Skip to content

Commit 3a22568

Browse files
elmarcobilelmoussaoui
authored andcommitted
gdk: use gl::types::GLsync
Signed-off-by: Marc-André Lureau <[email protected]>
1 parent b93098f commit 3a22568

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

gdk4/src/gl_texture_builder.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,11 @@
33
use crate::{GLContext, GLTextureBuilder, MemoryFormat, Texture};
44
use glib::{prelude::*, translate::*};
55

6-
// TODO add a feature for a "common" GL binding instead
7-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
8-
pub struct GLSync(*mut libc::c_void);
9-
10-
impl GLSync {
11-
#[inline]
12-
pub unsafe fn from_ptr(ptr: *mut libc::c_void) -> Self {
13-
Self(ptr)
14-
}
6+
#[cfg(not(feature = "gl"))]
7+
pub type GLsync = *const libc::c_void;
158

16-
#[inline]
17-
pub fn as_ptr(&self) -> *mut libc::c_void {
18-
self.0
19-
}
20-
}
9+
#[cfg(feature = "gl")]
10+
pub use gl::types::GLsync;
2111

2212
impl GLTextureBuilder {
2313
#[doc(alias = "gdk_gl_texture_builder_build")]
@@ -131,20 +121,20 @@ impl GLTextureBuilder {
131121

132122
#[doc(alias = "gdk_gl_texture_builder_get_sync")]
133123
#[doc(alias = "get_sync")]
134-
pub fn sync(&self) -> Option<GLSync> {
124+
pub fn sync(&self) -> Option<GLsync> {
135125
let ptr = unsafe { ffi::gdk_gl_texture_builder_get_sync(self.to_glib_none().0) };
136126
if ptr.is_null() {
137127
None
138128
} else {
139-
unsafe { Some(GLSync::from_ptr(ptr)) }
129+
Some(ptr as _)
140130
}
141131
}
142132

143133
#[doc(alias = "gdk_gl_texture_builder_set_sync")]
144-
pub fn set_sync(self, sync: Option<GLSync>) -> Self {
145-
let ptr = sync.map(|s| s.as_ptr()).unwrap_or(std::ptr::null_mut());
134+
pub fn set_sync(self, sync: Option<GLsync>) -> Self {
135+
let ptr = sync.unwrap_or(std::ptr::null());
146136
unsafe {
147-
ffi::gdk_gl_texture_builder_set_sync(self.to_glib_none().0, ptr);
137+
ffi::gdk_gl_texture_builder_set_sync(self.to_glib_none().0, ptr as _);
148138
}
149139

150140
self

0 commit comments

Comments
 (0)