OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkPDFResourceDict.h" | 8 #include "SkPDFResourceDict.h" |
9 #include "SkPostConfig.h" | 9 #include "SkPostConfig.h" |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 return keyString; | 54 return keyString; |
55 } | 55 } |
56 | 56 |
57 static void add_subdict( | 57 static void add_subdict( |
58 const SkTDArray<SkPDFObject*>& resourceList, | 58 const SkTDArray<SkPDFObject*>& resourceList, |
59 SkPDFResourceDict::SkPDFResourceType type, | 59 SkPDFResourceDict::SkPDFResourceType type, |
60 SkPDFDict* dst) { | 60 SkPDFDict* dst) { |
61 if (0 == resourceList.count()) { | 61 if (0 == resourceList.count()) { |
62 return; | 62 return; |
63 } | 63 } |
64 sk_sp<SkPDFDict> resources(new SkPDFDict); | 64 auto resources = sk_make_sp<SkPDFDict>(); |
65 for (int i = 0; i < resourceList.count(); i++) { | 65 for (int i = 0; i < resourceList.count(); i++) { |
66 resources->insertObjRef(SkPDFResourceDict::getResourceName(type, i), | 66 resources->insertObjRef(SkPDFResourceDict::getResourceName(type, i), |
67 SkRef(resourceList[i])); | 67 SkRef(resourceList[i])); |
68 } | 68 } |
69 dst->insertObject(get_resource_type_name(type), resources.release()); | 69 dst->insertObject(get_resource_type_name(type), resources.release()); |
70 } | 70 } |
71 | 71 |
72 SkPDFDict* SkPDFResourceDict::Create( | 72 SkPDFDict* SkPDFResourceDict::Create( |
73 const SkTDArray<SkPDFObject*>* gStateResources, | 73 const SkTDArray<SkPDFObject*>* gStateResources, |
74 const SkTDArray<SkPDFObject*>* patternResources, | 74 const SkTDArray<SkPDFObject*>* patternResources, |
75 const SkTDArray<SkPDFObject*>* xObjectResources, | 75 const SkTDArray<SkPDFObject*>* xObjectResources, |
76 const SkTDArray<SkPDFObject*>* fontResources) { | 76 const SkTDArray<SkPDFObject*>* fontResources) { |
77 sk_sp<SkPDFDict> dict(new SkPDFDict); | 77 auto dict = sk_make_sp<SkPDFDict>(); |
78 static const char kProcs[][7] = { | 78 static const char kProcs[][7] = { |
79 "PDF", "Text", "ImageB", "ImageC", "ImageI"}; | 79 "PDF", "Text", "ImageB", "ImageC", "ImageI"}; |
80 sk_sp<SkPDFArray> procSets(new SkPDFArray); | 80 auto procSets = sk_make_sp<SkPDFArray>(); |
81 | 81 |
82 procSets->reserve(SK_ARRAY_COUNT(kProcs)); | 82 procSets->reserve(SK_ARRAY_COUNT(kProcs)); |
83 for (size_t i = 0; i < SK_ARRAY_COUNT(kProcs); i++) { | 83 for (size_t i = 0; i < SK_ARRAY_COUNT(kProcs); i++) { |
84 procSets->appendName(kProcs[i]); | 84 procSets->appendName(kProcs[i]); |
85 } | 85 } |
86 dict->insertObject("ProcSets", procSets.release()); | 86 dict->insertObject("ProcSets", procSets.release()); |
87 | 87 |
88 if (gStateResources) { | 88 if (gStateResources) { |
89 add_subdict(*gStateResources, kExtGState_ResourceType, dict.get()); | 89 add_subdict(*gStateResources, kExtGState_ResourceType, dict.get()); |
90 } | 90 } |
91 if (patternResources) { | 91 if (patternResources) { |
92 add_subdict(*patternResources, kPattern_ResourceType, dict.get()); | 92 add_subdict(*patternResources, kPattern_ResourceType, dict.get()); |
93 } | 93 } |
94 if (xObjectResources) { | 94 if (xObjectResources) { |
95 add_subdict(*xObjectResources, kXObject_ResourceType, dict.get()); | 95 add_subdict(*xObjectResources, kXObject_ResourceType, dict.get()); |
96 } | 96 } |
97 if (fontResources) { | 97 if (fontResources) { |
98 add_subdict(*fontResources, kFont_ResourceType, dict.get()); | 98 add_subdict(*fontResources, kFont_ResourceType, dict.get()); |
99 } | 99 } |
100 return dict.release(); | 100 return dict.release(); |
101 } | 101 } |
OLD | NEW |