OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifndef SkBitmapHasher_DEFINED | 9 #ifndef SkBitmapHasher_DEFINED |
10 #define SkBitmapHasher_DEFINED | 10 #define SkBitmapHasher_DEFINED |
11 | 11 |
12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
13 | 13 |
14 // TODO(epoger): Soon, SkHashDigest will become a real class of its own, | |
15 // and callers won't be able to assume it converts to/from a uint64_t. | |
16 typedef uint64_t SkHashDigest; | |
17 | |
18 /** | 14 /** |
19 * Static class that can generate an SkHashDigest from an SkBitmap. | 15 * Static class that generates a uint64 hash digest from an SkBitmap. |
20 */ | 16 */ |
21 class SkBitmapHasher { | 17 class SkBitmapHasher { |
22 public: | 18 public: |
23 /** | 19 /** |
24 * Fills in "result" with a hash of the pixels in this bitmap. | 20 * Fills in "result" with a hash of the pixels in this bitmap. |
25 * | 21 * |
26 * If this is unable to compute the hash for some reason, | 22 * If this is unable to compute the hash for some reason, |
27 * it returns false. | 23 * it returns false. |
28 * | 24 * |
29 * Note: depending on the bitmap config, we may need to create an | 25 * Note: depending on the bitmap config, we may need to create an |
30 * intermediate SkBitmap and copy the pixels over to it... so in some | 26 * intermediate SkBitmap and copy the pixels over to it... so in some |
31 * cases, performance and memory usage can suffer. | 27 * cases, performance and memory usage can suffer. |
32 */ | 28 */ |
33 static bool ComputeDigest(const SkBitmap& bitmap, SkHashDigest *result); | 29 static bool ComputeDigest(const SkBitmap& bitmap, uint64_t *result); |
34 | 30 |
35 private: | 31 private: |
36 static bool ComputeDigestInternal(const SkBitmap& bitmap, SkHashDigest *resu
lt); | 32 static bool ComputeDigestInternal(const SkBitmap& bitmap, uint64_t *result); |
37 }; | 33 }; |
38 | 34 |
39 #endif | 35 #endif |
OLD | NEW |