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

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

Issue 1068343003: SkPDF: ResourceDict replaced by factory function (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-04-08 (Wednesday) 17:35:39 EDT 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 | src/pdf/SkPDFDevice.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 "SkPDFDevice.h" 10 #include "SkPDFDevice.h"
11 #include "SkPDFFont.h" 11 #include "SkPDFFont.h"
12 #include "SkPDFResourceDict.h"
13 #include "SkPDFStream.h" 12 #include "SkPDFStream.h"
14 #include "SkPDFTypes.h" 13 #include "SkPDFTypes.h"
15 #include "SkStream.h" 14 #include "SkStream.h"
16 15
17 static void emit_pdf_header(SkWStream* stream) { 16 static void emit_pdf_header(SkWStream* stream) {
18 stream->writeText("%PDF-1.4\n%"); 17 stream->writeText("%PDF-1.4\n%");
19 // The PDF spec recommends including a comment with four bytes, all 18 // The PDF spec recommends including a comment with four bytes, all
20 // with their high bits set. This is "Skia" with the high bits set. 19 // with their high bits set. This is "Skia" with the high bits set.
21 stream->write32(0xD3EBE9E1); 20 stream->write32(0xD3EBE9E1);
22 stream->writeText("\n"); 21 stream->writeText("\n");
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 entry->fFont->getFontSubset(entry->fGlyphSet)); 56 entry->fFont->getFontSubset(entry->fGlyphSet));
58 if (subsetFont) { 57 if (subsetFont) {
59 substituteMap->setSubstitute(entry->fFont, subsetFont.get()); 58 substituteMap->setSubstitute(entry->fFont, subsetFont.get());
60 } 59 }
61 entry = iterator.next(); 60 entry = iterator.next();
62 } 61 }
63 } 62 }
64 63
65 static SkPDFDict* create_pdf_page(const SkPDFDevice* pageDevice) { 64 static SkPDFDict* create_pdf_page(const SkPDFDevice* pageDevice) {
66 SkAutoTUnref<SkPDFDict> page(SkNEW_ARGS(SkPDFDict, ("Page"))); 65 SkAutoTUnref<SkPDFDict> page(SkNEW_ARGS(SkPDFDict, ("Page")));
67 SkAutoTUnref<SkPDFResourceDict> deviceResourceDict( 66 SkAutoTUnref<SkPDFDict> deviceResourceDict(
68 pageDevice->createResourceDict()); 67 pageDevice->createResourceDict());
69 page->insert("Resources", deviceResourceDict.get()); 68 page->insert("Resources", deviceResourceDict.get());
70 69
71 SkAutoTUnref<SkPDFArray> mediaBox(pageDevice->copyMediaBox()); 70 SkAutoTUnref<SkPDFArray> mediaBox(pageDevice->copyMediaBox());
72 page->insert("MediaBox", mediaBox.get()); 71 page->insert("MediaBox", mediaBox.get());
73 72
74 SkPDFArray* annots = pageDevice->getAnnotations(); 73 SkPDFArray* annots = pageDevice->getAnnotations();
75 if (annots && annots->size() > 0) { 74 if (annots && annots->size() > 0) {
76 page->insert("Annots", annots); 75 page->insert("Annots", annots);
77 } 76 }
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 359
361 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { 360 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
362 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); 361 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path));
363 if (!stream->isValid()) { 362 if (!stream->isValid()) {
364 SkDELETE(stream); 363 SkDELETE(stream);
365 return NULL; 364 return NULL;
366 } 365 }
367 auto delete_wstream = [](SkWStream* stream, bool) { SkDELETE(stream); }; 366 auto delete_wstream = [](SkWStream* stream, bool) { SkDELETE(stream); };
368 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi)); 367 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, dpi));
369 } 368 }
OLDNEW
« no previous file with comments | « no previous file | src/pdf/SkPDFDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698