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

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

Issue 1802033003: SkPDF: SkPDFDocument reorganized so that some objects can be serialized early. (Closed) Base URL: https://skia.googlesource.com/skia.git@SkPdfDumpMethod
Patch Set: 2016-03-21 (Monday) 16:31:34 EDT Created 4 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
« no previous file with comments | « no previous file | src/pdf/SkPDFDocument.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkPDFMetadata.h"
12 #include "SkPDFTypes.h"
11 13
12 sk_sp<SkDocument> SkPDFMakeDocument( 14 sk_sp<SkDocument> SkPDFMakeDocument(
13 SkWStream* stream, 15 SkWStream* stream,
14 void (*doneProc)(SkWStream*, bool), 16 void (*doneProc)(SkWStream*, bool),
15 SkScalar rasterDpi, 17 SkScalar rasterDpi,
16 SkPixelSerializer* jpegEncoder); 18 SkPixelSerializer* jpegEncoder);
17 19
20 // Logically part of SkPDFDocument (like SkPDFCanon), but separate to
21 // keep similar functionality together.
22 struct SkPDFObjectSerializer : SkNoncopyable {
23 SkPDFObjNumMap fObjNumMap;
24 SkPDFSubstituteMap fSubstituteMap;
25 SkTDArray<int32_t> fOffsets;
26 sk_sp<SkPDFObject> fInfoDict;
27 size_t fBaseOffset;
28 int32_t fNextToBeSerialized; // index in fObjNumMap
29
30 SkPDFObjectSerializer();
31 void addObjectRecursively(const sk_sp<SkPDFObject>&);
32 void serializeHeader(SkWStream*, const SkPDFMetadata&);
33 void serializeObjects(SkWStream*);
34 void serializeFooter(SkWStream*, const sk_sp<SkPDFObject>, sk_sp<SkPDFObject >);
35 int32_t offset(SkWStream*);
36 };
37
38 /** Concrete implementation of SkDocument that creates PDF files. This
39 class does not produced linearized or optimized PDFs; instead it
40 it attempts to use a minimum amount of RAM. */
41 class SkPDFDocument : public SkDocument {
42 public:
43 SkPDFDocument(SkWStream*,
44 void (*)(SkWStream*, bool),
45 SkScalar,
46 SkPixelSerializer*);
47 virtual ~SkPDFDocument();
48 SkCanvas* onBeginPage(SkScalar, SkScalar, const SkRect&) override;
49 void onEndPage() override;
50 bool onClose(SkWStream*) override;
51 void onAbort() override;
52 void setMetadata(const SkDocument::Attribute[],
53 int,
54 const SkTime::DateTime*,
55 const SkTime::DateTime*) override;
56 /**
57 Serialize the object, as well as any other objects it
58 indirectly refers to. If any any other objects have been added
59 to the SkPDFObjNumMap without serializing them, they will be
60 serialized as well.
61
62 It might go without saying that objects should not be changed
63 after calling serialize, since those changes will be too late.
64 The same goes for changes to the SkPDFSubstituteMap that effect
65 the object or its dependencies.
66 */
67 void serialize(const sk_sp<SkPDFObject>&);
68 SkPDFCanon* canon() { return &fCanon; }
69
70 private:
71 SkPDFObjectSerializer fObjectSerializer;
72 SkPDFCanon fCanon;
73 SkTArray<sk_sp<const SkPDFDevice>> fPageDevices;
74 sk_sp<SkCanvas> fCanvas;
75 SkScalar fRasterDpi;
76 SkPDFMetadata fMetadata;
77 };
78
18 #endif // SkPDFDocument_DEFINED 79 #endif // SkPDFDocument_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/pdf/SkPDFDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698