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

Side by Side Diff: src/utils/SkBitmapHasher.h

Issue 14265010: Make SkSHA1 and SkM5 use common SkDigestHash result type (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: add_SkHashDigest_wrapper_for_cityhash Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
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 #include "SkBitmapTransformer.h" 13 #include "SkBitmapTransformer.h"
14 #include "SkHashDigest.h"
14 15
15 // TODO(epoger): Soon, SkHashDigest will become a real class of its own, 16 // TODO(epoger): Once we figure out which bitmap hash algorithm to use
16 // and callers won't be able to assume it converts to/from a uint64_t. 17 // long-term, pick one BITMAP_HASH_TYPE setting and delete the unused code.
17 typedef uint64_t SkHashDigest; 18 //
19 // For now, disable this to keep the old uint64_t bitmap hash.
20 //#define BITMAP_HASH_TYPE_SkHashDigest
epoger 2013/04/18 16:39:34 Patchset 3 adds code (turned off by default by pre
21
22 // Set automatically using the above.
23 #ifdef BITMAP_HASH_TYPE_SkHashDigest
24 #define BITMAP_HASH_TYPE SkHashDigest
25 #else
26 #define BITMAP_HASH_TYPE uint64_t
27 #endif
18 28
19 /** 29 /**
20 * Static class that can generate an SkHashDigest from an SkBitmap. 30 * Static class that can generate an SkHashDigest from an SkBitmap.
21 */ 31 */
22 class SkBitmapHasher { 32 class SkBitmapHasher {
23 public: 33 public:
24 /** 34 /**
25 * Fills in "result" with a hash of the pixels in this bitmap. 35 * Fills in "result" with a hash of the pixels in this bitmap.
26 * 36 *
27 * If this is unable to compute the hash for some reason, 37 * If this is unable to compute the hash for some reason,
28 * it returns false. 38 * it returns false.
29 * 39 *
30 * Note: depending on the bitmap config, we may need to create an 40 * Note: depending on the bitmap config, we may need to create an
31 * intermediate SkBitmap and copy the pixels over to it... so in some 41 * intermediate SkBitmap and copy the pixels over to it... so in some
32 * cases, performance and memory usage can suffer. 42 * cases, performance and memory usage can suffer.
33 */ 43 */
34 static bool ComputeDigest(const SkBitmap& bitmap, SkHashDigest *result); 44 static bool ComputeDigest(const SkBitmap& bitmap, BITMAP_HASH_TYPE *result);
35 45
36 private: 46 private:
37 static bool ComputeDigestInternal(const SkBitmap& bitmap, 47 static bool ComputeDigestInternal(const SkBitmap& bitmap,
38 const SkBitmapTransformer& transformer, 48 const SkBitmapTransformer& transformer,
39 SkHashDigest *result); 49 BITMAP_HASH_TYPE *result);
40 }; 50 };
41 51
42 #endif 52 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698