Index: src/utils/SkBitmapHasher.cpp |
=================================================================== |
--- src/utils/SkBitmapHasher.cpp (revision 8985) |
+++ src/utils/SkBitmapHasher.cpp (working copy) |
@@ -7,10 +7,15 @@ |
#include "SkBitmap.h" |
#include "SkBitmapHasher.h" |
-#include "SkCityHash.h" |
#include "SkEndian.h" |
#include "SkImageEncoder.h" |
+ |
+#ifdef BITMAPHASHER_USES_TRUNCATED_MD5 |
+#include "SkMD5.h" |
+#else |
+#include "SkCityHash.h" |
#include "SkStream.h" |
+#endif |
/** |
* Write an integer value to a stream in little-endian order. |
@@ -25,12 +30,16 @@ |
/*static*/ bool SkBitmapHasher::ComputeDigestInternal(const SkBitmap& bitmap, |
SkHashDigest *result) { |
+#ifdef BITMAPHASHER_USES_TRUNCATED_MD5 |
+ SkMD5 out; |
+#else |
size_t pixelBufferSize = bitmap.width() * bitmap.height() * 4; |
size_t totalBufferSize = pixelBufferSize + 2 * sizeof(uint32_t); |
SkAutoMalloc bufferManager(totalBufferSize); |
char *bufferStart = static_cast<char *>(bufferManager.get()); |
SkMemoryWStream out(bufferStart, totalBufferSize); |
+#endif |
// start with the x/y dimensions |
write_int_to_buffer(SkToU32(bitmap.width()), &out); |
@@ -42,7 +51,13 @@ |
return false; |
} |
+#ifdef BITMAPHASHER_USES_TRUNCATED_MD5 |
+ SkMD5::Digest digest; |
+ out.finish(digest); |
+ *result = *((SkHashDigest *)&digest); |
bungeman-skia
2013/05/03 15:21:00
While I did write this, I wrote it more as an easy
epoger
2013/05/03 16:28:00
Good idea, thanks for the catch. I implemented it
|
+#else |
*result = SkCityHash::Compute64(bufferStart, totalBufferSize); |
+#endif |
return true; |
} |