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 | |
epoger@google.com | 908f583 | 2013-04-12 02:23:55 +0000 | [diff] [blame] | 14 | /** |
epoger@google.com | d4993ff | 2013-05-24 14:33:28 +0000 | [diff] [blame] | 15 | * Static class that generates a uint64 hash digest from an SkBitmap. |
epoger@google.com | 908f583 | 2013-04-12 02:23:55 +0000 | [diff] [blame] | 16 | */ |
| 17 | class SkBitmapHasher { |
| 18 | public: |
| 19 | /** |
| 20 | * Fills in "result" with a hash of the pixels in this bitmap. |
| 21 | * |
| 22 | * If this is unable to compute the hash for some reason, |
| 23 | * it returns false. |
| 24 | * |
reed | c77392e | 2014-06-02 13:07:26 -0700 | [diff] [blame] | 25 | * Note: depending on the bitmap colortype, we may need to create an |
epoger@google.com | 908f583 | 2013-04-12 02:23:55 +0000 | [diff] [blame] | 26 | * intermediate SkBitmap and copy the pixels over to it... so in some |
| 27 | * cases, performance and memory usage can suffer. |
| 28 | */ |
epoger@google.com | d4993ff | 2013-05-24 14:33:28 +0000 | [diff] [blame] | 29 | static bool ComputeDigest(const SkBitmap& bitmap, uint64_t *result); |
epoger@google.com | 908f583 | 2013-04-12 02:23:55 +0000 | [diff] [blame] | 30 | |
| 31 | private: |
epoger@google.com | d4993ff | 2013-05-24 14:33:28 +0000 | [diff] [blame] | 32 | static bool ComputeDigestInternal(const SkBitmap& bitmap, uint64_t *result); |
epoger@google.com | 908f583 | 2013-04-12 02:23:55 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | #endif |