OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkColorSpace_Base.h" | 8 #include "SkColorSpace_Base.h" |
9 #include "SkPDFCanvas.h" | 9 #include "SkPDFCanvas.h" |
10 #include "SkPDFDevice.h" | 10 #include "SkPDFDevice.h" |
11 #include "SkPDFDocument.h" | 11 #include "SkPDFDocument.h" |
12 #include "SkPDFStream.h" | |
13 #include "SkPDFUtils.h" | 12 #include "SkPDFUtils.h" |
14 #include "SkStream.h" | 13 #include "SkStream.h" |
15 | 14 |
16 SkPDFObjectSerializer::SkPDFObjectSerializer() : fBaseOffset(0), fNextToBeSerial
ized(0) {} | 15 SkPDFObjectSerializer::SkPDFObjectSerializer() : fBaseOffset(0), fNextToBeSerial
ized(0) {} |
17 | 16 |
18 template <class T> static void renew(T* t) { t->~T(); new (t) T; } | 17 template <class T> static void renew(T* t) { t->~T(); new (t) T; } |
19 | 18 |
20 SkPDFObjectSerializer::~SkPDFObjectSerializer() { | 19 SkPDFObjectSerializer::~SkPDFObjectSerializer() { |
21 for (int i = 0; i < fObjNumMap.objects().count(); ++i) { | 20 for (int i = 0; i < fObjNumMap.objects().count(); ++i) { |
22 fObjNumMap.objects()[i]->drop(); | 21 fObjNumMap.objects()[i]->drop(); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 313 } |
315 #endif // SK_SUPPORT_LEGACY_DOCUMENT_API | 314 #endif // SK_SUPPORT_LEGACY_DOCUMENT_API |
316 | 315 |
317 static sk_sp<SkData> SkSrgbIcm() { | 316 static sk_sp<SkData> SkSrgbIcm() { |
318 auto srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); | 317 auto srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); |
319 return as_CSB(srgb)->writeToICC(); | 318 return as_CSB(srgb)->writeToICC(); |
320 } | 319 } |
321 | 320 |
322 static sk_sp<SkPDFStream> make_srgb_color_profile() { | 321 static sk_sp<SkPDFStream> make_srgb_color_profile() { |
323 sk_sp<SkPDFStream> stream = sk_make_sp<SkPDFStream>(SkSrgbIcm()); | 322 sk_sp<SkPDFStream> stream = sk_make_sp<SkPDFStream>(SkSrgbIcm()); |
324 stream->insertInt("N", 3); | 323 stream->dict()->insertInt("N", 3); |
325 sk_sp<SkPDFArray> array = sk_make_sp<SkPDFArray>(); | 324 sk_sp<SkPDFArray> array = sk_make_sp<SkPDFArray>(); |
326 array->appendScalar(0.0f); | 325 array->appendScalar(0.0f); |
327 array->appendScalar(1.0f); | 326 array->appendScalar(1.0f); |
328 array->appendScalar(0.0f); | 327 array->appendScalar(0.0f); |
329 array->appendScalar(1.0f); | 328 array->appendScalar(1.0f); |
330 array->appendScalar(0.0f); | 329 array->appendScalar(0.0f); |
331 array->appendScalar(1.0f); | 330 array->appendScalar(1.0f); |
332 stream->insertObject("Range", std::move(array)); | 331 stream->dict()->insertObject("Range", std::move(array)); |
333 return stream; | 332 return stream; |
334 } | 333 } |
335 | 334 |
336 static sk_sp<SkPDFArray> make_srgb_output_intents() { | 335 static sk_sp<SkPDFArray> make_srgb_output_intents() { |
337 // sRGB is specified by HTML, CSS, and SVG. | 336 // sRGB is specified by HTML, CSS, and SVG. |
338 auto outputIntent = sk_make_sp<SkPDFDict>("OutputIntent"); | 337 auto outputIntent = sk_make_sp<SkPDFDict>("OutputIntent"); |
339 outputIntent->insertName("S", "GTS_PDFA1"); | 338 outputIntent->insertName("S", "GTS_PDFA1"); |
340 outputIntent->insertString("RegistryName", "http://www.color.org"); | 339 outputIntent->insertString("RegistryName", "http://www.color.org"); |
341 outputIntent->insertString("OutputConditionIdentifier", | 340 outputIntent->insertString("OutputConditionIdentifier", |
342 "Custom"); | 341 "Custom"); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 } | 415 } |
417 | 416 |
418 sk_sp<SkDocument> SkDocument::MakePDF(SkWStream* stream, | 417 sk_sp<SkDocument> SkDocument::MakePDF(SkWStream* stream, |
419 SkScalar dpi, | 418 SkScalar dpi, |
420 const SkDocument::PDFMetadata& metadata, | 419 const SkDocument::PDFMetadata& metadata, |
421 sk_sp<SkPixelSerializer> jpegEncoder, | 420 sk_sp<SkPixelSerializer> jpegEncoder, |
422 bool pdfa) { | 421 bool pdfa) { |
423 return SkPDFMakeDocument(stream, nullptr, dpi, metadata, | 422 return SkPDFMakeDocument(stream, nullptr, dpi, metadata, |
424 std::move(jpegEncoder), pdfa); | 423 std::move(jpegEncoder), pdfa); |
425 } | 424 } |
OLD | NEW |