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