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
This commit is contained in:
Jonas Ådahl 2017-08-01 17:13:32 +08:00
parent 0f861cecac
commit dbc63430d8
4 changed files with 26 additions and 1 deletions

View File

@ -267,6 +267,7 @@ clutter_stage_view_set_property (GObject *object,
priv->layout = *layout; priv->layout = *layout;
break; break;
case PROP_FRAMEBUFFER: case PROP_FRAMEBUFFER:
g_clear_pointer (&priv->framebuffer, cogl_object_unref);
priv->framebuffer = g_value_dup_boxed (value); priv->framebuffer = g_value_dup_boxed (value);
#ifndef G_DISABLE_CHECKS #ifndef G_DISABLE_CHECKS
if (priv->framebuffer) if (priv->framebuffer)
@ -284,6 +285,7 @@ clutter_stage_view_set_property (GObject *object,
#endif #endif
break; break;
case PROP_OFFSCREEN: case PROP_OFFSCREEN:
g_clear_pointer (&priv->offscreen, cogl_object_unref);
priv->offscreen = g_value_dup_boxed (value); priv->offscreen = g_value_dup_boxed (value);
break; break;
case PROP_SCALE: case PROP_SCALE:
@ -355,7 +357,7 @@ clutter_stage_view_class_init (ClutterStageViewClass *klass)
"Framebuffer used as intermediate buffer", "Framebuffer used as intermediate buffer",
COGL_TYPE_HANDLE, COGL_TYPE_HANDLE,
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
obj_props[PROP_SCALE] = obj_props[PROP_SCALE] =

View File

@ -668,11 +668,14 @@ meta_backend_native_pause (MetaBackendNative *native)
meta_backend_get_monitor_manager (backend); meta_backend_get_monitor_manager (backend);
MetaMonitorManagerKms *monitor_manager_kms = MetaMonitorManagerKms *monitor_manager_kms =
META_MONITOR_MANAGER_KMS (monitor_manager); META_MONITOR_MANAGER_KMS (monitor_manager);
MetaRendererNative *renderer_native =
META_RENDERER_NATIVE (meta_backend_get_renderer (backend));
clutter_evdev_release_devices (); clutter_evdev_release_devices ();
clutter_egl_freeze_master_clock (); clutter_egl_freeze_master_clock ();
meta_monitor_manager_kms_pause (monitor_manager_kms); meta_monitor_manager_kms_pause (monitor_manager_kms);
meta_renderer_native_pause (renderer_native);
} }
void meta_backend_native_resume (MetaBackendNative *native) void meta_backend_native_resume (MetaBackendNative *native)

View File

@ -1786,6 +1786,24 @@ meta_renderer_native_get_frame_counter (MetaRendererNative *renderer_native)
return renderer_native->frame_counter; 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 static void
meta_renderer_native_get_property (GObject *object, meta_renderer_native_get_property (GObject *object,
guint prop_id, guint prop_id,

View File

@ -71,4 +71,6 @@ void meta_renderer_native_finish_frame (MetaRendererNative *renderer_native);
int64_t meta_renderer_native_get_frame_counter (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 */ #endif /* META_RENDERER_NATIVE_H */