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

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

Issue 15028012: [PDF] Only output the Dests dictionary if it isn't epmpty (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 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 | « no previous file | no next file » | 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 2011 Google Inc. 3 * Copyright 2011 Google Inc.
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"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 /* TODO(vandebo): output intent 105 /* TODO(vandebo): output intent
106 SkAutoTUnref<SkPDFDict> outputIntent = new SkPDFDict("OutputIntent"); 106 SkAutoTUnref<SkPDFDict> outputIntent = new SkPDFDict("OutputIntent");
107 outputIntent->insert("S", new SkPDFName("GTS_PDFA1"))->unref(); 107 outputIntent->insert("S", new SkPDFName("GTS_PDFA1"))->unref();
108 outputIntent->insert("OutputConditionIdentifier", 108 outputIntent->insert("OutputConditionIdentifier",
109 new SkPDFString("sRGB"))->unref(); 109 new SkPDFString("sRGB"))->unref();
110 SkAutoTUnref<SkPDFArray> intentArray = new SkPDFArray; 110 SkAutoTUnref<SkPDFArray> intentArray = new SkPDFArray;
111 intentArray->append(outputIntent.get()); 111 intentArray->append(outputIntent.get());
112 fDocCatalog->insert("OutputIntent", intentArray.get()); 112 fDocCatalog->insert("OutputIntent", intentArray.get());
113 */ 113 */
114 114
115 SkPDFDict* dests = SkNEW(SkPDFDict); // fPageResources owns reference 115 SkAutoTUnref<SkPDFDict> dests(SkNEW(SkPDFDict));
116 fCatalog->addObject(dests, true /* onFirstPage */);
117 fFirstPageResources->add(dests);
118 116
119 bool firstPage = true; 117 bool firstPage = true;
120 /* The references returned in newResources are transfered to 118 /* The references returned in newResources are transfered to
121 * fFirstPageResources or fOtherPageResources depending on firstPage and 119 * fFirstPageResources or fOtherPageResources depending on firstPage and
122 * knownResources doesn't have a reference but just relies on the other 120 * knownResources doesn't have a reference but just relies on the other
123 * two sets to maintain a reference. 121 * two sets to maintain a reference.
124 */ 122 */
125 SkTSet<SkPDFObject*> knownResources; 123 SkTSet<SkPDFObject*> knownResources;
126 124
127 // mergeInto returns the number of duplicates. 125 // mergeInto returns the number of duplicates.
(...skipping 16 matching lines...) Expand all
144 SkDEBUGCODE(duplicates =) fOtherPageResources->mergeInto(newReso urces); 142 SkDEBUGCODE(duplicates =) fOtherPageResources->mergeInto(newReso urces);
145 } 143 }
146 SkASSERT(duplicates == 0); 144 SkASSERT(duplicates == 0);
147 145
148 SkDEBUGCODE(duplicates =) knownResources.mergeInto(newResources); 146 SkDEBUGCODE(duplicates =) knownResources.mergeInto(newResources);
149 SkASSERT(duplicates == 0); 147 SkASSERT(duplicates == 0);
150 148
151 fPages[i]->appendDestinations(dests); 149 fPages[i]->appendDestinations(dests);
152 } 150 }
153 151
154 fDocCatalog->insert("Dests", SkNEW_ARGS(SkPDFObjRef, (dests)))->unref(); 152 if (dests->size() > 0) {
153 SkPDFDict* raw_dests = dests.get();
154 fFirstPageResources->add(dests.detach()); // Transfer ownership.
155 fCatalog->addObject(raw_dests, true /* onFirstPage */);
156 fDocCatalog->insert("Dests", SkNEW_ARGS(SkPDFObjRef, (raw_dests)))-> unref();
157 }
155 158
156 // Build font subsetting info before proceeding. 159 // Build font subsetting info before proceeding.
157 perform_font_subsetting(fCatalog.get(), fPages, &fSubstitutes); 160 perform_font_subsetting(fCatalog.get(), fPages, &fSubstitutes);
158 161
159 // Figure out the size of things and inform the catalog of file offsets. 162 // Figure out the size of things and inform the catalog of file offsets.
160 off_t fileOffset = headerSize(); 163 off_t fileOffset = headerSize();
161 fileOffset += fCatalog->setFileOffset(fDocCatalog, fileOffset); 164 fileOffset += fCatalog->setFileOffset(fDocCatalog, fileOffset);
162 fileOffset += fCatalog->setFileOffset(fPages[0], fileOffset); 165 fileOffset += fCatalog->setFileOffset(fPages[0], fileOffset);
163 fileOffset += fPages[0]->getPageSize(fCatalog.get(), 166 fileOffset += fPages[0]->getPageSize(fCatalog.get(),
164 (size_t) fileOffset); 167 (size_t) fileOffset);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 fTrailerDict->insertInt("Size", int(objCount)); 300 fTrailerDict->insertInt("Size", int(objCount));
298 fTrailerDict->insert("Root", new SkPDFObjRef(fDocCatalog))->unref(); 301 fTrailerDict->insert("Root", new SkPDFObjRef(fDocCatalog))->unref();
299 } 302 }
300 303
301 stream->writeText("trailer\n"); 304 stream->writeText("trailer\n");
302 fTrailerDict->emitObject(stream, fCatalog.get(), false); 305 fTrailerDict->emitObject(stream, fCatalog.get(), false);
303 stream->writeText("\nstartxref\n"); 306 stream->writeText("\nstartxref\n");
304 stream->writeBigDecAsText(fXRefFileOffset); 307 stream->writeBigDecAsText(fXRefFileOffset);
305 stream->writeText("\n%%EOF"); 308 stream->writeText("\n%%EOF");
306 } 309 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698