OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 The Android Open Source Project | 3 * Copyright 2010 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkPDFDocument_DEFINED | 10 #ifndef SkPDFDocument_DEFINED |
11 #define SkPDFDocument_DEFINED | 11 #define SkPDFDocument_DEFINED |
12 | 12 |
13 #include "SkAdvancedTypefaceMetrics.h" | 13 #include "SkAdvancedTypefaceMetrics.h" |
14 #include "SkRefCnt.h" | |
15 #include "SkTDArray.h" | 14 #include "SkTDArray.h" |
16 #include "SkTemplates.h" | |
17 | 15 |
18 class SkPDFCatalog; | |
19 class SkPDFDevice; | 16 class SkPDFDevice; |
20 class SkPDFDict; | |
21 class SkPDFPage; | |
22 class SkPDFObject; | |
23 class SkWStream; | 17 class SkWStream; |
24 template <typename T> class SkTSet; | |
25 | 18 |
26 /** \class SkPDFDocument | 19 namespace SkPDFDocument { |
| 20 /** |
| 21 * Assemble pages together and generate a PDF document file. |
| 22 * |
| 23 * Output the PDF to the passed stream. It is an error to call this (it |
| 24 * will return false and not modify stream) if pageDevices is empty. |
| 25 * No device pointer can be NULL. |
| 26 * |
| 27 * @param pageDevices An array of pages, in order. All pages |
| 28 * should be created using the same SkPDFCanon. |
| 29 * TODO(halcanary): ASSERT this condition. |
| 30 * @param SkWStream The writable output stream to send the PDF to. |
| 31 */ |
| 32 bool EmitPDF(const SkTDArray<SkPDFDevice*>& pageDevices, SkWStream*); |
27 | 33 |
28 A SkPDFDocument assembles pages together and generates the final PDF file. | 34 /** Get the count of unique font types used in the given pages. |
29 */ | 35 */ |
30 class SkPDFDocument { | 36 void GetCountOfFontTypes(const SkTDArray<SkPDFDevice*>& pageDevices, |
31 public: | 37 int counts[SkAdvancedTypefaceMetrics::kOther_Font + 1], |
32 SkPDFDocument() {} | 38 int* notSubsettableCount, |
33 ~SkPDFDocument() { fPageDevices.unrefAll(); } | 39 int* notEmbedddableCount); |
34 | 40 } |
35 /** Output the PDF to the passed stream. It is an error to call this (it | |
36 * will return false and not modify stream) if pageDevices is empty. | |
37 * No device pointer can be NULL. | |
38 * | |
39 * @param pageDevices An array of pages, in order. All pages | |
40 * should be created using the same SkPDFCanon. | |
41 * TODO(halcanary): ASSERT this condition. | |
42 * @param SkWStream The writable output stream to send the PDF to. | |
43 */ | |
44 static bool EmitPDF(const SkTDArray<SkPDFDevice*>& pageDevices, SkWStream*); | |
45 | |
46 /** Output the PDF to the passed stream. It is an error to call this (it | |
47 * will return false and not modify stream) if no pages have been added. | |
48 * | |
49 * @param stream The writable output stream to send the PDF to. | |
50 */ | |
51 bool emitPDF(SkWStream* stream) const { | |
52 return SkPDFDocument::EmitPDF(fPageDevices, stream); | |
53 } | |
54 | |
55 /** Append the passed pdf device to the document as a new page. | |
56 * | |
57 * @param pdfDevice The page to add to this document. All pages | |
58 * added to this document should be created | |
59 * using the same SkPDFCanon. | |
60 */ | |
61 void appendPage(SkPDFDevice* pdfDevice) { | |
62 fPageDevices.push(SkRef(pdfDevice)); | |
63 } | |
64 | |
65 /** Get the count of unique font types used in the given pages. | |
66 */ | |
67 static void GetCountOfFontTypes( | |
68 const SkTDArray<SkPDFDevice*>& pageDevices, | |
69 int counts[SkAdvancedTypefaceMetrics::kOther_Font + 1], | |
70 int* notSubsettableCount, | |
71 int* notEmbedddableCount); | |
72 | |
73 /** Get the count of unique font types used in the document. | |
74 */ | |
75 void getCountOfFontTypes( | |
76 int counts[SkAdvancedTypefaceMetrics::kOther_Font + 1], | |
77 int* notSubsettableCount, | |
78 int* notEmbedddableCount) const { | |
79 return SkPDFDocument::GetCountOfFontTypes( | |
80 fPageDevices, counts, notSubsettableCount, notEmbedddableCount); | |
81 } | |
82 | |
83 private: | |
84 SkTDArray<SkPDFDevice*> fPageDevices; | |
85 }; | |
86 | 41 |
87 #endif | 42 #endif |
OLD | NEW |