Purge the SkLiteDL freelist when PurgeAllCaches() is called.
authormtklein <mtklein@chromium.org>
Tue, 9 Aug 2016 14:40:23 +0000 (07:40 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 9 Aug 2016 14:40:23 +0000 (07:40 -0700)
Seems like the polite thing to do.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2228953002

Review-Url: https://codereview.chromium.org/2228953002

src/core/SkGraphics.cpp
src/core/SkLiteDL.cpp
src/core/SkLiteDL.h

index 01b1432..397d03b 100644 (file)
@@ -14,6 +14,7 @@
 #include "SkGeometry.h"
 #include "SkGlyphCache.h"
 #include "SkImageFilter.h"
+#include "SkLiteDL.h"
 #include "SkMath.h"
 #include "SkMatrix.h"
 #include "SkOpts.h"
@@ -61,6 +62,7 @@ void SkGraphics::PurgeAllCaches() {
     SkGraphics::PurgeFontCache();
     SkGraphics::PurgeResourceCache();
     SkImageFilter::PurgeCache();
+    SkLiteDL::PurgeFreelist();
 }
 
 ///////////////////////////////////////////////////////////////////////////////
index 778f5c9..329edb0 100644 (file)
@@ -711,3 +711,12 @@ void SkLiteDL::internal_dispose() const {
 
     delete this;
 }
+
+void SkLiteDL::PurgeFreelist() {
+    SkAutoMutexAcquire lock(gFreeStackLock);
+    while (gFreeStack) {
+        SkLiteDL* top = gFreeStack;
+        gFreeStack = gFreeStack->fNext;
+        delete top;   // Calling unref() here would just put it back on the list!
+    }
+}
index 072672d..a0c1685 100644 (file)
@@ -21,6 +21,8 @@ class SkLiteDL final : public SkDrawable {
 public:
     static sk_sp<SkLiteDL> New(SkRect);
 
+    static void PurgeFreelist();
+
     void optimizeFor(GrContext*);
     void makeThreadsafe();