From: reed Date: Mon, 22 Feb 2016 14:19:54 +0000 (-0800) Subject: add SkGraphics::PurageAllCaches X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~129^2~1913 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1d56448400c1da722a9b34c80ff4a9e46dc3c173;p=platform%2Fupstream%2FlibSkiaSharp.git add SkGraphics::PurageAllCaches 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 --- diff --git a/include/core/SkGraphics.h b/include/core/SkGraphics.h index 5aecc7a..d5a730d 100644 --- a/include/core/SkGraphics.h +++ b/include/core/SkGraphics.h @@ -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 diff --git a/src/core/SkGraphics.cpp b/src/core/SkGraphics.cpp index 5290ea1..2b1212c 100644 --- a/src/core/SkGraphics.cpp +++ b/src/core/SkGraphics.cpp @@ -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";