stage-view/cogl: Add frame listener in constructor()

The onscreens are set on construction now, so no need to wait for it to
be set after.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1407
This commit is contained in:
Jonas Ådahl 2020-08-16 21:35:16 +02:00 committed by Georges Basile Stavracas Neto
parent df5af58d05
commit 3dfe3a248d

View File

@ -756,22 +756,6 @@ frame_cb (CoglOnscreen *onscreen,
clutter_stage_view_notify_presented (view, &clutter_frame_info);
}
static void
on_framebuffer_set (ClutterStageView *view)
{
CoglFramebuffer *framebuffer;
framebuffer = clutter_stage_view_get_onscreen (view);
if (framebuffer && cogl_is_onscreen (framebuffer))
{
cogl_onscreen_add_frame_callback (COGL_ONSCREEN (framebuffer),
frame_cb,
view,
NULL);
}
}
static void
clutter_stage_view_cogl_dispose (GObject *object)
{
@ -785,6 +769,25 @@ clutter_stage_view_cogl_dispose (GObject *object)
G_OBJECT_CLASS (clutter_stage_view_cogl_parent_class)->dispose (object);
}
static void
clutter_stage_view_cogl_constructed (GObject *object)
{
ClutterStageView *view = CLUTTER_STAGE_VIEW (view_cogl);
CoglFramebuffer *framebuffer;
framebuffer = clutter_stage_view_get_onscreen (view);
if (framebuffer && cogl_is_onscreen (framebuffer))
{
cogl_onscreen_add_frame_callback (COGL_ONSCREEN (framebuffer),
frame_cb,
view,
NULL);
}
G_OBJECT_CLASS (clutter_stage_view_cogl_parent_class)->constructed (object);
}
static void
clutter_stage_view_cogl_init (ClutterStageViewCogl *view_cogl)
{
@ -792,9 +795,6 @@ clutter_stage_view_cogl_init (ClutterStageViewCogl *view_cogl)
clutter_stage_view_cogl_get_instance_private (view_cogl);
view_priv->damage_history = clutter_damage_history_new ();
g_signal_connect (view_cogl, "notify::framebuffer",
G_CALLBACK (on_framebuffer_set), NULL);
}
static void
@ -802,5 +802,6 @@ clutter_stage_view_cogl_class_init (ClutterStageViewCoglClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = clutter_stage_view_cogl_constructed;
object_class->dispose = clutter_stage_view_cogl_dispose;
}