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

Side by Side Diff: src/doc/SkDocument_PDF.cpp

Issue 1038523004: SkPDF SkPDFObject::addResources signature simplified (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-03-25 (Wednesday) 15:53:41 EDT Created 5 years, 9 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
« no previous file with comments | « gyp/tests.gypi ('k') | src/pdf/SkPDFBitmap.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDocument.h" 8 #include "SkDocument.h"
9 #include "SkPDFCanon.h" 9 #include "SkPDFCanon.h"
10 #include "SkPDFCatalog.h" 10 #include "SkPDFCatalog.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 */ 204 */
205 205
206 if (dests->size() > 0) { 206 if (dests->size() > 0) {
207 docCatalog->insert("Dests", SkNEW_ARGS(SkPDFObjRef, (dests.get()))) 207 docCatalog->insert("Dests", SkNEW_ARGS(SkPDFObjRef, (dests.get())))
208 ->unref(); 208 ->unref();
209 } 209 }
210 210
211 // Build font subsetting info before proceeding. 211 // Build font subsetting info before proceeding.
212 perform_font_subsetting(pageDevices, &catalog); 212 perform_font_subsetting(pageDevices, &catalog);
213 213
214 SkTSet<SkPDFObject*> resourceSet; 214 if (catalog.addObject(docCatalog.get())) {
215 if (resourceSet.add(docCatalog.get())) { 215 docCatalog->addResources(&catalog);
216 docCatalog->addResources(&resourceSet, &catalog);
217 } 216 }
218 for (int i = 0; i < resourceSet.count(); ++i) {
219 SkAssertResult(catalog.addObject(resourceSet[i]));
220 }
221
222 size_t baseOffset = SkToOffT(stream->bytesWritten()); 217 size_t baseOffset = SkToOffT(stream->bytesWritten());
223 emit_pdf_header(stream); 218 emit_pdf_header(stream);
224 SkTDArray<int32_t> offsets; 219 SkTDArray<int32_t> offsets;
225 for (int i = 0; i < resourceSet.count(); ++i) { 220 for (int i = 0; i < catalog.objects().count(); ++i) {
226 SkPDFObject* object = resourceSet[i]; 221 SkPDFObject* object = catalog.objects()[i];
227 offsets.push(SkToS32(stream->bytesWritten() - baseOffset)); 222 offsets.push(SkToS32(stream->bytesWritten() - baseOffset));
228 SkASSERT(object == catalog.getSubstituteObject(object)); 223 SkASSERT(object == catalog.getSubstituteObject(object));
229 SkASSERT(catalog.getObjectNumber(object) == i + 1); 224 SkASSERT(catalog.getObjectNumber(object) == i + 1);
230 stream->writeDecAsText(i + 1); 225 stream->writeDecAsText(i + 1);
231 stream->writeText(" 0 obj\n"); // Generation number is always 0. 226 stream->writeText(" 0 obj\n"); // Generation number is always 0.
232 object->emitObject(stream, &catalog); 227 object->emitObject(stream, &catalog);
233 stream->writeText("\nendobj\n"); 228 stream->writeText("\nendobj\n");
234 } 229 }
235 int32_t xRefFileOffset = SkToS32(stream->bytesWritten() - baseOffset); 230 int32_t xRefFileOffset = SkToS32(stream->bytesWritten() - baseOffset);
236 231
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 358
364 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { 359 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
365 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); 360 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path));
366 if (!stream->isValid()) { 361 if (!stream->isValid()) {
367 SkDELETE(stream); 362 SkDELETE(stream);
368 return NULL; 363 return NULL;
369 } 364 }
370 auto delete_wstream = [](SkWStream* stream, bool) { SkDELETE(stream); }; 365 auto delete_wstream = [](SkWStream* stream, bool) { SkDELETE(stream); };
371 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi)); 366 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi));
372 } 367 }
OLDNEW
« no previous file with comments | « gyp/tests.gypi ('k') | src/pdf/SkPDFBitmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698