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" | 14 #include "SkRefCnt.h" |
15 #include "SkTDArray.h" | 15 #include "SkTDArray.h" |
16 #include "SkTemplates.h" | 16 #include "SkTemplates.h" |
17 | 17 |
18 class SkPDFCatalog; | 18 class SkPDFCatalog; |
19 class SkPDFDevice; | 19 class SkPDFDevice; |
20 class SkPDFDict; | 20 class SkPDFDict; |
21 class SkPDFPage; | 21 class SkPDFPage; |
22 class SkPDFObject; | 22 class SkPDFObject; |
23 class SkWStream; | 23 class SkWStream; |
24 template <typename T> class SkTSet; | 24 template <typename T> class SkTSet; |
25 | 25 |
26 /** \class SkPDFDocument | 26 /** \class SkPDFDocument |
27 | 27 |
28 A SkPDFDocument assembles pages together and generates the final PDF file. | 28 A SkPDFDocument assembles pages together and generates the final PDF file. |
29 */ | 29 */ |
30 class SkPDFDocument { | 30 class SkPDFDocument { |
mtklein
2015/03/25 13:10:08
It's starting to seem like SkPDFDocument doesn't n
hal.canary
2015/03/25 13:19:45
Options:
- Keep this functionality together in a
| |
31 public: | 31 public: |
32 SkPDFDocument(); | 32 SkPDFDocument() {} |
33 ~SkPDFDocument(); | 33 ~SkPDFDocument() { fPageDevices.unrefAll(); } |
mtklein
2015/03/25 13:10:08
This destructor seems like another good candidate
hal.canary
2015/03/25 13:19:45
It only gets called from one place (skdocument_pdf
| |
34 | 34 |
35 /** Output the PDF to the passed stream. It is an error to call this (it | 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 no pages have been added | 36 * will return false and not modify stream) if pageDevices is empty. |
37 * or there are pages missing (i.e. page 1 and 3 have been added, but not | 37 * No device pointer can be NULL. |
38 * page 2). | 38 * |
39 * @param pageDevices An array of pages, in order. All pages | |
40 * should be created using the same SkPDFCanon. | |
mtklein
2015/03/25 13:10:08
What happens if they're not? Conflicting IDs?
I'
hal.canary
2015/03/25 13:19:45
No de-duping across pages. (a too-big pdf)
| |
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. | |
39 * | 48 * |
40 * @param stream The writable output stream to send the PDF to. | 49 * @param stream The writable output stream to send the PDF to. |
41 */ | 50 */ |
42 bool emitPDF(SkWStream* stream); | 51 bool emitPDF(SkWStream* stream) const { |
52 return SkPDFDocument::EmitPDF(fPageDevices, stream); | |
53 } | |
43 | 54 |
44 /** Append the passed pdf device to the document as a new page. Returns | 55 /** Append the passed pdf device to the document as a new page. |
45 * true if successful. Will fail if the document has already been emitted. | |
46 * | 56 * |
47 * @param pdfDevice The page to add to this document. | 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. | |
48 */ | 60 */ |
49 bool appendPage(SkPDFDevice* pdfDevice) { | 61 void appendPage(SkPDFDevice* pdfDevice) { |
50 fPageDevices.push(SkRef(pdfDevice)); | 62 fPageDevices.push(SkRef(pdfDevice)); |
51 return true; | |
52 } | 63 } |
53 | 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 | |
54 /** Get the count of unique font types used in the document. | 73 /** Get the count of unique font types used in the document. |
55 */ | 74 */ |
56 void getCountOfFontTypes( | 75 void getCountOfFontTypes( |
57 int counts[SkAdvancedTypefaceMetrics::kOther_Font + 1], | 76 int counts[SkAdvancedTypefaceMetrics::kOther_Font + 1], |
58 int* notSubsettableCount, | 77 int* notSubsettableCount, |
59 int* notEmbedddableCount) const; | 78 int* notEmbedddableCount) const { |
79 return SkPDFDocument::GetCountOfFontTypes( | |
80 fPageDevices, counts, notSubsettableCount, notEmbedddableCount); | |
81 } | |
60 | 82 |
61 private: | 83 private: |
62 SkTDArray<SkPDFDevice*> fPageDevices; | 84 SkTDArray<SkPDFDevice*> fPageDevices; |
63 }; | 85 }; |
64 | 86 |
65 #endif | 87 #endif |
OLD | NEW |