Skip to main content

gstreamer_vulkan_wayland/
vulkan_display_wayland.rs

1// Copyright (C) 2024 Matthew Waters <matthew@centricular.com>
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9use glib::{ffi::gpointer, translate::*};
10use libc::uintptr_t;
11
12use crate::VulkanDisplayWayland;
13use crate::ffi;
14
15impl VulkanDisplayWayland {
16    /// Creates a new display connection from a wl_display Display.
17    /// ## `display`
18    /// an existing, wayland display
19    ///
20    /// # Returns
21    ///
22    /// a new [`VulkanDisplayWayland`][crate::VulkanDisplayWayland]
23    pub unsafe fn with_display(
24        display: uintptr_t,
25    ) -> Result<VulkanDisplayWayland, glib::error::BoolError> {
26        unsafe {
27            from_glib_full::<_, Option<VulkanDisplayWayland>>(
28                ffi::gst_vulkan_display_wayland_new_with_display(display as gpointer),
29            )
30            .ok_or_else(|| glib::bool_error!("Failed to create new Wayland Vulkan display"))
31        }
32    }
33}