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

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