From dbc63430d879c927f7e308e29e4570993eccbfde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 1 Aug 2017 17:13:32 +0800 Subject: [PATCH] renderer-native: Destroy monitor framebuffers when suspending When suspending (i.e. VT switching away, the GDM gnome-shell instance gets hidden, or changing user), destroy the onscreen and offscreen monitor framebuffers. When resuming, the stage views and framebuffers will be recreated anyway. https://bugzilla.gnome.org/show_bug.cgi?id=786299 --- clutter/clutter/clutter-stage-view.c | 4 +++- src/backends/native/meta-backend-native.c | 3 +++ src/backends/native/meta-renderer-native.c | 18 ++++++++++++++++++ src/backends/native/meta-renderer-native.h | 2 ++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/clutter/clutter/clutter-stage-view.c b/clutter/clutter/clutter-stage-view.c index 000371247..e2792a062 100644 --- a/clutter/clutter/clutter-stage-view.c +++ b/clutter/clutter/clutter-stage-view.c @@ -267,6 +267,7 @@ clutter_stage_view_set_property (GObject *object, priv->layout = *layout; break; case PROP_FRAMEBUFFER: + g_clear_pointer (&priv->framebuffer, cogl_object_unref); priv->framebuffer = g_value_dup_boxed (value); #ifndef G_DISABLE_CHECKS if (priv->framebuffer) @@ -284,6 +285,7 @@ clutter_stage_view_set_property (GObject *object, #endif break; case PROP_OFFSCREEN: + g_clear_pointer (&priv->offscreen, cogl_object_unref); priv->offscreen = g_value_dup_boxed (value); break; case PROP_SCALE: @@ -355,7 +357,7 @@ clutter_stage_view_class_init (ClutterStageViewClass *klass) "Framebuffer used as intermediate buffer", COGL_TYPE_HANDLE, G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | + G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); obj_props[PROP_SCALE] = diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c index eeb5ac15f..547bdde50 100644 --- a/src/backends/native/meta-backend-native.c +++ b/src/backends/native/meta-backend-native.c @@ -668,11 +668,14 @@ meta_backend_native_pause (MetaBackendNative *native) meta_backend_get_monitor_manager (backend); MetaMonitorManagerKms *monitor_manager_kms = META_MONITOR_MANAGER_KMS (monitor_manager); + MetaRendererNative *renderer_native = + META_RENDERER_NATIVE (meta_backend_get_renderer (backend)); clutter_evdev_release_devices (); clutter_egl_freeze_master_clock (); meta_monitor_manager_kms_pause (monitor_manager_kms); + meta_renderer_native_pause (renderer_native); } void meta_backend_native_resume (MetaBackendNative *native) diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index 85ee2789b..90a029f36 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -1786,6 +1786,24 @@ meta_renderer_native_get_frame_counter (MetaRendererNative *renderer_native) return renderer_native->frame_counter; } +void +meta_renderer_native_pause (MetaRendererNative *renderer_native) +{ + GList *views; + GList *l; + + views = meta_renderer_get_views (META_RENDERER (renderer_native)); + for (l = views; l; l = l->next) + { + ClutterStageView *stage_view = l->data; + + g_object_set (G_OBJECT (stage_view), + "framebuffer", NULL, + "offscreen", NULL, + NULL); + } +} + static void meta_renderer_native_get_property (GObject *object, guint prop_id, diff --git a/src/backends/native/meta-renderer-native.h b/src/backends/native/meta-renderer-native.h index 24cfdd35b..8a884763a 100644 --- a/src/backends/native/meta-renderer-native.h +++ b/src/backends/native/meta-renderer-native.h @@ -71,4 +71,6 @@ void meta_renderer_native_finish_frame (MetaRendererNative *renderer_native); int64_t meta_renderer_native_get_frame_counter (MetaRendererNative *renderer_native); +void meta_renderer_native_pause (MetaRendererNative *renderer_native); + #endif /* META_RENDERER_NATIVE_H */