gdk4/auto/
vulkan_context.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, DrawContext};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// GTK does not expose any Vulkan internals. This
16    ///   struct is a leftover that was accidentally exposed.
17    /// [`VulkanContext`][crate::VulkanContext] is an object representing the platform-specific
18    /// Vulkan draw context.
19    ///
20    /// [`VulkanContext`][crate::VulkanContext]s are created for a surface using
21    /// [`SurfaceExt::create_vulkan_context()`][crate::prelude::SurfaceExt::create_vulkan_context()], and the context will match
22    /// the characteristics of the surface.
23    ///
24    /// Support for [`VulkanContext`][crate::VulkanContext] is platform-specific and context creation
25    /// can fail, returning [`None`] context.
26    ///
27    /// This is an Abstract Base Class, you cannot instantiate it.
28    ///
29    /// ## Signals
30    ///
31    ///
32    /// #### `images-updated`
33    ///  Emitted when the images managed by this context have changed.
34    ///
35    /// Usually this means that the swapchain had to be recreated,
36    /// for example in response to a change of the surface size.
37    ///
38    ///
39    ///
40    /// # Implements
41    ///
42    /// [`DrawContextExt`][trait@crate::prelude::DrawContextExt], [`trait@gio::prelude::InitableExt`], [`DrawContextExtManual`][trait@crate::prelude::DrawContextExtManual]
43    #[doc(alias = "GdkVulkanContext")]
44    pub struct VulkanContext(Object<ffi::GdkVulkanContext>) @extends DrawContext, @implements gio::Initable;
45
46    match fn {
47        type_ => || ffi::gdk_vulkan_context_get_type(),
48    }
49}
50
51impl VulkanContext {
52    /// Emitted when the images managed by this context have changed.
53    ///
54    /// Usually this means that the swapchain had to be recreated,
55    /// for example in response to a change of the surface size.
56    #[doc(alias = "images-updated")]
57    pub fn connect_images_updated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
58        unsafe extern "C" fn images_updated_trampoline<F: Fn(&VulkanContext) + 'static>(
59            this: *mut ffi::GdkVulkanContext,
60            f: glib::ffi::gpointer,
61        ) {
62            let f: &F = &*(f as *const F);
63            f(&from_glib_borrow(this))
64        }
65        unsafe {
66            let f: Box_<F> = Box_::new(f);
67            connect_raw(
68                self.as_ptr() as *mut _,
69                b"images-updated\0".as_ptr() as *const _,
70                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
71                    images_updated_trampoline::<F> as *const (),
72                )),
73                Box_::into_raw(f),
74            )
75        }
76    }
77}