Commit 80498847 authored by Olivier Fourdan's avatar Olivier Fourdan 🛠

compositor: Add throttled repaint

When using vblank while the screen is turned off, only 1 notification
per second is triggered.

In such a case, there is no need for the compositor to retry repainting
the screen at such a high pace as when when the screen is on.

To avoid wasting power resources, simply throttle repaints after 100
unsuccessful retries.
Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <fourdan@xfce.org>
Closes:#502
parent cb06a039
Pipeline #6194 passed with stages
in 2 minutes and 50 seconds
...@@ -106,13 +106,17 @@ ...@@ -106,13 +106,17 @@
#define TIMEOUT_REPAINT_PRIORITY G_PRIORITY_DEFAULT #define TIMEOUT_REPAINT_PRIORITY G_PRIORITY_DEFAULT
#endif /* TIMEOUT_REPAINT_PRIORITY */ #endif /* TIMEOUT_REPAINT_PRIORITY */
#ifndef TIMEOUT_THROTTLED_REPAINT_PRIORITY
#define TIMEOUT_THROTTLED_REPAINT_PRIORITY G_PRIORITY_LOW
#endif /* TIMEOUT_THROTTLED_REPAINT_PRIORITY */
#ifndef TIMEOUT_REPAINT_MS #ifndef TIMEOUT_REPAINT_MS
#define TIMEOUT_REPAINT_MS 1 #define TIMEOUT_REPAINT_MS 1
#endif /* TIMEOUT_REPAINT_MS */ #endif /* TIMEOUT_REPAINT_MS */
#ifndef MONITOR_ROOT_PIXMAP #ifndef TIMEOUT_THROTTLED_REPAINT_MS
#define MONITOR_ROOT_PIXMAP 1 #define TIMEOUT_THROTTLED_REPAINT_MS 500
#endif /* MONITOR_ROOT_PIXMAP */ #endif /* TIMEOUT_THROTTLED_REPAINT_MS */
#ifndef MONITOR_ROOT_PIXMAP #ifndef MONITOR_ROOT_PIXMAP
#define MONITOR_ROOT_PIXMAP 1 #define MONITOR_ROOT_PIXMAP 1
...@@ -2740,15 +2744,36 @@ repair_screen (ScreenInfo *screen_info) ...@@ -2740,15 +2744,36 @@ repair_screen (ScreenInfo *screen_info)
static gboolean static gboolean
compositor_timeout_cb (gpointer data) compositor_timeout_cb (gpointer data)
{ {
static guint number_of_retries = 0;
ScreenInfo *screen_info; ScreenInfo *screen_info;
gboolean retry; gboolean retry;
screen_info = (ScreenInfo *) data; screen_info = (ScreenInfo *) data;
retry = repair_screen (screen_info); retry = repair_screen (screen_info);
if (retry == FALSE) if (retry)
{
if (number_of_retries <= 100)
{
number_of_retries++;
}
if (number_of_retries == 100)
{
DBG ("Throttling repaint after 100 unsuccessful retries");
/* Stop the current timeout repain */
g_source_remove (screen_info->compositor_timeout_id);
retry = FALSE;
/* Recreate a throttled timeout instead */
screen_info->compositor_timeout_id =
g_timeout_add_full (TIMEOUT_THROTTLED_REPAINT_PRIORITY,
TIMEOUT_THROTTLED_REPAINT_MS,
compositor_timeout_cb, screen_info, NULL);
}
}
else
{ {
screen_info->compositor_timeout_id = 0; screen_info->compositor_timeout_id = 0;
number_of_retries = 0;
} }
return retry; return retry;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment