gdk: Enable swap throttling on full screen windows

Since commit 6183eb3632 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.
This commit is contained in:
Emmanuele Bassi 2016-01-25 18:48:49 +00:00
parent 84b17220c0
commit c624230a8a

View File

@ -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