|
3 | 3 | use crate::{GLContext, GLTextureBuilder, MemoryFormat, Texture};
|
4 | 4 | use glib::{prelude::*, translate::*};
|
5 | 5 |
|
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; |
15 | 8 |
|
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; |
21 | 11 |
|
22 | 12 | impl GLTextureBuilder {
|
23 | 13 | #[doc(alias = "gdk_gl_texture_builder_build")]
|
@@ -131,20 +121,20 @@ impl GLTextureBuilder {
|
131 | 121 |
|
132 | 122 | #[doc(alias = "gdk_gl_texture_builder_get_sync")]
|
133 | 123 | #[doc(alias = "get_sync")]
|
134 |
| - pub fn sync(&self) -> Option<GLSync> { |
| 124 | + pub fn sync(&self) -> Option<GLsync> { |
135 | 125 | let ptr = unsafe { ffi::gdk_gl_texture_builder_get_sync(self.to_glib_none().0) };
|
136 | 126 | if ptr.is_null() {
|
137 | 127 | None
|
138 | 128 | } else {
|
139 |
| - unsafe { Some(GLSync::from_ptr(ptr)) } |
| 129 | + Some(ptr as _) |
140 | 130 | }
|
141 | 131 | }
|
142 | 132 |
|
143 | 133 | #[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()); |
146 | 136 | 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 _); |
148 | 138 | }
|
149 | 139 |
|
150 | 140 | self
|
|
0 commit comments