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