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 203882 0fc1d3f1a6d72952206c4a534d47abea5347e58b
parent 203881 d1a5bf375ddd39536225f540194e0e5a356ee003
child 203883 0f6a291473742f872f89e30511fbf21132b4d507
push id10
push userkli@mozilla.com
push dateTue, 09 Sep 2014 17:02:42 +0000
treeherdermozilla-b2g32_v2_0m@00fe86125e5e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, bajaj
bugs1061943
milestone32.0
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
@@ -200,16 +200,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
@@ -18,15 +18,16 @@ class gfxGradientCache {
 public:
   static gfx::GradientStops *GetGradientStops(gfx::DrawTarget *aDT,
 					      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
@@ -212,16 +212,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[] = {