OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 The Android Open Source Project | 2 * Copyright 2010 The Android Open Source Project |
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 | 8 |
9 #include "SkPDFFormXObject.h" | 9 #include "SkPDFFormXObject.h" |
10 | 10 |
11 sk_sp<SkPDFObject> SkPDFMakeFormXObject(std::unique_ptr<SkStreamAsset> content, | 11 sk_sp<SkPDFObject> SkPDFMakeFormXObject(std::unique_ptr<SkStreamAsset> content, |
12 sk_sp<SkPDFArray> mediaBox, | 12 sk_sp<SkPDFArray> mediaBox, |
13 sk_sp<SkPDFDict> resourceDict, | 13 sk_sp<SkPDFDict> resourceDict, |
14 const char* colorSpace) { | 14 const char* colorSpace) { |
15 auto form = sk_make_sp<SkPDFStream>(std::move(content)); | 15 auto form = sk_make_sp<SkPDFStream>(std::move(content)); |
16 form->insertName("Type", "XObject"); | 16 form->dict()->insertName("Type", "XObject"); |
17 form->insertName("Subtype", "Form"); | 17 form->dict()->insertName("Subtype", "Form"); |
18 form->insertObject("Resources", std::move(resourceDict)); | 18 form->dict()->insertObject("Resources", std::move(resourceDict)); |
19 form->insertObject("BBox", std::move(mediaBox)); | 19 form->dict()->insertObject("BBox", std::move(mediaBox)); |
20 | 20 |
21 // Right now FormXObject is only used for saveLayer, which implies | 21 // Right now FormXObject is only used for saveLayer, which implies |
22 // isolated blending. Do this conditionally if that changes. | 22 // isolated blending. Do this conditionally if that changes. |
23 // TODO(halcanary): Is this comment obsolete, since we use it for | 23 // TODO(halcanary): Is this comment obsolete, since we use it for |
24 // alpha masks? | 24 // alpha masks? |
25 auto group = sk_make_sp<SkPDFDict>("Group"); | 25 auto group = sk_make_sp<SkPDFDict>("Group"); |
26 group->insertName("S", "Transparency"); | 26 group->insertName("S", "Transparency"); |
27 if (colorSpace != nullptr) { | 27 if (colorSpace != nullptr) { |
28 group->insertName("CS", colorSpace); | 28 group->insertName("CS", colorSpace); |
29 } | 29 } |
30 group->insertBool("I", true); // Isolated. | 30 group->insertBool("I", true); // Isolated. |
31 form->insertObject("Group", std::move(group)); | 31 form->dict()->insertObject("Group", std::move(group)); |
32 return form; | 32 return form; |
33 } | 33 } |
OLD | NEW |