Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: src/pdf/SkPDFPage.cpp

Issue 19790007: Revert "Adds SkPDFResourceDict class to manage resource dicts. Refactors existing code to use this … (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/pdf/SkPDFFormXObject.cpp ('k') | src/pdf/SkPDFResourceDict.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkPDFCatalog.h" 10 #include "SkPDFCatalog.h"
11 #include "SkPDFDevice.h" 11 #include "SkPDFDevice.h"
12 #include "SkPDFPage.h" 12 #include "SkPDFPage.h"
13 #include "SkPDFResourceDict.h"
14 #include "SkStream.h" 13 #include "SkStream.h"
15 14
16 SkPDFPage::SkPDFPage(SkPDFDevice* content) 15 SkPDFPage::SkPDFPage(SkPDFDevice* content)
17 : SkPDFDict("Page"), 16 : SkPDFDict("Page"),
18 fDevice(content) { 17 fDevice(content) {
19 SkSafeRef(content); 18 SkSafeRef(content);
20 } 19 }
21 20
22 SkPDFPage::~SkPDFPage() {} 21 SkPDFPage::~SkPDFPage() {}
23 22
24 void SkPDFPage::finalizePage(SkPDFCatalog* catalog, bool firstPage, 23 void SkPDFPage::finalizePage(SkPDFCatalog* catalog, bool firstPage,
25 const SkTSet<SkPDFObject*>& knownResourceObjects, 24 const SkTSet<SkPDFObject*>& knownResourceObjects,
26 SkTSet<SkPDFObject*>* newResourceObjects) { 25 SkTSet<SkPDFObject*>* newResourceObjects) {
27 SkPDFResourceDict* resourceDict = fDevice->getResourceDict();
28 if (fContentStream.get() == NULL) { 26 if (fContentStream.get() == NULL) {
29 insert("Resources", resourceDict); 27 insert("Resources", fDevice->getResourceDict());
30 SkSafeUnref(this->insert("MediaBox", fDevice->copyMediaBox())); 28 SkSafeUnref(this->insert("MediaBox", fDevice->copyMediaBox()));
31 if (!SkToBool(catalog->getDocumentFlags() & 29 if (!SkToBool(catalog->getDocumentFlags() &
32 SkPDFDocument::kNoLinks_Flags)) { 30 SkPDFDocument::kNoLinks_Flags)) {
33 SkPDFArray* annots = fDevice->getAnnotations(); 31 SkPDFArray* annots = fDevice->getAnnotations();
34 if (annots && annots->size() > 0) { 32 if (annots && annots->size() > 0) {
35 insert("Annots", annots); 33 insert("Annots", annots);
36 } 34 }
37 } 35 }
38 36
39 SkAutoTUnref<SkStream> content(fDevice->content()); 37 SkAutoTUnref<SkStream> content(fDevice->content());
40 fContentStream.reset(new SkPDFStream(content.get())); 38 fContentStream.reset(new SkPDFStream(content.get()));
41 insert("Contents", new SkPDFObjRef(fContentStream.get()))->unref(); 39 insert("Contents", new SkPDFObjRef(fContentStream.get()))->unref();
42 } 40 }
43 catalog->addObject(fContentStream.get(), firstPage); 41 catalog->addObject(fContentStream.get(), firstPage);
44 resourceDict->getResources(knownResourceObjects, newResourceObjects, true); 42 fDevice->getResources(knownResourceObjects, newResourceObjects, true);
45 } 43 }
46 44
47 off_t SkPDFPage::getPageSize(SkPDFCatalog* catalog, off_t fileOffset) { 45 off_t SkPDFPage::getPageSize(SkPDFCatalog* catalog, off_t fileOffset) {
48 SkASSERT(fContentStream.get() != NULL); 46 SkASSERT(fContentStream.get() != NULL);
49 catalog->setFileOffset(fContentStream.get(), fileOffset); 47 catalog->setFileOffset(fContentStream.get(), fileOffset);
50 return fContentStream->getOutputSize(catalog, true); 48 return fContentStream->getOutputSize(catalog, true);
51 } 49 }
52 50
53 void SkPDFPage::emitPage(SkWStream* stream, SkPDFCatalog* catalog) { 51 void SkPDFPage::emitPage(SkWStream* stream, SkPDFCatalog* catalog) {
54 SkASSERT(fContentStream.get() != NULL); 52 SkASSERT(fContentStream.get() != NULL);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return fDevice->getFontResources(); 145 return fDevice->getFontResources();
148 } 146 }
149 147
150 const SkPDFGlyphSetMap& SkPDFPage::getFontGlyphUsage() const { 148 const SkPDFGlyphSetMap& SkPDFPage::getFontGlyphUsage() const {
151 return fDevice->getFontGlyphUsage(); 149 return fDevice->getFontGlyphUsage();
152 } 150 }
153 151
154 void SkPDFPage::appendDestinations(SkPDFDict* dict) { 152 void SkPDFPage::appendDestinations(SkPDFDict* dict) {
155 fDevice->appendDestinations(dict, this); 153 fDevice->appendDestinations(dict, this);
156 } 154 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFFormXObject.cpp ('k') | src/pdf/SkPDFResourceDict.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698