epoger@google.com | 908f583 | 2013-04-12 02:23:55 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2012 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
| 9 | #ifndef SkBitmapHasher_DEFINED |
| 10 | #define SkBitmapHasher_DEFINED |
| 11 | |
| 12 | #include "SkBitmap.h" |
epoger@google.com | 908f583 | 2013-04-12 02:23:55 +0000 | [diff] [blame] | 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 | /** |
| 19 | * Static class that can generate an SkHashDigest from an SkBitmap. |
| 20 | */ |
| 21 | class SkBitmapHasher { |
| 22 | public: |
| 23 | /** |
| 24 | * Fills in "result" with a hash of the pixels in this bitmap. |
| 25 | * |
| 26 | * If this is unable to compute the hash for some reason, |
| 27 | * it returns false. |
| 28 | * |
| 29 | * 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 |
| 31 | * cases, performance and memory usage can suffer. |
| 32 | */ |
| 33 | static bool ComputeDigest(const SkBitmap& bitmap, SkHashDigest *result); |
| 34 | |
| 35 | private: |
bungeman@google.com | 8c6a4f2 | 2013-04-23 18:06:23 +0000 | [diff] [blame] | 36 | static bool ComputeDigestInternal(const SkBitmap& bitmap, SkHashDigest *result); |
epoger@google.com | 908f583 | 2013-04-12 02:23:55 +0000 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | #endif |