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

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

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