[gnome-remote-desktop] egl-thread: Add API to run external functions in EGL thread
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-remote-desktop] egl-thread: Add API to run external functions in EGL thread
- Date: Wed, 16 Feb 2022 09:17:09 +0000 (UTC)
commit ba7d015165ad568288fb50d373f96e0fcbef89b4
Author: Pascal Nowack <Pascal Nowack gmx de>
Date: Fri Dec 31 13:04:36 2021 +0100
egl-thread: Add API to run external functions in EGL thread
This allows e.g. fetching the compute devices from the current GL
context for CUDA.
src/grd-egl-thread.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
src/grd-egl-thread.h | 8 ++++++++
2 files changed, 53 insertions(+)
---
diff --git a/src/grd-egl-thread.c b/src/grd-egl-thread.c
index 0675894d..17fb7dac 100644
--- a/src/grd-egl-thread.c
+++ b/src/grd-egl-thread.c
@@ -62,6 +62,14 @@ typedef struct _GrdEglTask
GDestroyNotify callback_destroy;
} GrdEglTask;
+typedef struct _GrdEglTaskCustom
+{
+ GrdEglTask base;
+
+ GrdEglThreadCustomFunc custom_func;
+ gpointer user_data;
+} GrdEglTaskCustom;
+
typedef struct _GrdEglTaskSync
{
GrdEglTask base;
@@ -738,6 +746,18 @@ sync_in_impl (gpointer data,
task->base.callback (TRUE, task->base.callback_user_data);
}
+static void
+run_custom_task_in_impl (gpointer data,
+ gpointer user_data)
+{
+ GrdEglTaskCustom *task = user_data;
+ gboolean success;
+
+ success = task->custom_func (task->user_data);
+
+ task->base.callback (success, task->base.callback_user_data);
+}
+
void
grd_egl_thread_download (GrdEglThread *egl_thread,
uint8_t *dst_data,
@@ -800,6 +820,31 @@ grd_egl_thread_sync (GrdEglThread *egl_thread,
g_main_context_wakeup (egl_thread->impl.main_context);
}
+void
+grd_egl_thread_run_custom_task (GrdEglThread *egl_thread,
+ GrdEglThreadCustomFunc custom_func,
+ gpointer custom_func_data,
+ GrdEglThreadCallback callback,
+ gpointer user_data,
+ GDestroyNotify destroy)
+{
+ GrdEglTaskCustom *task;
+
+ task = g_new0 (GrdEglTaskCustom, 1);
+
+ task->custom_func = custom_func;
+ task->user_data = custom_func_data;
+
+ task->base.func = run_custom_task_in_impl;
+ task->base.destroy = (GDestroyNotify) grd_egl_task_free;
+ task->base.callback = callback;
+ task->base.callback_user_data = user_data;
+ task->base.callback_destroy = destroy;
+
+ g_async_queue_push (egl_thread->task_queue, task);
+ g_main_context_wakeup (egl_thread->impl.main_context);
+}
+
gboolean
grd_egl_thread_get_modifiers_for_format (GrdEglThread *egl_thread,
uint32_t format,
diff --git a/src/grd-egl-thread.h b/src/grd-egl-thread.h
index 9af35eef..2e032513 100644
--- a/src/grd-egl-thread.h
+++ b/src/grd-egl-thread.h
@@ -28,6 +28,7 @@
typedef void (* GrdEglThreadCallback) (gboolean success,
gpointer user_data);
+typedef gboolean (* GrdEglThreadCustomFunc) (gpointer user_data);
GrdEglThread * grd_egl_thread_new (GError **error);
@@ -53,6 +54,13 @@ void grd_egl_thread_sync (GrdEglThread *egl_thread,
gpointer user_data,
GDestroyNotify destroy);
+void grd_egl_thread_run_custom_task (GrdEglThread *egl_thread,
+ GrdEglThreadCustomFunc custom_func,
+ gpointer custom_func_data,
+ GrdEglThreadCallback callback,
+ gpointer user_data,
+ GDestroyNotify destroy);
+
gboolean grd_egl_thread_get_modifiers_for_format (GrdEglThread *egl_thread,
uint32_t format,
int *out_n_modifiers,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]