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

Unified Diff: src/pdf/SkPDFDocument.cpp

Issue 1849453004: SkPDF: Make magic make sense (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-03-30 (Wednesday) 16:17:14 EDT Created 4 years, 9 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: src/pdf/SkPDFDocument.cpp
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index 32fffde676fc87db0be9d9ae0a4be1b82c75a4dc..740fa7dd5e89792840a2d7285f7cf1861f9845d5 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -28,9 +28,16 @@ void SkPDFObjectSerializer::addObjectRecursively(const sk_sp<SkPDFObject>& objec
fObjNumMap.addObjectRecursively(object.get(), fSubstituteMap);
}
+#define SKPDF_MAGIC "\xD3\xEB\xE9\xE1"
+#ifndef SK_BUILD_FOR_WIN32
+static_assert((SKPDF_MAGIC[0] & 0x7F) == "Skia"[0], "");
+static_assert((SKPDF_MAGIC[1] & 0x7F) == "Skia"[1], "");
+static_assert((SKPDF_MAGIC[2] & 0x7F) == "Skia"[2], "");
+static_assert((SKPDF_MAGIC[3] & 0x7F) == "Skia"[3], "");
+#endif
void SkPDFObjectSerializer::serializeHeader(SkWStream* wStream, const SkPDFMetadata& md) {
fBaseOffset = wStream->bytesWritten();
- static const char kHeader[] = "%PDF-1.4\n%\xE1\xE9\xEB\xD3\n";
+ static const char kHeader[] = "%PDF-1.4\n%" SKPDF_MAGIC "\n";
wStream->write(kHeader, strlen(kHeader));
// The PDF spec recommends including a comment with four
// bytes, all with their high bits set. "\xD3\xEB\xE9\xE1" is
@@ -39,6 +46,7 @@ void SkPDFObjectSerializer::serializeHeader(SkWStream* wStream, const SkPDFMetad
this->addObjectRecursively(fInfoDict);
this->serializeObjects(wStream);
}
+#undef SKPDF_MAGIC
// Serialize all objects in the fObjNumMap that have not yet been serialized;
void SkPDFObjectSerializer::serializeObjects(SkWStream* wStream) {
« 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