Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(760)

Unified Diff: dm/DMWriteTask.cpp

Issue 627473002: Handle getMemoryBase returning NULL in WriteTask. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698