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

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

Issue 870333002: Simplify reference management in SkPDF (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: make Created 5 years, 10 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/SkPDFCatalog.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 /* 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 SkPDFCatalog_DEFINED 10 #ifndef SkPDFCatalog_DEFINED
(...skipping 25 matching lines...) Expand all
36 */ 36 */
37 SkPDFObject* addObject(SkPDFObject* obj, bool onFirstPage); 37 SkPDFObject* addObject(SkPDFObject* obj, bool onFirstPage);
38 38
39 /** Inform the catalog of the object's position in the final stream. 39 /** Inform the catalog of the object's position in the final stream.
40 * The object should already have been added to the catalog. 40 * The object should already have been added to the catalog.
41 * @param obj The object to add. 41 * @param obj The object to add.
42 * @param offset The byte offset in the output stream of this object. 42 * @param offset The byte offset in the output stream of this object.
43 */ 43 */
44 void setFileOffset(SkPDFObject* obj, off_t offset); 44 void setFileOffset(SkPDFObject* obj, off_t offset);
45 45
46 /** Output the object number for the passed object. 46 /** Get the object number for the passed object.
47 * @param obj The object of interest. 47 * @param obj The object of interest.
48 * @param stream The writable output stream to send the output to.
49 */ 48 */
50 void emitObjectNumber(SkWStream* stream, SkPDFObject* obj); 49 int32_t getObjectNumber(SkPDFObject* obj);
51
52 /** Return the number of bytes that would be emitted for the passed
53 * object's object number.
54 * @param obj The object of interest
55 */
56 size_t getObjectNumberSize(SkPDFObject* obj);
57 50
58 /** Return the document flags in effect for this catalog/document. 51 /** Return the document flags in effect for this catalog/document.
59 */ 52 */
60 SkPDFDocument::Flags getDocumentFlags() const { return fDocumentFlags; } 53 SkPDFDocument::Flags getDocumentFlags() const { return fDocumentFlags; }
61 54
62 /** Output the cross reference table for objects in the catalog. 55 /** Output the cross reference table for objects in the catalog.
63 * Returns the total number of objects. 56 * Returns the total number of objects.
64 * @param stream The writable output stream to send the output to. 57 * @param stream The writable output stream to send the output to.
65 * @param firstPage If true, include first page objects only, otherwise 58 * @param firstPage If true, include first page objects only, otherwise
66 * include all objects not on the first page. 59 * include all objects not on the first page.
67 */ 60 */
68 int32_t emitXrefTable(SkWStream* stream, bool firstPage); 61 int32_t emitXrefTable(SkWStream* stream, bool firstPage);
69 62
70 /** Set substitute object for the passed object. 63 /** Set substitute object for the passed object.
71 */ 64 */
72 void setSubstitute(SkPDFObject* original, SkPDFObject* substitute); 65 void setSubstitute(SkPDFObject* original, SkPDFObject* substitute);
73 66
74 /** Find and return any substitute object set for the passed object. If 67 /** Find and return any substitute object set for the passed object. If
75 * there is none, return the passed object. 68 * there is none, return the passed object.
76 */ 69 */
77 SkPDFObject* getSubstituteObject(SkPDFObject* object); 70 SkPDFObject* getSubstituteObject(SkPDFObject* object);
78 71
79 /** get the resources of substitute objects.
80 */
81 SkTSet<SkPDFObject*>* getSubstituteList(bool firstPage);
82
83 private: 72 private:
84 struct Rec { 73 struct Rec {
85 Rec(SkPDFObject* object, bool onFirstPage) 74 Rec(SkPDFObject* object, bool onFirstPage)
86 : fObject(object), 75 : fObject(object),
87 fFileOffset(0), 76 fFileOffset(0),
88 fObjNumAssigned(false), 77 fObjNumAssigned(false),
89 fOnFirstPage(onFirstPage) { 78 fOnFirstPage(onFirstPage) {
90 } 79 }
91 SkPDFObject* fObject; 80 SkPDFObject* fObject;
92 off_t fFileOffset; 81 off_t fFileOffset;
93 bool fObjNumAssigned; 82 bool fObjNumAssigned;
94 bool fOnFirstPage; 83 bool fOnFirstPage;
95 }; 84 };
96 85
97 struct SubstituteMapping { 86 struct SubstituteMapping {
98 SubstituteMapping(SkPDFObject* original, SkPDFObject* substitute) 87 SubstituteMapping(SkPDFObject* original, SkPDFObject* substitute)
99 : fOriginal(original), fSubstitute(substitute) { 88 : fOriginal(original), fSubstitute(substitute) {
100 } 89 }
101 SkPDFObject* fOriginal; 90 SkPDFObject* fOriginal;
102 SkPDFObject* fSubstitute; 91 SkPDFObject* fSubstitute;
103 }; 92 };
104 93
105 // TODO(vandebo): Make this a hash if it's a performance problem. 94 // TODO(vandebo): Make this a hash if it's a performance problem.
106 SkTDArray<struct Rec> fCatalog; 95 SkTDArray<Rec> fCatalog;
107 96
108 // TODO(arthurhsu): Make this a hash if it's a performance problem. 97 // TODO(arthurhsu): Make this a hash if it's a performance problem.
109 SkTDArray<SubstituteMapping> fSubstituteMap; 98 SkTDArray<SubstituteMapping> fSubstituteMap;
110 SkTSet<SkPDFObject*> fSubstituteResourcesFirstPage; 99 SkTSet<SkPDFObject*> fSubstituteResourcesFirstPage;
111 SkTSet<SkPDFObject*> fSubstituteResourcesRemaining; 100 SkTSet<SkPDFObject*> fSubstituteResourcesRemaining;
112 101
113 // Number of objects on the first page. 102 // Number of objects on the first page.
114 uint32_t fFirstPageCount; 103 uint32_t fFirstPageCount;
115 // Next object number to assign (on page > 1). 104 // Next object number to assign (on page > 1).
116 uint32_t fNextObjNum; 105 uint32_t fNextObjNum;
117 // Next object number to assign on the first page. 106 // Next object number to assign on the first page.
118 uint32_t fNextFirstPageObjNum; 107 uint32_t fNextFirstPageObjNum;
119 108
120 SkPDFDocument::Flags fDocumentFlags; 109 SkPDFDocument::Flags fDocumentFlags;
121 110
122 int findObjectIndex(SkPDFObject* obj) const; 111 int findObjectIndex(SkPDFObject* obj);
123 112
124 int assignObjNum(SkPDFObject* obj); 113 int assignObjNum(SkPDFObject* obj);
125 }; 114 };
126 115
127 #endif 116 #endif
OLDNEW
« no previous file with comments | « no previous file | src/pdf/SkPDFCatalog.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698