OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 | 7 |
8 #ifndef SkPDFResourceDict_DEFINED | 8 #ifndef SkPDFResourceDict_DEFINED |
9 #define SkPDFResourceDict_DEFINED | 9 #define SkPDFResourceDict_DEFINED |
10 | 10 |
11 #include "SkPDFTypes.h" | 11 #include "SkPDFTypes.h" |
12 #include "SkTDArray.h" | 12 #include "SkTDArray.h" |
13 #include "SkTypes.h" | 13 #include "SkTypes.h" |
14 | 14 |
15 /** \class SkPDFResourceDict | 15 /** \class SkPDFResourceDict |
16 | 16 |
17 A resource dictionary, which maintains the relevant sub-dicts and | 17 A resource dictionary, which maintains the relevant sub-dicts and |
18 allows generation of a list of referenced SkPDFObjects inserted with | 18 allows generation of a list of referenced SkPDFObjects inserted with |
19 insertResourceAsRef. | 19 insertResourceAsRef. |
20 */ | 20 */ |
21 class SkPDFResourceDict : public SkPDFDict { | 21 class SkPDFResourceDict { |
22 public: | 22 public: |
23 SK_DECLARE_INST_COUNT(SkPDFResourceDict) | 23 enum SkPDFResourceType { |
24 | |
25 enum SkPDFResourceType{ | |
26 kExtGState_ResourceType, | 24 kExtGState_ResourceType, |
27 kPattern_ResourceType, | 25 kPattern_ResourceType, |
28 kXObject_ResourceType, | 26 kXObject_ResourceType, |
29 kFont_ResourceType, | 27 kFont_ResourceType, |
30 // These additional types are defined by the spec, but not | 28 // These additional types are defined by the spec, but not |
31 // currently used by Skia: ColorSpace, Shading, Properties | 29 // currently used by Skia: ColorSpace, Shading, Properties |
32 kResourceTypeCount | 30 kResourceTypeCount |
33 }; | 31 }; |
34 | 32 |
35 /** Create a PDF resource dictionary. | 33 /** Create a PDF resource dictionary. |
36 * The full set of ProcSet entries is automatically created for backwards | 34 * The full set of ProcSet entries is automatically created for backwards |
37 * compatibility, as recommended by the PDF spec. | 35 * compatibility, as recommended by the PDF spec. |
| 36 * |
| 37 * Any arguments can be NULL. |
38 */ | 38 */ |
39 SkPDFResourceDict(); | 39 static SkPDFDict* Create( |
40 | 40 const SkTDArray<SkPDFObject*>* gStateResources, |
41 /** Add the value SkPDFObject as a reference to the resource dictionary | 41 const SkTDArray<SkPDFObject*>* patternResources, |
42 * with the give type and key. | 42 const SkTDArray<SkPDFObject*>* xObjectResources, |
43 * The relevant sub-dicts will be automatically generated, and the | 43 const SkTDArray<SkPDFObject*>* fontResources); |
44 * resource will be named by concatenating a type-specific prefix and | |
45 * the input key. | |
46 * This object will be part of the resource list when requested later. | |
47 * @param type The type of resource being entered, like | |
48 * kPattern_ResourceType or kExtGState_ResourceType. | |
49 * @param key The resource key, should be unique within its type. | |
50 * @param value The resource itself. | |
51 * @return The value argument is returned. | |
52 */ | |
53 SkPDFObject* insertResourceAsReference(SkPDFResourceType type, int key, | |
54 SkPDFObject* value); | |
55 | 44 |
56 /** | 45 /** |
57 * Returns the name for the resource that will be generated by the resource | 46 * Returns the name for the resource that will be generated by the resource |
58 * dict. | 47 * dict. |
59 * | 48 * |
60 * @param type The type of resource being entered, like | 49 * @param type The type of resource being entered, like |
61 * kPattern_ResourceType or kExtGState_ResourceType. | 50 * kPattern_ResourceType or kExtGState_ResourceType. |
62 * @param key The resource key, should be unique within its type. | 51 * @param key The resource key, should be unique within its type. |
63 */ | 52 */ |
64 static SkString getResourceName(SkPDFResourceType type, int key); | 53 static SkString getResourceName(SkPDFResourceType type, int key); |
65 | |
66 private: | |
67 /** Add the value to the dictionary with the given key. Refs value. | |
68 * The relevant sub-dicts will be automatically generated, and the | |
69 * resource will be named by concatenating a type-specific prefix and | |
70 * the input key. | |
71 * The object will NOT be part of the resource list when requested later. | |
72 * @param type The type of resource being entered. | |
73 * @param key The resource key, should be unique within its type. | |
74 * @param value The resource itself. | |
75 * @return The value argument is returned. | |
76 */ | |
77 SkPDFObject* insertResource(SkPDFResourceType type, int key, | |
78 SkPDFObject* value); | |
79 | |
80 SkTDArray<SkPDFDict*> fTypes; | |
81 typedef SkPDFDict INHERITED; | |
82 }; | 54 }; |
83 | 55 |
84 #endif | 56 #endif |
OLD | NEW |