Chromium Code Reviews| Index: src/pdf/SkPDFResourceDict.h |
| diff --git a/src/pdf/SkPDFResourceDict.h b/src/pdf/SkPDFResourceDict.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a85e00c04147808c22ab9ab65a2612299f658669 |
| --- /dev/null |
| +++ b/src/pdf/SkPDFResourceDict.h |
| @@ -0,0 +1,89 @@ |
| +/* |
| + * Copyright 2013 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef SkPDFResourceDict_DEFINED |
| +#define SkPDFResourceDict_DEFINED |
| + |
| +#include "SkPDFTypes.h" |
| +#include "SkTDArray.h" |
| +#include "SkTSet.h" |
| +#include "SkTypes.h" |
| + |
| +/** \class SkPDFResourceDict |
| + |
| + A resource dictionary, which maintains the relevant sub-dicts and |
| + allows generation of a list of referenced SkPDFObjects inserted with |
| + insertResourceAsRef. |
| +*/ |
| +class SkPDFResourceDict : public SkPDFDict { |
| +public: |
| + SK_DECLARE_INST_COUNT(SkPDFResourceDict) |
| + |
| + enum SkPDFResourceType{ |
| + kExtGState_ResourceType, |
| + kPattern_ResourceType, |
| + kXObject_ResourceType, |
| + kFont_ResourceType |
| + // These additional types are defined by the spec, but not |
|
vandebo (ex-Chrome)
2013/07/11 17:50:23
You may want to add KResouceTypeCount to help with
ducky
2013/07/11 23:09:50
Done.
|
| + // currently used by Skia: |
| + // ColorSpace, Shading, Properties |
|
vandebo (ex-Chrome)
2013/07/11 17:50:23
nit, will fit on the previous line.
ducky
2013/07/11 23:09:50
Done.
|
| + }; |
| + |
| + /** Create a PDF resource dictionary. |
| + * The full set of ProcSet entries is automatically created for backwards |
| + * compatibility, as recommended by the PDF spec. |
| + */ |
| + SkPDFResourceDict(); |
| + |
| + /** Add the value to the dictionary with the given key. Refs value. |
| + * The relevant sub-dicts will be automatically generated, and the |
| + * resource will be named by concatenating a type-specific prefix and |
| + * the input key. |
| + * The object will NOT be part of the resource list when requested later. |
| + * @param type The type of resource being entered. |
| + * @param key The resource key, should be unique within its type. |
| + * @param value The resource itself. |
| + * @return The value argument is returned. |
| + */ |
| + SkPDFObject* insertResource(SkPDFResourceType type, int key, |
| + SkPDFObject* value); |
| + |
| + /** Add the value SkPDFObject as a reference to the resource dictionary |
| + * with the give type and key. |
| + * The relevant sub-dicts will be automatically generated, and the |
| + * resource will be named by concatenating a type-specific prefix and |
| + * the input key. |
| + * This object will be part of the resource list when requested later. |
| + * @param type The type of resource being entered, like Pattern or ExtGState. |
|
vandebo (ex-Chrome)
2013/07/11 17:50:23
Skia allows 100 column lines, but it looks like yo
vandebo (ex-Chrome)
2013/07/11 17:50:23
comment out of date, i.e. Pattern -> kPattern_Reso
ducky
2013/07/11 23:09:50
Adhering to 80 lines.
ducky
2013/07/11 23:09:50
Done.
|
| + * @param key The resource key, should be unique within its type. |
| + * @param value The resource itself. |
| + * @return The value argument is returned. |
| + */ |
| + SkPDFObject* insertResourceAsRef(SkPDFResourceType type, int 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. |
| + * @param recursive Whether or not to add resources of resources. |
| + */ |
| + void getResources( |
| + const SkTSet<SkPDFObject*>& knownResourceObjects, |
| + SkTSet<SkPDFObject*>* newResourceObjects, |
| + bool recursive) const; |
| + |
| +private: |
| + SkTSet<SkPDFObject*> fResources; |
| + |
| + SkTDArray<SkPDFDict*> fTypes; |
| +}; |
| + |
| +#endif |