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

Side by Side Diff: src/core/SkResourceCache.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/SkPaint.cpp ('k') | src/gpu/GrProgramDesc.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 2013 Google Inc. 2 * Copyright 2013 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 "SkChecksum.h"
9 #include "SkMessageBus.h" 8 #include "SkMessageBus.h"
10 #include "SkMipMap.h" 9 #include "SkMipMap.h"
11 #include "SkMutex.h" 10 #include "SkMutex.h"
11 #include "SkOpts.h"
12 #include "SkPixelRef.h" 12 #include "SkPixelRef.h"
13 #include "SkResourceCache.h" 13 #include "SkResourceCache.h"
14 #include "SkTraceMemoryDump.h" 14 #include "SkTraceMemoryDump.h"
15 15
16 #include <stddef.h> 16 #include <stddef.h>
17 #include <stdlib.h> 17 #include <stdlib.h>
18 18
19 DECLARE_SKMESSAGEBUS_MESSAGE(SkResourceCache::PurgeSharedIDMessage) 19 DECLARE_SKMESSAGEBUS_MESSAGE(SkResourceCache::PurgeSharedIDMessage)
20 20
21 // This can be defined by the caller's build system 21 // This can be defined by the caller's build system
(...skipping 17 matching lines...) Expand all
39 static const int kLocal32s = kUnhashedLocal32s + kHashedLocal32s; 39 static const int kLocal32s = kUnhashedLocal32s + kHashedLocal32s;
40 40
41 static_assert(sizeof(Key) == (kLocal32s << 2), "unaccounted_key_locals"); 41 static_assert(sizeof(Key) == (kLocal32s << 2), "unaccounted_key_locals");
42 static_assert(sizeof(Key) == offsetof(Key, fNamespace) + sizeof(fNamespace), 42 static_assert(sizeof(Key) == offsetof(Key, fNamespace) + sizeof(fNamespace),
43 "namespace_field_must_be_last"); 43 "namespace_field_must_be_last");
44 44
45 fCount32 = SkToS32(kLocal32s + (dataSize >> 2)); 45 fCount32 = SkToS32(kLocal32s + (dataSize >> 2));
46 fSharedID_lo = (uint32_t)sharedID; 46 fSharedID_lo = (uint32_t)sharedID;
47 fSharedID_hi = (uint32_t)(sharedID >> 32); 47 fSharedID_hi = (uint32_t)(sharedID >> 32);
48 fNamespace = nameSpace; 48 fNamespace = nameSpace;
49 // skip unhashed fields when computing the murmur 49 // skip unhashed fields when computing the hash
50 fHash = SkChecksum::Murmur3(this->as32() + kUnhashedLocal32s, 50 fHash = SkOpts::hash(this->as32() + kUnhashedLocal32s,
51 (fCount32 - kUnhashedLocal32s) << 2); 51 (fCount32 - kUnhashedLocal32s) << 2);
52 } 52 }
53 53
54 #include "SkTDynamicHash.h" 54 #include "SkTDynamicHash.h"
55 55
56 class SkResourceCache::Hash : 56 class SkResourceCache::Hash :
57 public SkTDynamicHash<SkResourceCache::Rec, SkResourceCache::Key> {}; 57 public SkTDynamicHash<SkResourceCache::Rec, SkResourceCache::Key> {};
58 58
59 59
60 /////////////////////////////////////////////////////////////////////////////// 60 ///////////////////////////////////////////////////////////////////////////////
61 61
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed( )); 690 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed( ));
691 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); 691 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr);
692 } 692 }
693 } 693 }
694 694
695 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { 695 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) {
696 // Since resource could be backed by malloc or discardable, the cache always dumps detailed 696 // Since resource could be backed by malloc or discardable, the cache always dumps detailed
697 // stats to be accurate. 697 // stats to be accurate.
698 VisitAll(sk_trace_dump_visitor, dump); 698 VisitAll(sk_trace_dump_visitor, dump);
699 } 699 }
OLDNEW
« no previous file with comments | « src/core/SkPaint.cpp ('k') | src/gpu/GrProgramDesc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698