blob: a9618b24235a46033f09c32684d8896057049555 [file] [log] [blame]
commit-bot@chromium.org47401352013-07-23 21:49:29 +00001/*
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
martina.kollarovab8d6af12016-06-29 05:12:31 -070011#include "SkRefCnt.h"
commit-bot@chromium.org47401352013-07-23 21:49:29 +000012#include "SkTDArray.h"
martina.kollarovab8d6af12016-06-29 05:12:31 -070013
14class SkPDFDict;
15class SkPDFObject;
commit-bot@chromium.org47401352013-07-23 21:49:29 +000016
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*/
halcanary2b861552015-04-09 13:27:40 -070023class SkPDFResourceDict {
commit-bot@chromium.org47401352013-07-23 21:49:29 +000024public:
halcanary2b861552015-04-09 13:27:40 -070025 enum SkPDFResourceType {
commit-bot@chromium.org47401352013-07-23 21:49:29 +000026 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
halcanary2b861552015-04-09 13:27:40 -070033 };
commit-bot@chromium.org47401352013-07-23 21:49:29 +000034
halcanaryc2f9ec12016-09-12 08:55:29 -070035 static char GetResourceTypePrefix(SkPDFResourceDict::SkPDFResourceType type);
36
commit-bot@chromium.org47401352013-07-23 21:49:29 +000037 /** 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.
halcanary2b861552015-04-09 13:27:40 -070040 *
halcanary96fcdcc2015-08-27 07:41:13 -070041 * Any arguments can be nullptr.
commit-bot@chromium.org47401352013-07-23 21:49:29 +000042 */
halcanary8103a342016-03-08 15:10:16 -080043 static sk_sp<SkPDFDict> Make(
halcanary2b861552015-04-09 13:27:40 -070044 const SkTDArray<SkPDFObject*>* gStateResources,
45 const SkTDArray<SkPDFObject*>* patternResources,
46 const SkTDArray<SkPDFObject*>* xObjectResources,
47 const SkTDArray<SkPDFObject*>* fontResources);
commit-bot@chromium.org47401352013-07-23 21:49:29 +000048
49 /**
commit-bot@chromium.org47401352013-07-23 21:49:29 +000050 * 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);
commit-bot@chromium.org47401352013-07-23 21:49:29 +000058};
59
60#endif