| 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 "SkPDFResourceDict.h" |
| 16 #include "SkPDFUtils.h" | 16 #include "SkPDFUtils.h" |
| 17 #include "SkStream.h" | 17 #include "SkStream.h" |
| 18 #include "SkTypes.h" | 18 #include "SkTypes.h" |
| 19 | 19 |
| 20 SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) { | 20 SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) { |
| 21 // 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 |
| 22 // of content, so reference or copy everything we need (content and | 22 // of content, so reference or copy everything we need (content and |
| 23 // resources). | 23 // resources). |
| 24 SkPDFResourceDict* resourceDict = device->getResourceDict(); | 24 SkAutoTUnref<SkPDFResourceDict> resourceDict(device->createResourceDict()); |
| 25 | 25 |
| 26 SkAutoTDelete<SkStreamAsset> content(device->content()); | 26 SkAutoTDelete<SkStreamAsset> content(device->content()); |
| 27 this->setData(content.get()); | 27 this->setData(content.get()); |
| 28 | 28 |
| 29 SkAutoTUnref<SkPDFArray> bboxArray(device->copyMediaBox()); | 29 SkAutoTUnref<SkPDFArray> bboxArray(device->copyMediaBox()); |
| 30 init(NULL, resourceDict, bboxArray); | 30 this->init(NULL, resourceDict.get(), bboxArray); |
| 31 | 31 |
| 32 // We invert the initial transform and apply that to the xobject so that | 32 // We invert the initial transform and apply that to the xobject so that |
| 33 // it doesn't get applied twice. We can't just undo it because it's | 33 // it doesn't get applied twice. We can't just undo it because it's |
| 34 // embedded in things like shaders and images. | 34 // embedded in things like shaders and images. |
| 35 if (!device->initialTransform().isIdentity()) { | 35 if (!device->initialTransform().isIdentity()) { |
| 36 SkMatrix inverse; | 36 SkMatrix inverse; |
| 37 if (!device->initialTransform().invert(&inverse)) { | 37 if (!device->initialTransform().invert(&inverse)) { |
| 38 // The initial transform should be invertible. | 38 // The initial transform should be invertible. |
| 39 SkASSERT(false); | 39 SkASSERT(false); |
| 40 inverse.reset(); | 40 inverse.reset(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 71 group->insertName("S", "Transparency"); | 71 group->insertName("S", "Transparency"); |
| 72 | 72 |
| 73 if (colorSpace != NULL) { | 73 if (colorSpace != NULL) { |
| 74 group->insertName("CS", colorSpace); | 74 group->insertName("CS", colorSpace); |
| 75 } | 75 } |
| 76 group->insert("I", new SkPDFBool(true))->unref(); // Isolated. | 76 group->insert("I", new SkPDFBool(true))->unref(); // Isolated. |
| 77 insert("Group", group.get()); | 77 insert("Group", group.get()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 SkPDFFormXObject::~SkPDFFormXObject() {} | 80 SkPDFFormXObject::~SkPDFFormXObject() {} |
| OLD | NEW |