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 "SkData.h" |
10 #include "SkPDFCatalog.h" | 11 #include "SkPDFCatalog.h" |
11 #include "SkPDFDevice.h" | 12 #include "SkPDFDevice.h" |
12 #include "SkPDFPage.h" | 13 #include "SkPDFPage.h" |
13 #include "SkPDFResourceDict.h" | 14 #include "SkPDFResourceDict.h" |
14 #include "SkStream.h" | |
15 | 15 |
16 SkPDFPage::SkPDFPage(SkPDFDevice* content) | 16 SkPDFPage::SkPDFPage(SkPDFDevice* content) |
17 : SkPDFDict("Page"), | 17 : SkPDFDict("Page"), |
18 fDevice(content) { | 18 fDevice(content) { |
19 SkSafeRef(content); | 19 SkSafeRef(content); |
20 } | 20 } |
21 | 21 |
22 SkPDFPage::~SkPDFPage() {} | 22 SkPDFPage::~SkPDFPage() {} |
23 | 23 |
24 void SkPDFPage::finalizePage(SkPDFCatalog* catalog, bool firstPage, | 24 void SkPDFPage::finalizePage(SkPDFCatalog* catalog, bool firstPage, |
25 const SkTSet<SkPDFObject*>& knownResourceObjects, | 25 const SkTSet<SkPDFObject*>& knownResourceObjects, |
26 SkTSet<SkPDFObject*>* newResourceObjects) { | 26 SkTSet<SkPDFObject*>* newResourceObjects) { |
27 SkPDFResourceDict* resourceDict = fDevice->getResourceDict(); | 27 SkPDFResourceDict* resourceDict = fDevice->getResourceDict(); |
28 if (fContentStream.get() == NULL) { | 28 if (fContentStream.get() == NULL) { |
29 insert("Resources", resourceDict); | 29 insert("Resources", resourceDict); |
30 SkSafeUnref(this->insert("MediaBox", fDevice->copyMediaBox())); | 30 SkSafeUnref(this->insert("MediaBox", fDevice->copyMediaBox())); |
31 if (!SkToBool(catalog->getDocumentFlags() & | 31 if (!SkToBool(catalog->getDocumentFlags() & |
32 SkPDFDocument::kNoLinks_Flags)) { | 32 SkPDFDocument::kNoLinks_Flags)) { |
33 SkPDFArray* annots = fDevice->getAnnotations(); | 33 SkPDFArray* annots = fDevice->getAnnotations(); |
34 if (annots && annots->size() > 0) { | 34 if (annots && annots->size() > 0) { |
35 insert("Annots", annots); | 35 insert("Annots", annots); |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 SkAutoTUnref<SkStream> content(fDevice->content()); | 39 SkAutoTUnref<SkData> content(fDevice->copyContentToData()); |
40 fContentStream.reset(new SkPDFStream(content.get())); | 40 fContentStream.reset(new SkPDFStream(content.get())); |
41 insert("Contents", new SkPDFObjRef(fContentStream.get()))->unref(); | 41 insert("Contents", new SkPDFObjRef(fContentStream.get()))->unref(); |
42 } | 42 } |
43 catalog->addObject(fContentStream.get(), firstPage); | 43 catalog->addObject(fContentStream.get(), firstPage); |
44 resourceDict->getReferencedResources(knownResourceObjects, | 44 resourceDict->getReferencedResources(knownResourceObjects, |
45 newResourceObjects, | 45 newResourceObjects, |
46 true); | 46 true); |
47 } | 47 } |
48 | 48 |
49 off_t SkPDFPage::getPageSize(SkPDFCatalog* catalog, off_t fileOffset) { | 49 off_t SkPDFPage::getPageSize(SkPDFCatalog* catalog, off_t fileOffset) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 return fDevice->getFontResources(); | 149 return fDevice->getFontResources(); |
150 } | 150 } |
151 | 151 |
152 const SkPDFGlyphSetMap& SkPDFPage::getFontGlyphUsage() const { | 152 const SkPDFGlyphSetMap& SkPDFPage::getFontGlyphUsage() const { |
153 return fDevice->getFontGlyphUsage(); | 153 return fDevice->getFontGlyphUsage(); |
154 } | 154 } |
155 | 155 |
156 void SkPDFPage::appendDestinations(SkPDFDict* dict) { | 156 void SkPDFPage::appendDestinations(SkPDFDict* dict) { |
157 fDevice->appendDestinations(dict, this); | 157 fDevice->appendDestinations(dict, this); |
158 } | 158 } |
OLD | NEW |