From 249512b06820d3e5dea3c8cc04563140cdad04d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 9 Oct 2020 22:00:29 +0200 Subject: [PATCH] cogl/onscreen: Add opaque user_data pointer to onscreen present calls This argument is intended to be used by clutter to be able to communicate with the onscreen backend, that happens to be the native backend. It will be used to pass a ClutterFrame pointer, where the result of page flips, mode sets etc can be communicated whenever it is available. Part-of: --- clutter/clutter/cogl/clutter-stage-cogl.c | 30 ++++++++++++++----- cogl/cogl/cogl-onscreen.c | 24 ++++++++++----- cogl/cogl/cogl-onscreen.h | 10 +++++-- cogl/cogl/winsys/cogl-winsys-egl.c | 6 ++-- cogl/cogl/winsys/cogl-winsys-glx.c | 6 ++-- cogl/cogl/winsys/cogl-winsys-private.h | 7 +++-- src/backends/native/meta-renderer-native.c | 7 +++-- .../x11/nested/meta-stage-x11-nested.c | 2 +- 8 files changed, 65 insertions(+), 27 deletions(-) diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c index 02b13781a..6c5593647 100644 --- a/clutter/clutter/cogl/clutter-stage-cogl.c +++ b/clutter/clutter/cogl/clutter-stage-cogl.c @@ -249,7 +249,8 @@ static void swap_framebuffer (ClutterStageWindow *stage_window, ClutterStageView *view, cairo_region_t *swap_region, - gboolean swap_with_damage) + gboolean swap_with_damage, + ClutterFrame *frame) { ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window); ClutterStageCoglPrivate *priv = @@ -289,7 +290,8 @@ swap_framebuffer (ClutterStageWindow *stage_window, cogl_onscreen_swap_region (onscreen, damage, n_rects, - frame_info); + frame_info, + frame); } else { @@ -298,7 +300,8 @@ swap_framebuffer (ClutterStageWindow *stage_window, cogl_onscreen_swap_buffers_with_damage (onscreen, damage, n_rects, - frame_info); + frame_info, + frame); } } else @@ -445,7 +448,8 @@ transform_swap_region_to_onscreen (ClutterStageView *view, static void clutter_stage_cogl_redraw_view_primary (ClutterStageCogl *stage_cogl, - ClutterStageView *view) + ClutterStageView *view, + ClutterFrame *frame) { ClutterStageWindow *stage_window = CLUTTER_STAGE_WINDOW (stage_cogl); ClutterStageViewCogl *view_cogl = CLUTTER_STAGE_VIEW_COGL (view); @@ -658,7 +662,8 @@ clutter_stage_cogl_redraw_view_primary (ClutterStageCogl *stage_cogl, swap_framebuffer (stage_window, view, swap_region, - swap_with_damage); + swap_with_damage, + frame); cairo_region_destroy (swap_region); } @@ -667,6 +672,7 @@ static gboolean clutter_stage_cogl_scanout_view (ClutterStageCogl *stage_cogl, ClutterStageView *view, CoglScanout *scanout, + ClutterFrame *frame, GError **error) { ClutterStageCoglPrivate *priv = @@ -681,7 +687,11 @@ clutter_stage_cogl_scanout_view (ClutterStageCogl *stage_cogl, frame_info = cogl_frame_info_new (priv->global_frame_counter); - if (!cogl_onscreen_direct_scanout (onscreen, scanout, frame_info, error)) + if (!cogl_onscreen_direct_scanout (onscreen, + scanout, + frame_info, + frame, + error)) { cogl_object_unref (frame_info); return FALSE; @@ -705,13 +715,17 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window, { g_autoptr (GError) error = NULL; - if (clutter_stage_cogl_scanout_view (stage_cogl, view, scanout, &error)) + if (clutter_stage_cogl_scanout_view (stage_cogl, + view, + scanout, + frame, + &error)) return; g_warning ("Failed to scan out client buffer: %s", error->message); } - clutter_stage_cogl_redraw_view_primary (stage_cogl, view); + clutter_stage_cogl_redraw_view_primary (stage_cogl, view, frame); clutter_frame_set_result (frame, CLUTTER_FRAME_RESULT_PENDING_PRESENTED); } diff --git a/cogl/cogl/cogl-onscreen.c b/cogl/cogl/cogl-onscreen.c index f6d21cf06..d9f26126d 100644 --- a/cogl/cogl/cogl-onscreen.c +++ b/cogl/cogl/cogl-onscreen.c @@ -303,7 +303,8 @@ void cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen, const int *rectangles, int n_rectangles, - CoglFrameInfo *info) + CoglFrameInfo *info, + gpointer user_data) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); const CoglWinsysVtable *winsys; @@ -321,7 +322,8 @@ cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen, winsys = _cogl_framebuffer_get_winsys (framebuffer); winsys->onscreen_swap_buffers_with_damage (onscreen, rectangles, n_rectangles, - info); + info, + user_data); cogl_framebuffer_discard_buffers (framebuffer, COGL_BUFFER_BIT_COLOR | COGL_BUFFER_BIT_DEPTH | @@ -346,16 +348,18 @@ cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen, void cogl_onscreen_swap_buffers (CoglOnscreen *onscreen, - CoglFrameInfo *info) + CoglFrameInfo *info, + gpointer user_data) { - cogl_onscreen_swap_buffers_with_damage (onscreen, NULL, 0, info); + cogl_onscreen_swap_buffers_with_damage (onscreen, NULL, 0, info, user_data); } void cogl_onscreen_swap_region (CoglOnscreen *onscreen, const int *rectangles, int n_rectangles, - CoglFrameInfo *info) + CoglFrameInfo *info, + gpointer user_data) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); const CoglWinsysVtable *winsys; @@ -379,7 +383,8 @@ cogl_onscreen_swap_region (CoglOnscreen *onscreen, winsys->onscreen_swap_region (COGL_ONSCREEN (framebuffer), rectangles, n_rectangles, - info); + info, + user_data); cogl_framebuffer_discard_buffers (framebuffer, COGL_BUFFER_BIT_COLOR | @@ -423,6 +428,7 @@ gboolean cogl_onscreen_direct_scanout (CoglOnscreen *onscreen, CoglScanout *scanout, CoglFrameInfo *info, + gpointer user_data, GError **error) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); @@ -435,7 +441,11 @@ cogl_onscreen_direct_scanout (CoglOnscreen *onscreen, g_queue_push_tail (&onscreen->pending_frame_infos, info); winsys = _cogl_framebuffer_get_winsys (framebuffer); - if (!winsys->onscreen_direct_scanout (onscreen, scanout, info, error)) + if (!winsys->onscreen_direct_scanout (onscreen, + scanout, + info, + user_data, + error)) { g_queue_pop_tail (&onscreen->pending_frame_infos); return FALSE; diff --git a/cogl/cogl/cogl-onscreen.h b/cogl/cogl/cogl-onscreen.h index 66f8c82f6..bc028105f 100644 --- a/cogl/cogl/cogl-onscreen.h +++ b/cogl/cogl/cogl-onscreen.h @@ -174,7 +174,8 @@ cogl_onscreen_hide (CoglOnscreen *onscreen); */ COGL_EXPORT void cogl_onscreen_swap_buffers (CoglOnscreen *onscreen, - CoglFrameInfo *frame_info); + CoglFrameInfo *frame_info, + gpointer user_data); /** @@ -281,7 +282,8 @@ COGL_EXPORT void cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen, const int *rectangles, int n_rectangles, - CoglFrameInfo *info); + CoglFrameInfo *info, + gpointer user_data); /** * cogl_onscreen_direct_scanout: (skip) @@ -290,6 +292,7 @@ COGL_EXPORT gboolean cogl_onscreen_direct_scanout (CoglOnscreen *onscreen, CoglScanout *scanout, CoglFrameInfo *info, + gpointer user_data, GError **error); /** @@ -316,7 +319,8 @@ COGL_EXPORT void cogl_onscreen_swap_region (CoglOnscreen *onscreen, const int *rectangles, int n_rectangles, - CoglFrameInfo *info); + CoglFrameInfo *info, + gpointer user_data); /** * CoglFrameEvent: diff --git a/cogl/cogl/winsys/cogl-winsys-egl.c b/cogl/cogl/winsys/cogl-winsys-egl.c index b9b49af21..041a25b56 100644 --- a/cogl/cogl/winsys/cogl-winsys-egl.c +++ b/cogl/cogl/winsys/cogl-winsys-egl.c @@ -769,7 +769,8 @@ static void _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen, const int *user_rectangles, int n_rectangles, - CoglFrameInfo *info) + CoglFrameInfo *info, + gpointer user_data) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); CoglContext *context = cogl_framebuffer_get_context (framebuffer); @@ -809,7 +810,8 @@ static void _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen, const int *rectangles, int n_rectangles, - CoglFrameInfo *info) + CoglFrameInfo *info, + gpointer user_data) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); CoglContext *context = cogl_framebuffer_get_context (framebuffer); diff --git a/cogl/cogl/winsys/cogl-winsys-glx.c b/cogl/cogl/winsys/cogl-winsys-glx.c index 759a15c71..686b8ac69 100644 --- a/cogl/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/cogl/winsys/cogl-winsys-glx.c @@ -1637,7 +1637,8 @@ static void _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen, const int *user_rectangles, int n_rectangles, - CoglFrameInfo *info) + CoglFrameInfo *info, + gpointer user_data) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); CoglContext *context = cogl_framebuffer_get_context (framebuffer); @@ -1844,7 +1845,8 @@ static void _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen, const int *rectangles, int n_rectangles, - CoglFrameInfo *info) + CoglFrameInfo *info, + gpointer user_data) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); CoglContext *context = cogl_framebuffer_get_context (framebuffer); diff --git a/cogl/cogl/winsys/cogl-winsys-private.h b/cogl/cogl/winsys/cogl-winsys-private.h index 2cf88f39b..9af682bc8 100644 --- a/cogl/cogl/winsys/cogl-winsys-private.h +++ b/cogl/cogl/winsys/cogl-winsys-private.h @@ -117,12 +117,14 @@ typedef struct _CoglWinsysVtable (*onscreen_swap_buffers_with_damage) (CoglOnscreen *onscreen, const int *rectangles, int n_rectangles, - CoglFrameInfo *info); + CoglFrameInfo *info, + gpointer user_data); gboolean (*onscreen_direct_scanout) (CoglOnscreen *onscreen, CoglScanout *scanout, CoglFrameInfo *info, + gpointer user_data, GError **error); void @@ -138,7 +140,8 @@ typedef struct _CoglWinsysVtable (*onscreen_swap_region) (CoglOnscreen *onscreen, const int *rectangles, int n_rectangles, - CoglFrameInfo *info); + CoglFrameInfo *info, + gpointer user_data); void (*onscreen_set_resizable) (CoglOnscreen *onscreen, gboolean resizable); diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index 00e5f445f..851c8ceac 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -1919,7 +1919,8 @@ static void meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen, const int *rectangles, int n_rectangles, - CoglFrameInfo *frame_info) + CoglFrameInfo *frame_info, + gpointer user_data) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer); @@ -1955,7 +1956,8 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen, parent_vtable->onscreen_swap_buffers_with_damage (onscreen, rectangles, n_rectangles, - frame_info); + frame_info, + user_data); renderer_gpu_data = meta_renderer_native_get_gpu_data (renderer_native, render_gpu); @@ -2170,6 +2172,7 @@ static gboolean meta_onscreen_native_direct_scanout (CoglOnscreen *onscreen, CoglScanout *scanout, CoglFrameInfo *frame_info, + gpointer user_data, GError **error) { CoglOnscreenEGL *onscreen_egl = onscreen->winsys; diff --git a/src/backends/x11/nested/meta-stage-x11-nested.c b/src/backends/x11/nested/meta-stage-x11-nested.c index 4f3f5b796..7a6c14a09 100644 --- a/src/backends/x11/nested/meta-stage-x11-nested.c +++ b/src/backends/x11/nested/meta-stage-x11-nested.c @@ -196,7 +196,7 @@ meta_stage_x11_nested_finish_frame (ClutterStageWindow *stage_window, } frame_info = cogl_frame_info_new (0); - cogl_onscreen_swap_buffers (stage_x11->onscreen, frame_info); + cogl_onscreen_swap_buffers (stage_x11->onscreen, frame_info, frame); if (!clutter_frame_has_result (frame)) clutter_frame_set_result (frame, CLUTTER_FRAME_RESULT_IDLE);