Blame SOURCES/0008-background-purge-all-background-textures-on-suspend.patch

657d8e
From c78a614b0d45a4bc8101a93c7138c9fb6102d13c Mon Sep 17 00:00:00 2001
657d8e
From: Ray Strode <rstrode@redhat.com>
657d8e
Date: Wed, 9 Jan 2019 16:57:05 -0500
657d8e
Subject: [PATCH 8/9] background: purge all background textures on suspend
657d8e
657d8e
This commit makes sure all background textures get purged
657d8e
on suspend, which is important for nvidia.
657d8e
---
657d8e
 src/compositor/meta-background-image.c | 28 ++++++++++++++++++++++++++
657d8e
 src/compositor/meta-background.c       | 17 +++++++++++++++-
657d8e
 src/meta/meta-background-image.h       |  2 ++
657d8e
 3 files changed, 46 insertions(+), 1 deletion(-)
657d8e
657d8e
diff --git a/src/compositor/meta-background-image.c b/src/compositor/meta-background-image.c
657d8e
index 14d3baf57..98909cb53 100644
657d8e
--- a/src/compositor/meta-background-image.c
657d8e
+++ b/src/compositor/meta-background-image.c
657d8e
@@ -283,6 +283,34 @@ meta_background_image_cache_purge (MetaBackgroundImageCache *cache,
657d8e
   image->in_cache = FALSE;
657d8e
 }
657d8e
 
657d8e
+/**
657d8e
+ * meta_background_image_cache_unload_all:
657d8e
+ * @cache: a #MetaBackgroundImageCache
657d8e
+ *
657d8e
+ * Remove all entries from the cache and unloads them; this would be used
657d8e
+ * if textures in video memory have been invalidated.
657d8e
+ */
657d8e
+void
657d8e
+meta_background_image_cache_unload_all (MetaBackgroundImageCache *cache)
657d8e
+{
657d8e
+  GHashTableIter iter;
657d8e
+  gpointer key, value;
657d8e
+
657d8e
+  g_return_if_fail (META_IS_BACKGROUND_IMAGE_CACHE (cache));
657d8e
+
657d8e
+  g_hash_table_iter_init (&iter, cache->images);
657d8e
+  while (g_hash_table_iter_next (&iter, &key, &value))
657d8e
+    {
657d8e
+      MetaBackgroundImage *image = value;
657d8e
+
657d8e
+      g_clear_pointer (&image->texture, cogl_object_unref);
657d8e
+      image->in_cache = FALSE;
657d8e
+      image->loaded = FALSE;
657d8e
+    }
657d8e
+
657d8e
+  g_hash_table_remove_all (cache->images);
657d8e
+}
657d8e
+
657d8e
 G_DEFINE_TYPE (MetaBackgroundImage, meta_background_image, G_TYPE_OBJECT);
657d8e
 
657d8e
 static void
657d8e
diff --git a/src/compositor/meta-background.c b/src/compositor/meta-background.c
657d8e
index c033395fe..abdfcc7df 100644
657d8e
--- a/src/compositor/meta-background.c
657d8e
+++ b/src/compositor/meta-background.c
657d8e
@@ -303,6 +303,18 @@ meta_background_finalize (GObject *object)
657d8e
   G_OBJECT_CLASS (meta_background_parent_class)->finalize (object);
657d8e
 }
657d8e
 
657d8e
+static void
657d8e
+free_textures (MetaBackground *self)
657d8e
+{
657d8e
+  free_color_texture (self);
657d8e
+  free_wallpaper_texture (self);
657d8e
+
657d8e
+  set_file (self, &self->file1, &self->background_image1, NULL);
657d8e
+  set_file (self, &self->file2, &self->background_image2, NULL);
657d8e
+
657d8e
+  mark_changed (self);
657d8e
+}
657d8e
+
657d8e
 static void
657d8e
 meta_background_constructed (GObject *object)
657d8e
 {
657d8e
@@ -312,7 +324,7 @@ meta_background_constructed (GObject *object)
657d8e
   G_OBJECT_CLASS (meta_background_parent_class)->constructed (object);
657d8e
 
657d8e
   g_signal_connect_object (self->display, "gl-video-memory-purged",
657d8e
-                           G_CALLBACK (mark_changed), object, G_CONNECT_SWAPPED);
657d8e
+                           G_CALLBACK (free_textures), object, G_CONNECT_SWAPPED);
657d8e
 
657d8e
   g_signal_connect_object (monitor_manager, "monitors-changed",
657d8e
                            G_CALLBACK (on_monitors_changed), self,
657d8e
@@ -950,8 +962,11 @@ meta_background_set_blend (MetaBackground          *self,
657d8e
 void
657d8e
 meta_background_refresh_all (void)
657d8e
 {
657d8e
+  MetaBackgroundImageCache *cache = meta_background_image_cache_get_default ();
657d8e
   GSList *l;
657d8e
 
657d8e
+  meta_background_image_cache_unload_all (cache);
657d8e
+
657d8e
   for (l = all_backgrounds; l; l = l->next)
657d8e
     mark_changed (l->data);
657d8e
 }
657d8e
diff --git a/src/meta/meta-background-image.h b/src/meta/meta-background-image.h
657d8e
index 137a6ff8e..87e40d251 100644
657d8e
--- a/src/meta/meta-background-image.h
657d8e
+++ b/src/meta/meta-background-image.h
657d8e
@@ -66,4 +66,6 @@ META_EXPORT
657d8e
 void                 meta_background_image_cache_purge (MetaBackgroundImageCache *cache,
657d8e
                                                         GFile                    *file);
657d8e
 
657d8e
+void                 meta_background_image_cache_unload_all (MetaBackgroundImageCache *cache);
657d8e
+
657d8e
 #endif /* __META_BACKGROUND_IMAGE_H__ */
657d8e
-- 
657d8e
2.21.0
657d8e