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

Unified Diff: dm/DMWriteTask.cpp

Issue 659793004: Fix DMWriteTask to write PDF files correctly (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Patch 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 819d7e83dffd8b3c8d1fcb69a0ae1a75f47cc047..35ae2a72097de79d75fbd3df060bfe00633a68b2 100644
--- a/dm/DMWriteTask.cpp
+++ b/dm/DMWriteTask.cpp
@@ -81,9 +81,13 @@ static SkString get_md5(const void* ptr, size_t len) {
return get_md5_string(&hasher);
}
+static bool write_asset(SkStreamAsset* input, SkWStream* output) {
+ return input->rewind() && output->writeStream(input, input->getLength());
+}
+
static SkString get_md5(SkStreamAsset* stream) {
SkMD5 hasher;
- hasher.writeStream(stream, stream->getLength());
+ write_asset(stream, &hasher);
return get_md5_string(&hasher);
}
@@ -154,7 +158,7 @@ void WriteTask::draw() {
return this->fail("Can't open file.");
}
- bool ok = fData ? file.writeStream(fData, fData->getLength())
+ bool ok = fData ? write_asset(fData, &file)
: SkImageEncoder::EncodeStream(&file, fBitmap, SkImageEncoder::kPNG_Type, 100);
if (!ok) {
return this->fail("Can't write to file.");
« 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