Index: dm/DMWriteTask.cpp |
diff --git a/dm/DMWriteTask.cpp b/dm/DMWriteTask.cpp |
index 08feb98431242216eef3f7f047093803a52bb0a1..7d0df94cfca8ab34a0fe21df93fff1716e341df0 100644 |
--- a/dm/DMWriteTask.cpp |
+++ b/dm/DMWriteTask.cpp |
@@ -64,11 +64,9 @@ void WriteTask::makeDirOrFail(SkString dir) { |
} |
} |
-static SkString get_md5(const void* ptr, size_t len) { |
- SkMD5 hasher; |
- hasher.write(ptr, len); |
+static SkString get_md5_string(SkMD5* hasher) { |
SkMD5::Digest digest; |
- hasher.finish(digest); |
+ hasher->finish(digest); |
SkString md5; |
for (int i = 0; i < 16; i++) { |
@@ -77,6 +75,18 @@ static SkString get_md5(const void* ptr, size_t len) { |
return md5; |
} |
+static SkString get_md5(const void* ptr, size_t len) { |
+ SkMD5 hasher; |
+ hasher.write(ptr, len); |
+ return get_md5_string(&hasher); |
+} |
+ |
+static SkString get_md5(SkStreamAsset* stream) { |
+ SkMD5 hasher; |
+ hasher.writeStream(stream, stream->getLength()); |
+ return get_md5_string(&hasher); |
+} |
+ |
struct JsonData { |
SkString name; // E.g. "ninepatch-stretch", "desk-gws_skp" |
SkString config; // "gpu", "8888" |
@@ -91,7 +101,7 @@ void WriteTask::draw() { |
SkString md5; |
{ |
SkAutoLockPixels lock(fBitmap); |
- md5 = fData ? get_md5(fData->getMemoryBase(), fData->getLength()) |
+ md5 = fData ? get_md5(fData) |
: get_md5(fBitmap.getPixels(), fBitmap.getSize()); |
} |