[metacity] xrender: move repaint idle to MetaCompositor
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] xrender: move repaint idle to MetaCompositor
- Date: Thu, 16 Mar 2017 19:13:14 +0000 (UTC)
commit 7852da13f07694f88c9942b5ed6759a65b917722
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Mar 16 20:55:13 2017 +0200
xrender: move repaint idle to MetaCompositor
src/compositor/meta-compositor-none.c | 6 +++
src/compositor/meta-compositor-private.h | 4 ++
src/compositor/meta-compositor-vulkan.c | 6 +++
src/compositor/meta-compositor-xrender.c | 70 ++++++++++-------------------
src/compositor/meta-compositor.c | 41 +++++++++++++++++
5 files changed, 81 insertions(+), 46 deletions(-)
---
diff --git a/src/compositor/meta-compositor-none.c b/src/compositor/meta-compositor-none.c
index 9964cc0..d195113 100644
--- a/src/compositor/meta-compositor-none.c
+++ b/src/compositor/meta-compositor-none.c
@@ -116,6 +116,11 @@ meta_compositor_none_sync_stack (MetaCompositor *compositor,
}
static void
+meta_compositor_none_redraw (MetaCompositor *compositor)
+{
+}
+
+static void
meta_compositor_none_class_init (MetaCompositorNoneClass *none_class)
{
MetaCompositorClass *compositor_class;
@@ -136,6 +141,7 @@ meta_compositor_none_class_init (MetaCompositorNoneClass *none_class)
compositor_class->unmaximize_window = meta_compositor_none_unmaximize_window;
compositor_class->sync_screen_size = meta_compositor_none_sync_screen_size;
compositor_class->sync_stack = meta_compositor_none_sync_stack;
+ compositor_class->redraw = meta_compositor_none_redraw;
}
static void
diff --git a/src/compositor/meta-compositor-private.h b/src/compositor/meta-compositor-private.h
index 614a122..a615e99 100644
--- a/src/compositor/meta-compositor-private.h
+++ b/src/compositor/meta-compositor-private.h
@@ -71,6 +71,8 @@ struct _MetaCompositorClass
void (* sync_stack) (MetaCompositor *compositor,
GList *stack);
+
+ void (* redraw) (MetaCompositor *compositor);
};
gboolean meta_compositor_set_selection (MetaCompositor *compositor,
@@ -83,6 +85,8 @@ gboolean meta_compositor_redirect_windows (MetaCompositor *compositor,
MetaDisplay *meta_compositor_get_display (MetaCompositor *compositor);
+void meta_compositor_queue_redraw (MetaCompositor *compositor);
+
G_END_DECLS
#endif
diff --git a/src/compositor/meta-compositor-vulkan.c b/src/compositor/meta-compositor-vulkan.c
index 4b2d3b1..43332b6 100644
--- a/src/compositor/meta-compositor-vulkan.c
+++ b/src/compositor/meta-compositor-vulkan.c
@@ -1302,6 +1302,11 @@ meta_compositor_vulkan_sync_stack (MetaCompositor *compositor,
}
static void
+meta_compositor_vulkan_redraw (MetaCompositor *compositor)
+{
+}
+
+static void
meta_compositor_vulkan_class_init (MetaCompositorVulkanClass *vulkan_class)
{
GObjectClass *object_class;
@@ -1326,6 +1331,7 @@ meta_compositor_vulkan_class_init (MetaCompositorVulkanClass *vulkan_class)
compositor_class->unmaximize_window = meta_compositor_vulkan_unmaximize_window;
compositor_class->sync_screen_size = meta_compositor_vulkan_sync_screen_size;
compositor_class->sync_stack = meta_compositor_vulkan_sync_stack;
+ compositor_class->redraw = meta_compositor_vulkan_redraw;
}
static void
diff --git a/src/compositor/meta-compositor-xrender.c b/src/compositor/meta-compositor-xrender.c
index 8b6d882..50eea98 100644
--- a/src/compositor/meta-compositor-xrender.c
+++ b/src/compositor/meta-compositor-xrender.c
@@ -167,8 +167,6 @@ struct _MetaCompositorXRender
gboolean clip_changed;
- guint repaint_id;
-
gboolean prefs_listener_added;
guint show_redraw : 1;
@@ -1665,52 +1663,9 @@ paint_all (MetaCompositorXRender *xrender,
}
static void
-repair_display (MetaCompositorXRender *xrender)
-{
- MetaCompositor *compositor = META_COMPOSITOR (xrender);
- MetaDisplay *display = meta_compositor_get_display (compositor);
- Display *xdisplay = meta_display_get_xdisplay (display);
-
- if (xrender->all_damage != None)
- {
- meta_error_trap_push (display);
-
- paint_all (xrender, xrender->all_damage);
- XFixesDestroyRegion (xdisplay, xrender->all_damage);
- xrender->all_damage = None;
- xrender->clip_changed = FALSE;
-
- meta_error_trap_pop (display);
- }
-}
-
-static gboolean
-compositor_idle_cb (gpointer data)
-{
- MetaCompositorXRender *xrender = META_COMPOSITOR_XRENDER (data);
-
- xrender->repaint_id = 0;
- repair_display (xrender);
-
- return FALSE;
-}
-
-static void
add_repair (MetaCompositorXRender *xrender)
{
- if (xrender->repaint_id > 0)
- return;
-
-#if 1
- xrender->repaint_id = g_idle_add_full (META_PRIORITY_REDRAW,
- compositor_idle_cb, xrender,
- NULL);
-#else
- /* Limit it to 50fps */
- xrender->repaint_id = g_timeout_add_full (G_PRIORITY_HIGH, 20,
- compositor_idle_cb, xrender,
- NULL);
-#endif
+ meta_compositor_queue_redraw (META_COMPOSITOR (xrender));
}
static void
@@ -3041,6 +2996,28 @@ meta_compositor_xrender_sync_stack (MetaCompositor *compositor,
}
static void
+meta_compositor_xrender_redraw (MetaCompositor *compositor)
+{
+ MetaCompositorXRender *xrender;
+ MetaDisplay *display;
+
+ xrender = META_COMPOSITOR_XRENDER (compositor);
+ display = meta_compositor_get_display (compositor);
+
+ if (xrender->all_damage == None)
+ return;
+
+ meta_error_trap_push (display);
+
+ paint_all (xrender, xrender->all_damage);
+ XFixesDestroyRegion (xrender->xdisplay, xrender->all_damage);
+ xrender->all_damage = None;
+ xrender->clip_changed = FALSE;
+
+ meta_error_trap_pop (display);
+}
+
+static void
meta_compositor_xrender_class_init (MetaCompositorXRenderClass *xrender_class)
{
GObjectClass *object_class;
@@ -3066,6 +3043,7 @@ meta_compositor_xrender_class_init (MetaCompositorXRenderClass *xrender_class)
compositor_class->unmaximize_window = meta_compositor_xrender_unmaximize_window;
compositor_class->sync_screen_size = meta_compositor_xrender_sync_screen_size;
compositor_class->sync_stack = meta_compositor_xrender_sync_stack;
+ compositor_class->redraw = meta_compositor_xrender_redraw;
}
static void
diff --git a/src/compositor/meta-compositor.c b/src/compositor/meta-compositor.c
index 4b5a9d4..3b4ed22 100644
--- a/src/compositor/meta-compositor.c
+++ b/src/compositor/meta-compositor.c
@@ -43,6 +43,9 @@ typedef struct
/* XCompositeRedirectSubwindows */
gboolean windows_redirected;
+
+ /* meta_compositor_queue_redraw */
+ guint redraw_id;
} MetaCompositorPrivate;
enum
@@ -64,6 +67,22 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (MetaCompositor, meta_compositor, G_TYPE_OBJECT
initable_iface_init))
static gboolean
+redraw_idle_cb (gpointer user_data)
+{
+ MetaCompositor *compositor;
+ MetaCompositorPrivate *priv;
+
+ compositor = META_COMPOSITOR (user_data);
+ priv = meta_compositor_get_instance_private (compositor);
+
+ META_COMPOSITOR_GET_CLASS (compositor)->redraw (compositor);
+
+ priv->redraw_id = 0;
+
+ return G_SOURCE_REMOVE;
+}
+
+static gboolean
check_common_extensions (MetaCompositor *compositor,
GError **error)
{
@@ -135,6 +154,12 @@ meta_compositor_finalize (GObject *object)
priv = meta_compositor_get_instance_private (compositor);
xdisplay = priv->display->xdisplay;
+ if (priv->redraw_id > 0)
+ {
+ g_source_remove (priv->redraw_id);
+ priv->redraw_id = 0;
+ }
+
if (priv->windows_redirected)
{
Window xroot;
@@ -569,3 +594,19 @@ meta_compositor_get_display (MetaCompositor *compositor)
return priv->display;
}
+
+void
+meta_compositor_queue_redraw (MetaCompositor *compositor)
+{
+ MetaCompositorPrivate *priv;
+ gint priority;
+
+ priv = meta_compositor_get_instance_private (compositor);
+ priority = META_PRIORITY_REDRAW;
+
+ if (priv->redraw_id > 0)
+ return;
+
+ priv->redraw_id = g_idle_add_full (priority, redraw_idle_cb, compositor, NULL);
+ g_source_set_name_by_id (priv->redraw_id, "[metacity] redraw_idle_cb");
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]