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 13 matching lines...) Expand all Loading... |
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 /** Return the size (number of bytes) of this object in the final output |
34 * file. Compound objects or objects that are computationally intensive | 34 * file. Only used for testing. |
35 * to output should override this method. | |
36 * @param catalog The object catalog to use. | 35 * @param catalog The object catalog to use. |
37 * @param indirect If true, output an object identifier with the object. | 36 * @param indirect If true, output an object identifier with the object. |
38 */ | 37 */ |
39 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); | 38 size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); |
40 | 39 |
41 /** For non-primitive objects (i.e. objects defined outside this file), | 40 /** For non-primitive objects (i.e. objects defined outside this file), |
42 * this method will add to newResourceObjects any objects that this method | 41 * this method will add to newResourceObjects any objects that this method |
43 * depends on, but not already in knownResourceObjects. This operates | 42 * depends on, but not already in knownResourceObjects. This operates |
44 * 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 |
45 * depends on two more, all three objects will be added. | 44 * depends on two more, all three objects will be added. |
46 * | 45 * |
47 * @param knownResourceObjects The set of resources to be ignored. | 46 * @param knownResourceObjects The set of resources to be ignored. |
48 * @param newResourceObjects The set to append dependant resources to. | 47 * @param newResourceObjects The set to append dependant resources to. |
49 */ | 48 */ |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 SK_DECLARE_INST_COUNT(SkPDFObjRef) | 108 SK_DECLARE_INST_COUNT(SkPDFObjRef) |
110 | 109 |
111 /** Create a reference to an existing SkPDFObject. | 110 /** Create a reference to an existing SkPDFObject. |
112 * @param obj The object to reference. | 111 * @param obj The object to reference. |
113 */ | 112 */ |
114 explicit SkPDFObjRef(SkPDFObject* obj); | 113 explicit SkPDFObjRef(SkPDFObject* obj); |
115 virtual ~SkPDFObjRef(); | 114 virtual ~SkPDFObjRef(); |
116 | 115 |
117 // The SkPDFObject interface. | 116 // The SkPDFObject interface. |
118 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; | 117 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; |
119 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); | |
120 | 118 |
121 private: | 119 private: |
122 SkAutoTUnref<SkPDFObject> fObj; | 120 SkAutoTUnref<SkPDFObject> fObj; |
123 | 121 |
124 typedef SkPDFObject INHERITED; | 122 typedef SkPDFObject INHERITED; |
125 }; | 123 }; |
126 | 124 |
127 /** \class SkPDFInt | 125 /** \class SkPDFInt |
128 | 126 |
129 An integer object in a PDF. | 127 An integer object in a PDF. |
(...skipping 26 matching lines...) Expand all Loading... |
156 SK_DECLARE_INST_COUNT(SkPDFBool) | 154 SK_DECLARE_INST_COUNT(SkPDFBool) |
157 | 155 |
158 /** Create a PDF boolean. | 156 /** Create a PDF boolean. |
159 * @param value true or false. | 157 * @param value true or false. |
160 */ | 158 */ |
161 explicit SkPDFBool(bool value); | 159 explicit SkPDFBool(bool value); |
162 virtual ~SkPDFBool(); | 160 virtual ~SkPDFBool(); |
163 | 161 |
164 // The SkPDFObject interface. | 162 // The SkPDFObject interface. |
165 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; | 163 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; |
166 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); | |
167 | 164 |
168 private: | 165 private: |
169 bool fValue; | 166 bool fValue; |
170 | 167 |
171 typedef SkPDFObject INHERITED; | 168 typedef SkPDFObject INHERITED; |
172 }; | 169 }; |
173 | 170 |
174 /** \class SkPDFScalar | 171 /** \class SkPDFScalar |
175 | 172 |
176 A real number object in a PDF. | 173 A real number object in a PDF. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 * @param value A string value. | 211 * @param value A string value. |
215 * @param len The length of value. | 212 * @param len The length of value. |
216 * @param wideChars Indicates if the top byte in value is significant and | 213 * @param wideChars Indicates if the top byte in value is significant and |
217 * should be encoded (true) or not (false). | 214 * should be encoded (true) or not (false). |
218 */ | 215 */ |
219 SkPDFString(const uint16_t* value, size_t len, bool wideChars); | 216 SkPDFString(const uint16_t* value, size_t len, bool wideChars); |
220 virtual ~SkPDFString(); | 217 virtual ~SkPDFString(); |
221 | 218 |
222 // The SkPDFObject interface. | 219 // The SkPDFObject interface. |
223 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; | 220 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; |
224 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); | |
225 | 221 |
226 static SkString FormatString(const char* input, size_t len); | 222 static SkString FormatString(const char* input, size_t len); |
227 static SkString FormatString(const uint16_t* input, size_t len, | 223 static SkString FormatString(const uint16_t* input, size_t len, |
228 bool wideChars); | 224 bool wideChars); |
229 private: | 225 private: |
230 static const size_t kMaxLen = 65535; | 226 static const size_t kMaxLen = 65535; |
231 | 227 |
232 const SkString fValue; | 228 const SkString fValue; |
233 | 229 |
234 static SkString DoFormatString(const void* input, size_t len, | 230 static SkString DoFormatString(const void* input, size_t len, |
(...skipping 14 matching lines...) Expand all Loading... |
249 * @param value The name. | 245 * @param value The name. |
250 */ | 246 */ |
251 explicit SkPDFName(const char name[]); | 247 explicit SkPDFName(const char name[]); |
252 explicit SkPDFName(const SkString& name); | 248 explicit SkPDFName(const SkString& name); |
253 virtual ~SkPDFName(); | 249 virtual ~SkPDFName(); |
254 | 250 |
255 bool operator==(const SkPDFName& b) const; | 251 bool operator==(const SkPDFName& b) const; |
256 | 252 |
257 // The SkPDFObject interface. | 253 // The SkPDFObject interface. |
258 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; | 254 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; |
259 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); | |
260 | 255 |
261 private: | 256 private: |
262 static const size_t kMaxLen = 127; | 257 static const size_t kMaxLen = 127; |
263 | 258 |
264 const SkString fValue; | 259 const SkString fValue; |
265 | 260 |
266 static SkString FormatName(const SkString& input); | 261 static SkString FormatName(const SkString& input); |
267 | 262 |
268 typedef SkPDFObject INHERITED; | 263 typedef SkPDFObject INHERITED; |
269 }; | 264 }; |
270 | 265 |
271 /** \class SkPDFArray | 266 /** \class SkPDFArray |
272 | 267 |
273 An array object in a PDF. | 268 An array object in a PDF. |
274 */ | 269 */ |
275 class SkPDFArray : public SkPDFObject { | 270 class SkPDFArray : public SkPDFObject { |
276 public: | 271 public: |
277 SK_DECLARE_INST_COUNT(SkPDFArray) | 272 SK_DECLARE_INST_COUNT(SkPDFArray) |
278 | 273 |
279 /** Create a PDF array. Maximum length is 8191. | 274 /** Create a PDF array. Maximum length is 8191. |
280 */ | 275 */ |
281 SkPDFArray(); | 276 SkPDFArray(); |
282 virtual ~SkPDFArray(); | 277 virtual ~SkPDFArray(); |
283 | 278 |
284 // The SkPDFObject interface. | 279 // The SkPDFObject interface. |
285 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; | 280 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; |
286 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); | |
287 | 281 |
288 /** The size of the array. | 282 /** The size of the array. |
289 */ | 283 */ |
290 int size() { return fValue.count(); } | 284 int size() { return fValue.count(); } |
291 | 285 |
292 /** Preallocate space for the given number of entries. | 286 /** Preallocate space for the given number of entries. |
293 * @param length The number of array slots to preallocate. | 287 * @param length The number of array slots to preallocate. |
294 */ | 288 */ |
295 void reserve(int length); | 289 void reserve(int length); |
296 | 290 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 342 |
349 /** Create a PDF dictionary with a Type entry. | 343 /** Create a PDF dictionary with a Type entry. |
350 * @param type The value of the Type entry. | 344 * @param type The value of the Type entry. |
351 */ | 345 */ |
352 explicit SkPDFDict(const char type[]); | 346 explicit SkPDFDict(const char type[]); |
353 | 347 |
354 virtual ~SkPDFDict(); | 348 virtual ~SkPDFDict(); |
355 | 349 |
356 // The SkPDFObject interface. | 350 // The SkPDFObject interface. |
357 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; | 351 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRID
E; |
358 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); | |
359 | 352 |
360 /** The size of the dictionary. | 353 /** The size of the dictionary. |
361 */ | 354 */ |
362 int size() const; | 355 int size() const; |
363 | 356 |
364 /** Add the value to the dictionary with the given key. Refs value. | 357 /** Add the value to the dictionary with the given key. Refs value. |
365 * @param key The key for this dictionary entry. | 358 * @param key The key for this dictionary entry. |
366 * @param value The value for this dictionary entry. | 359 * @param value The value for this dictionary entry. |
367 * @return The value argument is returned. | 360 * @return The value argument is returned. |
368 */ | 361 */ |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 | 428 |
436 mutable SkMutex fMutex; // protects modifications to fValue | 429 mutable SkMutex fMutex; // protects modifications to fValue |
437 SkTDArray<struct Rec> fValue; | 430 SkTDArray<struct Rec> fValue; |
438 | 431 |
439 SkPDFObject* append(SkPDFName* key, SkPDFObject* value); | 432 SkPDFObject* append(SkPDFName* key, SkPDFObject* value); |
440 | 433 |
441 typedef SkPDFObject INHERITED; | 434 typedef SkPDFObject INHERITED; |
442 }; | 435 }; |
443 | 436 |
444 #endif | 437 #endif |
OLD | NEW |