1 /*
2  * GStreamer
3  * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
4  * Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef __GST_VULKAN_WINDOW_H__
23 #define __GST_VULKAN_WINDOW_H__
24 
25 #include <gst/gst.h>
26 
27 #include <vk.h>
28 
29 G_BEGIN_DECLS
30 
31 #define GST_TYPE_VULKAN_WINDOW         (gst_vulkan_window_get_type())
32 #define GST_VULKAN_WINDOW(o)           (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_VULKAN_WINDOW, GstVulkanWindow))
33 #define GST_VULKAN_WINDOW_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GST_TYPE_VULKAN_WINDOW, GstVulkanWindowClass))
34 #define GST_IS_VULKAN_WINDOW(o)        (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_VULKAN_WINDOW))
35 #define GST_IS_VULKAN_WINDOW_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_VULKAN_WINDOW))
36 #define GST_VULKAN_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_VULKAN_WINDOW, GstVulkanWindowClass))
37 GType gst_vulkan_window_get_type     (void);
38 
39 #define GST_VULKAN_WINDOW_LOCK(w) g_mutex_lock(&GST_VULKAN_WINDOW(w)->lock)
40 #define GST_VULKAN_WINDOW_UNLOCK(w) g_mutex_unlock(&GST_VULKAN_WINDOW(w)->lock)
41 #define GST_VULKAN_WINDOW_GET_LOCK(w) (&GST_VULKAN_WINDOW(w)->lock)
42 
43 #define GST_VULKAN_WINDOW_ERROR (gst_vulkan_window_error_quark ())
44 GQuark gst_vulkan_window_error_quark (void);
45 
46 typedef enum
47 {
48   GST_VULKAN_WINDOW_ERROR_FAILED,
49   GST_VULKAN_WINDOW_ERROR_OLD_LIBS,
50   GST_VULKAN_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
51 } GstVulkanWindowError;
52 
53 /**
54  * GstVulkanWindow:
55  *
56  * #GstVulkanWindow is an opaque struct and should only be accessed through the
57  * provided api.
58  */
59 struct _GstVulkanWindow {
60   /*< private >*/
61   GstObject parent;
62 
63   GstVulkanDisplay       *display;
64 
65   GMutex                  lock;
66 
67   GstVulkanWindowPrivate *priv;
68 
69   gpointer                _reserved[GST_PADDING];
70 };
71 
72 /**
73  * GstVulkanWindowClass:
74  * @parent_class: Parent class
75  * @open: open the connection to the display
76  * @close: close the connection to the display
77  */
78 struct _GstVulkanWindowClass {
79   GstObjectClass parent_class;
80 
81   gboolean      (*open)                         (GstVulkanWindow *window,
82                                                  GError **error);
83   void          (*close)                        (GstVulkanWindow *window);
84 
85   VkSurfaceKHR  (*get_surface)                  (GstVulkanWindow *window,
86                                                  GError **error);
87   gboolean      (*get_presentation_support)     (GstVulkanWindow *window,
88                                                  GstVulkanDevice *device,
89                                                  guint32 queue_family_idx);
90   void          (*set_window_handle)            (GstVulkanWindow *window,
91                                                  guintptr handle);
92 
93   /*< private >*/
94   gpointer _reserved[GST_PADDING];
95 };
96 
97 GstVulkanWindow *  gst_vulkan_window_new                            (GstVulkanDisplay *display);
98 
99 GstVulkanDisplay * gst_vulkan_window_get_display                    (GstVulkanWindow *window);
100 VkSurfaceKHR       gst_vulkan_window_get_surface                    (GstVulkanWindow *window,
101                                                                      GError **error);
102 gboolean           gst_vulkan_window_get_presentation_support       (GstVulkanWindow *window,
103                                                                      GstVulkanDevice *device,
104                                                                      guint32 queue_family_idx);
105 void               gst_vulkan_window_set_window_handle              (GstVulkanWindow *window,
106                                                                      guintptr handle);
107 
108 gboolean           gst_vulkan_window_open                           (GstVulkanWindow *window,
109                                                                      GError ** error);
110 void               gst_vulkan_window_close                          (GstVulkanWindow *window);
111 
112 void               gst_vulkan_window_resize                         (GstVulkanWindow *window,
113                                                                      gint width,
114                                                                      gint height);
115 void               gst_vulkan_window_redraw                         (GstVulkanWindow *window);
116 
117 G_END_DECLS
118 
119 #endif /* __GST_VULKAN_WINDOW_H__ */
120