Skip to content

Commit

Permalink
Add Generic Buffer Manager handles
Browse files Browse the repository at this point in the history
  • Loading branch information
kchibisov authored Jul 14, 2022
1 parent e712ea2 commit e4496bb
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* **Breaking:** The `RawWindowHandle` variants were split into `RawDisplayHandle` and `RawWindowHandle`.
* The X11 screen is now present in new `XlibDisplayHandle` and `XcbDisplayHandle`.
- Add GBM support.

## 0.4.3 (2022-03-29)

Expand Down
16 changes: 14 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ pub use haiku::{HaikuDisplayHandle, HaikuWindowHandle};
pub use redox::{OrbitalDisplayHandle, OrbitalWindowHandle};
pub use uikit::{UiKitDisplayHandle, UiKitWindowHandle};
pub use unix::{
DrmDisplayHandle, DrmWindowHandle, WaylandDisplayHandle, WaylandWindowHandle, XcbDisplayHandle,
XcbWindowHandle, XlibDisplayHandle, XlibWindowHandle,
DrmDisplayHandle, DrmWindowHandle, GbmDisplayHandle, GbmWindowHandle, WaylandDisplayHandle,
WaylandWindowHandle, XcbDisplayHandle, XcbWindowHandle, XlibDisplayHandle, XlibWindowHandle,
};
pub use web::{WebDisplayHandle, WebWindowHandle};
pub use windows::{Win32WindowHandle, WinRtWindowHandle, WindowsDisplayHandle};
Expand Down Expand Up @@ -143,6 +143,12 @@ pub enum RawWindowHandle {
/// ## Availability Hints
/// This variant is used on Linux when neither X nor Wayland are available
Drm(DrmWindowHandle),
/// A raw window handle for the Linux Generic Buffer Manager.
///
/// ## Availability Hints
/// This variant is present regardless of windowing backend and likely to be used with
/// EGL_MESA_platfrom_gbm or EGL_KHR_platfrom_gbm.
Gbm(GbmWindowHandle),
/// A raw window handle for Win32.
///
/// ## Availability Hints
Expand Down Expand Up @@ -272,6 +278,12 @@ pub enum RawDisplayHandle {
/// ## Availability Hints
/// This variant is used on Linux when neither X nor Wayland are available
Drm(DrmDisplayHandle),
/// A raw display handle for the Linux Generic Buffer Manager.
///
/// ## Availability Hints
/// This variant is present regardless of windowing backend and likely to be used with
/// EGL_MESA_platfrom_gbm or EGL_KHR_platfrom_gbm.
Gbm(GbmDisplayHandle),
/// A raw display handle for Win32.
///
/// ## Availability Hints
Expand Down
46 changes: 46 additions & 0 deletions src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,36 @@ pub struct DrmWindowHandle {
pub plane: u32,
}

/// Raw display handle for the Linux Generic Buffer Manager.
///
/// ## Construction
/// ```
/// # use raw_window_handle::GbmDisplayHandle;
/// let display_handle = GbmDisplayHandle::empty();
/// /* set fields */
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct GbmDisplayHandle {
/// The gbm device.
pub gbm_device: *mut c_void,
}

/// Raw window handle for the Linux Generic Buffer Manager.
///
/// ## Construction
/// ```
/// # use raw_window_handle::GbmWindowHandle;
/// let handle = GbmWindowHandle::empty();
/// /* set fields */
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct GbmWindowHandle {
/// The gbm surface.
pub gbm_surface: *mut c_void,
}

impl XlibDisplayHandle {
pub fn empty() -> Self {
Self {
Expand Down Expand Up @@ -204,3 +234,19 @@ impl DrmWindowHandle {
Self { plane: 0 }
}
}

impl GbmDisplayHandle {
pub fn empty() -> Self {
Self {
gbm_device: ptr::null_mut(),
}
}
}

impl GbmWindowHandle {
pub fn empty() -> Self {
Self {
gbm_surface: ptr::null_mut(),
}
}
}

0 comments on commit e4496bb

Please sign in to comment.