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 SkPDFTypes_DEFINED | 10 #ifndef SkPDFTypes_DEFINED |
11 #define SkPDFTypes_DEFINED | 11 #define SkPDFTypes_DEFINED |
12 | 12 |
13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
14 #include "SkScalar.h" | 14 #include "SkScalar.h" |
15 #include "SkString.h" | 15 #include "SkString.h" |
16 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
17 #include "SkTSet.h" | |
18 #include "SkTypes.h" | 17 #include "SkTypes.h" |
19 | 18 |
20 class SkPDFCatalog; | 19 class SkPDFCatalog; |
21 class SkWStream; | 20 class SkWStream; |
22 | 21 |
23 class SkPDFObject; | 22 class SkPDFObject; |
24 | 23 |
25 /** \class SkPDFObject | 24 /** \class SkPDFObject |
26 | 25 |
27 A PDF Object is the base class for primitive elements in a PDF file. A | 26 A PDF Object is the base class for primitive elements in a PDF file. A |
28 common subtype is used to ease the use of indirect object references, | 27 common subtype is used to ease the use of indirect object references, |
29 which are common in the PDF format. | 28 which are common in the PDF format. |
30 */ | 29 */ |
31 class SkPDFObject : public SkRefCnt { | 30 class SkPDFObject : public SkRefCnt { |
32 public: | 31 public: |
33 SK_DECLARE_INST_COUNT(SkPDFObject) | 32 SK_DECLARE_INST_COUNT(SkPDFObject) |
34 | 33 |
35 /** Subclasses must implement this method to print the object to the | 34 /** Subclasses must implement this method to print the object to the |
36 * PDF file. | 35 * PDF file. |
37 * @param catalog The object catalog to use. | 36 * @param catalog The object catalog to use. |
38 * @param stream The writable output stream to send the output to. | 37 * @param stream The writable output stream to send the output to. |
39 */ | 38 */ |
40 // TODO(halcanary): make this method const | 39 // TODO(halcanary): make this method const |
41 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) = 0; | 40 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) = 0; |
42 | 41 |
43 /** | 42 /** |
44 * Adds all transitive dependencies of this object to resourceSet. | 43 * Adds all transitive dependencies of this object to the |
45 * | 44 * catalog. Implementations should respect the catalog's object |
46 * @param catalog Implementations should respect the catalog's | 45 * substitution map. |
47 * object substitution map. | |
48 */ | 46 */ |
49 virtual void addResources(SkTSet<SkPDFObject*>* resourceSet, | 47 virtual void addResources(SkPDFCatalog* catalog) const {} |
50 SkPDFCatalog* catalog) const {} | |
51 | 48 |
52 private: | 49 private: |
53 typedef SkRefCnt INHERITED; | 50 typedef SkRefCnt INHERITED; |
54 }; | 51 }; |
55 | 52 |
56 /** \class SkPDFObjRef | 53 /** \class SkPDFObjRef |
57 | 54 |
58 An indirect reference to a PDF object. | 55 An indirect reference to a PDF object. |
59 */ | 56 */ |
60 class SkPDFObjRef : public SkPDFObject { | 57 class SkPDFObjRef : public SkPDFObject { |
61 public: | 58 public: |
62 SK_DECLARE_INST_COUNT(SkPDFObjRef) | 59 SK_DECLARE_INST_COUNT(SkPDFObjRef) |
63 | 60 |
64 /** Create a reference to an existing SkPDFObject. | 61 /** Create a reference to an existing SkPDFObject. |
65 * @param obj The object to reference. | 62 * @param obj The object to reference. |
66 */ | 63 */ |
67 explicit SkPDFObjRef(SkPDFObject* obj); | 64 explicit SkPDFObjRef(SkPDFObject* obj); |
68 virtual ~SkPDFObjRef(); | 65 virtual ~SkPDFObjRef(); |
69 | 66 |
70 // The SkPDFObject interface. | 67 // The SkPDFObject interface. |
71 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; | 68 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; |
72 virtual void addResources(SkTSet<SkPDFObject*>*, SkPDFCatalog*) const SK_OVE
RRIDE; | 69 virtual void addResources(SkPDFCatalog*) const SK_OVERRIDE; |
73 | 70 |
74 private: | 71 private: |
75 SkAutoTUnref<SkPDFObject> fObj; | 72 SkAutoTUnref<SkPDFObject> fObj; |
76 | 73 |
77 typedef SkPDFObject INHERITED; | 74 typedef SkPDFObject INHERITED; |
78 }; | 75 }; |
79 | 76 |
80 /** \class SkPDFInt | 77 /** \class SkPDFInt |
81 | 78 |
82 An integer object in a PDF. | 79 An integer object in a PDF. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 public: | 223 public: |
227 SK_DECLARE_INST_COUNT(SkPDFArray) | 224 SK_DECLARE_INST_COUNT(SkPDFArray) |
228 | 225 |
229 /** Create a PDF array. Maximum length is 8191. | 226 /** Create a PDF array. Maximum length is 8191. |
230 */ | 227 */ |
231 SkPDFArray(); | 228 SkPDFArray(); |
232 virtual ~SkPDFArray(); | 229 virtual ~SkPDFArray(); |
233 | 230 |
234 // The SkPDFObject interface. | 231 // The SkPDFObject interface. |
235 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; | 232 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; |
236 virtual void addResources(SkTSet<SkPDFObject*>*, SkPDFCatalog*) const SK_OVE
RRIDE; | 233 virtual void addResources(SkPDFCatalog*) const SK_OVERRIDE; |
237 | 234 |
238 /** The size of the array. | 235 /** The size of the array. |
239 */ | 236 */ |
240 int size() { return fValue.count(); } | 237 int size() { return fValue.count(); } |
241 | 238 |
242 /** Preallocate space for the given number of entries. | 239 /** Preallocate space for the given number of entries. |
243 * @param length The number of array slots to preallocate. | 240 * @param length The number of array slots to preallocate. |
244 */ | 241 */ |
245 void reserve(int length); | 242 void reserve(int length); |
246 | 243 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 295 |
299 /** Create a PDF dictionary with a Type entry. | 296 /** Create a PDF dictionary with a Type entry. |
300 * @param type The value of the Type entry. | 297 * @param type The value of the Type entry. |
301 */ | 298 */ |
302 explicit SkPDFDict(const char type[]); | 299 explicit SkPDFDict(const char type[]); |
303 | 300 |
304 virtual ~SkPDFDict(); | 301 virtual ~SkPDFDict(); |
305 | 302 |
306 // The SkPDFObject interface. | 303 // The SkPDFObject interface. |
307 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; | 304 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; |
308 virtual void addResources(SkTSet<SkPDFObject*>*, SkPDFCatalog*) const SK_OVE
RRIDE; | 305 virtual void addResources(SkPDFCatalog*) const SK_OVERRIDE; |
309 | 306 |
310 /** The size of the dictionary. | 307 /** The size of the dictionary. |
311 */ | 308 */ |
312 int size() const; | 309 int size() const; |
313 | 310 |
314 /** Add the value to the dictionary with the given key. Refs value. | 311 /** Add the value to the dictionary with the given key. Refs value. |
315 * @param key The key for this dictionary entry. | 312 * @param key The key for this dictionary entry. |
316 * @param value The value for this dictionary entry. | 313 * @param value The value for this dictionary entry. |
317 * @return The value argument is returned. | 314 * @return The value argument is returned. |
318 */ | 315 */ |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 static const int kMaxLen = 4095; | 381 static const int kMaxLen = 4095; |
385 | 382 |
386 SkTDArray<struct Rec> fValue; | 383 SkTDArray<struct Rec> fValue; |
387 | 384 |
388 SkPDFObject* append(SkPDFName* key, SkPDFObject* value); | 385 SkPDFObject* append(SkPDFName* key, SkPDFObject* value); |
389 | 386 |
390 typedef SkPDFObject INHERITED; | 387 typedef SkPDFObject INHERITED; |
391 }; | 388 }; |
392 | 389 |
393 #endif | 390 #endif |
OLD | NEW |