Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: src/core/SkImageFilterCache.cpp

Issue 2208903002: Use sse4.2 CRC32 instructions to hash when available. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkDescriptor.h ('k') | src/core/SkOpts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkImageFilterCache.h" 8 #include "SkImageFilterCache.h"
9 9
10 #include "SkChecksum.h"
11 #include "SkMutex.h" 10 #include "SkMutex.h"
12 #include "SkOnce.h" 11 #include "SkOnce.h"
12 #include "SkOpts.h"
13 #include "SkRefCnt.h" 13 #include "SkRefCnt.h"
14 #include "SkSpecialImage.h" 14 #include "SkSpecialImage.h"
15 #include "SkTDynamicHash.h" 15 #include "SkTDynamicHash.h"
16 #include "SkTInternalLList.h" 16 #include "SkTInternalLList.h"
17 17
18 #ifdef SK_BUILD_FOR_IOS 18 #ifdef SK_BUILD_FOR_IOS
19 enum { kDefaultCacheSize = 2 * 1024 * 1024 }; 19 enum { kDefaultCacheSize = 2 * 1024 * 1024 };
20 #else 20 #else
21 enum { kDefaultCacheSize = 128 * 1024 * 1024 }; 21 enum { kDefaultCacheSize = 128 * 1024 * 1024 };
22 #endif 22 #endif
(...skipping 17 matching lines...) Expand all
40 Value(const Key& key, SkSpecialImage* image, const SkIPoint& offset) 40 Value(const Key& key, SkSpecialImage* image, const SkIPoint& offset)
41 : fKey(key), fImage(SkRef(image)), fOffset(offset) {} 41 : fKey(key), fImage(SkRef(image)), fOffset(offset) {}
42 42
43 Key fKey; 43 Key fKey;
44 SkAutoTUnref<SkSpecialImage> fImage; 44 SkAutoTUnref<SkSpecialImage> fImage;
45 SkIPoint fOffset; 45 SkIPoint fOffset;
46 static const Key& GetKey(const Value& v) { 46 static const Key& GetKey(const Value& v) {
47 return v.fKey; 47 return v.fKey;
48 } 48 }
49 static uint32_t Hash(const Key& key) { 49 static uint32_t Hash(const Key& key) {
50 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(&key), sizeof(Key)); 50 return SkOpts::hash(reinterpret_cast<const uint32_t*>(&key), sizeof( Key));
51 } 51 }
52 SK_DECLARE_INTERNAL_LLIST_INTERFACE(Value); 52 SK_DECLARE_INTERNAL_LLIST_INTERFACE(Value);
53 }; 53 };
54 54
55 SkSpecialImage* get(const Key& key, SkIPoint* offset) const override { 55 SkSpecialImage* get(const Key& key, SkIPoint* offset) const override {
56 SkAutoMutexAcquire mutex(fMutex); 56 SkAutoMutexAcquire mutex(fMutex);
57 if (Value* v = fLookup.find(key)) { 57 if (Value* v = fLookup.find(key)) {
58 *offset = v->fOffset; 58 *offset = v->fOffset;
59 if (v != fLRU.head()) { 59 if (v != fLRU.head()) {
60 fLRU.remove(v); 60 fLRU.remove(v);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return new CacheImpl(maxBytes); 125 return new CacheImpl(maxBytes);
126 } 126 }
127 127
128 SkImageFilterCache* SkImageFilterCache::Get() { 128 SkImageFilterCache* SkImageFilterCache::Get() {
129 static SkOnce once; 129 static SkOnce once;
130 static SkImageFilterCache* cache; 130 static SkImageFilterCache* cache;
131 131
132 once([]{ cache = SkImageFilterCache::Create(kDefaultCacheSize); }); 132 once([]{ cache = SkImageFilterCache::Create(kDefaultCacheSize); });
133 return cache; 133 return cache;
134 } 134 }
OLDNEW
« no previous file with comments | « src/core/SkDescriptor.h ('k') | src/core/SkOpts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698