add SkGraphics::PurageAllCaches
authorreed <reed@google.com>
Mon, 22 Feb 2016 14:19:54 +0000 (06:19 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 22 Feb 2016 14:19:54 +0000 (06:19 -0800)
BUG=skia:4755
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1722603002

TBR=

Review URL: https://codereview.chromium.org/1722603002

include/core/SkGraphics.h
src/core/SkGraphics.cpp

index 5aecc7a..d5a730d 100644 (file)
@@ -120,6 +120,14 @@ public:
     static void DumpMemoryStatistics(SkTraceMemoryDump* dump);
 
     /**
+     *  Free as much globally cached memory as possible. This will purge all private caches in Skia,
+     *  including font and image caches.
+     *
+     *  If there are caches associated with GPU context, those will not be affected by this call.
+     */
+    static void PurgeAllCaches();
+
+    /**
      *  Applications with command line options may pass optional state, such
      *  as cache sizes, here, for instance:
      *  font-cache-limit=12345678
index 5290ea1..2b1212c 100644 (file)
@@ -13,6 +13,7 @@
 #include "SkCanvas.h"
 #include "SkGeometry.h"
 #include "SkGlyphCache.h"
+#include "SkImageFilter.h"
 #include "SkMath.h"
 #include "SkMatrix.h"
 #include "SkOpts.h"
@@ -65,6 +66,12 @@ void SkGraphics::DumpMemoryStatistics(SkTraceMemoryDump* dump) {
   SkGlyphCache::DumpMemoryStatistics(dump);
 }
 
+void SkGraphics::PurgeAllCaches() {
+    SkGraphics::PurgeFontCache();
+    SkGraphics::PurgeResourceCache();
+    SkImageFilter::PurgeCache();
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 
 static const char kFontCacheLimitStr[] = "font-cache-limit";