aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2016-04-22 06:10:21 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-22 06:10:21 -0700
commit488165e689baf0f215d5798c87d0031b58e4bc8d (patch)
tree594ac2d1ae5f41c9e21a6a9fbca2adf0a1465ba0
parent2e6055b3ea14a04fcde1ac1974a70bf00b1e295b (diff)
SkPDF: PDF/A runtime switch
TODO: remove gyp variable and modify API in SkDocument.h SkMD5 now moved into core as pdf depends on it now. BUG=skia:3110 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1891873002 Committed: https://skia.googlesource.com/skia/+/570f18b43417d73c3fbd113cc0b4258e08b14c82 Review URL: https://codereview.chromium.org/1891873002
-rw-r--r--bench/PDFBench.cpp2
-rw-r--r--gyp/core.gypi2
-rw-r--r--src/core/SkMD5.cpp252
-rw-r--r--src/core/SkMD5.h61
-rw-r--r--src/pdf/SkPDFDevice.cpp4
-rw-r--r--src/pdf/SkPDFDocument.cpp315
-rw-r--r--src/pdf/SkPDFDocument.h9
-rw-r--r--src/pdf/SkPDFMetadata.cpp8
-rw-r--r--src/pdf/SkPDFMetadata.h2
-rw-r--r--src/utils/SkMD5.cpp253
-rw-r--r--src/utils/SkMD5.h62
11 files changed, 476 insertions, 494 deletions
diff --git a/bench/PDFBench.cpp b/bench/PDFBench.cpp
index df6873c596..e3505450d2 100644
--- a/bench/PDFBench.cpp
+++ b/bench/PDFBench.cpp
@@ -182,7 +182,7 @@ struct PDFShaderBench : public Benchmark {
SkASSERT(fShader);
while (loops-- > 0) {
NullWStream nullStream;
- SkPDFDocument doc(&nullStream, nullptr, 72, nullptr);
+ SkPDFDocument doc(&nullStream, nullptr, 72, nullptr, false);
sk_sp<SkPDFObject> shader(
SkPDFShader::GetPDFShader(
&doc, 72, fShader.get(), SkMatrix::I(),
diff --git a/gyp/core.gypi b/gyp/core.gypi
index 29f3b25a8e..66c9541a10 100644
--- a/gyp/core.gypi
+++ b/gyp/core.gypi
@@ -166,6 +166,8 @@
'<(skia_src_path)/core/SkLocalMatrixImageFilter.cpp',
'<(skia_src_path)/core/SkLocalMatrixImageFilter.h',
'<(skia_src_path)/core/SkLocalMatrixShader.cpp',
+ '<(skia_src_path)/core/SkMD5.cpp',
+ '<(skia_src_path)/core/SkMD5.h',
'<(skia_src_path)/core/SkMallocPixelRef.cpp',
'<(skia_src_path)/core/SkMask.cpp',
'<(skia_src_path)/core/SkMaskCache.cpp',
diff --git a/src/core/SkMD5.cpp b/src/core/SkMD5.cpp
new file mode 100644
index 0000000000..725ae55f3f
--- /dev/null
+++ b/src/core/SkMD5.cpp
@@ -0,0 +1,252 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * The following code is based on the description in RFC 1321.
+ * http://www.ietf.org/rfc/rfc1321.txt
+ */
+
+#include "SkTypes.h"
+#include "SkMD5.h"
+#include <string.h>
+
+/** MD5 basic transformation. Transforms state based on block. */
+static void transform(uint32_t state[4], const uint8_t block[64]);
+
+/** Encodes input into output (4 little endian 32 bit values). */
+static void encode(uint8_t output[16], const uint32_t input[4]);
+
+/** Encodes input into output (little endian 64 bit value). */
+static void encode(uint8_t output[8], const uint64_t input);
+
+/** Decodes input (4 little endian 32 bit values) into storage, if required. */
+static const uint32_t* decode(uint32_t storage[16], const uint8_t input[64]);
+
+SkMD5::SkMD5() : byteCount(0) {
+ // These are magic numbers from the specification.
+ this->state[0] = 0x67452301;
+ this->state[1] = 0xefcdab89;
+ this->state[2] = 0x98badcfe;
+ this->state[3] = 0x10325476;
+}
+
+void SkMD5::update(const uint8_t* input, size_t inputLength) {
+ unsigned int bufferIndex = (unsigned int)(this->byteCount & 0x3F);
+ unsigned int bufferAvailable = 64 - bufferIndex;
+
+ unsigned int inputIndex;
+ if (inputLength >= bufferAvailable) {
+ if (bufferIndex) {
+ memcpy(&this->buffer[bufferIndex], input, bufferAvailable);
+ transform(this->state, this->buffer);
+ inputIndex = bufferAvailable;
+ } else {
+ inputIndex = 0;
+ }
+
+ for (; inputIndex + 63 < inputLength; inputIndex += 64) {
+ transform(this->state, &input[inputIndex]);
+ }
+
+ bufferIndex = 0;
+ } else {
+ inputIndex = 0;
+ }
+
+ memcpy(&this->buffer[bufferIndex], &input[inputIndex], inputLength - inputIndex);
+
+ this->byteCount += inputLength;
+}
+
+void SkMD5::finish(Digest& digest) {
+ // Get the number of bits before padding.
+ uint8_t bits[8];
+ encode(bits, this->byteCount << 3);
+
+ // Pad out to 56 mod 64.
+ unsigned int bufferIndex = (unsigned int)(this->byteCount & 0x3F);
+ unsigned int paddingLength = (bufferIndex < 56) ? (56 - bufferIndex) : (120 - bufferIndex);
+ static uint8_t PADDING[64] = {
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ };
+ this->update(PADDING, paddingLength);
+
+ // Append length (length before padding, will cause final update).
+ this->update(bits, 8);
+
+ // Write out digest.
+ encode(digest.data, this->state);
+
+#if defined(SK_MD5_CLEAR_DATA)
+ // Clear state.
+ memset(this, 0, sizeof(*this));
+#endif
+}
+
+struct F { uint32_t operator()(uint32_t x, uint32_t y, uint32_t z) {
+ //return (x & y) | ((~x) & z);
+ return ((y ^ z) & x) ^ z; //equivelent but faster
+}};
+
+struct G { uint32_t operator()(uint32_t x, uint32_t y, uint32_t z) {
+ return (x & z) | (y & (~z));
+ //return ((x ^ y) & z) ^ y; //equivelent but slower
+}};
+
+struct H { uint32_t operator()(uint32_t x, uint32_t y, uint32_t z) {
+ return x ^ y ^ z;
+}};
+
+struct I { uint32_t operator()(uint32_t x, uint32_t y, uint32_t z) {
+ return y ^ (x | (~z));
+}};
+
+/** Rotates x left n bits. */
+static inline uint32_t rotate_left(uint32_t x, uint8_t n) {
+ return (x << n) | (x >> (32 - n));
+}
+
+template <typename T>
+static inline void operation(T operation, uint32_t& a, uint32_t b, uint32_t c, uint32_t d,
+ uint32_t x, uint8_t s, uint32_t t) {
+ a = b + rotate_left(a + operation(b, c, d) + x + t, s);
+}
+
+static void transform(uint32_t state[4], const uint8_t block[64]) {
+ uint32_t a = state[0], b = state[1], c = state[2], d = state[3];
+
+ uint32_t storage[16];
+ const uint32_t* X = decode(storage, block);
+
+ // Round 1
+ operation(F(), a, b, c, d, X[ 0], 7, 0xd76aa478); // 1
+ operation(F(), d, a, b, c, X[ 1], 12, 0xe8c7b756); // 2
+ operation(F(), c, d, a, b, X[ 2], 17, 0x242070db); // 3
+ operation(F(), b, c, d, a, X[ 3], 22, 0xc1bdceee); // 4
+ operation(F(), a, b, c, d, X[ 4], 7, 0xf57c0faf); // 5
+ operation(F(), d, a, b, c, X[ 5], 12, 0x4787c62a); // 6
+ operation(F(), c, d, a, b, X[ 6], 17, 0xa8304613); // 7
+ operation(F(), b, c, d, a, X[ 7], 22, 0xfd469501); // 8
+ operation(F(), a, b, c, d, X[ 8], 7, 0x698098d8); // 9
+ operation(F(), d, a, b, c, X[ 9], 12, 0x8b44f7af); // 10
+ operation(F(), c, d, a, b, X[10], 17, 0xffff5bb1); // 11
+ operation(F(), b, c, d, a, X[11], 22, 0x895cd7be); // 12
+ operation(F(), a, b, c, d, X[12], 7, 0x6b901122); // 13
+ operation(F(), d, a, b, c, X[13], 12, 0xfd987193); // 14
+ operation(F(), c, d, a, b, X[14], 17, 0xa679438e); // 15
+ operation(F(), b, c, d, a, X[15], 22, 0x49b40821); // 16
+
+ // Round 2
+ operation(G(), a, b, c, d, X[ 1], 5, 0xf61e2562); // 17
+ operation(G(), d, a, b, c, X[ 6], 9, 0xc040b340); // 18
+ operation(G(), c, d, a, b, X[11], 14, 0x265e5a51); // 19
+ operation(G(), b, c, d, a, X[ 0], 20, 0xe9b6c7aa); // 20
+ operation(G(), a, b, c, d, X[ 5], 5, 0xd62f105d); // 21
+ operation(G(), d, a, b, c, X[10], 9, 0x2441453); // 22
+ operation(G(), c, d, a, b, X[15], 14, 0xd8a1e681); // 23
+ operation(G(), b, c, d, a, X[ 4], 20, 0xe7d3fbc8); // 24
+ operation(G(), a, b, c, d, X[ 9], 5, 0x21e1cde6); // 25
+ operation(G(), d, a, b, c, X[14], 9, 0xc33707d6); // 26
+ operation(G(), c, d, a, b, X[ 3], 14, 0xf4d50d87); // 27
+ operation(G(), b, c, d, a, X[ 8], 20, 0x455a14ed); // 28
+ operation(G(), a, b, c, d, X[13], 5, 0xa9e3e905); // 29
+ operation(G(), d, a, b, c, X[ 2], 9, 0xfcefa3f8); // 30
+ operation(G(), c, d, a, b, X[ 7], 14, 0x676f02d9); // 31
+ operation(G(), b, c, d, a, X[12], 20, 0x8d2a4c8a); // 32
+
+ // Round 3
+ operation(H(), a, b, c, d, X[ 5], 4, 0xfffa3942); // 33
+ operation(H(), d, a, b, c, X[ 8], 11, 0x8771f681); // 34
+ operation(H(), c, d, a, b, X[11], 16, 0x6d9d6122); // 35
+ operation(H(), b, c, d, a, X[14], 23, 0xfde5380c); // 36
+ operation(H(), a, b, c, d, X[ 1], 4, 0xa4beea44); // 37
+ operation(H(), d, a, b, c, X[ 4], 11, 0x4bdecfa9); // 38
+ operation(H(), c, d, a, b, X[ 7], 16, 0xf6bb4b60); // 39
+ operation(H(), b, c, d, a, X[10], 23, 0xbebfbc70); // 40
+ operation(H(), a, b, c, d, X[13], 4, 0x289b7ec6); // 41
+ operation(H(), d, a, b, c, X[ 0], 11, 0xeaa127fa); // 42
+ operation(H(), c, d, a, b, X[ 3], 16, 0xd4ef3085); // 43
+ operation(H(), b, c, d, a, X[ 6], 23, 0x4881d05); // 44
+ operation(H(), a, b, c, d, X[ 9], 4, 0xd9d4d039); // 45
+ operation(H(), d, a, b, c, X[12], 11, 0xe6db99e5); // 46
+ operation(H(), c, d, a, b, X[15], 16, 0x1fa27cf8); // 47
+ operation(H(), b, c, d, a, X[ 2], 23, 0xc4ac5665); // 48
+
+ // Round 4
+ operation(I(), a, b, c, d, X[ 0], 6, 0xf4292244); // 49
+ operation(I(), d, a, b, c, X[ 7], 10, 0x432aff97); // 50
+ operation(I(), c, d, a, b, X[14], 15, 0xab9423a7); // 51
+ operation(I(), b, c, d, a, X[ 5], 21, 0xfc93a039); // 52
+ operation(I(), a, b, c, d, X[12], 6, 0x655b59c3); // 53
+ operation(I(), d, a, b, c, X[ 3], 10, 0x8f0ccc92); // 54
+ operation(I(), c, d, a, b, X[10], 15, 0xffeff47d); // 55
+ operation(I(), b, c, d, a, X[ 1], 21, 0x85845dd1); // 56
+ operation(I(), a, b, c, d, X[ 8], 6, 0x6fa87e4f); // 57
+ operation(I(), d, a, b, c, X[15], 10, 0xfe2ce6e0); // 58
+ operation(I(), c, d, a, b, X[ 6], 15, 0xa3014314); // 59
+ operation(I(), b, c, d, a, X[13], 21, 0x4e0811a1); // 60
+ operation(I(), a, b, c, d, X[ 4], 6, 0xf7537e82); // 61
+ operation(I(), d, a, b, c, X[11], 10, 0xbd3af235); // 62
+ operation(I(), c, d, a, b, X[ 2], 15, 0x2ad7d2bb); // 63
+ operation(I(), b, c, d, a, X[ 9], 21, 0xeb86d391); // 64
+
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+
+#if defined(SK_MD5_CLEAR_DATA)
+ // Clear sensitive information.
+ if (X == &storage) {
+ memset(storage, 0, sizeof(storage));
+ }
+#endif
+}
+
+static void encode(uint8_t output[16], const uint32_t input[4]) {
+ for (size_t i = 0, j = 0; i < 4; i++, j += 4) {
+ output[j ] = (uint8_t) (input[i] & 0xff);
+ output[j+1] = (uint8_t)((input[i] >> 8) & 0xff);
+ output[j+2] = (uint8_t)((input[i] >> 16) & 0xff);
+ output[j+3] = (uint8_t)((input[i] >> 24) & 0xff);
+ }
+}
+
+static void encode(uint8_t output[8], const uint64_t input) {
+ output[0] = (uint8_t) (input & 0xff);
+ output[1] = (uint8_t)((input >> 8) & 0xff);
+ output[2] = (uint8_t)((input >> 16) & 0xff);
+ output[3] = (uint8_t)((input >> 24) & 0xff);
+ output[4] = (uint8_t)((input >> 32) & 0xff);
+ output[5] = (uint8_t)((input >> 40) & 0xff);
+ output[6] = (uint8_t)((input >> 48) & 0xff);
+ output[7] = (uint8_t)((input >> 56) & 0xff);
+}
+
+static inline bool is_aligned(const void *pointer, size_t byte_count) {
+ return reinterpret_cast<uintptr_t>(pointer) % byte_count == 0;
+}
+
+static const uint32_t* decode(uint32_t storage[16], const uint8_t input[64]) {
+#if defined(SK_CPU_LENDIAN) && defined(SK_CPU_FAST_UNALIGNED_ACCESS)
+ return reinterpret_cast<const uint32_t*>(input);
+#else
+#if defined(SK_CPU_LENDIAN)
+ if (is_aligned(input, 4)) {
+ return reinterpret_cast<const uint32_t*>(input);
+ }
+#endif
+ for (size_t i = 0, j = 0; j < 64; i++, j += 4) {
+ storage[i] = ((uint32_t)input[j ]) |
+ (((uint32_t)input[j+1]) << 8) |
+ (((uint32_t)input[j+2]) << 16) |
+ (((uint32_t)input[j+3]) << 24);
+ }
+ return storage;
+#endif
+}
diff --git a/src/core/SkMD5.h b/src/core/SkMD5.h
new file mode 100644
index 0000000000..ed557931c2
--- /dev/null
+++ b/src/core/SkMD5.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkMD5_DEFINED
+#define SkMD5_DEFINED
+
+#include "SkTypes.h"
+#include "SkEndian.h"
+#include "SkStream.h"
+
+//The following macros can be defined to affect the MD5 code generated.
+//SK_MD5_CLEAR_DATA causes all intermediate state to be overwritten with 0's.
+//SK_CPU_LENDIAN allows 32 bit <=> 8 bit conversions without copies (if alligned).
+//SK_CPU_FAST_UNALIGNED_ACCESS allows 32 bit <=> 8 bit conversions without copies if SK_CPU_LENDIAN.
+
+class SkMD5 : public SkWStream {
+public:
+ SkMD5();
+
+ /** Processes input, adding it to the digest.
+ * Note that this treats the buffer as a series of uint8_t values.
+ */
+ bool write(const void* buffer, size_t size) override {
+ this->update(reinterpret_cast<const uint8_t*>(buffer), size);
+ return true;
+ }
+
+ size_t bytesWritten() const override { return SkToSizeT(this->byteCount); }
+
+ /** Processes input, adding it to the digest. Calling this after finish is undefined. */
+ void update(const uint8_t* input, size_t length);
+
+ struct Digest {
+ uint8_t data[16];
+ bool operator ==(Digest const& other) const {
+ return 0 == memcmp(data, other.data, sizeof(data));
+ }
+ bool operator !=(Digest const& other) const {
+ return 0 != memcmp(data, other.data, sizeof(data));
+ }
+ };
+
+ /** Computes and returns the digest. */
+ void finish(Digest& digest);
+
+private:
+ // number of bytes, modulo 2^64
+ uint64_t byteCount;
+
+ // state (ABCD)
+ uint32_t state[4];
+
+ // input buffer
+ uint8_t buffer[64];
+};
+
+#endif
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 5c933ee7d5..fb4d2510b7 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -827,9 +827,7 @@ void SkPDFDevice::drawPoints(const SkDraw& d,
static sk_sp<SkPDFDict> create_link_annotation(const SkRect& translatedRect) {
auto annotation = sk_make_sp<SkPDFDict>("Annot");
annotation->insertName("Subtype", "Link");
- #ifdef SK_PDF_GENERATE_PDFA
- annotation->insertInt("F", 4); // required by ISO 19005
- #endif
+ annotation->insertInt("F", 4); // required by ISO 19005
auto border = sk_make_sp<SkPDFArray>();
border->reserve(3);
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index 5b1bbcf499..28602ed176 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -215,9 +215,11 @@ template <typename T> static T* clone(const T* o) { return o ? new T(*o) : nullp
SkPDFDocument::SkPDFDocument(SkWStream* stream,
void (*doneProc)(SkWStream*, bool),
SkScalar rasterDpi,
- SkPixelSerializer* jpegEncoder)
+ SkPixelSerializer* jpegEncoder,
+ bool pdfa)
: SkDocument(stream, doneProc)
- , fRasterDpi(rasterDpi) {
+ , fRasterDpi(rasterDpi)
+ , fPDFA(pdfa) {
fCanon.setPixelSerializer(SkSafeRef(jpegEncoder));
}
@@ -238,7 +240,7 @@ SkCanvas* SkPDFDocument::onBeginPage(SkScalar width, SkScalar height,
// if this is the first page if the document.
fObjectSerializer.serializeHeader(this->getStream(), fMetadata);
fDests = sk_make_sp<SkPDFDict>();
- #ifdef SK_PDF_GENERATE_PDFA
+ if (fPDFA) {
SkPDFMetadata::UUID uuid = fMetadata.uuid();
// We use the same UUID for Document ID and Instance ID since this
// is the first revision of this document (and Skia does not
@@ -249,7 +251,7 @@ SkCanvas* SkPDFDocument::onBeginPage(SkScalar width, SkScalar height,
fXMP.reset(fMetadata.createXMPObject(uuid, uuid));
fObjectSerializer.addObjectRecursively(fXMP);
fObjectSerializer.serializeObjects(this->getStream());
- #endif
+ }
}
SkISize pageSize = SkISize::Make(
SkScalarRoundToInt(width), SkScalarRoundToInt(height));
@@ -300,142 +302,118 @@ void SkPDFDocument::setMetadata(const SkDocument::Attribute info[],
fMetadata.fModified.reset(clone(modifiedDate));
}
-#ifdef SK_PDF_GENERATE_PDFA
static sk_sp<SkData> SkSrgbIcm() {
// Source: http://www.argyllcms.com/icclibsrc.html
static const char kProfile[] =
- "\000\000\014\214argl\002 \000\000mntrRGB XYZ \007\335\000\007\000\037"
- "\000\023\000\020\000'acspMSFT\000\000\000\000IEC sRGB\000\000\000\000"
- "\000\000\000\000\000\000\000\000\000\000\366\326\000\001\000\000\000"
- "\000\323-argl\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\021"
- "desc\000\000\001P\000\000\000\231cprt\000\000\001\354\000\000\000g"
- "dmnd\000\000\002T\000\000\000pdmdd\000\000\002\304\000\000\000\210"
- "tech\000\000\003L\000\000\000\014vued\000\000\003X\000\000\000gvie"
- "w\000\000\003\300\000\000\000$lumi\000\000\003\344\000\000\000\024"
- "meas\000\000\003\370\000\000\000$wtpt\000\000\004\034\000\000\000\024"
- "bkpt\000\000\0040\000\000\000\024rXYZ\000\000\004D\000\000\000\024"
- "gXYZ\000\000\004X\000\000\000\024bXYZ\000\000\004l\000\000\000\024"
- "rTRC\000\000\004\200\000\000\010\014gTRC\000\000\004\200\000\000\010"
- "\014bTRC\000\000\004\200\000\000\010\014desc\000\000\000\000\000\000"
- "\000?sRGB IEC61966-2.1 (Equivalent to www.srgb.com 1998 HP profile"
- ")\000\000\000\000\000\000\000\000\000\000\000?sRGB IEC61966-2.1 (E"
- "quivalent to www.srgb.com 1998 HP profile)\000\000\000\000\000\000"
- "\000\000text\000\000\000\000Created by Graeme W. Gill. Released in"
- "to the public domain. No Warranty, Use at your own risk.\000\000de"
- "sc\000\000\000\000\000\000\000\026IEC http://www.iec.ch\000\000\000"
- "\000\000\000\000\000\000\000\000\026IEC http://www.iec.ch\000\000\000"
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
- "\000\000\000\000\000\000\000\000\000desc\000\000\000\000\000\000\000"
- ".IEC 61966-2.1 Default RGB colour space - sRGB\000\000\000\000\000"
- "\000\000\000\000\000\000.IEC 61966-2.1 Default RGB colour space - "
- "sRGB\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
- "\000\000\000\000\000\000sig \000\000\000\000CRT desc\000\000\000\000"
- "\000\000\000\rIEC61966-2.1\000\000\000\000\000\000\000\000\000\000"
- "\000\rIEC61966-2.1\000\000\000\000\000\000\000\000\000\000\000\000"
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
- "\000\000\000\000\000\000\000\000\000\000view\000\000\000\000\000\023"
- "\244|\000\024_0\000\020\316\002\000\003\355\262\000\004\023\n\000\003"
- "\\g\000\000\000\001XYZ \000\000\000\000\000L\n=\000P\000\000\000W\036"
- "\270meas\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000"
- "\000\000\000\000\000\000\000\000\000\000\000\002\217\000\000\000\002"
- "XYZ \000\000\000\000\000\000\363Q\000\001\000\000\000\001\026\314X"
- "YZ \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
- "XYZ \000\000\000\000\000\000o\240\000\0008\365\000\000\003\220XYZ "
- "\000\000\000\000\000\000b\227\000\000\267\207\000\000\030\331XYZ \000"
- "\000\000\000\000\000$\237\000\000\017\204\000\000\266\303curv\000\000"
- "\000\000\000\000\004\000\000\000\000\005\000\n\000\017\000\024\000"
- "\031\000\036\000#\000(\000-\0002\0007\000;\000@\000E\000J\000O\000"
- "T\000Y\000^\000c\000h\000m\000r\000w\000|\000\201\000\206\000\213\000"
- "\220\000\225\000\232\000\237\000\244\000\251\000\256\000\262\000\267"
- "\000\274\000\301\000\306\000\313\000\320\000\325\000\333\000\340\000"
- "\345\000\353\000\360\000\366\000\373\001\001\001\007\001\r\001\023"
- "\001\031\001\037\001%\001+\0012\0018\001>\001E\001L\001R\001Y\001`"
- "\001g\001n\001u\001|\001\203\001\213\001\222\001\232\001\241\001\251"
- "\001\261\001\271\001\301\001\311\001\321\001\331\001\341\001\351\001"
- "\362\001\372\002\003\002\014\002\024\002\035\002&\002/\0028\002A\002"
- "K\002T\002]\002g\002q\002z\002\204\002\216\002\230\002\242\002\254"
- "\002\266\002\301\002\313\002\325\002\340\002\353\002\365\003\000\003"
- "\013\003\026\003!\003-\0038\003C\003O\003Z\003f\003r\003~\003\212\003"
- "\226\003\242\003\256\003\272\003\307\003\323\003\340\003\354\003\371"
- "\004\006\004\023\004 \004-\004;\004H\004U\004c\004q\004~\004\214\004"
- "\232\004\250\004\266\004\304\004\323\004\341\004\360\004\376\005\r"
- "\005\034\005+\005:\005I\005X\005g\005w\005\206\005\226\005\246\005"
- "\265\005\305\005\325\005\345\005\366\006\006\006\026\006'\0067\006"
- "H\006Y\006j\006{\006\214\006\235\006\257\006\300\006\321\006\343\006"
- "\365\007\007\007\031\007+\007=\007O\007a\007t\007\206\007\231\007\254"
- "\007\277\007\322\007\345\007\370\010\013\010\037\0102\010F\010Z\010"
- "n\010\202\010\226\010\252\010\276\010\322\010\347\010\373\t\020\t%"
- "\t:\tO\td\ty\t\217\t\244\t\272\t\317\t\345\t\373\n\021\n'\n=\nT\nj"
- "\n\201\n\230\n\256\n\305\n\334\n\363\013\013\013\"\0139\013Q\013i\013"
- "\200\013\230\013\260\013\310\013\341\013\371\014\022\014*\014C\014"
- "\\\014u\014\216\014\247\014\300\014\331\014\363\r\r\r&\r@\rZ\rt\r\216"
- "\r\251\r\303\r\336\r\370\016\023\016.\016I\016d\016\177\016\233\016"
- "\266\016\322\016\356\017\t\017%\017A\017^\017z\017\226\017\263\017"
- "\317\017\354\020\t\020&\020C\020a\020~\020\233\020\271\020\327\020"
- "\365\021\023\0211\021O\021m\021\214\021\252\021\311\021\350\022\007"
- "\022&\022E\022d\022\204\022\243\022\303\022\343\023\003\023#\023C\023"
- "c\023\203\023\244\023\305\023\345\024\006\024'\024I\024j\024\213\024"
- "\255\024\316\024\360\025\022\0254\025V\025x\025\233\025\275\025\340"
- "\026\003\026&\026I\026l\026\217\026\262\026\326\026\372\027\035\027"
- "A\027e\027\211\027\256\027\322\027\367\030\033\030@\030e\030\212\030"
- "\257\030\325\030\372\031 \031E\031k\031\221\031\267\031\335\032\004"
- "\032*\032Q\032w\032\236\032\305\032\354\033\024\033;\033c\033\212\033"
- "\262\033\332\034\002\034*\034R\034{\034\243\034\314\034\365\035\036"
- "\035G\035p\035\231\035\303\035\354\036\026\036@\036j\036\224\036\276"
- "\036\351\037\023\037>\037i\037\224\037\277\037\352 \025 A l \230 \304"
- " \360!\034!H!u!\241!\316!\373\"'\"U\"\202\"\257\"\335#\n#8#f#\224#"
- "\302#\360$\037$M$|$\253$\332%\t%8%h%\227%\307%\367&'&W&\207&\267&\350"
- "'\030'I'z'\253'\334(\r(?(q(\242(\324)\006)8)k)\235)\320*\002*5*h*\233"
- "*\317+\002+6+i+\235+\321,\005,9,n,\242,\327-\014-A-v-\253-\341.\026"
- ".L.\202.\267.\356/$/Z/\221/\307/\376050l0\2440\3331\0221J1\2021\272"
- "1\3622*2c2\2332\3243\r3F3\1773\2703\3614+4e4\2364\3305\0235M5\2075"
- "\3025\375676r6\2566\3517$7`7\2347\3278\0248P8\2148\3109\0059B9\177"
- "9\2749\371:6:t:\262:\357;-;k;\252;\350<'<e<\244<\343=\"=a=\241=\340"
- "> >`>\240>\340?!?a?\242?\342@#@d@\246@\347A)AjA\254A\356B0BrB\265B"
- "\367C:C}C\300D\003DGD\212D\316E\022EUE\232E\336F\"FgF\253F\360G5G{"
- "G\300H\005HKH\221H\327I\035IcI\251I\360J7J}J\304K\014KSK\232K\342L"
- "*LrL\272M\002MJM\223M\334N%NnN\267O\000OIO\223O\335P'PqP\273Q\006Q"
- "PQ\233Q\346R1R|R\307S\023S_S\252S\366TBT\217T\333U(UuU\302V\017V\\"
- "V\251V\367WDW\222W\340X/X}X\313Y\032YiY\270Z\007ZVZ\246Z\365[E[\225"
- "[\345\\5\\\206\\\326]']x]\311^\032^l^\275_\017_a_\263`\005`W`\252`"
- "\374aOa\242a\365bIb\234b\360cCc\227c\353d@d\224d\351e=e\222e\347f="
- "f\222f\350g=g\223g\351h?h\226h\354iCi\232i\361jHj\237j\367kOk\247k"
- "\377lWl\257m\010m`m\271n\022nkn\304o\036oxo\321p+p\206p\340q:q\225"
- "q\360rKr\246s\001s]s\270t\024tpt\314u(u\205u\341v>v\233v\370wVw\263"
- "x\021xnx\314y*y\211y\347zFz\245{\004{c{\302|!|\201|\341}A}\241~\001"
- "~b~\302\177#\177\204\177\345\200G\200\250\201\n\201k\201\315\2020\202"
- "\222\202\364\203W\203\272\204\035\204\200\204\343\205G\205\253\206"
- "\016\206r\206\327\207;\207\237\210\004\210i\210\316\2113\211\231\211"
- "\376\212d\212\312\2130\213\226\213\374\214c\214\312\2151\215\230\215"
- "\377\216f\216\316\2176\217\236\220\006\220n\220\326\221?\221\250\222"
- "\021\222z\222\343\223M\223\266\224 \224\212\224\364\225_\225\311\226"
- "4\226\237\227\n\227u\227\340\230L\230\270\231$\231\220\231\374\232"
- "h\232\325\233B\233\257\234\034\234\211\234\367\235d\235\322\236@\236"
- "\256\237\035\237\213\237\372\240i\240\330\241G\241\266\242&\242\226"
- "\243\006\243v\243\346\244V\244\307\2458\245\251\246\032\246\213\246"
- "\375\247n\247\340\250R\250\304\2517\251\251\252\034\252\217\253\002"
- "\253u\253\351\254\\\254\320\255D\255\270\256-\256\241\257\026\257\213"
- "\260\000\260u\260\352\261`\261\326\262K\262\302\2638\263\256\264%\264"
- "\234\265\023\265\212\266\001\266y\266\360\267h\267\340\270Y\270\321"
- "\271J\271\302\272;\272\265\273.\273\247\274!\274\233\275\025\275\217"
- "\276\n\276\204\276\377\277z\277\365\300p\300\354\301g\301\343\302_"
- "\302\333\303X\303\324\304Q\304\316\305K\305\310\306F\306\303\307A\307"
- "\277\310=\310\274\311:\311\271\3128\312\267\3136\313\266\3145\314\265"
- "\3155\315\265\3166\316\266\3177\317\270\3209\320\272\321<\321\276\322"
- "?\322\301\323D\323\306\324I\324\313\325N\325\321\326U\326\330\327\\"
- "\327\340\330d\330\350\331l\331\361\332v\332\373\333\200\334\005\334"
- "\212\335\020\335\226\336\034\336\242\337)\337\257\3406\340\275\341"
- "D\341\314\342S\342\333\343c\343\353\344s\344\374\345\204\346\r\346"
- "\226\347\037\347\251\3502\350\274\351F\351\320\352[\352\345\353p\353"
- "\373\354\206\355\021\355\234\356(\356\264\357@\357\314\360X\360\345"
- "\361r\361\377\362\214\363\031\363\247\3644\364\302\365P\365\336\366"
- "m\366\373\367\212\370\031\370\250\3718\371\307\372W\372\347\373w\374"
- "\007\374\230\375)\375\272\376K\376\334\377m\377\377";
- return SkData::MakeWithoutCopy(kProfile, sizeof(kProfile) - 1);
+ "\0\0\14\214argl\2 \0\0mntrRGB XYZ \7\336\0\1\0\6\0\26\0\17\0:acspM"
+ "SFT\0\0\0\0IEC sRGB\0\0\0\0\0\0\0\0\0\0\0\0\0\0\366\326\0\1\0\0\0\0"
+ "\323-argl\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\21desc\0\0\1P\0\0\0\231cprt\0"
+ "\0\1\354\0\0\0gdmnd\0\0\2T\0\0\0pdmdd\0\0\2\304\0\0\0\210tech\0\0\3"
+ "L\0\0\0\14vued\0\0\3X\0\0\0gview\0\0\3\300\0\0\0$lumi\0\0\3\344\0\0"
+ "\0\24meas\0\0\3\370\0\0\0$wtpt\0\0\4\34\0\0\0\24bkpt\0\0\0040\0\0\0"
+ "\24rXYZ\0\0\4D\0\0\0\24gXYZ\0\0\4X\0\0\0\24bXYZ\0\0\4l\0\0\0\24rTR"
+ "C\0\0\4\200\0\0\10\14gTRC\0\0\4\200\0\0\10\14bTRC\0\0\4\200\0\0\10"
+ "\14desc\0\0\0\0\0\0\0?sRGB IEC61966-2.1 (Equivalent to www.srgb.co"
+ "m 1998 HP profile)\0\0\0\0\0\0\0\0\0\0\0?sRGB IEC61966-2.1 (Equiva"
+ "lent to www.srgb.com 1998 HP profile)\0\0\0\0\0\0\0\0text\0\0\0\0C"
+ "reated by Graeme W. Gill. Released into the public domain. No Warr"
+ "anty, Use at your own risk.\0\0desc\0\0\0\0\0\0\0\26IEC http://www"
+ ".iec.ch\0\0\0\0\0\0\0\0\0\0\0\26IEC http://www.iec.ch\0\0\0\0\0\0\0"
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+ "\0\0\0\0\0\0desc\0\0\0\0\0\0\0.IEC 61966-2.1 Default RGB colour sp"
+ "ace - sRGB\0\0\0\0\0\0\0\0\0\0\0.IEC 61966-2.1 Default RGB colour "
+ "space - sRGB\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0sig \0\0\0"
+ "\0CRT desc\0\0\0\0\0\0\0\rIEC61966-2.1\0\0\0\0\0\0\0\0\0\0\0\rIEC6"
+ "1966-2.1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0view\0\0\0\0"
+ "\0\23\244|\0\24_0\0\20\316\2\0\3\355\262\0\4\23\n\0\3\\g\0\0\0\1XY"
+ "Z \0\0\0\0\0L\n=\0P\0\0\0W\36\270meas\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0"
+ "\0\0\0\0\0\0\0\0\0\0\0\2\217\0\0\0\2XYZ \0\0\0\0\0\0\363Q\0\1\0\0\0"
+ "\1\26\314XYZ \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0XYZ \0\0\0\0\0\0o\240"
+ "\0\0008\365\0\0\3\220XYZ \0\0\0\0\0\0b\227\0\0\267\207\0\0\30\331X"
+ "YZ \0\0\0\0\0\0$\237\0\0\17\204\0\0\266\304curv\0\0\0\0\0\0\4\0\0\0"
+ "\0\5\0\n\0\17\0\24\0\31\0\36\0#\0(\0-\0002\0007\0;\0@\0E\0J\0O\0T\0"
+ "Y\0^\0c\0h\0m\0r\0w\0|\0\201\0\206\0\213\0\220\0\225\0\232\0\237\0"
+ "\244\0\251\0\256\0\262\0\267\0\274\0\301\0\306\0\313\0\320\0\325\0"
+ "\333\0\340\0\345\0\353\0\360\0\366\0\373\1\1\1\7\1\r\1\23\1\31\1\37"
+ "\1%\1+\0012\0018\1>\1E\1L\1R\1Y\1`\1g\1n\1u\1|\1\203\1\213\1\222\1"
+ "\232\1\241\1\251\1\261\1\271\1\301\1\311\1\321\1\331\1\341\1\351\1"
+ "\362\1\372\2\3\2\14\2\24\2\35\2&\2/\0028\2A\2K\2T\2]\2g\2q\2z\2\204"
+ "\2\216\2\230\2\242\2\254\2\266\2\301\2\313\2\325\2\340\2\353\2\365"
+ "\3\0\3\13\3\26\3!\3-\0038\3C\3O\3Z\3f\3r\3~\3\212\3\226\3\242\3\256"
+ "\3\272\3\307\3\323\3\340\3\354\3\371\4\6\4\23\4 \4-\4;\4H\4U\4c\4q"
+ "\4~\4\214\4\232\4\250\4\266\4\304\4\323\4\341\4\360\4\376\5\r\5\34"
+ "\5+\5:\5I\5X\5g\5w\5\206\5\226\5\246\5\265\5\305\5\325\5\345\5\366"
+ "\6\6\6\26\6'\0067\6H\6Y\6j\6{\6\214\6\235\6\257\6\300\6\321\6\343\6"
+ "\365\7\7\7\31\7+\7=\7O\7a\7t\7\206\7\231\7\254\7\277\7\322\7\345\7"
+ "\370\10\13\10\37\0102\10F\10Z\10n\10\202\10\226\10\252\10\276\10\322"
+ "\10\347\10\373\t\20\t%\t:\tO\td\ty\t\217\t\244\t\272\t\317\t\345\t"
+ "\373\n\21\n'\n=\nT\nj\n\201\n\230\n\256\n\305\n\334\n\363\13\13\13"
+ "\"\0139\13Q\13i\13\200\13\230\13\260\13\310\13\341\13\371\14\22\14"
+ "*\14C\14\\\14u\14\216\14\247\14\300\14\331\14\363\r\r\r&\r@\rZ\rt\r"
+ "\216\r\251\r\303\r\336\r\370\16\23\16.\16I\16d\16\177\16\233\16\266"
+ "\16\322\16\356\17\t\17%\17A\17^\17z\17\226\17\263\17\317\17\354\20"
+ "\t\20&\20C\20a\20~\20\233\20\271\20\327\20\365\21\23\0211\21O\21m\21"
+ "\214\21\252\21\311\21\350\22\7\22&\22E\22d\22\204\22\243\22\303\22"
+ "\343\23\3\23#\23C\23c\23\203\23\244\23\305\23\345\24\6\24'\24I\24j"
+ "\24\213\24\255\24\316\24\360\25\22\0254\25V\25x\25\233\25\275\25\340"
+ "\26\3\26&\26I\26l\26\217\26\262\26\326\26\372\27\35\27A\27e\27\211"
+ "\27\256\27\322\27\367\30\33\30@\30e\30\212\30\257\30\325\30\372\31"
+ " \31E\31k\31\221\31\267\31\335\32\4\32*\32Q\32w\32\236\32\305\32\354"
+ "\33\24\33;\33c\33\212\33\262\33\332\34\2\34*\34R\34{\34\243\34\314"
+ "\34\365\35\36\35G\35p\35\231\35\303\35\354\36\26\36@\36j\36\224\36"
+ "\276\36\351\37\23\37>\37i\37\224\37\277\37\352 \25 A l \230 \304 \360"
+ "!\34!H!u!\241!\316!\373\"'\"U\"\202\"\257\"\335#\n#8#f#\224#\302#\360"
+ "$\37$M$|$\253$\332%\t%8%h%\227%\307%\367&'&W&\207&\267&\350'\30'I'"
+ "z'\253'\334(\r(?(q(\242(\324)\6)8)k)\235)\320*\2*5*h*\233*\317+\2+"
+ "6+i+\235+\321,\5,9,n,\242,\327-\14-A-v-\253-\341.\26.L.\202.\267.\356"
+ "/$/Z/\221/\307/\376050l0\2440\3331\0221J1\2021\2721\3622*2c2\2332\324"
+ "3\r3F3\1773\2703\3614+4e4\2364\3305\0235M5\2075\3025\375676r6\2566"
+ "\3517$7`7\2347\3278\0248P8\2148\3109\0059B9\1779\2749\371:6:t:\262"
+ ":\357;-;k;\252;\350<'<e<\244<\343=\"=a=\241=\340> >`>\240>\340?!?a"
+ "?\242?\342@#@d@\246@\347A)AjA\254A\356B0BrB\265B\367C:C}C\300D\3DG"
+ "D\212D\316E\22EUE\232E\336F\"FgF\253F\360G5G{G\300H\5HKH\221H\327I"
+ "\35IcI\251I\360J7J}J\304K\14KSK\232K\342L*LrL\272M\2MJM\223M\334N%"
+ "NnN\267O\0OIO\223O\335P'PqP\273Q\6QPQ\233Q\346R1R|R\307S\23S_S\252"
+ "S\366TBT\217T\333U(UuU\302V\17V\\V\251V\367WDW\222W\340X/X}X\313Y\32"
+ "YiY\270Z\7ZVZ\246Z\365[E[\225[\345\\5\\\206\\\326]']x]\311^\32^l^\275"
+ "_\17_a_\263`\5`W`\252`\374aOa\242a\365bIb\234b\360cCc\227c\353d@d\224"
+ "d\351e=e\222e\347f=f\222f\350g=g\223g\351h?h\226h\354iCi\232i\361j"
+ "Hj\237j\367kOk\247k\377lWl\257m\10m`m\271n\22nkn\304o\36oxo\321p+p"
+ "\206p\340q:q\225q\360rKr\246s\1s]s\270t\24tpt\314u(u\205u\341v>v\233"
+ "v\370wVw\263x\21xnx\314y*y\211y\347zFz\245{\4{c{\302|!|\201|\341}A"
+ "}\241~\1~b~\302\177#\177\204\177\345\200G\200\250\201\n\201k\201\315"
+ "\2020\202\222\202\364\203W\203\272\204\35\204\200\204\343\205G\205"
+ "\253\206\16\206r\206\327\207;\207\237\210\4\210i\210\316\2113\211\231"
+ "\211\376\212d\212\312\2130\213\226\213\374\214c\214\312\2151\215\230"
+ "\215\377\216f\216\316\2176\217\236\220\6\220n\220\326\221?\221\250"
+ "\222\21\222z\222\343\223M\223\266\224 \224\212\224\364\225_\225\311"
+ "\2264\226\237\227\n\227u\227\340\230L\230\270\231$\231\220\231\374"
+ "\232h\232\325\233B\233\257\234\34\234\211\234\367\235d\235\322\236"
+ "@\236\256\237\35\237\213\237\372\240i\240\330\241G\241\266\242&\242"
+ "\226\243\6\243v\243\346\244V\244\307\2458\245\251\246\32\246\213\246"
+ "\375\247n\247\340\250R\250\304\2517\251\251\252\34\252\217\253\2\253"
+ "u\253\351\254\\\254\320\255D\255\270\256-\256\241\257\26\257\213\260"
+ "\0\260u\260\352\261`\261\326\262K\262\302\2638\263\256\264%\264\234"
+ "\265\23\265\212\266\1\266y\266\360\267h\267\340\270Y\270\321\271J\271"
+ "\302\272;\272\265\273.\273\247\274!\274\233\275\25\275\217\276\n\276"
+ "\204\276\377\277z\277\365\300p\300\354\301g\301\343\302_\302\333\303"
+ "X\303\324\304Q\304\316\305K\305\310\306F\306\303\307A\307\277\310="
+ "\310\274\311:\311\271\3128\312\267\3136\313\266\3145\314\265\3155\315"
+ "\265\3166\316\266\3177\317\270\3209\320\272\321<\321\276\322?\322\301"
+ "\323D\323\306\324I\324\313\325N\325\321\326U\326\330\327\\\327\340"
+ "\330d\330\350\331l\331\361\332v\332\373\333\200\334\5\334\212\335\20"
+ "\335\226\336\34\336\242\337)\337\257\3406\340\275\341D\341\314\342"
+ "S\342\333\343c\343\353\344s\344\374\345\204\346\r\346\226\347\37\347"
+ "\251\3502\350\274\351F\351\320\352[\352\345\353p\353\373\354\206\355"
+ "\21\355\234\356(\356\264\357@\357\314\360X\360\345\361r\361\377\362"
+ "\214\363\31\363\247\3644\364\302\365P\365\336\366m\366\373\367\212"
+ "\370\31\370\250\3718\371\307\372W\372\347\373w\374\7\374\230\375)\375"
+ "\272\376K\376\334\377m\377\377";
+ const size_t kProfileLength = 3212;
+ static_assert(kProfileLength == sizeof(kProfile) - 1, "");
+ return SkData::MakeWithoutCopy(kProfile, kProfileLength);
}
static sk_sp<SkPDFStream> make_srgb_color_profile() {
@@ -452,7 +430,21 @@ static sk_sp<SkPDFStream> make_srgb_color_profile() {
stream->insertObject("Range", std::move(array));
return stream;
}
-#endif // SK_PDF_GENERATE_PDFA
+
+static sk_sp<SkPDFArray> make_srgb_output_intents() {
+ // sRGB is specified by HTML, CSS, and SVG.
+ auto outputIntent = sk_make_sp<SkPDFDict>("OutputIntent");
+ outputIntent->insertName("S", "GTS_PDFA1");
+ outputIntent->insertString("RegistryName", "http://www.color.org");
+ outputIntent->insertString("OutputConditionIdentifier",
+ "Custom");
+ outputIntent->insertString("Info","sRGB IEC61966-2.1");
+ outputIntent->insertObjRef("DestOutputProfile",
+ make_srgb_color_profile());
+ auto intentArray = sk_make_sp<SkPDFArray>();
+ intentArray->appendObject(std::move(outputIntent));
+ return intentArray;
+}
bool SkPDFDocument::onClose(SkWStream* stream) {
SkASSERT(!fCanvas.get());
@@ -463,25 +455,16 @@ bool SkPDFDocument::onClose(SkWStream* stream) {
return false;
}
auto docCatalog = sk_make_sp<SkPDFDict>("Catalog");
- #ifdef SK_PDF_GENERATE_PDFA
+ if (fPDFA) {
SkASSERT(fXMP);
docCatalog->insertObjRef("Metadata", fXMP);
- // sRGB is specified by HTML, CSS, and SVG.
- auto outputIntent = sk_make_sp<SkPDFDict>("OutputIntent");
- outputIntent->insertName("S", "GTS_PDFA1");
- outputIntent->insertString("RegistryName", "http://www.color.org");
- outputIntent->insertString("OutputConditionIdentifier",
- "Custom");
- outputIntent->insertString("Info","sRGB IEC61966-2.1");
- outputIntent->insertObjRef("DestOutputProfile",
- make_srgb_color_profile());
- auto intentArray = sk_make_sp<SkPDFArray>();
- intentArray->appendObject(std::move(outputIntent));
// Don't specify OutputIntents if we are not in PDF/A mode since
// no one has ever asked for this feature.
- docCatalog->insertObject("OutputIntents", std::move(intentArray));
- #endif
+ docCatalog->insertObject("OutputIntents", make_srgb_output_intents());
+ }
+ SkASSERT(!fPages.empty());
docCatalog->insertObjRef("Pages", generate_page_tree(&fPages));
+ SkASSERT(fPages.empty());
if (fDests->size() > 0) {
docCatalog->insertObjRef("Dests", std::move(fDests));
@@ -499,13 +482,7 @@ bool SkPDFDocument::onClose(SkWStream* stream) {
fObjectSerializer.addObjectRecursively(docCatalog);
fObjectSerializer.serializeObjects(this->getStream());
- #ifdef SK_PDF_GENERATE_PDFA
- fObjectSerializer.serializeFooter(this->getStream(), docCatalog, fID);
- #else
- fObjectSerializer.serializeFooter(
- this->getStream(), docCatalog, nullptr);
- #endif
- SkASSERT(fPages.count() == 0);
+ fObjectSerializer.serializeFooter(this->getStream(), docCatalog, fID);
fCanon.reset();
renew(&fObjectSerializer);
return true;
@@ -516,24 +493,34 @@ bool SkPDFDocument::onClose(SkWStream* stream) {
sk_sp<SkDocument> SkPDFMakeDocument(SkWStream* stream,
void (*proc)(SkWStream*, bool),
SkScalar dpi,
- SkPixelSerializer* jpeg) {
- return stream ? sk_make_sp<SkPDFDocument>(stream, proc, dpi, jpeg) : nullptr;
+ SkPixelSerializer* jpeg,
+ bool pdfa) {
+ return stream ? sk_make_sp<SkPDFDocument>(stream, proc, dpi, jpeg, pdfa)
+ : nullptr;
}
+#ifdef SK_PDF_GENERATE_PDFA
+ static const bool kPDFA = true;
+#else
+ static const bool kPDFA = false;
+#endif
+
SkDocument* SkDocument::CreatePDF(SkWStream* stream, SkScalar dpi) {
- return SkPDFMakeDocument(stream, nullptr, dpi, nullptr).release();
+ return SkPDFMakeDocument(stream, nullptr, dpi, nullptr, kPDFA).release();
}
SkDocument* SkDocument::CreatePDF(SkWStream* stream,
SkScalar dpi,
SkPixelSerializer* jpegEncoder) {
- return SkPDFMakeDocument(stream, nullptr, dpi, jpegEncoder).release();
+ return SkPDFMakeDocument(stream, nullptr, dpi,
+ jpegEncoder, kPDFA).release();
}
SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
auto delete_wstream = [](SkWStream* stream, bool) { delete stream; };
std::unique_ptr<SkFILEWStream> stream(new SkFILEWStream(path));
return stream->isValid()
- ? SkPDFMakeDocument(stream.release(), delete_wstream, dpi, nullptr).release()
+ ? SkPDFMakeDocument(stream.release(), delete_wstream, dpi,
+ nullptr, kPDFA).release()
: nullptr;
}
diff --git a/src/pdf/SkPDFDocument.h b/src/pdf/SkPDFDocument.h
index da14e8d60e..f5e8a11d84 100644
--- a/src/pdf/SkPDFDocument.h
+++ b/src/pdf/SkPDFDocument.h
@@ -18,7 +18,8 @@ sk_sp<SkDocument> SkPDFMakeDocument(
SkWStream* stream,
void (*doneProc)(SkWStream*, bool),
SkScalar rasterDpi,
- SkPixelSerializer* jpegEncoder);
+ SkPixelSerializer* jpegEncoder,
+ bool pdfa);
// Logically part of SkPDFDocument (like SkPDFCanon), but separate to
// keep similar functionality together.
@@ -47,7 +48,8 @@ public:
SkPDFDocument(SkWStream*,
void (*)(SkWStream*, bool),
SkScalar,
- SkPixelSerializer*);
+ SkPixelSerializer*,
+ bool);
virtual ~SkPDFDocument();
SkCanvas* onBeginPage(SkScalar, SkScalar, const SkRect&) override;
void onEndPage() override;
@@ -79,12 +81,11 @@ private:
sk_sp<SkPDFDict> fDests;
sk_sp<SkPDFDevice> fPageDevice;
sk_sp<SkCanvas> fCanvas;
- #ifdef SK_PDF_GENERATE_PDFA
sk_sp<SkPDFObject> fID;
sk_sp<SkPDFObject> fXMP;
- #endif
SkScalar fRasterDpi;
SkPDFMetadata fMetadata;
+ bool fPDFA;
};
#endif // SkPDFDocument_DEFINED
diff --git a/src/pdf/SkPDFMetadata.cpp b/src/pdf/SkPDFMetadata.cpp
index a5476a2df0..2765d4d189 100644
--- a/src/pdf/SkPDFMetadata.cpp
+++ b/src/pdf/SkPDFMetadata.cpp
@@ -5,15 +5,12 @@
* found in the LICENSE file.
*/
+#include "SkMD5.h"
#include "SkMilestone.h"
#include "SkPDFMetadata.h"
#include "SkPDFTypes.h"
#include <utility>
-#ifdef SK_PDF_GENERATE_PDFA
-#include "SkMD5.h"
-#endif
-
static SkString pdf_date(const SkTime::DateTime& dt) {
int timeZoneMinutes = SkToInt(dt.fTimeZoneMinutes);
char timezoneSign = timeZoneMinutes >= 0 ? '+' : '-';
@@ -52,7 +49,6 @@ SkPDFObject* SkPDFMetadata::createDocumentInformationDict() const {
return dict.release();
}
-#ifdef SK_PDF_GENERATE_PDFA
SkPDFMetadata::UUID SkPDFMetadata::uuid() const {
// The main requirement is for the UUID to be unique; the exact
// format of the data that will be hashed is not important.
@@ -350,8 +346,6 @@ SkPDFObject* SkPDFMetadata::createXMPObject(const UUID& doc,
documentID.c_str(), instanceID.c_str(), keywords2.c_str()));
}
-#endif // SK_PDF_GENERATE_PDFA
-
#undef SKPDF_STRING
#undef SKPDF_STRING_IMPL
diff --git a/src/pdf/SkPDFMetadata.h b/src/pdf/SkPDFMetadata.h
index eb14e48e23..663dc24b39 100644
--- a/src/pdf/SkPDFMetadata.h
+++ b/src/pdf/SkPDFMetadata.h
@@ -20,14 +20,12 @@ struct SkPDFMetadata {
SkPDFObject* createDocumentInformationDict() const;
-#ifdef SK_PDF_GENERATE_PDFA
struct UUID {
uint8_t fData[16];
};
UUID uuid() const;
static SkPDFObject* CreatePdfId(const UUID& doc, const UUID& instance);
SkPDFObject* createXMPObject(const UUID& doc, const UUID& instance) const;
-#endif // SK_PDF_GENERATE_PDFA
};
#endif // SkPDFMetadata_DEFINED
diff --git a/src/utils/SkMD5.cpp b/src/utils/SkMD5.cpp
index 725ae55f3f..71f8fba33d 100644
--- a/src/utils/SkMD5.cpp
+++ b/src/utils/SkMD5.cpp
@@ -1,252 +1 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * The following code is based on the description in RFC 1321.
- * http://www.ietf.org/rfc/rfc1321.txt
- */
-
-#include "SkTypes.h"
-#include "SkMD5.h"
-#include <string.h>
-
-/** MD5 basic transformation. Transforms state based on block. */
-static void transform(uint32_t state[4], const uint8_t block[64]);
-
-/** Encodes input into output (4 little endian 32 bit values). */
-static void encode(uint8_t output[16], const uint32_t input[4]);
-
-/** Encodes input into output (little endian 64 bit value). */
-static void encode(uint8_t output[8], const uint64_t input);
-
-/** Decodes input (4 little endian 32 bit values) into storage, if required. */
-static const uint32_t* decode(uint32_t storage[16], const uint8_t input[64]);
-
-SkMD5::SkMD5() : byteCount(0) {
- // These are magic numbers from the specification.
- this->state[0] = 0x67452301;
- this->state[1] = 0xefcdab89;
- this->state[2] = 0x98badcfe;
- this->state[3] = 0x10325476;
-}
-
-void SkMD5::update(const uint8_t* input, size_t inputLength) {
- unsigned int bufferIndex = (unsigned int)(this->byteCount & 0x3F);
- unsigned int bufferAvailable = 64 - bufferIndex;
-
- unsigned int inputIndex;
- if (inputLength >= bufferAvailable) {
- if (bufferIndex) {
- memcpy(&this->buffer[bufferIndex], input, bufferAvailable);
- transform(this->state, this->buffer);
- inputIndex = bufferAvailable;
- } else {
- inputIndex = 0;
- }
-
- for (; inputIndex + 63 < inputLength; inputIndex += 64) {
- transform(this->state, &input[inputIndex]);
- }
-
- bufferIndex = 0;
- } else {
- inputIndex = 0;
- }
-
- memcpy(&this->buffer[bufferIndex], &input[inputIndex], inputLength - inputIndex);
-
- this->byteCount += inputLength;
-}
-
-void SkMD5::finish(Digest& digest) {
- // Get the number of bits before padding.
- uint8_t bits[8];
- encode(bits, this->byteCount << 3);
-
- // Pad out to 56 mod 64.
- unsigned int bufferIndex = (unsigned int)(this->byteCount & 0x3F);
- unsigned int paddingLength = (bufferIndex < 56) ? (56 - bufferIndex) : (120 - bufferIndex);
- static uint8_t PADDING[64] = {
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- };
- this->update(PADDING, paddingLength);
-
- // Append length (length before padding, will cause final update).
- this->update(bits, 8);
-
- // Write out digest.
- encode(digest.data, this->state);
-
-#if defined(SK_MD5_CLEAR_DATA)
- // Clear state.
- memset(this, 0, sizeof(*this));
-#endif
-}
-
-struct F { uint32_t operator()(uint32_t x, uint32_t y, uint32_t z) {
- //return (x & y) | ((~x) & z);
- return ((y ^ z) & x) ^ z; //equivelent but faster
-}};
-
-struct G { uint32_t operator()(uint32_t x, uint32_t y, uint32_t z) {
- return (x & z) | (y & (~z));
- //return ((x ^ y) & z) ^ y; //equivelent but slower
-}};
-
-struct H { uint32_t operator()(uint32_t x, uint32_t y, uint32_t z) {
- return x ^ y ^ z;
-}};
-
-struct I { uint32_t operator()(uint32_t x, uint32_t y, uint32_t z) {
- return y ^ (x | (~z));
-}};
-
-/** Rotates x left n bits. */
-static inline uint32_t rotate_left(uint32_t x, uint8_t n) {
- return (x << n) | (x >> (32 - n));
-}
-
-template <typename T>
-static inline void operation(T operation, uint32_t& a, uint32_t b, uint32_t c, uint32_t d,
- uint32_t x, uint8_t s, uint32_t t) {
- a = b + rotate_left(a + operation(b, c, d) + x + t, s);
-}
-
-static void transform(uint32_t state[4], const uint8_t block[64]) {
- uint32_t a = state[0], b = state[1], c = state[2], d = state[3];
-
- uint32_t storage[16];
- const uint32_t* X = decode(storage, block);
-
- // Round 1
- operation(F(), a, b, c, d, X[ 0], 7, 0xd76aa478); // 1
- operation(F(), d, a, b, c, X[ 1], 12, 0xe8c7b756); // 2
- operation(F(), c, d, a, b, X[ 2], 17, 0x242070db); // 3
- operation(F(), b, c, d, a, X[ 3], 22, 0xc1bdceee); // 4
- operation(F(), a, b, c, d, X[ 4], 7, 0xf57c0faf); // 5
- operation(F(), d, a, b, c, X[ 5], 12, 0x4787c62a); // 6
- operation(F(), c, d, a, b, X[ 6], 17, 0xa8304613); // 7
- operation(F(), b, c, d, a, X[ 7], 22, 0xfd469501); // 8
- operation(F(), a, b, c, d, X[ 8], 7, 0x698098d8); // 9
- operation(F(), d, a, b, c, X[ 9], 12, 0x8b44f7af); // 10
- operation(F(), c, d, a, b, X[10], 17, 0xffff5bb1); // 11
- operation(F(), b, c, d, a, X[11], 22, 0x895cd7be); // 12
- operation(F(), a, b, c, d, X[12], 7, 0x6b901122); // 13
- operation(F(), d, a, b, c, X[13], 12, 0xfd987193); // 14
- operation(F(), c, d, a, b, X[14], 17, 0xa679438e); // 15
- operation(F(), b, c, d, a, X[15], 22, 0x49b40821); // 16
-
- // Round 2
- operation(G(), a, b, c, d, X[ 1], 5, 0xf61e2562); // 17
- operation(G(), d, a, b, c, X[ 6], 9, 0xc040b340); // 18
- operation(G(), c, d, a, b, X[11], 14, 0x265e5a51); // 19
- operation(G(), b, c, d, a, X[ 0], 20, 0xe9b6c7aa); // 20
- operation(G(), a, b, c, d, X[ 5], 5, 0xd62f105d); // 21
- operation(G(), d, a, b, c, X[10], 9, 0x2441453); // 22
- operation(G(), c, d, a, b, X[15], 14, 0xd8a1e681); // 23
- operation(G(), b, c, d, a, X[ 4], 20, 0xe7d3fbc8); // 24
- operation(G(), a, b, c, d, X[ 9], 5, 0x21e1cde6); // 25
- operation(G(), d, a, b, c, X[14], 9, 0xc33707d6); // 26
- operation(G(), c, d, a, b, X[ 3], 14, 0xf4d50d87); // 27
- operation(G(), b, c, d, a, X[ 8], 20, 0x455a14ed); // 28
- operation(G(), a, b, c, d, X[13], 5, 0xa9e3e905); // 29
- operation(G(), d, a, b, c, X[ 2], 9, 0xfcefa3f8); // 30
- operation(G(), c, d, a, b, X[ 7], 14, 0x676f02d9); // 31
- operation(G(), b, c, d, a, X[12], 20, 0x8d2a4c8a); // 32
-
- // Round 3
- operation(H(), a, b, c, d, X[ 5], 4, 0xfffa3942); // 33
- operation(H(), d, a, b, c, X[ 8], 11, 0x8771f681); // 34
- operation(H(), c, d, a, b, X[11], 16, 0x6d9d6122); // 35
- operation(H(), b, c, d, a, X[14], 23, 0xfde5380c); // 36
- operation(H(), a, b, c, d, X[ 1], 4, 0xa4beea44); // 37
- operation(H(), d, a, b, c, X[ 4], 11, 0x4bdecfa9); // 38
- operation(H(), c, d, a, b, X[ 7], 16, 0xf6bb4b60); // 39
- operation(H(), b, c, d, a, X[10], 23, 0xbebfbc70); // 40
- operation(H(), a, b, c, d, X[13], 4, 0x289b7ec6); // 41
- operation(H(), d, a, b, c, X[ 0], 11, 0xeaa127fa); // 42
- operation(H(), c, d, a, b, X[ 3], 16, 0xd4ef3085); // 43
- operation(H(), b, c, d, a, X[ 6], 23, 0x4881d05); // 44
- operation(H(), a, b, c, d, X[ 9], 4, 0xd9d4d039); // 45
- operation(H(), d, a, b, c, X[12], 11, 0xe6db99e5); // 46
- operation(H(), c, d, a, b, X[15], 16, 0x1fa27cf8); // 47
- operation(H(), b, c, d, a, X[ 2], 23, 0xc4ac5665); // 48
-
- // Round 4
- operation(I(), a, b, c, d, X[ 0], 6, 0xf4292244); // 49
- operation(I(), d, a, b, c, X[ 7], 10, 0x432aff97); // 50
- operation(I(), c, d, a, b, X[14], 15, 0xab9423a7); // 51
- operation(I(), b, c, d, a, X[ 5], 21, 0xfc93a039); // 52
- operation(I(), a, b, c, d, X[12], 6, 0x655b59c3); // 53
- operation(I(), d, a, b, c, X[ 3], 10, 0x8f0ccc92); // 54
- operation(I(), c, d, a, b, X[10], 15, 0xffeff47d); // 55
- operation(I(), b, c, d, a, X[ 1], 21, 0x85845dd1); // 56
- operation(I(), a, b, c, d, X[ 8], 6, 0x6fa87e4f); // 57
- operation(I(), d, a, b, c, X[15], 10, 0xfe2ce6e0); // 58
- operation(I(), c, d, a, b, X[ 6], 15, 0xa3014314); // 59
- operation(I(), b, c, d, a, X[13], 21, 0x4e0811a1); // 60
- operation(I(), a, b, c, d, X[ 4], 6, 0xf7537e82); // 61
- operation(I(), d, a, b, c, X[11], 10, 0xbd3af235); // 62
- operation(I(), c, d, a, b, X[ 2], 15, 0x2ad7d2bb); // 63
- operation(I(), b, c, d, a, X[ 9], 21, 0xeb86d391); // 64
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-
-#if defined(SK_MD5_CLEAR_DATA)
- // Clear sensitive information.
- if (X == &storage) {
- memset(storage, 0, sizeof(storage));
- }
-#endif
-}
-
-static void encode(uint8_t output[16], const uint32_t input[4]) {
- for (size_t i = 0, j = 0; i < 4; i++, j += 4) {
- output[j ] = (uint8_t) (input[i] & 0xff);
- output[j+1] = (uint8_t)((input[i] >> 8) & 0xff);
- output[j+2] = (uint8_t)((input[i] >> 16) & 0xff);
- output[j+3] = (uint8_t)((input[i] >> 24) & 0xff);
- }
-}
-
-static void encode(uint8_t output[8], const uint64_t input) {
- output[0] = (uint8_t) (input & 0xff);
- output[1] = (uint8_t)((input >> 8) & 0xff);
- output[2] = (uint8_t)((input >> 16) & 0xff);
- output[3] = (uint8_t)((input >> 24) & 0xff);
- output[4] = (uint8_t)((input >> 32) & 0xff);
- output[5] = (uint8_t)((input >> 40) & 0xff);
- output[6] = (uint8_t)((input >> 48) & 0xff);
- output[7] = (uint8_t)((input >> 56) & 0xff);
-}
-
-static inline bool is_aligned(const void *pointer, size_t byte_count) {
- return reinterpret_cast<uintptr_t>(pointer) % byte_count == 0;
-}
-
-static const uint32_t* decode(uint32_t storage[16], const uint8_t input[64]) {
-#if defined(SK_CPU_LENDIAN) && defined(SK_CPU_FAST_UNALIGNED_ACCESS)
- return reinterpret_cast<const uint32_t*>(input);
-#else
-#if defined(SK_CPU_LENDIAN)
- if (is_aligned(input, 4)) {
- return reinterpret_cast<const uint32_t*>(input);
- }
-#endif
- for (size_t i = 0, j = 0; j < 64; i++, j += 4) {
- storage[i] = ((uint32_t)input[j ]) |
- (((uint32_t)input[j+1]) << 8) |
- (((uint32_t)input[j+2]) << 16) |
- (((uint32_t)input[j+3]) << 24);
- }
- return storage;
-#endif
-}
+// Copyright 2016 Google Inc.
diff --git a/src/utils/SkMD5.h b/src/utils/SkMD5.h
index ed557931c2..71f8fba33d 100644
--- a/src/utils/SkMD5.h
+++ b/src/utils/SkMD5.h
@@ -1,61 +1 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkMD5_DEFINED
-#define SkMD5_DEFINED
-
-#include "SkTypes.h"
-#include "SkEndian.h"
-#include "SkStream.h"
-
-//The following macros can be defined to affect the MD5 code generated.
-//SK_MD5_CLEAR_DATA causes all intermediate state to be overwritten with 0's.
-//SK_CPU_LENDIAN allows 32 bit <=> 8 bit conversions without copies (if alligned).
-//SK_CPU_FAST_UNALIGNED_ACCESS allows 32 bit <=> 8 bit conversions without copies if SK_CPU_LENDIAN.
-
-class SkMD5 : public SkWStream {
-public:
- SkMD5();
-
- /** Processes input, adding it to the digest.
- * Note that this treats the buffer as a series of uint8_t values.
- */
- bool write(const void* buffer, size_t size) override {
- this->update(reinterpret_cast<const uint8_t*>(buffer), size);
- return true;
- }
-
- size_t bytesWritten() const override { return SkToSizeT(this->byteCount); }
-
- /** Processes input, adding it to the digest. Calling this after finish is undefined. */
- void update(const uint8_t* input, size_t length);
-
- struct Digest {
- uint8_t data[16];
- bool operator ==(Digest const& other) const {
- return 0 == memcmp(data, other.data, sizeof(data));
- }
- bool operator !=(Digest const& other) const {
- return 0 != memcmp(data, other.data, sizeof(data));
- }
- };
-
- /** Computes and returns the digest. */
- void finish(Digest& digest);
-
-private:
- // number of bytes, modulo 2^64
- uint64_t byteCount;
-
- // state (ABCD)
- uint32_t state[4];
-
- // input buffer
- uint8_t buffer[64];
-};
-
-#endif
+// Copyright 2016 Google Inc.