| 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 SkBitmapChecksummer_DEFINED | 9 #ifndef SkBitmapHasher_DEFINED |
| 10 #define SkBitmapChecksummer_DEFINED | 10 #define SkBitmapHasher_DEFINED |
| 11 | 11 |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 #include "SkBitmapTransformer.h" | 13 #include "SkBitmapTransformer.h" |
| 14 | 14 |
| 15 // TODO(epoger): Soon, SkHashDigest will become a real class of its own, |
| 16 // and callers won't be able to assume it converts to/from a uint64_t. |
| 17 typedef uint64_t SkHashDigest; |
| 18 |
| 15 /** | 19 /** |
| 16 * Static class that can generate checksums from SkBitmaps. | 20 * Static class that can generate an SkHashDigest from an SkBitmap. |
| 17 */ | 21 */ |
| 18 class SkBitmapChecksummer { | 22 class SkBitmapHasher { |
| 19 public: | 23 public: |
| 20 /** | 24 /** |
| 21 * Returns a 64-bit checksum of the pixels in this bitmap. | 25 * Fills in "result" with a hash of the pixels in this bitmap. |
| 22 * | 26 * |
| 23 * If this is unable to compute the checksum for some reason, | 27 * If this is unable to compute the hash for some reason, |
| 24 * it returns 0. | 28 * it returns false. |
| 25 * | 29 * |
| 26 * Note: depending on the bitmap config, we may need to create an | 30 * Note: depending on the bitmap config, we may need to create an |
| 27 * intermediate SkBitmap and copy the pixels over to it... so in some | 31 * intermediate SkBitmap and copy the pixels over to it... so in some |
| 28 * cases, performance and memory usage can suffer. | 32 * cases, performance and memory usage can suffer. |
| 29 */ | 33 */ |
| 30 static uint64_t Compute64(const SkBitmap& bitmap); | 34 static bool ComputeDigest(const SkBitmap& bitmap, SkHashDigest *result); |
| 31 | 35 |
| 32 private: | 36 private: |
| 33 static uint64_t Compute64Internal(const SkBitmap& bitmap, | 37 static bool ComputeDigestInternal(const SkBitmap& bitmap, |
| 34 const SkBitmapTransformer& transformer); | 38 const SkBitmapTransformer& transformer, |
| 39 SkHashDigest *result); |
| 35 }; | 40 }; |
| 36 | 41 |
| 37 #endif | 42 #endif |
| OLD | NEW |