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 "SkDocument.h" | 8 #include "SkDocument.h" |
9 #include "SkPDFCanon.h" | 9 #include "SkPDFCanon.h" |
10 #include "SkPDFDevice.h" | 10 #include "SkPDFDevice.h" |
11 #include "SkPDFFont.h" | 11 #include "SkPDFFont.h" |
12 #include "SkPDFResourceDict.h" | |
13 #include "SkPDFStream.h" | 12 #include "SkPDFStream.h" |
14 #include "SkPDFTypes.h" | 13 #include "SkPDFTypes.h" |
15 #include "SkStream.h" | 14 #include "SkStream.h" |
16 | 15 |
17 static void emit_pdf_header(SkWStream* stream) { | 16 static void emit_pdf_header(SkWStream* stream) { |
18 stream->writeText("%PDF-1.4\n%"); | 17 stream->writeText("%PDF-1.4\n%"); |
19 // The PDF spec recommends including a comment with four bytes, all | 18 // The PDF spec recommends including a comment with four bytes, all |
20 // with their high bits set. This is "Skia" with the high bits set. | 19 // with their high bits set. This is "Skia" with the high bits set. |
21 stream->write32(0xD3EBE9E1); | 20 stream->write32(0xD3EBE9E1); |
22 stream->writeText("\n"); | 21 stream->writeText("\n"); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 entry->fFont->getFontSubset(entry->fGlyphSet)); | 56 entry->fFont->getFontSubset(entry->fGlyphSet)); |
58 if (subsetFont) { | 57 if (subsetFont) { |
59 substituteMap->setSubstitute(entry->fFont, subsetFont.get()); | 58 substituteMap->setSubstitute(entry->fFont, subsetFont.get()); |
60 } | 59 } |
61 entry = iterator.next(); | 60 entry = iterator.next(); |
62 } | 61 } |
63 } | 62 } |
64 | 63 |
65 static SkPDFDict* create_pdf_page(const SkPDFDevice* pageDevice) { | 64 static SkPDFDict* create_pdf_page(const SkPDFDevice* pageDevice) { |
66 SkAutoTUnref<SkPDFDict> page(SkNEW_ARGS(SkPDFDict, ("Page"))); | 65 SkAutoTUnref<SkPDFDict> page(SkNEW_ARGS(SkPDFDict, ("Page"))); |
67 SkAutoTUnref<SkPDFResourceDict> deviceResourceDict( | 66 SkAutoTUnref<SkPDFDict> deviceResourceDict( |
68 pageDevice->createResourceDict()); | 67 pageDevice->createResourceDict()); |
69 page->insert("Resources", deviceResourceDict.get()); | 68 page->insert("Resources", deviceResourceDict.get()); |
70 | 69 |
71 SkAutoTUnref<SkPDFArray> mediaBox(pageDevice->copyMediaBox()); | 70 SkAutoTUnref<SkPDFArray> mediaBox(pageDevice->copyMediaBox()); |
72 page->insert("MediaBox", mediaBox.get()); | 71 page->insert("MediaBox", mediaBox.get()); |
73 | 72 |
74 SkPDFArray* annots = pageDevice->getAnnotations(); | 73 SkPDFArray* annots = pageDevice->getAnnotations(); |
75 if (annots && annots->size() > 0) { | 74 if (annots && annots->size() > 0) { |
76 page->insert("Annots", annots); | 75 page->insert("Annots", annots); |
77 } | 76 } |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 359 |
361 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { | 360 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { |
362 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); | 361 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); |
363 if (!stream->isValid()) { | 362 if (!stream->isValid()) { |
364 SkDELETE(stream); | 363 SkDELETE(stream); |
365 return NULL; | 364 return NULL; |
366 } | 365 } |
367 auto delete_wstream = [](SkWStream* stream, bool) { SkDELETE(stream); }; | 366 auto delete_wstream = [](SkWStream* stream, bool) { SkDELETE(stream); }; |
368 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi)); | 367 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi)); |
369 } | 368 } |
OLD | NEW |