Blame SOURCES/0003-st-texture-cache-purge-on-resume.patch

c7fac9
From fd9a803159ca7e7fbe6bee1842cc78deff0da7fa Mon Sep 17 00:00:00 2001
c7fac9
From: Ray Strode <rstrode@redhat.com>
c7fac9
Date: Tue, 15 Jan 2019 12:54:32 -0500
c7fac9
Subject: [PATCH 3/4] st-texture-cache: purge on resume
c7fac9
c7fac9
With the proprietary nvidia driver, textures get garbled on suspend,
c7fac9
so the texture cache needs to evict all textures in that situation.
c7fac9
---
c7fac9
 js/ui/main.js             |  6 +++++-
c7fac9
 src/st/st-texture-cache.c | 12 ++++++++++++
c7fac9
 src/st/st-texture-cache.h |  1 +
c7fac9
 3 files changed, 18 insertions(+), 1 deletion(-)
c7fac9
c7fac9
diff --git a/js/ui/main.js b/js/ui/main.js
c7fac9
index a8779bf09..faaf07399 100644
c7fac9
--- a/js/ui/main.js
c7fac9
+++ b/js/ui/main.js
c7fac9
@@ -184,61 +184,65 @@ function _initializeUI() {
c7fac9
 
c7fac9
     messageTray = new MessageTray.MessageTray();
c7fac9
     panel = new Panel.Panel();
c7fac9
     keyboard = new Keyboard.Keyboard();
c7fac9
     notificationDaemon = new NotificationDaemon.NotificationDaemon();
c7fac9
     windowAttentionHandler = new WindowAttentionHandler.WindowAttentionHandler();
c7fac9
     componentManager = new Components.ComponentManager();
c7fac9
 
c7fac9
     introspectService = new Introspect.IntrospectService();
c7fac9
 
c7fac9
     layoutManager.init();
c7fac9
     overview.init();
c7fac9
 
c7fac9
     _a11ySettings = new Gio.Settings({ schema_id: A11Y_SCHEMA });
c7fac9
 
c7fac9
     global.display.connect('overlay-key', () => {
c7fac9
         if (!_a11ySettings.get_boolean (STICKY_KEYS_ENABLE))
c7fac9
             overview.toggle();
c7fac9
     });
c7fac9
 
c7fac9
     global.display.connect('show-restart-message', (display, message) => {
c7fac9
         showRestartMessage(message);
c7fac9
         return true;
c7fac9
     });
c7fac9
 
c7fac9
     global.display.connect('restart', () => {
c7fac9
         global.reexec_self();
c7fac9
         return true;
c7fac9
     });
c7fac9
 
c7fac9
-    global.display.connect('gl-video-memory-purged', loadTheme);
c7fac9
+    global.display.connect('gl-video-memory-purged', () => {
c7fac9
+        let cache = St.TextureCache.get_default();
c7fac9
+        cache.clear();
c7fac9
+        loadTheme();
c7fac9
+    });
c7fac9
 
c7fac9
     // Provide the bus object for gnome-session to
c7fac9
     // initiate logouts.
c7fac9
     EndSessionDialog.init();
c7fac9
 
c7fac9
     // We're ready for the session manager to move to the next phase
c7fac9
     Meta.register_with_session();
c7fac9
 
c7fac9
     _startDate = new Date();
c7fac9
 
c7fac9
     let perfModuleName = GLib.getenv("SHELL_PERF_MODULE");
c7fac9
     if (perfModuleName) {
c7fac9
         let perfOutput = GLib.getenv("SHELL_PERF_OUTPUT");
c7fac9
         let module = eval('imports.perf.' + perfModuleName + ';');
c7fac9
         Scripting.runPerfScript(module, perfOutput);
c7fac9
     }
c7fac9
 
c7fac9
     ExtensionDownloader.init();
c7fac9
     ExtensionSystem.init();
c7fac9
 
c7fac9
     if (sessionMode.isGreeter && screenShield) {
c7fac9
         layoutManager.connect('startup-prepared', () => {
c7fac9
             screenShield.showDialog();
c7fac9
         });
c7fac9
     }
c7fac9
 
c7fac9
     layoutManager.connect('startup-complete', () => {
c7fac9
         if (actionMode == Shell.ActionMode.NONE) {
c7fac9
             actionMode = Shell.ActionMode.NORMAL;
c7fac9
         }
c7fac9
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
c7fac9
index 0c794a3ab..5a3dcd81f 100644
c7fac9
--- a/src/st/st-texture-cache.c
c7fac9
+++ b/src/st/st-texture-cache.c
c7fac9
@@ -78,60 +78,72 @@ set_texture_cogl_texture (ClutterTexture *clutter_texture, CoglTexture *cogl_tex
c7fac9
 {
c7fac9
   clutter_texture_set_cogl_texture (clutter_texture, cogl_texture);
c7fac9
   g_object_set (clutter_texture, "opacity", 255, NULL);
c7fac9
 }
c7fac9
 
c7fac9
 static void
c7fac9
 st_texture_cache_class_init (StTextureCacheClass *klass)
c7fac9
 {
c7fac9
   GObjectClass *gobject_class = (GObjectClass *)klass;
c7fac9
 
c7fac9
   gobject_class->dispose = st_texture_cache_dispose;
c7fac9
   gobject_class->finalize = st_texture_cache_finalize;
c7fac9
 
c7fac9
   signals[ICON_THEME_CHANGED] =
c7fac9
     g_signal_new ("icon-theme-changed",
c7fac9
                   G_TYPE_FROM_CLASS (klass),
c7fac9
                   G_SIGNAL_RUN_LAST,
c7fac9
                   0, /* no default handler slot */
c7fac9
                   NULL, NULL, NULL,
c7fac9
                   G_TYPE_NONE, 0);
c7fac9
 
c7fac9
   signals[TEXTURE_FILE_CHANGED] =
c7fac9
     g_signal_new ("texture-file-changed",
c7fac9
                   G_TYPE_FROM_CLASS (klass),
c7fac9
                   G_SIGNAL_RUN_LAST,
c7fac9
                   0, /* no default handler slot */
c7fac9
                   NULL, NULL, NULL,
c7fac9
                   G_TYPE_NONE, 1, G_TYPE_FILE);
c7fac9
 }
c7fac9
 
c7fac9
+/* Evicts all cached textures */
c7fac9
+void
c7fac9
+st_texture_cache_clear (StTextureCache *cache)
c7fac9
+{
c7fac9
+  GHashTableIter iter;
c7fac9
+  gpointer key;
c7fac9
+  gpointer value;
c7fac9
+
c7fac9
+  g_hash_table_remove_all (cache->priv->keyed_cache);
c7fac9
+  g_signal_emit (cache, signals[ICON_THEME_CHANGED], 0);
c7fac9
+}
c7fac9
+
c7fac9
 /* Evicts all cached textures for named icons */
c7fac9
 static void
c7fac9
 st_texture_cache_evict_icons (StTextureCache *cache)
c7fac9
 {
c7fac9
   GHashTableIter iter;
c7fac9
   gpointer key;
c7fac9
   gpointer value;
c7fac9
 
c7fac9
   g_hash_table_iter_init (&iter, cache->priv->keyed_cache);
c7fac9
   while (g_hash_table_iter_next (&iter, &key, &value))
c7fac9
     {
c7fac9
       const char *cache_key = key;
c7fac9
 
c7fac9
       /* This is too conservative - it takes out all cached textures
c7fac9
        * for GIcons even when they aren't named icons, but it's not
c7fac9
        * worth the complexity of parsing the key and calling
c7fac9
        * g_icon_new_for_string(); icon theme changes aren't normal */
c7fac9
       if (g_str_has_prefix (cache_key, CACHE_PREFIX_ICON))
c7fac9
         g_hash_table_iter_remove (&iter);
c7fac9
     }
c7fac9
 }
c7fac9
 
c7fac9
 static void
c7fac9
 on_icon_theme_changed (GtkIconTheme   *icon_theme,
c7fac9
                        StTextureCache *cache)
c7fac9
 {
c7fac9
   st_texture_cache_evict_icons (cache);
c7fac9
   g_signal_emit (cache, signals[ICON_THEME_CHANGED], 0);
c7fac9
 }
c7fac9
 
c7fac9
diff --git a/src/st/st-texture-cache.h b/src/st/st-texture-cache.h
c7fac9
index 26f9c30ac..b87adc4d5 100644
c7fac9
--- a/src/st/st-texture-cache.h
c7fac9
+++ b/src/st/st-texture-cache.h
c7fac9
@@ -25,60 +25,61 @@
c7fac9
 #if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
c7fac9
 #error "Only <st/st.h> can be included directly.h"
c7fac9
 #endif
c7fac9
 
c7fac9
 #include <gio/gio.h>
c7fac9
 #include <gtk/gtk.h>
c7fac9
 #include <clutter/clutter.h>
c7fac9
 
c7fac9
 #include <st/st-types.h>
c7fac9
 #include <st/st-theme-node.h>
c7fac9
 
c7fac9
 #define ST_TYPE_TEXTURE_CACHE                 (st_texture_cache_get_type ())
c7fac9
 G_DECLARE_FINAL_TYPE (StTextureCache, st_texture_cache,
c7fac9
                       ST, TEXTURE_CACHE, GObject)
c7fac9
 
c7fac9
 typedef struct _StTextureCachePrivate StTextureCachePrivate;
c7fac9
 
c7fac9
 struct _StTextureCache
c7fac9
 {
c7fac9
   GObject parent;
c7fac9
 
c7fac9
   StTextureCachePrivate *priv;
c7fac9
 };
c7fac9
 
c7fac9
 typedef enum {
c7fac9
   ST_TEXTURE_CACHE_POLICY_NONE,
c7fac9
   ST_TEXTURE_CACHE_POLICY_FOREVER
c7fac9
 } StTextureCachePolicy;
c7fac9
 
c7fac9
 StTextureCache* st_texture_cache_get_default (void);
c7fac9
+void st_texture_cache_clear (StTextureCache *cache);
c7fac9
 
c7fac9
 ClutterActor *
c7fac9
 st_texture_cache_load_sliced_image (StTextureCache *cache,
c7fac9
                                     GFile          *file,
c7fac9
                                     gint            grid_width,
c7fac9
                                     gint            grid_height,
c7fac9
                                     gint            scale,
c7fac9
                                     GFunc           load_callback,
c7fac9
                                     gpointer        user_data);
c7fac9
 
c7fac9
 ClutterActor *st_texture_cache_bind_cairo_surface_property (StTextureCache    *cache,
c7fac9
                                                             GObject           *object,
c7fac9
                                                             const char        *property_name);
c7fac9
 
c7fac9
 ClutterActor *st_texture_cache_load_gicon (StTextureCache *cache,
c7fac9
                                            StThemeNode    *theme_node,
c7fac9
                                            GIcon          *icon,
c7fac9
                                            gint            size,
c7fac9
                                            gint            scale);
c7fac9
 
c7fac9
 ClutterActor *st_texture_cache_load_file_async (StTextureCache    *cache,
c7fac9
                                                 GFile             *file,
c7fac9
                                                 int                available_width,
c7fac9
                                                 int                available_height,
c7fac9
                                                 int                scale);
c7fac9
 
c7fac9
 CoglTexture     *st_texture_cache_load_file_to_cogl_texture (StTextureCache *cache,
c7fac9
                                                              GFile          *file,
c7fac9
                                                              gint            scale);
c7fac9
 
c7fac9
-- 
c7fac9
2.18.1
c7fac9