michael@0: /* michael@0: * Copyright 2013 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkPDFResourceDict_DEFINED michael@0: #define SkPDFResourceDict_DEFINED michael@0: michael@0: #include "SkPDFTypes.h" michael@0: #include "SkTDArray.h" michael@0: #include "SkTSet.h" michael@0: #include "SkTypes.h" michael@0: michael@0: /** \class SkPDFResourceDict michael@0: michael@0: A resource dictionary, which maintains the relevant sub-dicts and michael@0: allows generation of a list of referenced SkPDFObjects inserted with michael@0: insertResourceAsRef. michael@0: */ michael@0: class SkPDFResourceDict : public SkPDFDict { michael@0: public: michael@0: SK_DECLARE_INST_COUNT(SkPDFResourceDict) michael@0: michael@0: enum SkPDFResourceType{ michael@0: kExtGState_ResourceType, michael@0: kPattern_ResourceType, michael@0: kXObject_ResourceType, michael@0: kFont_ResourceType, michael@0: // These additional types are defined by the spec, but not michael@0: // currently used by Skia: ColorSpace, Shading, Properties michael@0: kResourceTypeCount michael@0: }; michael@0: michael@0: /** Create a PDF resource dictionary. michael@0: * The full set of ProcSet entries is automatically created for backwards michael@0: * compatibility, as recommended by the PDF spec. michael@0: */ michael@0: SkPDFResourceDict(); michael@0: michael@0: /** Add the value SkPDFObject as a reference to the resource dictionary michael@0: * with the give type and key. michael@0: * The relevant sub-dicts will be automatically generated, and the michael@0: * resource will be named by concatenating a type-specific prefix and michael@0: * the input key. michael@0: * This object will be part of the resource list when requested later. michael@0: * @param type The type of resource being entered, like michael@0: * kPattern_ResourceType or kExtGState_ResourceType. michael@0: * @param key The resource key, should be unique within its type. michael@0: * @param value The resource itself. michael@0: * @return The value argument is returned. michael@0: */ michael@0: SkPDFObject* insertResourceAsReference(SkPDFResourceType type, int key, michael@0: SkPDFObject* value); michael@0: michael@0: /** michael@0: * Gets resources inserted into this dictionary as a reference. michael@0: * michael@0: * @param knownResourceObjects Set containing currently known resources. michael@0: * Resources in the dict and this set will not be added to the output. michael@0: * @param newResourceObjects Output set to which non-preexisting resources michael@0: * will be added. michael@0: * @param recursive Whether or not to add resources of resources. michael@0: */ michael@0: void getReferencedResources( michael@0: const SkTSet& knownResourceObjects, michael@0: SkTSet* newResourceObjects, michael@0: bool recursive) const; michael@0: michael@0: /** michael@0: * Returns the name for the resource that will be generated by the resource michael@0: * dict. michael@0: * michael@0: * @param type The type of resource being entered, like michael@0: * kPattern_ResourceType or kExtGState_ResourceType. michael@0: * @param key The resource key, should be unique within its type. michael@0: */ michael@0: static SkString getResourceName(SkPDFResourceType type, int key); michael@0: michael@0: private: michael@0: /** Add the value to the dictionary with the given key. Refs value. michael@0: * The relevant sub-dicts will be automatically generated, and the michael@0: * resource will be named by concatenating a type-specific prefix and michael@0: * the input key. michael@0: * The object will NOT be part of the resource list when requested later. michael@0: * @param type The type of resource being entered. michael@0: * @param key The resource key, should be unique within its type. michael@0: * @param value The resource itself. michael@0: * @return The value argument is returned. michael@0: */ michael@0: SkPDFObject* insertResource(SkPDFResourceType type, int key, michael@0: SkPDFObject* value); michael@0: michael@0: SkTSet fResources; michael@0: michael@0: SkTDArray fTypes; michael@0: typedef SkPDFDict INHERITED; michael@0: }; michael@0: michael@0: #endif