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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 /** \class SkPDFObject | 23 /** \class SkPDFObject |
24 | 24 |
25 A PDF Object is the base class for primitive elements in a PDF file. A | 25 A PDF Object is the base class for primitive elements in a PDF file. A |
26 common subtype is used to ease the use of indirect object references, | 26 common subtype is used to ease the use of indirect object references, |
27 which are common in the PDF format. | 27 which are common in the PDF format. |
28 */ | 28 */ |
29 class SkPDFObject : public SkRefCnt { | 29 class SkPDFObject : public SkRefCnt { |
30 public: | 30 public: |
31 SK_DECLARE_INST_COUNT(SkPDFObject) | 31 SK_DECLARE_INST_COUNT(SkPDFObject) |
32 | 32 |
33 /** Return the size (number of bytes) of this object in the final output | 33 /** Subclasses must implement this method to print the object to the |
34 * file. Only used for testing. | 34 * PDF file. |
35 * @param catalog The object catalog to use. | 35 * @param catalog The object catalog to use. |
36 * @param indirect If true, output an object identifier with the object. | 36 * @param stream The writable output stream to send the output to. |
37 */ | 37 */ |
38 size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); | 38 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) = 0; |
39 | 39 |
40 /** For non-primitive objects (i.e. objects defined outside this file), | 40 /** For non-primitive objects (i.e. objects defined outside this file), |
41 * this method will add to newResourceObjects any objects that this method | 41 * this method will add to newResourceObjects any objects that this method |
42 * depends on, but not already in knownResourceObjects. This operates | 42 * depends on, but not already in knownResourceObjects. This operates |
43 * recursively so if this object depends on another object and that object | 43 * recursively so if this object depends on another object and that object |
44 * depends on two more, all three objects will be added. | 44 * depends on two more, all three objects will be added. |
45 * | 45 * |
46 * @param knownResourceObjects The set of resources to be ignored. | 46 * @param knownResourceObjects The set of resources to be ignored. |
47 * @param newResourceObjects The set to append dependant resources to. | 47 * @param newResourceObjects The set to append dependant resources to. |
48 */ | 48 */ |
49 virtual void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, | 49 virtual void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, |
50 SkTSet<SkPDFObject*>* newResourceObjects); | 50 SkTSet<SkPDFObject*>* newResourceObjects); |
51 | 51 |
52 /** Emit this object unless the catalog has a substitute object, in which | |
53 * case emit that. | |
54 * @see emitObject | |
55 */ | |
56 void emit(SkWStream* stream, SkPDFCatalog* catalog, bool indirect); | |
57 | |
58 /** Helper function to output an indirect object. | |
59 * @param catalog The object catalog to use. | |
60 * @param stream The writable output stream to send the output to. | |
61 */ | |
62 void emitIndirectObject(SkWStream* stream, SkPDFCatalog* catalog); | |
63 | |
64 /** Helper function to find the size of an indirect object. | |
65 * @param catalog The object catalog to use. | |
66 */ | |
67 size_t getIndirectOutputSize(SkPDFCatalog* catalog); | |
68 | |
69 /** Static helper function to add a resource to a list. The list takes | 52 /** Static helper function to add a resource to a list. The list takes |
70 * a reference. | 53 * a reference. |
71 * @param resource The resource to add. | 54 * @param resource The resource to add. |
72 * @param list The list to add the resource to. | 55 * @param list The list to add the resource to. |
73 */ | 56 */ |
74 static void AddResourceHelper(SkPDFObject* resource, | 57 static void AddResourceHelper(SkPDFObject* resource, |
75 SkTDArray<SkPDFObject*>* list); | 58 SkTDArray<SkPDFObject*>* list); |
76 | 59 |
77 /** Static helper function to copy and reference the resources (and all | 60 /** Static helper function to copy and reference the resources (and all |
78 * their subresources) into a new list. | 61 * their subresources) into a new list. |
79 * @param resources The resource list. | 62 * @param resources The resource list. |
80 * @param newResourceObjects All the resource objects (recursively) used on | 63 * @param newResourceObjects All the resource objects (recursively) used on |
81 * the page are added to this array. This gives | 64 * the page are added to this array. This gives |
82 * the caller a chance to deduplicate resources | 65 * the caller a chance to deduplicate resources |
83 * across pages. | 66 * across pages. |
84 * @param knownResourceObjects The set of resources to be ignored. | 67 * @param knownResourceObjects The set of resources to be ignored. |
85 */ | 68 */ |
86 static void GetResourcesHelper( | 69 static void GetResourcesHelper( |
87 const SkTDArray<SkPDFObject*>* resources, | 70 const SkTDArray<SkPDFObject*>* resources, |
88 const SkTSet<SkPDFObject*>& knownResourceObjects, | 71 const SkTSet<SkPDFObject*>& knownResourceObjects, |
89 SkTSet<SkPDFObject*>* newResourceObjects); | 72 SkTSet<SkPDFObject*>* newResourceObjects); |
90 | 73 |
91 protected: | 74 private: |
92 /** Subclasses must implement this method to print the object to the | |
93 * PDF file. | |
94 * @param catalog The object catalog to use. | |
95 * @param stream The writable output stream to send the output to. | |
96 */ | |
97 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) = 0; | |
98 | |
99 typedef SkRefCnt INHERITED; | 75 typedef SkRefCnt INHERITED; |
100 }; | 76 }; |
101 | 77 |
102 /** \class SkPDFObjRef | 78 /** \class SkPDFObjRef |
103 | 79 |
104 An indirect reference to a PDF object. | 80 An indirect reference to a PDF object. |
105 */ | 81 */ |
106 class SkPDFObjRef : public SkPDFObject { | 82 class SkPDFObjRef : public SkPDFObject { |
107 public: | 83 public: |
108 SK_DECLARE_INST_COUNT(SkPDFObjRef) | 84 SK_DECLARE_INST_COUNT(SkPDFObjRef) |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 404 |
429 mutable SkMutex fMutex; // protects modifications to fValue | 405 mutable SkMutex fMutex; // protects modifications to fValue |
430 SkTDArray<struct Rec> fValue; | 406 SkTDArray<struct Rec> fValue; |
431 | 407 |
432 SkPDFObject* append(SkPDFName* key, SkPDFObject* value); | 408 SkPDFObject* append(SkPDFName* key, SkPDFObject* value); |
433 | 409 |
434 typedef SkPDFObject INHERITED; | 410 typedef SkPDFObject INHERITED; |
435 }; | 411 }; |
436 | 412 |
437 #endif | 413 #endif |
OLD | NEW |