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 /// Represents the platform-specific Vulkan draw context.
18 ///
19 /// [`VulkanContext`][crate::VulkanContext]s are created for a surface using
20 /// [`SurfaceExt::create_vulkan_context()`][crate::prelude::SurfaceExt::create_vulkan_context()], and the context will match
21 /// the characteristics of the surface.
22 ///
23 /// Support for [`VulkanContext`][crate::VulkanContext] is platform-specific and context creation
24 /// can fail, returning [`None`] context.
25 ///
26 /// This is an Abstract Base Class, you cannot instantiate it.
27 ///
28 /// ## Signals
29 ///
30 ///
31 /// #### `images-updated`
32 /// Emitted when the images managed by this context have changed.
33 ///
34 /// Usually this means that the swapchain had to be recreated,
35 /// for example in response to a change of the surface size.
36 ///
37 ///
38 ///
39 /// # Implements
40 ///
41 /// [`DrawContextExt`][trait@crate::prelude::DrawContextExt], [`trait@gio::prelude::InitableExt`], [`DrawContextExtManual`][trait@crate::prelude::DrawContextExtManual]
42 #[doc(alias = "GdkVulkanContext")]
43 pub struct VulkanContext(Object<ffi::GdkVulkanContext>) @extends DrawContext, @implements gio::Initable;
44
45 match fn {
46 type_ => || ffi::gdk_vulkan_context_get_type(),
47 }
48}
49
50impl VulkanContext {
51 /// Emitted when the images managed by this context have changed.
52 ///
53 /// Usually this means that the swapchain had to be recreated,
54 /// for example in response to a change of the surface size.
55 #[doc(alias = "images-updated")]
56 pub fn connect_images_updated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
57 unsafe extern "C" fn images_updated_trampoline<F: Fn(&VulkanContext) + 'static>(
58 this: *mut ffi::GdkVulkanContext,
59 f: glib::ffi::gpointer,
60 ) {
61 let f: &F = &*(f as *const F);
62 f(&from_glib_borrow(this))
63 }
64 unsafe {
65 let f: Box_<F> = Box_::new(f);
66 connect_raw(
67 self.as_ptr() as *mut _,
68 c"images-updated".as_ptr() as *const _,
69 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
70 images_updated_trampoline::<F> as *const (),
71 )),
72 Box_::into_raw(f),
73 )
74 }
75 }
76}