Bug 946541 - Fix Skia cache purging. r=gw280
authorAndreas Gal <gal@uci.edu>
Wed, 04 Dec 2013 23:52:03 -0500
changeset 158905 eb7a2bcb3e6f49e2f8efc2fac3bf31fe3b31799f
parent 158904 bb4d1db9477cd9eaec3d1a02f0463f073b421013
child 158906 e25fe2e1417dc4d5c1bc504a2c1fc7d7792aaceb
push id25765
push usercbook@mozilla.com
push dateThu, 05 Dec 2013 11:57:42 +0000
treeherdermozilla-central@118234ab24ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw280
bugs946541
milestone28.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 946541 - Fix Skia cache purging. r=gw280
gfx/2d/2D.h
gfx/2d/DrawTargetSkia.cpp
gfx/2d/DrawTargetSkia.h
gfx/2d/Factory.cpp
gfx/thebes/gfxPlatform.cpp
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -1036,17 +1036,17 @@ public:
                                                       GrGLInterface* aGrGLInterface,
                                                       const IntSize &aSize,
                                                       SurfaceFormat aFormat);
 
   static void
     SetGlobalSkiaCacheLimits(int aCount, int aSizeInBytes);
 #endif
 
-  static void PurgeTextureCaches();
+  static void PurgeAllCaches();
 
 #if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
   static TemporaryRef<GlyphRenderingOptions>
     CreateCairoGlyphRenderingOptions(FontHinting aHinting, bool aAutoHinting);
 #endif
   static TemporaryRef<DrawTarget>
     CreateDualDrawTarget(DrawTarget *targetA, DrawTarget *targetB);
 
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -127,33 +127,30 @@ DrawTargetSkia::SetGlobalCacheLimits(int
 {
   sTextureCacheCount = aCount;
   sTextureCacheSizeInBytes = aSizeInBytes;
 
   DrawTargetSkia::RebalanceCacheLimits();
 }
 
 void
-DrawTargetSkia::PurgeCache()
+DrawTargetSkia::PurgeCaches()
 {
   if (mGrContext) {
-    mGrContext->purgeCache();
+    mGrContext->freeGpuResources();
   }
 }
 
 /* static */ void
-DrawTargetSkia::PurgeTextureCaches()
+DrawTargetSkia::PurgeAllCaches()
 {
   std::vector<DrawTargetSkia*>& targets = GLDrawTargets();
   uint32_t targetCount = targets.size();
-  if (targetCount == 0)
-    return;
-
   for (uint32_t i = 0; i < targetCount; i++) {
-    targets[i]->PurgeCache();
+    targets[i]->PurgeCaches();
   }
 }
 
 #endif
 
 static SkBitmap
 GetBitmapForSurface(SourceSurface *aSurface)
 {
--- a/gfx/2d/DrawTargetSkia.h
+++ b/gfx/2d/DrawTargetSkia.h
@@ -106,21 +106,21 @@ public:
 #ifdef USE_SKIA_GPU
   virtual GenericRefCountedBase* GetGLContext() const MOZ_OVERRIDE { return mGLContext; }
   void InitWithGLContextAndGrGLInterface(GenericRefCountedBase* aGLContext,
                                          GrGLInterface* aGrGLInterface,
                                          const IntSize &aSize,
                                          SurfaceFormat aFormat) MOZ_OVERRIDE;
 
   void SetCacheLimits(int aCount, int aSizeInBytes);
-  void PurgeCache();
+  void PurgeCaches();
 
   static void SetGlobalCacheLimits(int aCount, int aSizeInBytes);
   static void RebalanceCacheLimits();
-  static void PurgeTextureCaches();
+  static void PurgeAllCaches();
 #endif
 
   operator std::string() const {
     std::stringstream stream;
     stream << "DrawTargetSkia(" << this << ")";
     return stream.str();
   }
 
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -544,20 +544,20 @@ Factory::CreateDrawTargetSkiaWithGLConte
 void
 Factory::SetGlobalSkiaCacheLimits(int aCount, int aSizeInBytes)
 {
     DrawTargetSkia::SetGlobalCacheLimits(aCount, aSizeInBytes);
 }
 #endif // USE_SKIA_GPU
 
 void
-Factory::PurgeTextureCaches()
+Factory::PurgeAllCaches()
 {
 #ifdef USE_SKIA_GPU
-  DrawTargetSkia::PurgeTextureCaches();
+  DrawTargetSkia::PurgeAllCaches();
 #endif
 }
 
 #ifdef USE_SKIA_FREETYPE
 TemporaryRef<GlyphRenderingOptions>
 Factory::CreateCairoGlyphRenderingOptions(FontHinting aHinting, bool aAutoHinting)
 {
   RefPtr<GlyphRenderingOptionsCairo> options =
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -228,17 +228,17 @@ public:
 NS_IMPL_ISUPPORTS1(MemoryPressureObserver, nsIObserver)
 
 NS_IMETHODIMP
 MemoryPressureObserver::Observe(nsISupports *aSubject,
                                 const char *aTopic,
                                 const PRUnichar *someData)
 {
     NS_ASSERTION(strcmp(aTopic, "memory-pressure") == 0, "unexpected event topic");
-    Factory::PurgeTextureCaches();
+    Factory::PurgeAllCaches();
     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[] = {
     "x-western",
     "x-central-euro",