aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFResourceDict.h
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-23 21:49:29 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-23 21:49:29 +0000
commit47401354074549d8591da7fa115241766d3ee3d2 (patch)
treeff20e362854570da72e06bc274ffe9a840534b41 /src/pdf/SkPDFResourceDict.h
parent1f080163ac58e0a5a621a720de5fc63e7b736765 (diff)
Fix Clang build on SkPDFResourceDict (CL 18977002)
R=edisonn@google.com, vandebo@chromium.org Author: richardlin@chromium.org Review URL: https://chromiumcodereview.appspot.com/19954011 git-svn-id: http://skia.googlecode.com/svn/trunk@10295 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pdf/SkPDFResourceDict.h')
-rw-r--r--src/pdf/SkPDFResourceDict.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/pdf/SkPDFResourceDict.h b/src/pdf/SkPDFResourceDict.h
new file mode 100644
index 0000000000..ab25b4a4dc
--- /dev/null
+++ b/src/pdf/SkPDFResourceDict.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkPDFResourceDict_DEFINED
+#define SkPDFResourceDict_DEFINED
+
+#include "SkPDFTypes.h"
+#include "SkTDArray.h"
+#include "SkTSet.h"
+#include "SkTypes.h"
+
+/** \class SkPDFResourceDict
+
+ A resource dictionary, which maintains the relevant sub-dicts and
+ allows generation of a list of referenced SkPDFObjects inserted with
+ insertResourceAsRef.
+*/
+class SkPDFResourceDict : public SkPDFDict {
+public:
+ SK_DECLARE_INST_COUNT(SkPDFResourceDict)
+
+ enum SkPDFResourceType{
+ kExtGState_ResourceType,
+ kPattern_ResourceType,
+ kXObject_ResourceType,
+ kFont_ResourceType,
+ // These additional types are defined by the spec, but not
+ // currently used by Skia: ColorSpace, Shading, Properties
+ kResourceTypeCount
+ };
+
+ /** Create a PDF resource dictionary.
+ * The full set of ProcSet entries is automatically created for backwards
+ * compatibility, as recommended by the PDF spec.
+ */
+ SkPDFResourceDict();
+
+ /** Add the value SkPDFObject as a reference to the resource dictionary
+ * with the give type and key.
+ * The relevant sub-dicts will be automatically generated, and the
+ * resource will be named by concatenating a type-specific prefix and
+ * the input key.
+ * This object will be part of the resource list when requested later.
+ * @param type The type of resource being entered, like
+ * kPattern_ResourceType or kExtGState_ResourceType.
+ * @param key The resource key, should be unique within its type.
+ * @param value The resource itself.
+ * @return The value argument is returned.
+ */
+ SkPDFObject* insertResourceAsReference(SkPDFResourceType type, int key,
+ SkPDFObject* value);
+
+ /**
+ * Gets resources inserted into this dictionary as a reference.
+ *
+ * @param knownResourceObjects Set containing currently known resources.
+ * Resources in the dict and this set will not be added to the output.
+ * @param newResourceObjects Output set to which non-preexisting resources
+ * will be added.
+ * @param recursive Whether or not to add resources of resources.
+ */
+ void getReferencedResources(
+ const SkTSet<SkPDFObject*>& knownResourceObjects,
+ SkTSet<SkPDFObject*>* newResourceObjects,
+ bool recursive) const;
+
+ /**
+ * Returns the name for the resource that will be generated by the resource
+ * dict.
+ *
+ * @param type The type of resource being entered, like
+ * kPattern_ResourceType or kExtGState_ResourceType.
+ * @param key The resource key, should be unique within its type.
+ */
+ static SkString getResourceName(SkPDFResourceType type, int key);
+
+private:
+ /** Add the value to the dictionary with the given key. Refs value.
+ * The relevant sub-dicts will be automatically generated, and the
+ * resource will be named by concatenating a type-specific prefix and
+ * the input key.
+ * The object will NOT be part of the resource list when requested later.
+ * @param type The type of resource being entered.
+ * @param key The resource key, should be unique within its type.
+ * @param value The resource itself.
+ * @return The value argument is returned.
+ */
+ SkPDFObject* insertResource(SkPDFResourceType type, int key,
+ SkPDFObject* value);
+
+ SkTSet<SkPDFObject*> fResources;
+
+ SkTDArray<SkPDFDict*> fTypes;
+};
+
+#endif