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..e21467dd912dc75e9e00caaaab6ca60dbb839f7c |
| --- /dev/null |
| +++ b/src/pdf/SkPDFResourceDict.h |
| @@ -0,0 +1,116 @@ |
| + |
|
vandebo (ex-Chrome)
2013/07/10 18:24:31
nit: remove blank line. Other files have it becau
ducky
2013/07/10 22:54:34
Done.
|
| +/* |
| + * Copyright 2013 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| + |
|
vandebo (ex-Chrome)
2013/07/10 18:24:31
nit: remove extra blank line.
ducky
2013/07/10 22:54:34
Done.
|
| +#ifndef SkPDFResourceDict_DEFINED |
| +#define SkPDFResourceDict_DEFINED |
| + |
| +#include "SkRefCnt.h" |
|
vandebo (ex-Chrome)
2013/07/10 18:24:31
omit
ducky
2013/07/10 22:54:34
Done.
|
| +#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: |
|
vandebo (ex-Chrome)
2013/07/10 18:24:31
nit: no indent.
ducky
2013/07/10 22:54:34
Done. Not really sure where that came from...
|
| + SK_DECLARE_INST_COUNT(SkPDFResourceDict) |
| + |
| + enum SkPDFResourceType{ |
| + kExtGState_ResourceType, |
| + kColorSpace_ResourceType, |
|
vandebo (ex-Chrome)
2013/07/10 18:24:31
omit, since not used. A comment with the unused t
ducky
2013/07/10 22:54:34
Done.
|
| + kPattern_ResourceType, |
| + kShading_ResourceType, |
| + kXObject_ResourceType, |
| + kFont_ResourceType, |
| + kProperties_ResourceType |
| + }; |
| + |
| + /** Create a PDF resource dictionary. |
| + */ |
| + SkPDFResourceDict() : SkPDFDict() {}; |
|
vandebo (ex-Chrome)
2013/07/10 18:24:31
non-POD member variable means that the constructor
vandebo (ex-Chrome)
2013/07/10 18:24:31
Why both a no argument constructor and a construct
ducky
2013/07/10 22:54:34
Done.
ducky
2013/07/10 22:54:34
Done. It looked useful at once point in time, but
|
| + |
| + /** Create a PDF resource dictionary, optionally also creating the full |
| + * set of ProcSet entries for backwards compatibility (as recommended |
| + * by the PDF spec). |
| + */ |
| + SkPDFResourceDict(bool createProcSets); |
|
vandebo (ex-Chrome)
2013/07/10 18:24:31
Is this ever set to false? If not, omit the argum
ducky
2013/07/10 22:54:34
No, it's never set to false. The original idea was
|
| + |
| + /** 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, |
|
vandebo (ex-Chrome)
2013/07/10 18:24:31
Not used, omit.
ducky
2013/07/10 22:54:34
It's used by insertResourceAsRef, and it's possibl
vandebo (ex-Chrome)
2013/07/11 17:50:23
If we're not using it, don't make it part of the p
|
| + 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. |
| + * @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; |
| + |
| + /** |
| + * Gets the prefix associated with a resource type, like G for ExtGState |
| + * or P for Pattern. |
| + */ |
| + const char* getResourceTypePrefix(SkPDFResourceType type); |
|
vandebo (ex-Chrome)
2013/07/10 18:24:31
return a char, instead of a c-string
vandebo (ex-Chrome)
2013/07/10 18:24:31
Not used publicly, make private. Actually it does
ducky
2013/07/10 22:54:34
Now moved into a static function in the implementa
|
| + /** |
| + * Gets the name of a resource type, like ExtGState or Pattern. |
| + */ |
| + const char* getResourceTypeName(SkPDFResourceType type); |
|
vandebo (ex-Chrome)
2013/07/10 18:24:31
Same as above.
ducky
2013/07/10 22:54:34
Done.
|
| + private: |
|
vandebo (ex-Chrome)
2013/07/10 18:24:31
nit: no indent.
ducky
2013/07/10 22:54:34
Done.
|
| + /** |
| + * 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 |