compositor: Don't access use the onscreen framebuffer directly

Instead of assuming there is a single onscreen framebuffer, use the
helper functions for setting the frame callback and getting the frame
counter.

https://bugzilla.gnome.org/show_bug.cgi?id=768976
This commit is contained in:
Jonas Ådahl 2016-05-25 14:40:12 +08:00
parent a465e4c5b8
commit 7f0e6b9b4b
5 changed files with 40 additions and 11 deletions

View File

@ -36,6 +36,14 @@ void clutter_set_custom_backend_func (ClutterBackend *(* func) (void));
CLUTTER_AVAILABLE_IN_MUTTER CLUTTER_AVAILABLE_IN_MUTTER
gboolean _clutter_get_sync_to_vblank (void); gboolean _clutter_get_sync_to_vblank (void);
CLUTTER_AVAILABLE_IN_MUTTER
CoglFrameClosure *clutter_stage_add_frame_callback (ClutterStage *stage,
CoglFrameCallback callback,
gpointer user_data);
CLUTTER_AVAILABLE_IN_MUTTER
int64_t clutter_stage_get_frame_counter (ClutterStage *stage);
#undef __CLUTTER_H_INSIDE__ #undef __CLUTTER_H_INSIDE__
#endif /* __CLUTTER_MUTTER_H__ */ #endif /* __CLUTTER_MUTTER_H__ */

View File

@ -4510,3 +4510,25 @@ _clutter_stage_set_scale_factor (ClutterStage *stage,
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage)); clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
} }
CoglFrameClosure *
clutter_stage_add_frame_callback (ClutterStage *stage,
CoglFrameCallback callback,
gpointer user_data)
{
ClutterStageWindow *stage_window;
stage_window = _clutter_stage_get_window (stage);
return _clutter_stage_window_set_frame_callback (stage_window,
callback,
user_data);
}
int64_t
clutter_stage_get_frame_counter (ClutterStage *stage)
{
ClutterStageWindow *stage_window;
stage_window = _clutter_stage_get_window (stage);
return _clutter_stage_window_get_frame_counter (stage_window);
}

View File

@ -29,7 +29,6 @@ struct _MetaCompositor
GList *windows; GList *windows;
Window output; Window output;
CoglOnscreen *onscreen;
CoglFrameClosure *frame_closure; CoglFrameClosure *frame_closure;
CoglContext *context; CoglContext *context;

View File

@ -77,6 +77,7 @@
#include "meta-sync-ring.h" #include "meta-sync-ring.h"
#include "backends/x11/meta-backend-x11.h" #include "backends/x11/meta-backend-x11.h"
#include "clutter/clutter-mutter.h"
#ifdef HAVE_WAYLAND #ifdef HAVE_WAYLAND
#include "wayland/meta-wayland-private.h" #include "wayland/meta-wayland-private.h"
@ -1044,13 +1045,12 @@ meta_pre_paint_func (gpointer data)
MetaWindowActor *top_window; MetaWindowActor *top_window;
MetaCompositor *compositor = data; MetaCompositor *compositor = data;
if (compositor->onscreen == NULL) if (!compositor->frame_closure)
{ {
compositor->onscreen = COGL_ONSCREEN (cogl_get_draw_framebuffer ()); compositor->frame_closure =
compositor->frame_closure = cogl_onscreen_add_frame_callback (compositor->onscreen, clutter_stage_add_frame_callback (CLUTTER_STAGE (compositor->stage),
frame_callback, frame_callback,
compositor, compositor);
NULL);
} }
if (compositor->windows == NULL) if (compositor->windows == NULL)

View File

@ -23,6 +23,7 @@
#include <meta/meta-enum-types.h> #include <meta/meta-enum-types.h>
#include <meta/meta-shadow-factory.h> #include <meta/meta-shadow-factory.h>
#include "clutter/clutter-mutter.h"
#include "compositor-private.h" #include "compositor-private.h"
#include "meta-shaped-texture-private.h" #include "meta-shaped-texture-private.h"
#include "meta-window-actor-private.h" #include "meta-window-actor-private.h"
@ -659,6 +660,8 @@ static void
assign_frame_counter_to_frames (MetaWindowActor *self) assign_frame_counter_to_frames (MetaWindowActor *self)
{ {
MetaWindowActorPrivate *priv = self->priv; MetaWindowActorPrivate *priv = self->priv;
MetaCompositor *compositor = priv->compositor;
ClutterStage *stage = CLUTTER_STAGE (compositor->stage);
GList *l; GList *l;
/* If the window is obscured, then we're expecting to deal with sending /* If the window is obscured, then we're expecting to deal with sending
@ -672,10 +675,7 @@ assign_frame_counter_to_frames (MetaWindowActor *self)
FrameData *frame = l->data; FrameData *frame = l->data;
if (frame->frame_counter == -1) if (frame->frame_counter == -1)
{ frame->frame_counter = clutter_stage_get_frame_counter (stage);
CoglOnscreen *onscreen = COGL_ONSCREEN (cogl_get_draw_framebuffer());
frame->frame_counter = cogl_onscreen_get_frame_counter (onscreen);
}
} }
} }