Bug 1061943 - Purge all GradientCache on memory-pressure. r=jrmuizel, a=bajaj
authorSotaro Ikeda <sikeda@mozilla.com>
Thu, 04 Sep 2014 10:28:43 -0700
changeset 217352 edf91fe901ca0ea6030984a5ef23981445e20b68
parent 217351 7bc34d12c09516b8bbd27bfa947ecbbfa05c5824
child 217353 34b9f8cfa6aaade33db29965c5b69a046bd35deb
push id6783
push userryanvm@gmail.com
push dateMon, 08 Sep 2014 15:11:55 +0000
treeherdermozilla-aurora@885be57b98b7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, bajaj
bugs1061943
milestone34.0a2
Bug 1061943 - Purge all GradientCache on memory-pressure. r=jrmuizel, a=bajaj
gfx/thebes/gfxGradientCache.cpp
gfx/thebes/gfxGradientCache.h
gfx/thebes/gfxPlatform.cpp
--- a/gfx/thebes/gfxGradientCache.cpp
+++ b/gfx/thebes/gfxGradientCache.cpp
@@ -203,16 +203,24 @@ gfxGradientCache::GetOrCreateGradientSto
     if (!gGradientCache->RegisterEntry(cached)) {
       delete cached;
     }
   }
   return gs;
 }
 
 void
+gfxGradientCache::PurgeAllCaches()
+{
+  if (gGradientCache) {
+    gGradientCache->AgeAllGenerations();
+  }
+}
+
+void
 gfxGradientCache::Shutdown()
 {
   delete gGradientCache;
   gGradientCache = nullptr;
 }
 
 }
 }
--- a/gfx/thebes/gfxGradientCache.h
+++ b/gfx/thebes/gfxGradientCache.h
@@ -21,15 +21,16 @@ public:
                      nsTArray<gfx::GradientStop>& aStops,
                      gfx::ExtendMode aExtend);
 
     static gfx::GradientStops*
     GetOrCreateGradientStops(gfx::DrawTarget *aDT,
                              nsTArray<gfx::GradientStop>& aStops,
                              gfx::ExtendMode aExtend);
 
+    static void PurgeAllCaches();
     static void Shutdown();
 };
 
 }
 }
 
 #endif
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -215,16 +215,17 @@ NS_IMPL_ISUPPORTS(MemoryPressureObserver
 
 NS_IMETHODIMP
 MemoryPressureObserver::Observe(nsISupports *aSubject,
                                 const char *aTopic,
                                 const char16_t *someData)
 {
     NS_ASSERTION(strcmp(aTopic, "memory-pressure") == 0, "unexpected event topic");
     Factory::PurgeAllCaches();
+    gfxGradientCache::PurgeAllCaches();
 
     gfxPlatform::GetPlatform()->PurgeSkiaCache();
     return NS_OK;
 }
 
 // this needs to match the list of pref font.default.xx entries listed in all.js!
 // the order *must* match the order in eFontPrefLang
 static const char *gPrefLangNames[] = {