mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
cogl/onscreen: Let swap buffer caller create frame info
We currently have mutter set a global frame counter on the frame info in the native backend, but in order to do this from clutter, change the frame info construction from being implicitly done so when swapping buffers to having the caller create the frame info and passing that to the swap buffers call. While this commit doesn't introduce any other changes than the API, the intention is later to have the caller be able to pass it's own state (e.g. the global frame count) along with the frame info. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
This commit is contained in:
parent
31a3b1b4c5
commit
2a6e8bda8d
@ -369,6 +369,7 @@ swap_framebuffer (ClutterStageWindow *stage_window,
|
||||
{
|
||||
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
|
||||
int *damage, n_rects, i;
|
||||
CoglFrameInfo *frame_info;
|
||||
|
||||
n_rects = cairo_region_num_rectangles (swap_region);
|
||||
damage = g_newa (int, n_rects * 4);
|
||||
@ -383,6 +384,8 @@ swap_framebuffer (ClutterStageWindow *stage_window,
|
||||
damage[i * 4 + 3] = rect.height;
|
||||
}
|
||||
|
||||
frame_info = cogl_frame_info_new ();
|
||||
|
||||
/* push on the screen */
|
||||
if (n_rects > 0 && !swap_with_damage)
|
||||
{
|
||||
@ -391,7 +394,8 @@ swap_framebuffer (ClutterStageWindow *stage_window,
|
||||
onscreen);
|
||||
|
||||
cogl_onscreen_swap_region (onscreen,
|
||||
damage, n_rects);
|
||||
damage, n_rects,
|
||||
frame_info);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -401,7 +405,8 @@ swap_framebuffer (ClutterStageWindow *stage_window,
|
||||
onscreen);
|
||||
|
||||
cogl_onscreen_swap_buffers_with_damage (onscreen,
|
||||
damage, n_rects);
|
||||
damage, n_rects,
|
||||
frame_info);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -747,11 +752,15 @@ clutter_stage_cogl_scanout_view (ClutterStageCogl *stage_cogl,
|
||||
{
|
||||
CoglFramebuffer *framebuffer = clutter_stage_view_get_framebuffer (view);
|
||||
CoglOnscreen *onscreen;
|
||||
CoglFrameInfo *frame_info;
|
||||
|
||||
g_return_if_fail (cogl_is_onscreen (framebuffer));
|
||||
|
||||
onscreen = COGL_ONSCREEN (framebuffer);
|
||||
cogl_onscreen_direct_scanout (onscreen, scanout);
|
||||
|
||||
frame_info = cogl_frame_info_new ();
|
||||
|
||||
cogl_onscreen_direct_scanout (onscreen, scanout, frame_info);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -45,6 +45,7 @@ struct _CoglFrameInfo
|
||||
int64_t global_frame_counter;
|
||||
};
|
||||
|
||||
CoglFrameInfo *_cogl_frame_info_new (void);
|
||||
COGL_EXPORT
|
||||
CoglFrameInfo *cogl_frame_info_new (void);
|
||||
|
||||
#endif /* __COGL_FRAME_INFO_PRIVATE_H */
|
||||
|
@ -39,7 +39,7 @@ COGL_OBJECT_DEFINE (FrameInfo, frame_info);
|
||||
COGL_GTYPE_DEFINE_CLASS (FrameInfo, frame_info);
|
||||
|
||||
CoglFrameInfo *
|
||||
_cogl_frame_info_new (void)
|
||||
cogl_frame_info_new (void)
|
||||
{
|
||||
CoglFrameInfo *info;
|
||||
|
||||
|
@ -45,6 +45,11 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* CoglFrameInfo:
|
||||
*
|
||||
* Frame information.
|
||||
*/
|
||||
typedef struct _CoglFrameInfo CoglFrameInfo;
|
||||
#define COGL_FRAME_INFO(X) ((CoglFrameInfo *)(X))
|
||||
|
||||
|
@ -293,15 +293,14 @@ _cogl_onscreen_queue_event (CoglOnscreen *onscreen,
|
||||
void
|
||||
cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
||||
const int *rectangles,
|
||||
int n_rectangles)
|
||||
int n_rectangles,
|
||||
CoglFrameInfo *info)
|
||||
{
|
||||
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
||||
const CoglWinsysVtable *winsys;
|
||||
CoglFrameInfo *info;
|
||||
|
||||
g_return_if_fail (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN);
|
||||
|
||||
info = _cogl_frame_info_new ();
|
||||
info->frame_counter = onscreen->frame_counter;
|
||||
g_queue_push_tail (&onscreen->pending_frame_infos, info);
|
||||
|
||||
@ -310,7 +309,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);
|
||||
rectangles, n_rectangles,
|
||||
info);
|
||||
cogl_framebuffer_discard_buffers (framebuffer,
|
||||
COGL_BUFFER_BIT_COLOR |
|
||||
COGL_BUFFER_BIT_DEPTH |
|
||||
@ -334,23 +334,23 @@ cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_onscreen_swap_buffers (CoglOnscreen *onscreen)
|
||||
cogl_onscreen_swap_buffers (CoglOnscreen *onscreen,
|
||||
CoglFrameInfo *info)
|
||||
{
|
||||
cogl_onscreen_swap_buffers_with_damage (onscreen, NULL, 0);
|
||||
cogl_onscreen_swap_buffers_with_damage (onscreen, NULL, 0, info);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_onscreen_swap_region (CoglOnscreen *onscreen,
|
||||
const int *rectangles,
|
||||
int n_rectangles)
|
||||
int n_rectangles,
|
||||
CoglFrameInfo *info)
|
||||
{
|
||||
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
||||
const CoglWinsysVtable *winsys;
|
||||
CoglFrameInfo *info;
|
||||
|
||||
g_return_if_fail (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN);
|
||||
|
||||
info = _cogl_frame_info_new ();
|
||||
info->frame_counter = onscreen->frame_counter;
|
||||
g_queue_push_tail (&onscreen->pending_frame_infos, info);
|
||||
|
||||
@ -365,7 +365,8 @@ cogl_onscreen_swap_region (CoglOnscreen *onscreen,
|
||||
|
||||
winsys->onscreen_swap_region (COGL_ONSCREEN (framebuffer),
|
||||
rectangles,
|
||||
n_rectangles);
|
||||
n_rectangles,
|
||||
info);
|
||||
|
||||
cogl_framebuffer_discard_buffers (framebuffer,
|
||||
COGL_BUFFER_BIT_COLOR |
|
||||
@ -406,22 +407,21 @@ cogl_onscreen_get_buffer_age (CoglOnscreen *onscreen)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_onscreen_direct_scanout (CoglOnscreen *onscreen,
|
||||
CoglScanout *scanout)
|
||||
cogl_onscreen_direct_scanout (CoglOnscreen *onscreen,
|
||||
CoglScanout *scanout,
|
||||
CoglFrameInfo *info)
|
||||
{
|
||||
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
||||
const CoglWinsysVtable *winsys;
|
||||
CoglFrameInfo *info;
|
||||
|
||||
g_return_if_fail (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN);
|
||||
g_return_if_fail (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT));
|
||||
|
||||
info = _cogl_frame_info_new ();
|
||||
info->frame_counter = onscreen->frame_counter;
|
||||
g_queue_push_tail (&onscreen->pending_frame_infos, info);
|
||||
|
||||
winsys = _cogl_framebuffer_get_winsys (framebuffer);
|
||||
winsys->onscreen_direct_scanout (onscreen, scanout);
|
||||
winsys->onscreen_direct_scanout (onscreen, scanout, info);
|
||||
|
||||
onscreen->frame_counter++;
|
||||
}
|
||||
|
@ -178,7 +178,8 @@ cogl_onscreen_hide (CoglOnscreen *onscreen);
|
||||
* Stability: unstable
|
||||
*/
|
||||
COGL_EXPORT void
|
||||
cogl_onscreen_swap_buffers (CoglOnscreen *onscreen);
|
||||
cogl_onscreen_swap_buffers (CoglOnscreen *onscreen,
|
||||
CoglFrameInfo *frame_info);
|
||||
|
||||
|
||||
/**
|
||||
@ -284,14 +285,16 @@ cogl_onscreen_get_buffer_age (CoglOnscreen *onscreen);
|
||||
COGL_EXPORT void
|
||||
cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
||||
const int *rectangles,
|
||||
int n_rectangles);
|
||||
int n_rectangles,
|
||||
CoglFrameInfo *info);
|
||||
|
||||
/**
|
||||
* cogl_onscreen_direct_scanout: (skip)
|
||||
*/
|
||||
COGL_EXPORT void
|
||||
cogl_onscreen_direct_scanout (CoglOnscreen *onscreen,
|
||||
CoglScanout *scanout);
|
||||
cogl_onscreen_direct_scanout (CoglOnscreen *onscreen,
|
||||
CoglScanout *scanout,
|
||||
CoglFrameInfo *info);
|
||||
|
||||
/**
|
||||
* cogl_onscreen_swap_region:
|
||||
@ -316,7 +319,8 @@ cogl_onscreen_direct_scanout (CoglOnscreen *onscreen,
|
||||
COGL_EXPORT void
|
||||
cogl_onscreen_swap_region (CoglOnscreen *onscreen,
|
||||
const int *rectangles,
|
||||
int n_rectangles);
|
||||
int n_rectangles,
|
||||
CoglFrameInfo *info);
|
||||
|
||||
/**
|
||||
* CoglFrameEvent:
|
||||
|
@ -77,6 +77,7 @@ cogl_headers = [
|
||||
'cogl-bitmap.h',
|
||||
'cogl-color.h',
|
||||
'cogl-context.h',
|
||||
'cogl-frame-info.h',
|
||||
'cogl-framebuffer.h',
|
||||
'cogl-matrix.h',
|
||||
'cogl-object.h',
|
||||
@ -106,7 +107,6 @@ cogl_nonintrospected_headers = [
|
||||
'cogl-indices.h',
|
||||
'cogl-attribute.h',
|
||||
'cogl-primitive.h',
|
||||
'cogl-frame-info.h',
|
||||
'cogl-output.h',
|
||||
'cogl-matrix-stack.h',
|
||||
'cogl-poll.h',
|
||||
|
@ -726,7 +726,8 @@ _cogl_winsys_onscreen_get_buffer_age (CoglOnscreen *onscreen)
|
||||
static void
|
||||
_cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
|
||||
const int *user_rectangles,
|
||||
int n_rectangles)
|
||||
int n_rectangles,
|
||||
CoglFrameInfo *info)
|
||||
{
|
||||
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
|
||||
CoglRenderer *renderer = context->display->renderer;
|
||||
@ -765,7 +766,8 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
|
||||
static void
|
||||
_cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
||||
const int *rectangles,
|
||||
int n_rectangles)
|
||||
int n_rectangles,
|
||||
CoglFrameInfo *info)
|
||||
{
|
||||
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
|
||||
CoglRenderer *renderer = context->display->renderer;
|
||||
|
@ -1673,7 +1673,8 @@ set_frame_info_output (CoglOnscreen *onscreen,
|
||||
static void
|
||||
_cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
|
||||
const int *user_rectangles,
|
||||
int n_rectangles)
|
||||
int n_rectangles,
|
||||
CoglFrameInfo *info)
|
||||
{
|
||||
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
||||
CoglContext *context = framebuffer->context;
|
||||
@ -1879,7 +1880,8 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
|
||||
static void
|
||||
_cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
||||
const int *rectangles,
|
||||
int n_rectangles)
|
||||
int n_rectangles,
|
||||
CoglFrameInfo *info)
|
||||
{
|
||||
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
||||
CoglContext *context = framebuffer->context;
|
||||
|
@ -116,11 +116,13 @@ typedef struct _CoglWinsysVtable
|
||||
void
|
||||
(*onscreen_swap_buffers_with_damage) (CoglOnscreen *onscreen,
|
||||
const int *rectangles,
|
||||
int n_rectangles);
|
||||
int n_rectangles,
|
||||
CoglFrameInfo *info);
|
||||
|
||||
void
|
||||
(*onscreen_direct_scanout) (CoglOnscreen *onscreen,
|
||||
CoglScanout *scanout);
|
||||
(*onscreen_direct_scanout) (CoglOnscreen *onscreen,
|
||||
CoglScanout *scanout,
|
||||
CoglFrameInfo *info);
|
||||
|
||||
void
|
||||
(*onscreen_set_visibility) (CoglOnscreen *onscreen,
|
||||
@ -134,7 +136,8 @@ typedef struct _CoglWinsysVtable
|
||||
void
|
||||
(*onscreen_swap_region) (CoglOnscreen *onscreen,
|
||||
const int *rectangles,
|
||||
int n_rectangles);
|
||||
int n_rectangles,
|
||||
CoglFrameInfo *info);
|
||||
|
||||
void
|
||||
(*onscreen_set_resizable) (CoglOnscreen *onscreen, gboolean resizable);
|
||||
|
@ -2067,9 +2067,10 @@ ensure_crtc_modes (CoglOnscreen *onscreen,
|
||||
}
|
||||
|
||||
static void
|
||||
meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
||||
const int *rectangles,
|
||||
int n_rectangles)
|
||||
meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
||||
const int *rectangles,
|
||||
int n_rectangles,
|
||||
CoglFrameInfo *frame_info)
|
||||
{
|
||||
CoglContext *cogl_context = COGL_FRAMEBUFFER (onscreen)->context;
|
||||
CoglDisplay *cogl_display = cogl_context_get_display (cogl_context);
|
||||
@ -2084,7 +2085,6 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
||||
CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
|
||||
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
|
||||
MetaGpuKms *render_gpu = onscreen_native->render_gpu;
|
||||
CoglFrameInfo *frame_info;
|
||||
gboolean egl_context_changed = FALSE;
|
||||
MetaKmsUpdate *kms_update;
|
||||
g_autoptr (GError) error = NULL;
|
||||
@ -2112,7 +2112,8 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
|
||||
|
||||
parent_vtable->onscreen_swap_buffers_with_damage (onscreen,
|
||||
rectangles,
|
||||
n_rectangles);
|
||||
n_rectangles,
|
||||
frame_info);
|
||||
|
||||
renderer_gpu_data = meta_renderer_native_get_gpu_data (renderer_native,
|
||||
render_gpu);
|
||||
@ -2296,8 +2297,9 @@ meta_onscreen_native_is_buffer_scanout_compatible (CoglOnscreen *onscreen,
|
||||
}
|
||||
|
||||
static void
|
||||
meta_onscreen_native_direct_scanout (CoglOnscreen *onscreen,
|
||||
CoglScanout *scanout)
|
||||
meta_onscreen_native_direct_scanout (CoglOnscreen *onscreen,
|
||||
CoglScanout *scanout,
|
||||
CoglFrameInfo *frame_info)
|
||||
{
|
||||
CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
|
||||
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
|
||||
@ -2311,7 +2313,6 @@ meta_onscreen_native_direct_scanout (CoglOnscreen *onscreen,
|
||||
MetaBackend *backend = meta_renderer_get_backend (renderer);
|
||||
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
||||
MetaKms *kms = meta_backend_native_get_kms (backend_native);
|
||||
CoglFrameInfo *frame_info;
|
||||
MetaKmsUpdate *kms_update;
|
||||
g_autoptr (GError) error = NULL;
|
||||
|
||||
|
@ -168,6 +168,7 @@ meta_stage_x11_nested_finish_frame (ClutterStageWindow *stage_window)
|
||||
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
||||
CoglFramebuffer *onscreen = COGL_FRAMEBUFFER (stage_x11->onscreen);
|
||||
GList *l;
|
||||
CoglFrameInfo *frame_info;
|
||||
|
||||
if (!stage_nested->pipeline)
|
||||
stage_nested->pipeline = cogl_pipeline_new (clutter_backend->cogl_context);
|
||||
@ -193,7 +194,8 @@ meta_stage_x11_nested_finish_frame (ClutterStageWindow *stage_window)
|
||||
draw_view (stage_nested, renderer_view, texture);
|
||||
}
|
||||
|
||||
cogl_onscreen_swap_buffers (stage_x11->onscreen);
|
||||
frame_info = cogl_frame_info_new ();
|
||||
cogl_onscreen_swap_buffers (stage_x11->onscreen, frame_info);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user