Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: src/pdf/SkPDFDocument.h

Issue 1033543002: SKPDF: refactor pdfcatalog and pdfdocument (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-03-23 (Monday) 19:02:27 EDT Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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; 17 class SkPDFPage;
22 class SkPDFObject;
23 class SkWStream; 18 class SkWStream;
24 template <typename T> class SkTSet;
25 19
26 /** \class SkPDFDocument 20 /** \class SkPDFDocument
27 21
28 A SkPDFDocument assembles pages together and generates the final PDF file. 22 A SkPDFDocument assembles pages together and generates the final PDF file.
29 */ 23 */
30 class SkPDFDocument { 24 class SkPDFDocument {
31 public: 25 public:
32 SkPDFDocument(); 26 SkPDFDocument();
33 ~SkPDFDocument(); 27 ~SkPDFDocument();
34 28
35 /** Output the PDF to the passed stream. It is an error to call this (it 29 /** 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 30 * will return false and not modify stream) if no pages have been added
37 * or there are pages missing (i.e. page 1 and 3 have been added, but not 31 * or there are pages missing (i.e. page 1 and 3 have been added, but not
38 * page 2). 32 * page 2).
39 * 33 *
40 * @param stream The writable output stream to send the PDF to. 34 * @param stream The writable output stream to send the PDF to.
41 */ 35 */
42 bool emitPDF(SkWStream* stream); 36 bool emitPDF(SkWStream* stream);
43 37
44 /** Sets the specific page to the passed PDF device. If the specified
45 * page is already set, this overrides it. Returns true if successful.
46 * Will fail if the document has already been emitted.
47 *
48 * @param pageNumber The position to add the passed device (1 based).
49 * @param pdfDevice The page to add to this document.
50 */
51 bool setPage(int pageNumber, SkPDFDevice* pdfDevice);
52
53 /** Append the passed pdf device to the document as a new page. Returns 38 /** Append the passed pdf device to the document as a new page. Returns
54 * true if successful. Will fail if the document has already been emitted. 39 * true if successful. Will fail if the document has already been emitted.
55 * 40 *
56 * @param pdfDevice The page to add to this document. 41 * @param pdfDevice The page to add to this document.
57 */ 42 */
58 bool appendPage(SkPDFDevice* pdfDevice); 43 bool appendPage(SkPDFDevice* pdfDevice);
59 44
60 /** Get the count of unique font types used in the document. 45 /** Get the count of unique font types used in the document.
61 * DEPRECATED.
62 */
63 void getCountOfFontTypes(
64 int counts[SkAdvancedTypefaceMetrics::kOther_Font + 2]) const;
65
66 /** Get the count of unique font types used in the document.
67 */ 46 */
68 void getCountOfFontTypes( 47 void getCountOfFontTypes(
69 int counts[SkAdvancedTypefaceMetrics::kOther_Font + 1], 48 int counts[SkAdvancedTypefaceMetrics::kOther_Font + 1],
70 int* notSubsettableCount, 49 int* notSubsettableCount,
71 int* notEmbedddableCount) const; 50 int* notEmbedddableCount) const;
72 51
73 private: 52 private:
74 SkAutoTDelete<SkPDFCatalog> fCatalog;
75 int64_t fXRefFileOffset;
76
77 SkTDArray<SkPDFPage*> fPages; 53 SkTDArray<SkPDFPage*> fPages;
78 SkTDArray<SkPDFDict*> fPageTree;
79 SkPDFDict* fDocCatalog;
80 SkTSet<SkPDFObject*>* fFirstPageResources;
81 SkTSet<SkPDFObject*>* fOtherPageResources;
82 SkTDArray<SkPDFObject*> fSubstitutes;
83
84 SkPDFDict* fTrailerDict;
85
86 /** Output the PDF header to the passed stream.
87 * @param stream The writable output stream to send the header to.
88 */
89 void emitHeader(SkWStream* stream);
90
91 /** Get the size of the header.
92 */
93 size_t headerSize();
94
95 /** Output the PDF footer to the passed stream.
96 * @param stream The writable output stream to send the footer to.
97 * @param objCount The number of objects in the PDF.
98 */
99 void emitFooter(SkWStream* stream, int64_t objCount);
100 }; 54 };
101 55
102 #endif 56 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698