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