aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-12-18 05:23:09 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-18 05:23:09 -0800
commite848ff59651e4441b2c303ef14db10fd678cee9f (patch)
treeb37673f16982a0346818979a29c988199dcfab9f /src/core
parent9cb5d755e7ea8647bcf8bb1ee151ca4c86051107 (diff)
Revert of Create a hash table from id<-->key in SkImageFilter::CacheImpl (patchset #7 id:120001 of https://codereview.chromium.org/1514893003/ )
Reason for revert: speculative revert to try to unblock DEPS roll https://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_asan_rel_ng/builds/94665 Original issue's description: > Create a hash table from id<-->key in SkImageFilter::CacheImpl > > There is memory leak in the SkImageFilter::Cache. There are two sources > of memory leak: > 1. The cache filling up quickly. > 2. A slow small leak that never stops. > This CL solves the first issue, which prevents the cache filling up quickly. > This CL creates a new hash table that index the > SkImageFilter::uniqueID to an array of keys, and with the existing > key<-->Value hash table, we can have SkImageFilters proactively > purge content derived cached content when destroyed. > > BUG=489543 > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1514893003 > > Committed: https://skia.googlesource.com/skia/+/f5d1f8dcc841516d7ea63c151b13059af40ca76d TBR=mtklein@google.com,junov@chromium.org,xidachen@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=489543 Review URL: https://codereview.chromium.org/1537923002
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkImageFilter.cpp33
1 files changed, 5 insertions, 28 deletions
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 9bf9b28ab6..a3f89d08fa 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -18,7 +18,6 @@
#include "SkReadBuffer.h"
#include "SkRect.h"
#include "SkTDynamicHash.h"
-#include "SkTHash.h"
#include "SkTInternalLList.h"
#include "SkValidationUtils.h"
#include "SkWriteBuffer.h"
@@ -202,7 +201,6 @@ SkImageFilter::~SkImageFilter() {
SkSafeUnref(fInputs[i]);
}
delete[] fInputs;
- Cache::Get()->purgeByImageFilterId(fUniqueID);
}
SkImageFilter::SkImageFilter(int inputCount, SkReadBuffer& buffer)
@@ -602,13 +600,6 @@ public:
removeInternal(v);
}
Value* v = new Value(key, result, offset);
- if (SkTArray<Key>** array = fIdToKeys.find(key.fUniqueID)) {
- (*array)->push_back(key);
- } else {
- SkTArray<Key>* keyArray = new SkTArray<Key>();
- keyArray->push_back(key);
- fIdToKeys.set(key.fUniqueID, keyArray);
- }
fLookup.add(v);
fLRU.addToHead(v);
fCurrentBytes += result.getSize();
@@ -631,19 +622,6 @@ public:
}
}
- void purgeByImageFilterId(uint32_t uniqueID) override {
- SkAutoMutexAcquire mutex(fMutex);
- if (SkTArray<Key>** array = fIdToKeys.find(uniqueID)) {
- for (auto& key : **array) {
- if (Value* v = fLookup.find(key)) {
- this->removeInternal(v);
- }
- }
- fIdToKeys.remove(uniqueID);
- delete *array; // This can be deleted outside the lock
- }
- }
-
private:
void removeInternal(Value* v) {
fCurrentBytes -= v->fBitmap.getSize();
@@ -652,12 +630,11 @@ private:
delete v;
}
private:
- SkTDynamicHash<Value, Key> fLookup;
- SkTHashMap<uint32_t, SkTArray<Key>*> fIdToKeys;
- mutable SkTInternalLList<Value> fLRU;
- size_t fMaxBytes;
- size_t fCurrentBytes;
- mutable SkMutex fMutex;
+ SkTDynamicHash<Value, Key> fLookup;
+ mutable SkTInternalLList<Value> fLRU;
+ size_t fMaxBytes;
+ size_t fCurrentBytes;
+ mutable SkMutex fMutex;
};
} // namespace