OLD | NEW |
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 "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkChecksum.h" | |
11 #include "SkFontHost.h" | 10 #include "SkFontHost.h" |
12 #include "SkPaint.h" | 11 #include "SkPaint.h" |
13 #include "SkString.h" | 12 #include "SkString.h" |
14 #include "SkTemplates.h" | 13 #include "SkTemplates.h" |
15 | 14 |
16 #include "gUniqueGlyphIDs.h" | 15 #include "gUniqueGlyphIDs.h" |
17 #define gUniqueGlyphIDs_Sentinel 0xFFFF | 16 #define gUniqueGlyphIDs_Sentinel 0xFFFF |
18 | 17 |
19 static int count_glyphs(const uint16_t start[]) { | 18 static int count_glyphs(const uint16_t start[]) { |
20 const uint16_t* curr = start; | 19 const uint16_t* curr = start; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 return (value >> bits) | (value << (32 - bits)); | 57 return (value >> bits) | (value << (32 - bits)); |
59 } | 58 } |
60 | 59 |
61 typedef uint32_t (*HasherProc)(uint32_t); | 60 typedef uint32_t (*HasherProc)(uint32_t); |
62 | 61 |
63 static uint32_t hasher0(uint32_t value) { | 62 static uint32_t hasher0(uint32_t value) { |
64 value = value ^ (value >> 16); | 63 value = value ^ (value >> 16); |
65 return value ^ (value >> 8); | 64 return value ^ (value >> 8); |
66 } | 65 } |
67 | 66 |
| 67 static uint32_t hasher2(uint32_t h) { |
| 68 h ^= h >> 16; |
| 69 h *= 0x85ebca6b; |
| 70 h ^= h >> 13; |
| 71 h *= 0xc2b2ae35; |
| 72 h ^= h >> 16; |
| 73 |
| 74 h ^= (h >> 8); |
| 75 return h; |
| 76 } |
| 77 |
68 static const struct { | 78 static const struct { |
69 const char* fName; | 79 const char* fName; |
70 HasherProc fHasher; | 80 HasherProc fHasher; |
71 } gRec[] = { | 81 } gRec[] = { |
72 { "hasher0", hasher0 }, | 82 { "hasher0", hasher0 }, |
73 { "hasher2", SkChecksum::Mix }, | 83 { "hasher2", hasher2 }, |
74 }; | 84 }; |
75 | 85 |
76 #define kMaxHashBits 12 | 86 #define kMaxHashBits 12 |
77 #define kMaxHashCount (1 << kMaxHashBits) | 87 #define kMaxHashCount (1 << kMaxHashBits) |
78 | 88 |
79 static int count_collisions(const uint16_t array[], int count, HasherProc proc, | 89 static int count_collisions(const uint16_t array[], int count, HasherProc proc, |
80 unsigned hashMask) { | 90 unsigned hashMask) { |
81 char table[kMaxHashCount]; | 91 char table[kMaxHashCount]; |
82 sk_bzero(table, sizeof(table)); | 92 sk_bzero(table, sizeof(table)); |
83 | 93 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 private: | 149 private: |
140 typedef Benchmark INHERITED; | 150 typedef Benchmark INHERITED; |
141 }; | 151 }; |
142 | 152 |
143 /////////////////////////////////////////////////////////////////////////////// | 153 /////////////////////////////////////////////////////////////////////////////// |
144 | 154 |
145 DEF_BENCH( return new FontCacheBench(); ) | 155 DEF_BENCH( return new FontCacheBench(); ) |
146 | 156 |
147 // undefine this to run the efficiency test | 157 // undefine this to run the efficiency test |
148 //DEF_BENCH( return new FontCacheEfficiency(); ) | 158 //DEF_BENCH( return new FontCacheEfficiency(); ) |
OLD | NEW |