OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 The Android Open Source Project | 3 * Copyright 2010 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkPDFFormXObject.h" | 10 #include "SkPDFFormXObject.h" |
11 | 11 |
12 #include "SkMatrix.h" | 12 #include "SkMatrix.h" |
13 #include "SkPDFCatalog.h" | 13 #include "SkPDFCatalog.h" |
14 #include "SkPDFDevice.h" | 14 #include "SkPDFDevice.h" |
15 #include "SkPDFResourceDict.h" | |
16 #include "SkPDFUtils.h" | 15 #include "SkPDFUtils.h" |
17 #include "SkStream.h" | 16 #include "SkStream.h" |
18 #include "SkTypes.h" | 17 #include "SkTypes.h" |
19 | 18 |
20 SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) { | 19 SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) { |
21 // We don't want to keep around device because we'd have two copies | 20 // We don't want to keep around device because we'd have two copies |
22 // of content, so reference or copy everything we need (content and | 21 // of content, so reference or copy everything we need (content and |
23 // resources). | 22 // resources). |
24 SkTSet<SkPDFObject*> emptySet; | 23 SkTSet<SkPDFObject*> emptySet; |
25 SkPDFResourceDict* resourceDict = device->getResourceDict(); | 24 device->getResources(emptySet, &fResources, false); |
26 resourceDict->getResources(emptySet, &fResources, false); | |
27 | 25 |
28 SkAutoTUnref<SkStream> content(device->content()); | 26 SkAutoTUnref<SkStream> content(device->content()); |
29 setData(content.get()); | 27 setData(content.get()); |
30 | 28 |
31 insertName("Type", "XObject"); | 29 insertName("Type", "XObject"); |
32 insertName("Subtype", "Form"); | 30 insertName("Subtype", "Form"); |
33 SkSafeUnref(this->insert("BBox", device->copyMediaBox())); | 31 SkSafeUnref(this->insert("BBox", device->copyMediaBox())); |
34 insert("Resources", resourceDict); | 32 insert("Resources", device->getResourceDict()); |
35 | 33 |
36 // We invert the initial transform and apply that to the xobject so that | 34 // We invert the initial transform and apply that to the xobject so that |
37 // it doesn't get applied twice. We can't just undo it because it's | 35 // it doesn't get applied twice. We can't just undo it because it's |
38 // embedded in things like shaders and images. | 36 // embedded in things like shaders and images. |
39 if (!device->initialTransform().isIdentity()) { | 37 if (!device->initialTransform().isIdentity()) { |
40 SkMatrix inverse; | 38 SkMatrix inverse; |
41 if (!device->initialTransform().invert(&inverse)) { | 39 if (!device->initialTransform().invert(&inverse)) { |
42 // The initial transform should be invertible. | 40 // The initial transform should be invertible. |
43 SkASSERT(false); | 41 SkASSERT(false); |
44 inverse.reset(); | 42 inverse.reset(); |
(...skipping 13 matching lines...) Expand all Loading... |
58 fResources.unrefAll(); | 56 fResources.unrefAll(); |
59 } | 57 } |
60 | 58 |
61 void SkPDFFormXObject::getResources( | 59 void SkPDFFormXObject::getResources( |
62 const SkTSet<SkPDFObject*>& knownResourceObjects, | 60 const SkTSet<SkPDFObject*>& knownResourceObjects, |
63 SkTSet<SkPDFObject*>* newResourceObjects) { | 61 SkTSet<SkPDFObject*>* newResourceObjects) { |
64 GetResourcesHelper(&fResources.toArray(), | 62 GetResourcesHelper(&fResources.toArray(), |
65 knownResourceObjects, | 63 knownResourceObjects, |
66 newResourceObjects); | 64 newResourceObjects); |
67 } | 65 } |
OLD | NEW |