2015-10-24 06:29:05 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
2019-04-11 06:52:54 +00:00
|
|
|
* Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
|
2015-10-24 06:29:05 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2017-03-08 18:01:13 +00:00
|
|
|
* SECTION:vkwindow
|
2015-10-24 06:29:05 +00:00
|
|
|
* @title: GstVulkanWindow
|
2019-04-11 06:52:54 +00:00
|
|
|
* @short_description: window/surface abstraction
|
|
|
|
* @see_also: #GstVulkanDisplay
|
2015-10-24 06:29:05 +00:00
|
|
|
*
|
|
|
|
* GstVulkanWindow represents a window that elements can render into. A window can
|
|
|
|
* either be a user visible window (onscreen) or hidden (offscreen).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gmodule.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2019-04-08 11:35:22 +00:00
|
|
|
#include "gstvkwindow.h"
|
2015-10-24 06:29:05 +00:00
|
|
|
|
|
|
|
#if GST_VULKAN_HAVE_WINDOW_XCB
|
2019-04-08 11:35:22 +00:00
|
|
|
#include "xcb/gstvkwindow_xcb.h"
|
2015-10-24 06:29:05 +00:00
|
|
|
#endif
|
2016-04-10 07:46:15 +00:00
|
|
|
#if GST_VULKAN_HAVE_WINDOW_WAYLAND
|
2019-04-08 11:35:22 +00:00
|
|
|
#include "wayland/gstvkwindow_wayland.h"
|
2016-04-10 07:46:15 +00:00
|
|
|
#endif
|
2019-03-25 06:50:13 +00:00
|
|
|
#if GST_VULKAN_HAVE_WINDOW_COCOA
|
2019-04-08 11:35:22 +00:00
|
|
|
#include "cocoa/gstvkwindow_cocoa.h"
|
2019-03-25 06:50:13 +00:00
|
|
|
#endif
|
2019-03-27 06:56:28 +00:00
|
|
|
#if GST_VULKAN_HAVE_WINDOW_IOS
|
2019-04-08 11:35:22 +00:00
|
|
|
#include "ios/gstvkwindow_ios.h"
|
2019-03-27 06:56:28 +00:00
|
|
|
#endif
|
2019-06-08 13:57:21 +00:00
|
|
|
#if GST_VULKAN_HAVE_WINDOW_WIN32
|
|
|
|
#include "win32/gstvkwindow_win32.h"
|
|
|
|
#endif
|
2019-10-16 06:17:51 +00:00
|
|
|
#if GST_VULKAN_HAVE_WINDOW_ANDROID
|
|
|
|
#include "android/gstvkwindow_android.h"
|
|
|
|
#endif
|
2015-10-24 06:29:05 +00:00
|
|
|
|
|
|
|
#define GST_CAT_DEFAULT gst_vulkan_window_debug
|
|
|
|
GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
|
|
|
|
|
|
|
|
struct _GstVulkanWindowPrivate
|
|
|
|
{
|
|
|
|
guint surface_width;
|
|
|
|
guint surface_height;
|
|
|
|
};
|
|
|
|
|
2019-11-06 15:41:10 +00:00
|
|
|
#define GET_PRIV(window) gst_vulkan_window_get_instance_private (window)
|
|
|
|
|
2018-06-23 22:17:26 +00:00
|
|
|
#define gst_vulkan_window_parent_class parent_class
|
|
|
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GstVulkanWindow, gst_vulkan_window,
|
|
|
|
GST_TYPE_OBJECT);
|
|
|
|
|
2015-10-24 06:29:05 +00:00
|
|
|
static void gst_vulkan_window_finalize (GObject * object);
|
|
|
|
|
|
|
|
typedef struct _GstVulkanDummyWindow
|
|
|
|
{
|
|
|
|
GstVulkanWindow parent;
|
|
|
|
|
|
|
|
guintptr handle;
|
|
|
|
} GstVulkanDummyWindow;
|
|
|
|
|
|
|
|
typedef struct _GstVulkanDummyWindowCass
|
|
|
|
{
|
|
|
|
GstVulkanWindowClass parent;
|
|
|
|
} GstVulkanDummyWindowClass;
|
|
|
|
|
|
|
|
GstVulkanDummyWindow *gst_vulkan_dummy_window_new (void);
|
|
|
|
|
2019-07-05 06:20:05 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_DISPLAY,
|
|
|
|
};
|
|
|
|
|
2015-10-24 06:29:05 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SIGNAL_0,
|
2015-12-01 05:28:28 +00:00
|
|
|
SIGNAL_CLOSE,
|
2015-12-01 07:37:34 +00:00
|
|
|
SIGNAL_DRAW,
|
2019-08-09 04:49:24 +00:00
|
|
|
SIGNAL_RESIZE,
|
2020-02-17 04:03:34 +00:00
|
|
|
SIGNAL_MOUSE_EVENT,
|
|
|
|
SIGNAL_KEY_EVENT,
|
2015-10-24 06:29:05 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2015-12-01 05:28:28 +00:00
|
|
|
static guint gst_vulkan_window_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_accum_logical_and (GSignalInvocationHint * ihint, GValue * return_accu,
|
|
|
|
const GValue * handler_return, gpointer data)
|
|
|
|
{
|
|
|
|
gboolean val = g_value_get_boolean (handler_return);
|
|
|
|
gboolean val2 = g_value_get_boolean (return_accu);
|
|
|
|
|
|
|
|
g_value_set_boolean (return_accu, val && val2);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2015-10-24 06:29:05 +00:00
|
|
|
|
|
|
|
GQuark
|
|
|
|
gst_vulkan_window_error_quark (void)
|
|
|
|
{
|
|
|
|
return g_quark_from_static_string ("gst-gl-window-error-quark");
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_vulkan_window_default_open (GstVulkanWindow * window, GError ** error)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vulkan_window_default_close (GstVulkanWindow * window)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_init_debug (void)
|
|
|
|
{
|
|
|
|
static volatile gsize _init = 0;
|
|
|
|
|
|
|
|
if (g_once_init_enter (&_init)) {
|
|
|
|
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "vulkanwindow", 0,
|
|
|
|
"Vulkan Window");
|
|
|
|
g_once_init_leave (&_init, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-05 06:20:05 +00:00
|
|
|
static void
|
|
|
|
gst_vulkan_window_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstVulkanWindow *window = GST_VULKAN_WINDOW (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_DISPLAY:
|
|
|
|
window->display = g_value_dup_object (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vulkan_window_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstVulkanWindow *window = GST_VULKAN_WINDOW (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_DISPLAY:
|
|
|
|
g_value_set_object (value, window->display);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-24 06:29:05 +00:00
|
|
|
static void
|
|
|
|
gst_vulkan_window_init (GstVulkanWindow * window)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vulkan_window_class_init (GstVulkanWindowClass * klass)
|
|
|
|
{
|
2019-07-05 06:20:05 +00:00
|
|
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
|
|
|
|
2015-10-24 06:29:05 +00:00
|
|
|
klass->open = GST_DEBUG_FUNCPTR (gst_vulkan_window_default_open);
|
|
|
|
klass->close = GST_DEBUG_FUNCPTR (gst_vulkan_window_default_close);
|
|
|
|
|
2015-12-01 05:28:28 +00:00
|
|
|
gst_vulkan_window_signals[SIGNAL_CLOSE] =
|
|
|
|
g_signal_new ("close", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0,
|
|
|
|
(GSignalAccumulator) _accum_logical_and, NULL, NULL, G_TYPE_BOOLEAN, 0);
|
|
|
|
|
2015-12-01 07:37:34 +00:00
|
|
|
gst_vulkan_window_signals[SIGNAL_DRAW] =
|
|
|
|
g_signal_new ("draw", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0,
|
|
|
|
NULL, NULL, NULL, G_TYPE_NONE, 0);
|
|
|
|
|
2019-08-09 04:49:24 +00:00
|
|
|
gst_vulkan_window_signals[SIGNAL_RESIZE] =
|
|
|
|
g_signal_new ("resize", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0,
|
|
|
|
NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
|
|
|
|
|
2020-02-17 04:03:34 +00:00
|
|
|
/**
|
|
|
|
* GstVulkanWindow::mouse-event:
|
|
|
|
* @object: the #GstVulkanWindow
|
|
|
|
* @id: the name of the event
|
|
|
|
* @button: the id of the button
|
|
|
|
* @x: the x coordinate of the mouse event
|
|
|
|
* @y: the y coordinate of the mouse event
|
|
|
|
*
|
|
|
|
* Will be emitted when a mouse event is received by the #GstVulkanWindow.
|
|
|
|
*
|
|
|
|
* Since: 1.18
|
|
|
|
*/
|
|
|
|
gst_vulkan_window_signals[SIGNAL_MOUSE_EVENT] =
|
|
|
|
g_signal_new ("mouse-event", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 4, G_TYPE_STRING,
|
|
|
|
G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVulkanWindow::key-event:
|
|
|
|
* @object: the #GstVulkanWindow
|
|
|
|
* @id: the name of the event
|
|
|
|
* @key: the id of the key pressed
|
|
|
|
*
|
|
|
|
* Will be emitted when a key event is received by the #GstVulkanWindow.
|
|
|
|
*
|
|
|
|
* Since: 1.18
|
|
|
|
*/
|
|
|
|
gst_vulkan_window_signals[SIGNAL_KEY_EVENT] =
|
|
|
|
g_signal_new ("key-event", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING);
|
|
|
|
|
2019-07-05 06:20:05 +00:00
|
|
|
gobject_class->set_property = gst_vulkan_window_set_property;
|
|
|
|
gobject_class->get_property = gst_vulkan_window_get_property;
|
|
|
|
gobject_class->finalize = gst_vulkan_window_finalize;
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_DISPLAY,
|
|
|
|
g_param_spec_object ("display", "Display",
|
|
|
|
"Associated Vulkan Display",
|
|
|
|
GST_TYPE_VULKAN_DISPLAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2015-10-24 06:29:05 +00:00
|
|
|
|
|
|
|
_init_debug ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vulkan_window_new:
|
2019-04-11 06:52:54 +00:00
|
|
|
* @display: a #GstVulkanDisplay
|
2015-10-24 06:29:05 +00:00
|
|
|
*
|
|
|
|
* Returns: (transfer full): a new #GstVulkanWindow using @display's connection
|
|
|
|
*
|
2019-04-11 06:52:54 +00:00
|
|
|
* Since: 1.18
|
2015-10-24 06:29:05 +00:00
|
|
|
*/
|
|
|
|
GstVulkanWindow *
|
|
|
|
gst_vulkan_window_new (GstVulkanDisplay * display)
|
|
|
|
{
|
|
|
|
GstVulkanWindow *window = NULL;
|
|
|
|
const gchar *user_choice;
|
|
|
|
|
|
|
|
g_return_val_if_fail (display != NULL, NULL);
|
|
|
|
|
|
|
|
_init_debug ();
|
|
|
|
|
|
|
|
user_choice = g_getenv ("GST_VULKAN_WINDOW");
|
|
|
|
GST_INFO ("creating a window, user choice:%s", user_choice);
|
|
|
|
#if GST_VULKAN_HAVE_WINDOW_XCB
|
|
|
|
if (!window && (!user_choice || g_strstr_len (user_choice, 3, "xcb")))
|
|
|
|
window = GST_VULKAN_WINDOW (gst_vulkan_window_xcb_new (display));
|
2016-04-10 07:46:15 +00:00
|
|
|
#endif
|
|
|
|
#if GST_VULKAN_HAVE_WINDOW_WAYLAND
|
|
|
|
if (!window && (!user_choice || g_strstr_len (user_choice, 7, "wayland")))
|
|
|
|
window = GST_VULKAN_WINDOW (gst_vulkan_window_wayland_new (display));
|
2019-03-25 06:50:13 +00:00
|
|
|
#endif
|
|
|
|
#if GST_VULKAN_HAVE_WINDOW_COCOA
|
|
|
|
if (!window && (!user_choice || g_strstr_len (user_choice, 5, "cocoa")))
|
|
|
|
window = GST_VULKAN_WINDOW (gst_vulkan_window_cocoa_new (display));
|
2019-03-27 06:56:28 +00:00
|
|
|
#endif
|
|
|
|
#if GST_VULKAN_HAVE_WINDOW_IOS
|
|
|
|
if (!window && (!user_choice || g_strstr_len (user_choice, 3, "ios")))
|
|
|
|
window = GST_VULKAN_WINDOW (gst_vulkan_window_ios_new (display));
|
2019-06-08 13:57:21 +00:00
|
|
|
#endif
|
|
|
|
#if GST_VULKAN_HAVE_WINDOW_WIN32
|
|
|
|
if (!window && (!user_choice || g_strstr_len (user_choice, 5, "win32")))
|
|
|
|
window = GST_VULKAN_WINDOW (gst_vulkan_window_win32_new (display));
|
2019-10-16 06:17:51 +00:00
|
|
|
#endif
|
|
|
|
#if GST_VULKAN_HAVE_WINDOW_ANDROID
|
|
|
|
if (!window && (!user_choice || g_strstr_len (user_choice, 7, "android")))
|
|
|
|
window = GST_VULKAN_WINDOW (gst_vulkan_window_android_new (display));
|
2015-10-24 06:29:05 +00:00
|
|
|
#endif
|
|
|
|
if (!window) {
|
|
|
|
/* subclass returned a NULL window */
|
|
|
|
GST_WARNING ("Could not create window. user specified %s, creating dummy"
|
|
|
|
" window", user_choice ? user_choice : "(null)");
|
|
|
|
|
|
|
|
window = GST_VULKAN_WINDOW (gst_vulkan_dummy_window_new ());
|
|
|
|
}
|
|
|
|
|
|
|
|
window->display = gst_object_ref (display);
|
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vulkan_window_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GstVulkanWindow *window = GST_VULKAN_WINDOW (object);
|
|
|
|
|
|
|
|
gst_object_unref (window->display);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gst_vulkan_window_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2019-04-11 06:52:54 +00:00
|
|
|
/**
|
|
|
|
* gst_vulkan_window_get_display:
|
|
|
|
* @window: a #GstVulkanWindow
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): the #GstVulkanDisplay for @window
|
|
|
|
*
|
|
|
|
* Since: 1.18
|
|
|
|
*/
|
2015-10-24 06:29:05 +00:00
|
|
|
GstVulkanDisplay *
|
|
|
|
gst_vulkan_window_get_display (GstVulkanWindow * window)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_VULKAN_WINDOW (window), NULL);
|
|
|
|
|
|
|
|
return gst_object_ref (window->display);
|
|
|
|
}
|
|
|
|
|
2019-04-11 06:52:54 +00:00
|
|
|
/**
|
|
|
|
* gst_vulkan_window_get_surface: (skip)
|
|
|
|
* @window: a #GstVulkanWindow
|
|
|
|
* @error: a #GError
|
|
|
|
*
|
2019-08-23 04:19:22 +00:00
|
|
|
* Returns: the VkSurface for displaying into. The caller is responsible for
|
|
|
|
* calling `VkDestroySurface` on the returned surface.
|
2019-04-11 06:52:54 +00:00
|
|
|
*
|
|
|
|
* Since: 1.18
|
|
|
|
*/
|
2015-12-29 05:05:17 +00:00
|
|
|
VkSurfaceKHR
|
|
|
|
gst_vulkan_window_get_surface (GstVulkanWindow * window, GError ** error)
|
2015-10-24 06:29:05 +00:00
|
|
|
{
|
|
|
|
GstVulkanWindowClass *klass;
|
|
|
|
|
2017-02-01 05:05:23 +00:00
|
|
|
g_return_val_if_fail (GST_IS_VULKAN_WINDOW (window), (VkSurfaceKHR) 0);
|
2015-10-24 06:29:05 +00:00
|
|
|
klass = GST_VULKAN_WINDOW_GET_CLASS (window);
|
2017-02-01 05:05:23 +00:00
|
|
|
g_return_val_if_fail (klass->get_surface != NULL, (VkSurfaceKHR) 0);
|
2015-10-24 06:29:05 +00:00
|
|
|
|
2015-12-29 05:05:17 +00:00
|
|
|
return klass->get_surface (window, error);
|
|
|
|
}
|
|
|
|
|
2019-04-11 06:52:54 +00:00
|
|
|
/**
|
|
|
|
* gst_vulkan_window_get_presentation_support:
|
|
|
|
* @window: a #GstVulkanWindow
|
|
|
|
* @device: a #GstVulkanDevice
|
|
|
|
* @queue_family_idx: the queue family
|
|
|
|
*
|
|
|
|
* Returns: whether the given combination of @window, @device and
|
|
|
|
* @queue_family_idx supports presentation
|
|
|
|
*
|
|
|
|
* Since: 1.18
|
|
|
|
*/
|
2015-12-29 05:05:17 +00:00
|
|
|
gboolean
|
|
|
|
gst_vulkan_window_get_presentation_support (GstVulkanWindow * window,
|
|
|
|
GstVulkanDevice * device, guint32 queue_family_idx)
|
|
|
|
{
|
|
|
|
GstVulkanWindowClass *klass;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_VULKAN_WINDOW (window), FALSE);
|
|
|
|
klass = GST_VULKAN_WINDOW_GET_CLASS (window);
|
|
|
|
g_return_val_if_fail (klass->get_presentation_support != NULL, FALSE);
|
|
|
|
|
|
|
|
return klass->get_presentation_support (window, device, queue_family_idx);
|
2015-10-24 06:29:05 +00:00
|
|
|
}
|
|
|
|
|
2019-04-11 06:52:54 +00:00
|
|
|
/**
|
|
|
|
* gst_vulkan_window_open:
|
|
|
|
* @window: a #GstVulkanWindow
|
|
|
|
* @error: a #GError
|
|
|
|
*
|
2019-09-02 19:08:44 +00:00
|
|
|
* Returns: whether @window could be successfully opened
|
2019-04-11 06:52:54 +00:00
|
|
|
*
|
|
|
|
* Since: 1.18
|
|
|
|
*/
|
2015-10-24 06:29:05 +00:00
|
|
|
gboolean
|
|
|
|
gst_vulkan_window_open (GstVulkanWindow * window, GError ** error)
|
|
|
|
{
|
|
|
|
GstVulkanWindowClass *klass;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_VULKAN_WINDOW (window), FALSE);
|
|
|
|
klass = GST_VULKAN_WINDOW_GET_CLASS (window);
|
|
|
|
g_return_val_if_fail (klass->open != NULL, FALSE);
|
|
|
|
|
|
|
|
return klass->open (window, error);
|
|
|
|
}
|
|
|
|
|
2019-04-11 06:52:54 +00:00
|
|
|
/**
|
|
|
|
* gst_vulkan_window_close:
|
|
|
|
* @window: a #GstVulkanWindow
|
|
|
|
*
|
|
|
|
* Attempt to close the window.
|
|
|
|
*
|
|
|
|
* Since: 1.18
|
|
|
|
*/
|
2015-10-24 06:29:05 +00:00
|
|
|
void
|
|
|
|
gst_vulkan_window_close (GstVulkanWindow * window)
|
|
|
|
{
|
|
|
|
GstVulkanWindowClass *klass;
|
2015-12-01 05:28:28 +00:00
|
|
|
gboolean to_close;
|
2015-10-24 06:29:05 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_VULKAN_WINDOW (window));
|
|
|
|
klass = GST_VULKAN_WINDOW_GET_CLASS (window);
|
|
|
|
g_return_if_fail (klass->close != NULL);
|
|
|
|
|
2015-12-01 05:28:28 +00:00
|
|
|
g_signal_emit (window, gst_vulkan_window_signals[SIGNAL_CLOSE], 0, &to_close);
|
|
|
|
|
|
|
|
if (to_close)
|
|
|
|
klass->close (window);
|
|
|
|
}
|
|
|
|
|
2019-04-11 06:52:54 +00:00
|
|
|
/**
|
|
|
|
* gst_vulkan_window_resize:
|
|
|
|
* @window: a #GstVulkanWindow
|
|
|
|
* @width: the new width
|
|
|
|
* @height: the new height
|
|
|
|
*
|
|
|
|
* Resize the output surface.
|
|
|
|
*
|
|
|
|
* Currently intended for subclasses to update internal state.
|
|
|
|
*
|
|
|
|
* Since: 1.18
|
|
|
|
*/
|
2015-12-01 05:28:28 +00:00
|
|
|
void
|
|
|
|
gst_vulkan_window_resize (GstVulkanWindow * window, gint width, gint height)
|
|
|
|
{
|
2019-11-06 15:41:10 +00:00
|
|
|
GstVulkanWindowPrivate *priv;
|
|
|
|
|
2015-12-01 05:28:28 +00:00
|
|
|
g_return_if_fail (GST_IS_VULKAN_WINDOW (window));
|
|
|
|
|
2019-11-06 15:41:10 +00:00
|
|
|
priv = GET_PRIV (window);
|
|
|
|
|
|
|
|
priv->surface_width = width;
|
|
|
|
priv->surface_height = height;
|
2015-12-01 05:28:28 +00:00
|
|
|
|
2019-08-09 04:49:24 +00:00
|
|
|
g_signal_emit (window, gst_vulkan_window_signals[SIGNAL_RESIZE], 0, width,
|
|
|
|
height);
|
2015-10-24 06:29:05 +00:00
|
|
|
}
|
|
|
|
|
2019-04-11 06:52:54 +00:00
|
|
|
/**
|
|
|
|
* gst_vulkan_window_redraw:
|
|
|
|
* @window: a #GstVulkanWindow
|
|
|
|
*
|
|
|
|
* Ask the @window to redraw its contents
|
|
|
|
*
|
|
|
|
* Since: 1.18
|
|
|
|
*/
|
2015-12-01 07:37:34 +00:00
|
|
|
void
|
|
|
|
gst_vulkan_window_redraw (GstVulkanWindow * window)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_VULKAN_WINDOW (window));
|
|
|
|
|
|
|
|
g_signal_emit (window, gst_vulkan_window_signals[SIGNAL_DRAW], 0);
|
|
|
|
}
|
|
|
|
|
2019-03-27 06:56:28 +00:00
|
|
|
void
|
|
|
|
gst_vulkan_window_set_window_handle (GstVulkanWindow * window, guintptr handle)
|
|
|
|
{
|
|
|
|
GstVulkanWindowClass *klass;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_VULKAN_WINDOW (window));
|
|
|
|
klass = GST_VULKAN_WINDOW_GET_CLASS (window);
|
|
|
|
|
|
|
|
if (!klass->set_window_handle) {
|
|
|
|
if (handle)
|
|
|
|
g_warning ("%s does not implement the set_window_handle vfunc. "
|
|
|
|
"Output will not be embedded into the specified surface.",
|
|
|
|
GST_OBJECT_NAME (window));
|
|
|
|
} else {
|
|
|
|
klass->set_window_handle (window, handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-09 04:49:24 +00:00
|
|
|
void
|
|
|
|
gst_vulkan_window_get_surface_dimensions (GstVulkanWindow * window,
|
|
|
|
guint * width, guint * height)
|
|
|
|
{
|
2019-11-06 15:41:10 +00:00
|
|
|
GstVulkanWindowPrivate *priv;
|
2019-08-09 04:49:24 +00:00
|
|
|
GstVulkanWindowClass *klass;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_VULKAN_WINDOW (window));
|
|
|
|
klass = GST_VULKAN_WINDOW_GET_CLASS (window);
|
2019-11-06 15:41:10 +00:00
|
|
|
priv = GET_PRIV (window);
|
2019-08-09 04:49:24 +00:00
|
|
|
|
|
|
|
if (klass->get_surface_dimensions) {
|
|
|
|
klass->get_surface_dimensions (window, width, height);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (window, "Returning size %ix%i",
|
2019-11-06 15:41:10 +00:00
|
|
|
priv->surface_width, priv->surface_height);
|
|
|
|
*width = priv->surface_width;
|
|
|
|
*height = priv->surface_height;
|
2019-08-09 04:49:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-17 04:03:34 +00:00
|
|
|
void
|
|
|
|
gst_vulkan_window_send_key_event (GstVulkanWindow * window,
|
|
|
|
const char *event_type, const char *key_str)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_VULKAN_WINDOW (window));
|
|
|
|
|
|
|
|
g_signal_emit (window, gst_vulkan_window_signals[SIGNAL_KEY_EVENT], 0,
|
|
|
|
event_type, key_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_vulkan_window_send_mouse_event (GstVulkanWindow * window,
|
|
|
|
const char *event_type, int button, double posx, double posy)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_VULKAN_WINDOW (window));
|
|
|
|
|
|
|
|
g_signal_emit (window, gst_vulkan_window_signals[SIGNAL_MOUSE_EVENT], 0,
|
|
|
|
event_type, button, posx, posy);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vulkan_window_handle_events:
|
|
|
|
* @window: a #GstVulkanWindow
|
|
|
|
* @handle_events: a #gboolean indicating if events should be handled or not.
|
|
|
|
*
|
|
|
|
* Tell a @window that it should handle events from the window system. These
|
|
|
|
* events are forwarded upstream as navigation events. In some window systems
|
|
|
|
* events are not propagated in the window hierarchy if a client is listening
|
|
|
|
* for them. This method allows you to disable events handling completely
|
|
|
|
* from the @window.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_vulkan_window_handle_events (GstVulkanWindow * window,
|
|
|
|
gboolean handle_events)
|
|
|
|
{
|
|
|
|
GstVulkanWindowClass *window_class;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_VULKAN_WINDOW (window));
|
|
|
|
window_class = GST_VULKAN_WINDOW_GET_CLASS (window);
|
|
|
|
|
|
|
|
if (window_class->handle_events)
|
|
|
|
window_class->handle_events (window, handle_events);
|
|
|
|
}
|
|
|
|
|
2015-10-24 06:29:05 +00:00
|
|
|
GType gst_vulkan_dummy_window_get_type (void);
|
|
|
|
G_DEFINE_TYPE (GstVulkanDummyWindow, gst_vulkan_dummy_window,
|
|
|
|
GST_TYPE_VULKAN_WINDOW);
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vulkan_dummy_window_class_init (GstVulkanDummyWindowClass * klass)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vulkan_dummy_window_init (GstVulkanDummyWindow * dummy)
|
|
|
|
{
|
|
|
|
dummy->handle = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
GstVulkanDummyWindow *
|
|
|
|
gst_vulkan_dummy_window_new (void)
|
|
|
|
{
|
2017-05-15 17:31:31 +00:00
|
|
|
GstVulkanDummyWindow *window;
|
|
|
|
|
|
|
|
window = g_object_new (gst_vulkan_dummy_window_get_type (), NULL);
|
|
|
|
gst_object_ref_sink (window);
|
|
|
|
|
|
|
|
return window;
|
2015-10-24 06:29:05 +00:00
|
|
|
}
|