Bug 1061943 - Purge all GradientCache on memory-pressure r=jrmuizel
authorSotaro Ikeda <sikeda@mozilla.com>
Thu, 04 Sep 2014 10:28:43 -0700
changeset 203636 b9f45ad6a96ebca1f2b3a1db1eea45169b5a5da1
parent 203635 1c04e1da900e07613d54662cf09549568f7a69b0
child 203637 4b60964c73f75b33ddd07b82c7d8513e07022265
push id27433
push userkwierso@gmail.com
push dateFri, 05 Sep 2014 01:31:29 +0000
treeherdermozilla-central@db7212847c14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1061943
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1061943 - Purge all GradientCache on memory-pressure r=jrmuizel
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[] = {