Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Side by Side Diff: src/pdf/SkPDFResourceDict.h

Issue 18977002: Add SkPDFResourceDict class, refactor existing code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fixes 80 cols Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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 "SkPDFTypes.h"
12 #include "SkTDArray.h"
13 #include "SkTSet.h"
14 #include "SkTypes.h"
15
16 /** \class SkPDFResourceDict
17
18 A resource dictionary, which maintains the relevant sub-dicts and
19 allows generation of a list of referenced SkPDFObjects inserted with
20 insertResourceAsRef.
21 */
22 class SkPDFResourceDict : public SkPDFDict {
23 public:
24 SK_DECLARE_INST_COUNT(SkPDFResourceDict)
25
26 enum SkPDFResourceType{
27 kExtGState_ResourceType,
28 kPattern_ResourceType,
29 kXObject_ResourceType,
30 kFont_ResourceType,
31 kResourceTypeCount
32 // These additional types are defined by the spec, but not
vandebo (ex-Chrome) 2013/07/12 19:14:59 nit: I would put Count below this comment.
ducky 2013/07/12 21:18:17 Done.
33 // currently used by Skia: ColorSpace, Shading, Properties
34 };
35
36 /** Create a PDF resource dictionary.
37 * The full set of ProcSet entries is automatically created for backwards
38 * compatibility, as recommended by the PDF spec.
39 */
40 SkPDFResourceDict();
41
42 /** Add the value SkPDFObject as a reference to the resource dictionary
43 * with the give type and key.
44 * The relevant sub-dicts will be automatically generated, and the
45 * resource will be named by concatenating a type-specific prefix and
46 * the input key.
47 * This object will be part of the resource list when requested later.
48 * @param type The type of resource being entered, like
49 * kPattern_ResourceType or kExtGState_ResourceType.
50 * @param key The resource key, should be unique within its type.
51 * @param value The resource itself.
52 * @return The value argument is returned.
53 */
54 SkPDFObject* insertResourceAsRef(SkPDFResourceType type, int key,
55 SkPDFObject* value);
56
57 /**
58 * Gets resources inserted into this dictionary.
59 *
60 * @param knownResourceObjects Set containing currently known resources.
61 * Resources in the dict and this set will not be added to the output.
62 * @param newResourceObjects Output set to which non-preexisting resources
63 * will be added.
64 * @param recursive Whether or not to add resources of resources.
65 */
66 void getResources(
67 const SkTSet<SkPDFObject*>& knownResourceObjects,
68 SkTSet<SkPDFObject*>* newResourceObjects,
69 bool recursive) const;
70
71 private:
72 /** Add the value to the dictionary with the given key. Refs value.
73 * The relevant sub-dicts will be automatically generated, and the
74 * resource will be named by concatenating a type-specific prefix and
75 * the input key.
76 * The object will NOT be part of the resource list when requested later.
77 * @param type The type of resource being entered.
78 * @param key The resource key, should be unique within its type.
79 * @param value The resource itself.
80 * @return The value argument is returned.
81 */
82 SkPDFObject* insertResource(SkPDFResourceType type, int key,
83 SkPDFObject* value);
84
85 SkTSet<SkPDFObject*> fResources;
86
87 SkTDArray<SkPDFDict*> fTypes;
88 };
89
90 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698