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

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: 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
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.
2 /*
3 * Copyright 2013 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
vandebo (ex-Chrome) 2013/07/10 18:24:31 nit: remove extra blank line.
ducky 2013/07/10 22:54:34 Done.
10 #ifndef SkPDFResourceDict_DEFINED
11 #define SkPDFResourceDict_DEFINED
12
13 #include "SkRefCnt.h"
vandebo (ex-Chrome) 2013/07/10 18:24:31 omit
ducky 2013/07/10 22:54:34 Done.
14 #include "SkPDFTypes.h"
15 #include "SkTDArray.h"
16 #include "SkTSet.h"
17 #include "SkTypes.h"
18
19 /** \class SkPDFResourceDict
20
21 A resource dictionary, which maintains the relevant sub-dicts and
22 allows generation of a list of referenced SkPDFObjects inserted with
23 insertResourceAsRef.
24 */
25 class SkPDFResourceDict : public SkPDFDict {
26 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...
27 SK_DECLARE_INST_COUNT(SkPDFResourceDict)
28
29 enum SkPDFResourceType{
30 kExtGState_ResourceType,
31 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.
32 kPattern_ResourceType,
33 kShading_ResourceType,
34 kXObject_ResourceType,
35 kFont_ResourceType,
36 kProperties_ResourceType
37 };
38
39 /** Create a PDF resource dictionary.
40 */
41 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
42
43 /** Create a PDF resource dictionary, optionally also creating the full
44 * set of ProcSet entries for backwards compatibility (as recommended
45 * by the PDF spec).
46 */
47 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
48
49 /** Add the value to the dictionary with the given key. Refs value.
50 * The relevant sub-dicts will be automatically generated, and the
51 * resource will be named by concatenating a type-specific prefix and
52 * the input key.
53 * The object will NOT be part of the resource list when requested later.
54 * @param type The type of resource being entered.
55 * @param key The resource key, should be unique within its type.
56 * @param value The resource itself.
57 * @return The value argument is returned.
58 */
59 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
60 SkPDFObject* value);
61
62 /** Add the value SkPDFObject as a reference to the resource dictionary
63 * with the give type and key.
64 * The relevant sub-dicts will be automatically generated, and the
65 * resource will be named by concatenating a type-specific prefix and
66 * the input key.
67 * This object will be part of the resource list when requested later.
68 * @param type The type of resource being entered, like Pattern or ExtGSta te.
69 * @param key The resource key, should be unique within its type.
70 * @param value The resource itself.
71 * @return The value argument is returned.
72 */
73 SkPDFObject* insertResourceAsRef(SkPDFResourceType type, int key,
74 SkPDFObject* value);
75
76 /**
77 * Gets resources inserted into this dictionary.
78 *
79 * @param knownResourceObjects Set containing currently known resources.
80 * Resources in the dict and in this set will not be added to the output .
81 * @param newResourceObjects Output set to which non-preexisting resources
82 * will be added.
83 * @param recursive Whether or not to add resources of resources.
84 */
85 void getResources(
86 const SkTSet<SkPDFObject*>& knownResourceObjects,
87 SkTSet<SkPDFObject*>* newResourceObjects,
88 bool recursive) const;
89
90 /**
91 * Gets the prefix associated with a resource type, like G for ExtGState
92 * or P for Pattern.
93 */
94 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
95 /**
96 * Gets the name of a resource type, like ExtGState or Pattern.
97 */
98 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.
99 private:
vandebo (ex-Chrome) 2013/07/10 18:24:31 nit: no indent.
ducky 2013/07/10 22:54:34 Done.
100 /**
101 * Returns the sub-dict associated with the resource type type.
102 * If none currently exists, this will create a sub-dict and index it for
103 * future use.
104 */
105 SkPDFDict* getResourceTypeDict(SkPDFName* type);
106
107 SkTSet<SkPDFObject*> fResources;
108
109 struct DictRec {
110 SkPDFName* key;
111 SkPDFDict* value;
112 };
113 SkTDArray<struct DictRec> fTypes;
114 };
115
116 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698