Home | History | Annotate | Download | only in pdf
      1 /*
      2  * Copyright 2013 Google Inc.
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 #ifndef SkPDFResourceDict_DEFINED
      9 #define SkPDFResourceDict_DEFINED
     10 
     11 #include "SkRefCnt.h"
     12 #include "SkTDArray.h"
     13 
     14 class SkPDFDict;
     15 class SkPDFObject;
     16 
     17 /** \class SkPDFResourceDict
     18 
     19     A resource dictionary, which maintains the relevant sub-dicts and
     20     allows generation of a list of referenced SkPDFObjects inserted with
     21     insertResourceAsRef.
     22 */
     23 class SkPDFResourceDict {
     24 public:
     25     enum SkPDFResourceType {
     26         kExtGState_ResourceType,
     27         kPattern_ResourceType,
     28         kXObject_ResourceType,
     29         kFont_ResourceType,
     30         // These additional types are defined by the spec, but not
     31         // currently used by Skia: ColorSpace, Shading, Properties
     32         kResourceTypeCount
     33     };
     34 
     35     static char GetResourceTypePrefix(SkPDFResourceDict::SkPDFResourceType type);
     36 
     37     /** Create a PDF resource dictionary.
     38      *  The full set of ProcSet entries is automatically created for backwards
     39      *  compatibility, as recommended by the PDF spec.
     40      *
     41      *  Any arguments can be nullptr.
     42      */
     43     static sk_sp<SkPDFDict> Make(
     44         const SkTDArray<SkPDFObject*>* gStateResources,
     45         const SkTDArray<SkPDFObject*>* patternResources,
     46         const SkTDArray<SkPDFObject*>* xObjectResources,
     47         const SkTDArray<SkPDFObject*>* fontResources);
     48 
     49     /**
     50      * Returns the name for the resource that will be generated by the resource
     51      * dict.
     52      *
     53      *  @param type  The type of resource being entered, like
     54      *    kPattern_ResourceType or kExtGState_ResourceType.
     55      *  @param key   The resource key, should be unique within its type.
     56      */
     57     static SkString getResourceName(SkPDFResourceType type, int key);
     58 };
     59 
     60 #endif
     61