OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 #ifndef SkPDFDocument_DEFINED | 7 #ifndef SkPDFDocument_DEFINED |
8 #define SkPDFDocument_DEFINED | 8 #define SkPDFDocument_DEFINED |
9 | 9 |
10 #include "SkDocument.h" | 10 #include "SkDocument.h" |
11 #include "SkPDFCanon.h" | 11 #include "SkPDFCanon.h" |
12 #include "SkPDFMetadata.h" | 12 #include "SkPDFMetadata.h" |
13 #include "SkPDFFont.h" | 13 #include "SkPDFFont.h" |
14 | 14 |
15 class SkPDFDevice; | 15 class SkPDFDevice; |
16 | 16 |
17 sk_sp<SkDocument> SkPDFMakeDocument( | 17 sk_sp<SkDocument> SkPDFMakeDocument( |
18 SkWStream* stream, | 18 SkWStream* stream, |
19 void (*doneProc)(SkWStream*, bool), | 19 void (*doneProc)(SkWStream*, bool), |
20 SkScalar rasterDpi, | 20 SkScalar rasterDpi, |
21 SkPixelSerializer* jpegEncoder); | 21 SkPixelSerializer* jpegEncoder, |
| 22 bool pdfa); |
22 | 23 |
23 // Logically part of SkPDFDocument (like SkPDFCanon), but separate to | 24 // Logically part of SkPDFDocument (like SkPDFCanon), but separate to |
24 // keep similar functionality together. | 25 // keep similar functionality together. |
25 struct SkPDFObjectSerializer : SkNoncopyable { | 26 struct SkPDFObjectSerializer : SkNoncopyable { |
26 SkPDFObjNumMap fObjNumMap; | 27 SkPDFObjNumMap fObjNumMap; |
27 SkPDFSubstituteMap fSubstituteMap; | 28 SkPDFSubstituteMap fSubstituteMap; |
28 SkTDArray<int32_t> fOffsets; | 29 SkTDArray<int32_t> fOffsets; |
29 sk_sp<SkPDFObject> fInfoDict; | 30 sk_sp<SkPDFObject> fInfoDict; |
30 size_t fBaseOffset; | 31 size_t fBaseOffset; |
31 int32_t fNextToBeSerialized; // index in fObjNumMap | 32 int32_t fNextToBeSerialized; // index in fObjNumMap |
32 | 33 |
33 SkPDFObjectSerializer(); | 34 SkPDFObjectSerializer(); |
34 ~SkPDFObjectSerializer(); | 35 ~SkPDFObjectSerializer(); |
35 void addObjectRecursively(const sk_sp<SkPDFObject>&); | 36 void addObjectRecursively(const sk_sp<SkPDFObject>&); |
36 void serializeHeader(SkWStream*, const SkPDFMetadata&); | 37 void serializeHeader(SkWStream*, const SkPDFMetadata&); |
37 void serializeObjects(SkWStream*); | 38 void serializeObjects(SkWStream*); |
38 void serializeFooter(SkWStream*, const sk_sp<SkPDFObject>, sk_sp<SkPDFObject
>); | 39 void serializeFooter(SkWStream*, const sk_sp<SkPDFObject>, sk_sp<SkPDFObject
>); |
39 int32_t offset(SkWStream*); | 40 int32_t offset(SkWStream*); |
40 }; | 41 }; |
41 | 42 |
42 /** Concrete implementation of SkDocument that creates PDF files. This | 43 /** Concrete implementation of SkDocument that creates PDF files. This |
43 class does not produced linearized or optimized PDFs; instead it | 44 class does not produced linearized or optimized PDFs; instead it |
44 it attempts to use a minimum amount of RAM. */ | 45 it attempts to use a minimum amount of RAM. */ |
45 class SkPDFDocument : public SkDocument { | 46 class SkPDFDocument : public SkDocument { |
46 public: | 47 public: |
47 SkPDFDocument(SkWStream*, | 48 SkPDFDocument(SkWStream*, |
48 void (*)(SkWStream*, bool), | 49 void (*)(SkWStream*, bool), |
49 SkScalar, | 50 SkScalar, |
50 SkPixelSerializer*); | 51 SkPixelSerializer*, |
| 52 bool); |
51 virtual ~SkPDFDocument(); | 53 virtual ~SkPDFDocument(); |
52 SkCanvas* onBeginPage(SkScalar, SkScalar, const SkRect&) override; | 54 SkCanvas* onBeginPage(SkScalar, SkScalar, const SkRect&) override; |
53 void onEndPage() override; | 55 void onEndPage() override; |
54 bool onClose(SkWStream*) override; | 56 bool onClose(SkWStream*) override; |
55 void onAbort() override; | 57 void onAbort() override; |
56 void setMetadata(const SkDocument::Attribute[], | 58 void setMetadata(const SkDocument::Attribute[], |
57 int, | 59 int, |
58 const SkTime::DateTime*, | 60 const SkTime::DateTime*, |
59 const SkTime::DateTime*) override; | 61 const SkTime::DateTime*) override; |
60 /** | 62 /** |
(...skipping 11 matching lines...) Expand all Loading... |
72 SkPDFCanon* canon() { return &fCanon; } | 74 SkPDFCanon* canon() { return &fCanon; } |
73 | 75 |
74 private: | 76 private: |
75 SkPDFObjectSerializer fObjectSerializer; | 77 SkPDFObjectSerializer fObjectSerializer; |
76 SkPDFCanon fCanon; | 78 SkPDFCanon fCanon; |
77 SkPDFGlyphSetMap fGlyphUsage; | 79 SkPDFGlyphSetMap fGlyphUsage; |
78 SkTArray<sk_sp<SkPDFDict>> fPages; | 80 SkTArray<sk_sp<SkPDFDict>> fPages; |
79 sk_sp<SkPDFDict> fDests; | 81 sk_sp<SkPDFDict> fDests; |
80 sk_sp<SkPDFDevice> fPageDevice; | 82 sk_sp<SkPDFDevice> fPageDevice; |
81 sk_sp<SkCanvas> fCanvas; | 83 sk_sp<SkCanvas> fCanvas; |
82 #ifdef SK_PDF_GENERATE_PDFA | |
83 sk_sp<SkPDFObject> fID; | 84 sk_sp<SkPDFObject> fID; |
84 sk_sp<SkPDFObject> fXMP; | 85 sk_sp<SkPDFObject> fXMP; |
85 #endif | |
86 SkScalar fRasterDpi; | 86 SkScalar fRasterDpi; |
87 SkPDFMetadata fMetadata; | 87 SkPDFMetadata fMetadata; |
| 88 bool fPDFA; |
88 }; | 89 }; |
89 | 90 |
90 #endif // SkPDFDocument_DEFINED | 91 #endif // SkPDFDocument_DEFINED |
OLD | NEW |