compositor: Expose the MetaCompositorView in before_paint () vfunc
The idea is that the state of the MetaCompositorView shall be up-to-date only in specific scenarios, thus allowing operations performed on it to be queued and aggregated to be handled in the right time, and only if they are still necessary. For example, in a following commit, the top window actor in each view will be planned (if needed) only once before painting a frame, rendering the top window actor in the MetaCompositorView potentially stale in all other times. Similarly, if a MetaCompositorView is destroyed before the beginning of the frame, a queued operation to update its top window actor can be discarded. As an interface segragation measure, and as part of an attempt to avoid the use of g_return_if_fail () to check the validity of the MetaCompositorView's state in multiple places (which is still prone to human error), the interfaces through which a MetaCompositorView is made available would only ones where it's state is gurenteed to be up-to-date. Specifically, this commit gurentees that the state of the MetaCompositorView would be up-to-date during the before_paint () and after_paint () vfuncs exposed to child classes of the MetaCompositor. The frame_in_progress variable will be used in a following commit to guarantee that the MetaCompositorView's state is not invalidated during this time. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2526>
This commit is contained in:
parent
049db7c7e5
commit
2ead3874f5
4 changed files with 56 additions and 23 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "clutter/clutter-mutter.h"
|
||||
#include "clutter/clutter.h"
|
||||
#include "compositor/meta-compositor-view.h"
|
||||
#include "compositor/meta-plugin-manager.h"
|
||||
#include "compositor/meta-window-actor-private.h"
|
||||
#include "meta/compositor.h"
|
||||
|
@ -24,10 +25,10 @@ struct _MetaCompositorClass
|
|||
gboolean (* manage) (MetaCompositor *compositor,
|
||||
GError **error);
|
||||
void (* unmanage) (MetaCompositor *compositor);
|
||||
void (* before_paint) (MetaCompositor *compositor,
|
||||
ClutterStageView *stage_view);
|
||||
void (* after_paint) (MetaCompositor *compositor,
|
||||
ClutterStageView *stage_view);
|
||||
void (* before_paint) (MetaCompositor *compositor,
|
||||
MetaCompositorView *compositor_view);
|
||||
void (* after_paint) (MetaCompositor *compositor,
|
||||
MetaCompositorView *compositor_view);
|
||||
void (* remove_window) (MetaCompositor *compositor,
|
||||
MetaWindow *window);
|
||||
int64_t (* monotonic_to_high_res_xserver_time) (MetaCompositor *compositor,
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
#include "backends/x11/meta-stage-x11.h"
|
||||
#include "clutter/clutter-mutter.h"
|
||||
#include "cogl/cogl.h"
|
||||
#include "compositor/meta-compositor-view.h"
|
||||
#include "compositor/meta-later-private.h"
|
||||
#include "compositor/meta-window-actor-x11.h"
|
||||
#include "compositor/meta-window-actor-private.h"
|
||||
|
@ -131,6 +130,8 @@ typedef struct _MetaCompositorPrivate
|
|||
|
||||
int switch_workspace_in_progress;
|
||||
|
||||
gboolean frame_in_progress;
|
||||
|
||||
MetaPluginManager *plugin_mgr;
|
||||
|
||||
MetaLaters *laters;
|
||||
|
@ -986,34 +987,44 @@ on_presented (ClutterStage *stage,
|
|||
}
|
||||
|
||||
static void
|
||||
meta_compositor_real_before_paint (MetaCompositor *compositor,
|
||||
ClutterStageView *stage_view)
|
||||
meta_compositor_real_before_paint (MetaCompositor *compositor,
|
||||
MetaCompositorView *compositor_view)
|
||||
{
|
||||
MetaCompositorPrivate *priv =
|
||||
meta_compositor_get_instance_private (compositor);
|
||||
ClutterStageView *stage_view;
|
||||
GList *l;
|
||||
|
||||
stage_view = meta_compositor_view_get_stage_view (compositor_view);
|
||||
|
||||
for (l = priv->windows; l; l = l->next)
|
||||
meta_window_actor_before_paint (l->data, stage_view);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_compositor_before_paint (MetaCompositor *compositor,
|
||||
ClutterStageView *stage_view)
|
||||
meta_compositor_before_paint (MetaCompositor *compositor,
|
||||
MetaCompositorView *compositor_view)
|
||||
{
|
||||
MetaCompositorPrivate *priv =
|
||||
meta_compositor_get_instance_private (compositor);
|
||||
|
||||
COGL_TRACE_BEGIN_SCOPED (MetaCompositorPrePaint,
|
||||
"Compositor (before-paint)");
|
||||
META_COMPOSITOR_GET_CLASS (compositor)->before_paint (compositor, stage_view);
|
||||
|
||||
priv->frame_in_progress = TRUE;
|
||||
|
||||
META_COMPOSITOR_GET_CLASS (compositor)->before_paint (compositor, compositor_view);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_compositor_real_after_paint (MetaCompositor *compositor,
|
||||
ClutterStageView *stage_view)
|
||||
meta_compositor_real_after_paint (MetaCompositor *compositor,
|
||||
MetaCompositorView *compositor_view)
|
||||
{
|
||||
MetaCompositorPrivate *priv =
|
||||
meta_compositor_get_instance_private (compositor);
|
||||
ClutterActor *stage_actor = meta_backend_get_stage (priv->backend);
|
||||
CoglGraphicsResetStatus status;
|
||||
ClutterStageView *stage_view;
|
||||
GList *l;
|
||||
|
||||
status = cogl_get_graphics_reset_status (priv->context);
|
||||
|
@ -1040,6 +1051,8 @@ meta_compositor_real_after_paint (MetaCompositor *compositor,
|
|||
break;
|
||||
}
|
||||
|
||||
stage_view = meta_compositor_view_get_stage_view (compositor_view);
|
||||
|
||||
for (l = priv->windows; l; l = l->next)
|
||||
{
|
||||
ClutterActor *actor = l->data;
|
||||
|
@ -1052,12 +1065,17 @@ meta_compositor_real_after_paint (MetaCompositor *compositor,
|
|||
}
|
||||
|
||||
static void
|
||||
meta_compositor_after_paint (MetaCompositor *compositor,
|
||||
ClutterStageView *stage_view)
|
||||
meta_compositor_after_paint (MetaCompositor *compositor,
|
||||
MetaCompositorView *compositor_view)
|
||||
{
|
||||
MetaCompositorPrivate *priv =
|
||||
meta_compositor_get_instance_private (compositor);
|
||||
|
||||
COGL_TRACE_BEGIN_SCOPED (MetaCompositorPostPaint,
|
||||
"Compositor (after-paint)");
|
||||
META_COMPOSITOR_GET_CLASS (compositor)->after_paint (compositor, stage_view);
|
||||
META_COMPOSITOR_GET_CLASS (compositor)->after_paint (compositor, compositor_view);
|
||||
|
||||
priv->frame_in_progress = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1065,7 +1083,14 @@ on_before_paint (ClutterStage *stage,
|
|||
ClutterStageView *stage_view,
|
||||
MetaCompositor *compositor)
|
||||
{
|
||||
meta_compositor_before_paint (compositor, stage_view);
|
||||
MetaCompositorView *compositor_view;
|
||||
|
||||
compositor_view = g_object_get_qdata (G_OBJECT (stage_view),
|
||||
quark_compositor_view);
|
||||
|
||||
g_assert (compositor_view != NULL);
|
||||
|
||||
meta_compositor_before_paint (compositor, compositor_view);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1073,7 +1098,14 @@ on_after_paint (ClutterStage *stage,
|
|||
ClutterStageView *stage_view,
|
||||
MetaCompositor *compositor)
|
||||
{
|
||||
meta_compositor_after_paint (compositor, stage_view);
|
||||
MetaCompositorView *compositor_view;
|
||||
|
||||
compositor_view = g_object_get_qdata (G_OBJECT (stage_view),
|
||||
quark_compositor_view);
|
||||
|
||||
g_assert (compositor_view != NULL);
|
||||
|
||||
meta_compositor_after_paint (compositor, compositor_view);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -156,8 +156,8 @@ done:
|
|||
#endif /* HAVE_WAYLAND */
|
||||
|
||||
static void
|
||||
meta_compositor_native_before_paint (MetaCompositor *compositor,
|
||||
ClutterStageView *stage_view)
|
||||
meta_compositor_native_before_paint (MetaCompositor *compositor,
|
||||
MetaCompositorView *compositor_view)
|
||||
{
|
||||
MetaCompositorClass *parent_class;
|
||||
|
||||
|
@ -166,7 +166,7 @@ meta_compositor_native_before_paint (MetaCompositor *compositor,
|
|||
#endif
|
||||
|
||||
parent_class = META_COMPOSITOR_CLASS (meta_compositor_native_parent_class);
|
||||
parent_class->before_paint (compositor, stage_view);
|
||||
parent_class->before_paint (compositor, compositor_view);
|
||||
}
|
||||
|
||||
MetaCompositorNative *
|
||||
|
|
|
@ -385,8 +385,8 @@ on_after_update (ClutterStage *stage,
|
|||
}
|
||||
|
||||
static void
|
||||
meta_compositor_x11_before_paint (MetaCompositor *compositor,
|
||||
ClutterStageView *stage_view)
|
||||
meta_compositor_x11_before_paint (MetaCompositor *compositor,
|
||||
MetaCompositorView *compositor_view)
|
||||
{
|
||||
MetaCompositorX11 *compositor_x11 = META_COMPOSITOR_X11 (compositor);
|
||||
MetaCompositorClass *parent_class;
|
||||
|
@ -394,7 +394,7 @@ meta_compositor_x11_before_paint (MetaCompositor *compositor,
|
|||
maybe_unredirect_top_window (compositor_x11);
|
||||
|
||||
parent_class = META_COMPOSITOR_CLASS (meta_compositor_x11_parent_class);
|
||||
parent_class->before_paint (compositor, stage_view);
|
||||
parent_class->before_paint (compositor, compositor_view);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue