Index: src/pdf/SkPDFTypes.h |
diff --git a/src/pdf/SkPDFTypes.h b/src/pdf/SkPDFTypes.h |
index 5ed6386bddc1235d33a9dbcabe65c78a33a8bb6e..7f4d06e8106376a4fd7980c052ef3be2292a94af 100644 |
--- a/src/pdf/SkPDFTypes.h |
+++ b/src/pdf/SkPDFTypes.h |
@@ -441,4 +441,85 @@ private: |
typedef SkPDFObject INHERITED; |
}; |
+/** \class SkPDFResourceDict |
+ |
+ A resource dictionary, which also allows generation of a list of referenced |
+ SkPDFObjects. These must be added to the dict with insertResource. |
+*/ |
+class SkPDFResourceDict : public SkPDFDict { |
vandebo (ex-Chrome)
2013/07/08 19:02:25
Not sure I'm happy with how this turned out. It's
ducky
2013/07/09 02:56:23
Looks like it can be used in SkPDFDevice, the only
|
+ public: |
+ SK_DECLARE_INST_COUNT(SkPDFResourceDict) |
+ |
+ /** Create a PDF dictionary. Maximum number of entries is 4095. |
vandebo (ex-Chrome)
2013/07/08 19:02:25
comments are out of date....
ducky
2013/07/09 02:56:23
Done.
|
+ */ |
+ SkPDFResourceDict() : SkPDFDict() {}; |
+ |
+ /** Create a PDF dictionary with a Type entry. |
+ * @param type The value of the Type entry. |
+ */ |
+ explicit SkPDFResourceDict(const char type[]) : SkPDFDict(type) {}; |
+ |
+ |
+ /** Add the value to the dictionary with the given key. Refs value. |
+ * The object will NOT be part of the resource list when requested later. |
+ * @param type The type of resource being entered, like Pattern or ExtGState. |
+ * @param key The resource key, unique within the type. |
+ * @param value The resource itself. |
+ * @return The value argument is returned. |
+ */ |
+ SkPDFObject* insertResource(SkPDFName* type, SkPDFName* key, |
+ SkPDFObject* value); |
+ |
+ /** Add the value to the dictionary with the given key. Refs value. |
+ * The object will NOT be part of the resource list when requested later. |
+ * This method will create the SkPDFName object. |
+ * @param type The type of resource being entered, like Pattern or ExtGState. |
+ * @param key The resource key, unique within the type. |
+ * @param value The resource itself. |
+ * @return The value argument is returned. |
+ */ |
+ SkPDFObject* insertResource(const char type[], const char key[], |
+ SkPDFObject* value); |
+ |
+ /** Add the value SkPDFObject as a reference to the dictionary |
+ * with the given key. Refs value. |
+ * This object will be part of the resource list when requested later. |
+ * This method will create the SkPDFName object. |
+ * @param type The type of resource being entered, like Pattern or ExtGState. |
+ * @param key The resource key, unique within the type. |
+ * @param value The resource itself. |
+ * @return The value argument is returned. |
+ */ |
+ SkPDFObject* insertResourceAsRef(const char type[], const char key[], |
+ SkPDFObject* value); |
+ |
+ /** |
+ * Gets resources inserted into this dictionary. |
+ * |
+ * @param knownResourceObjects Set containing currently known resources. |
+ * Resources in the dict and in this set will not be added to the output. |
+ * @param newResourceObjects Output set to which non-preexisting resources |
+ * will be added. |
+ */ |
+ void getResources( |
+ const SkTSet<SkPDFObject*>& knownResourceObjects, |
+ SkTSet<SkPDFObject*>* newResourceObjects); |
+ |
+ private: |
+ /** |
+ * Returns the sub-dict associated with the resource type type. |
+ * If none currently exists, this will create a sub-dict and index it for |
+ * future use. |
+ */ |
+ SkPDFDict* getResourceTypeDict(SkPDFName* type); |
+ |
+ SkTSet<SkPDFObject*> fResources; |
+ |
+ struct DictRec { |
+ SkPDFName* key; |
+ SkPDFDict* value; |
+ }; |
+ SkTDArray<struct DictRec> fTypes; |
+}; |
+ |
#endif |