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