[clutter] gdk: Enable swap throttling on full screen windows



commit c624230a8a125ae6a06e9139151b0d292aa87915
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Jan 25 18:48:49 2016 +0000

    gdk: Enable swap throttling on full screen windows
    
    Since commit 6183eb363282e5143bfd52aa36b5e6a318c4c992 we disabled swap
    throttling in favour of being driven by the GDK frame clock (and thus by
    the compositor).
    
    Compositors may decide to unredirect full screen windows to avoid the
    performance penalty of the additional copy, especially on X11, which
    means that a Clutter application marked as full screen is not going to
    be driven by the compositor, and it's not going to be throttled by the
    underlying GL machinery. This has a performance impact on constrained
    platforms.
    
    For this reason, we should re-enable swap throttling when the window is
    full screen.
    
    As the change was introduced especially because of Wayland, we should
    check that we're not running as clients under a Wayland compositor; if
    we do, we always keep swap throttling disabled, as the compositor will
    always manage our output, even when full screen.

 clutter/gdk/clutter-stage-gdk.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/clutter/gdk/clutter-stage-gdk.c b/clutter/gdk/clutter-stage-gdk.c
index 10b5550..742de58 100644
--- a/clutter/gdk/clutter-stage-gdk.c
+++ b/clutter/gdk/clutter-stage-gdk.c
@@ -485,7 +485,9 @@ clutter_stage_gdk_set_fullscreen (ClutterStageWindow *stage_window,
                                   gboolean            is_fullscreen)
 {
   ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
+  ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
   ClutterStage *stage = CLUTTER_STAGE_COGL (stage_window)->wrapper;
+  gboolean swap_throttle;
 
   if (stage == NULL || CLUTTER_ACTOR_IN_DESTRUCTION (stage))
     return;
@@ -499,6 +501,26 @@ clutter_stage_gdk_set_fullscreen (ClutterStageWindow *stage_window,
     gdk_window_fullscreen (stage_gdk->window);
   else
     gdk_window_unfullscreen (stage_gdk->window);
+
+  /* Full-screen stages are usually unredirected to improve performance
+   * by avoiding a copy; when that happens, we need to turn back swap
+   * throttling because we won't be managed by the compositor any more,
+   */
+  swap_throttle = is_fullscreen;
+
+#ifdef GDK_WINDOWING_WAYLAND
+  {
+    /* Except on Wayland, where there's a deadlock due to both Cogl
+     * and GDK attempting to consume the throttling event; see bug
+     * https://bugzilla.gnome.org/show_bug.cgi?id=754671#c1
+     */
+    GdkDisplay *display = clutter_gdk_get_default_display ();
+    if (GDK_IS_WAYLAND_DISPLAY (display))
+      swap_throttle = FALSE;
+  }
+#endif
+
+  cogl_onscreen_set_swap_throttled (stage_cogl->onscreen, swap_throttle);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]