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

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

Issue 869783003: Cleanup SkPDFObject::emit* (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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 | src/pdf/SkPDFTypes.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 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 SkDELETE(fOtherPageResources); 82 SkDELETE(fOtherPageResources);
83 } 83 }
84 84
85 namespace { 85 namespace {
86 class Streamer { 86 class Streamer {
87 public: 87 public:
88 Streamer(SkPDFCatalog* cat, SkWStream* out) 88 Streamer(SkPDFCatalog* cat, SkWStream* out)
89 : fCat(cat), fOut(out), fBaseOffset(SkToOffT(out->bytesWritten())) { 89 : fCat(cat), fOut(out), fBaseOffset(SkToOffT(out->bytesWritten())) {
90 } 90 }
91 91
92 void stream(SkPDFObject* obj) { 92 void stream(SkPDFObject* object) {
93 fCat->setFileOffset(obj, this->offset()); 93 fCat->setFileOffset(object, this->offset());
94 obj->emit(fOut, fCat, true); 94 SkPDFObject* realObject = fCat->getSubstituteObject(object);
95 fCat->emitObjectNumber(fOut, realObject);
96 fOut->writeText(" obj\n");
97 realObject->emitObject(fOut, fCat);
98 fOut->writeText("\nendobj\n");
95 } 99 }
96 100
97 off_t offset() { 101 off_t offset() {
98 return SkToOffT(fOut->bytesWritten()) - fBaseOffset; 102 return SkToOffT(fOut->bytesWritten()) - fBaseOffset;
99 } 103 }
100 104
101 private: 105 private:
102 SkPDFCatalog* const fCat; 106 SkPDFCatalog* const fCat;
103 SkWStream* const fOut; 107 SkWStream* const fOut;
104 const off_t fBaseOffset; 108 const off_t fBaseOffset;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 fTrailerDict->insertInt("Size", int(objCount)); 349 fTrailerDict->insertInt("Size", int(objCount));
346 fTrailerDict->insert("Root", new SkPDFObjRef(fDocCatalog))->unref(); 350 fTrailerDict->insert("Root", new SkPDFObjRef(fDocCatalog))->unref();
347 } 351 }
348 352
349 stream->writeText("trailer\n"); 353 stream->writeText("trailer\n");
350 fTrailerDict->emitObject(stream, fCatalog.get()); 354 fTrailerDict->emitObject(stream, fCatalog.get());
351 stream->writeText("\nstartxref\n"); 355 stream->writeText("\nstartxref\n");
352 stream->writeBigDecAsText(fXRefFileOffset); 356 stream->writeBigDecAsText(fXRefFileOffset);
353 stream->writeText("\n%%EOF"); 357 stream->writeText("\n%%EOF");
354 } 358 }
OLDNEW
« no previous file with comments | « no previous file | src/pdf/SkPDFTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698