From 0fdf6a6405db4ff4da794d2ab869f5fca7e8fc8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 19 Oct 2020 22:24:26 +0200 Subject: [PATCH] cogl/onscreen: Move direct scanout to CoglOnscreen class Part-of: --- cogl/cogl/cogl-onscreen.c | 22 +++++++++++++++------- cogl/cogl/cogl-onscreen.h | 9 +++++++-- cogl/cogl/winsys/cogl-winsys-private.h | 7 ------- src/backends/native/meta-onscreen-native.c | 3 ++- src/backends/native/meta-onscreen-native.h | 6 ------ src/backends/native/meta-renderer-native.c | 2 -- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/cogl/cogl/cogl-onscreen.c b/cogl/cogl/cogl-onscreen.c index 11868cde2..232b57564 100644 --- a/cogl/cogl/cogl-onscreen.c +++ b/cogl/cogl/cogl-onscreen.c @@ -30,6 +30,8 @@ #include "cogl-config.h" +#include + #include "cogl-util.h" #include "cogl-onscreen-private.h" #include "cogl-frame-info-private.h" @@ -442,20 +444,26 @@ cogl_onscreen_direct_scanout (CoglOnscreen *onscreen, { CoglOnscreenPrivate *priv = cogl_onscreen_get_instance_private (onscreen); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); - const CoglWinsysVtable *winsys; + CoglOnscreenClass *klass = COGL_ONSCREEN_GET_CLASS (onscreen); g_warn_if_fail (COGL_IS_ONSCREEN (framebuffer)); g_warn_if_fail (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT)); + if (!klass->direct_scanout) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "Direct scanout not supported"); + return FALSE; + } + info->frame_counter = priv->frame_counter; g_queue_push_tail (&priv->pending_frame_infos, info); - winsys = _cogl_framebuffer_get_winsys (framebuffer); - if (!winsys->onscreen_direct_scanout (onscreen, - scanout, - info, - user_data, - error)) + if (!klass->direct_scanout (onscreen, + scanout, + info, + user_data, + error)) { g_queue_pop_tail (&priv->pending_frame_infos); return FALSE; diff --git a/cogl/cogl/cogl-onscreen.h b/cogl/cogl/cogl-onscreen.h index 14d28a9b3..8842eb123 100644 --- a/cogl/cogl/cogl-onscreen.h +++ b/cogl/cogl/cogl-onscreen.h @@ -47,6 +47,8 @@ G_BEGIN_DECLS +typedef struct _CoglScanout CoglScanout; + #define COGL_TYPE_ONSCREEN (cogl_onscreen_get_type ()) COGL_EXPORT G_DECLARE_DERIVABLE_TYPE (CoglOnscreen, cogl_onscreen, @@ -72,6 +74,11 @@ struct _CoglOnscreenClass CoglFrameInfo *info, gpointer user_data); + gboolean (* direct_scanout) (CoglOnscreen *onscreen, + CoglScanout *scanout, + CoglFrameInfo *info, + gpointer user_data, + GError **error); }; #define COGL_SCANOUT_ERROR (cogl_scanout_error_quark ()) @@ -83,8 +90,6 @@ typedef enum _CoglScanoutError COGL_SCANOUT_ERROR_INHIBITED, } CoglScanoutError; -typedef struct _CoglScanout CoglScanout; - #ifdef COGL_HAS_X11 /** * cogl_x11_onscreen_get_window_xid: diff --git a/cogl/cogl/winsys/cogl-winsys-private.h b/cogl/cogl/winsys/cogl-winsys-private.h index 6956f4692..536ae7471 100644 --- a/cogl/cogl/winsys/cogl-winsys-private.h +++ b/cogl/cogl/winsys/cogl-winsys-private.h @@ -104,13 +104,6 @@ typedef struct _CoglWinsysVtable void (*context_deinit) (CoglContext *context); - gboolean - (*onscreen_direct_scanout) (CoglOnscreen *onscreen, - CoglScanout *scanout, - CoglFrameInfo *info, - gpointer user_data, - GError **error); - void (*onscreen_set_visibility) (CoglOnscreen *onscreen, gboolean visibility); diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index 5f3a3d982..50c21d26d 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -1177,7 +1177,7 @@ meta_onscreen_native_is_buffer_scanout_compatible (CoglOnscreen *onscreen, return TRUE; } -gboolean +static gboolean meta_onscreen_native_direct_scanout (CoglOnscreen *onscreen, CoglScanout *scanout, CoglFrameInfo *frame_info, @@ -2112,4 +2112,5 @@ meta_onscreen_native_class_init (MetaOnscreenNativeClass *klass) onscreen_class->swap_buffers_with_damage = meta_onscreen_native_swap_buffers_with_damage; + onscreen_class->direct_scanout = meta_onscreen_native_direct_scanout; } diff --git a/src/backends/native/meta-onscreen-native.h b/src/backends/native/meta-onscreen-native.h index ef0849899..f3fcc0f83 100644 --- a/src/backends/native/meta-onscreen-native.h +++ b/src/backends/native/meta-onscreen-native.h @@ -35,12 +35,6 @@ G_DECLARE_FINAL_TYPE (MetaOnscreenNative, meta_onscreen_native, void meta_renderer_native_release_onscreen (CoglOnscreen *onscreen); -gboolean meta_onscreen_native_direct_scanout (CoglOnscreen *onscreen, - CoglScanout *scanout, - CoglFrameInfo *frame_info, - gpointer user_data, - GError **error); - void meta_onscreen_native_finish_frame (CoglOnscreen *onscreen, ClutterFrame *frame); diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index 62f780e18..c4df1407c 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -940,8 +940,6 @@ get_native_cogl_winsys_vtable (CoglRenderer *cogl_renderer) vtable.renderer_disconnect = meta_renderer_native_disconnect; vtable.renderer_create_dma_buf = meta_renderer_native_create_dma_buf; - vtable.onscreen_direct_scanout = meta_onscreen_native_direct_scanout; - vtable.context_get_clock_time = meta_renderer_native_get_clock_time; vtable_inited = TRUE;