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

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

Issue 1012483003: SkPDF fix object counting error (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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 | « 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 * 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 offsets.push(SkToS32(stream->bytesWritten() - baseOffset)); 222 offsets.push(SkToS32(stream->bytesWritten() - baseOffset));
223 SkASSERT(object == catalog.getSubstituteObject(object)); 223 SkASSERT(object == catalog.getSubstituteObject(object));
224 SkASSERT(catalog.getObjectNumber(object) == i + 1); 224 SkASSERT(catalog.getObjectNumber(object) == i + 1);
225 stream->writeDecAsText(i + 1); 225 stream->writeDecAsText(i + 1);
226 stream->writeText(" 0 obj\n"); // Generation number is always 0. 226 stream->writeText(" 0 obj\n"); // Generation number is always 0.
227 object->emitObject(stream, &catalog); 227 object->emitObject(stream, &catalog);
228 stream->writeText("\nendobj\n"); 228 stream->writeText("\nendobj\n");
229 } 229 }
230 int32_t xRefFileOffset = SkToS32(stream->bytesWritten() - baseOffset); 230 int32_t xRefFileOffset = SkToS32(stream->bytesWritten() - baseOffset);
231 231
232 // Include the zeroth object in the count.
232 int32_t objCount = SkToS32(offsets.count() + 1); 233 int32_t objCount = SkToS32(offsets.count() + 1);
233 234
234 stream->writeText("xref\n0 "); 235 stream->writeText("xref\n0 ");
235 stream->writeDecAsText(objCount + 1); 236 stream->writeDecAsText(objCount);
236 stream->writeText("\n0000000000 65535 f \n"); 237 stream->writeText("\n0000000000 65535 f \n");
237 for (int i = 0; i < offsets.count(); i++) { 238 for (int i = 0; i < offsets.count(); i++) {
238 SkASSERT(offsets[i] > 0); 239 SkASSERT(offsets[i] > 0);
239 stream->writeBigDecAsText(offsets[i], 10); 240 stream->writeBigDecAsText(offsets[i], 10);
240 stream->writeText(" 00000 n \n"); 241 stream->writeText(" 00000 n \n");
241 } 242 }
242 emit_pdf_footer(stream, &catalog, docCatalog.get(), objCount, 243 emit_pdf_footer(stream, &catalog, docCatalog.get(), objCount,
243 xRefFileOffset); 244 xRefFileOffset);
244 245
245 // The page tree has both child and parent pointers, so it creates a 246 // The page tree has both child and parent pointers, so it creates a
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 359
359 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { 360 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
360 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); 361 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path));
361 if (!stream->isValid()) { 362 if (!stream->isValid()) {
362 SkDELETE(stream); 363 SkDELETE(stream);
363 return NULL; 364 return NULL;
364 } 365 }
365 auto delete_wstream = [](SkWStream* stream, bool) { SkDELETE(stream); }; 366 auto delete_wstream = [](SkWStream* stream, bool) { SkDELETE(stream); };
366 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi)); 367 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi));
367 } 368 }
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