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

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

Issue 1257533004: Merge sub-device annotations in SkPDFDevice::drawDevice() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase and address comment Created 5 years, 3 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 | « gm/annotated_text.cpp ('k') | 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"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 static SkPDFObject* create_pdf_page_content(const SkPDFDevice* pageDevice) { 64 static SkPDFObject* create_pdf_page_content(const SkPDFDevice* pageDevice) {
65 SkAutoTDelete<SkStreamAsset> content(pageDevice->content()); 65 SkAutoTDelete<SkStreamAsset> content(pageDevice->content());
66 return new SkPDFStream(content.get()); 66 return new SkPDFStream(content.get());
67 } 67 }
68 68
69 static SkPDFDict* create_pdf_page(const SkPDFDevice* pageDevice) { 69 static SkPDFDict* create_pdf_page(const SkPDFDevice* pageDevice) {
70 SkAutoTUnref<SkPDFDict> page(new SkPDFDict("Page")); 70 SkAutoTUnref<SkPDFDict> page(new SkPDFDict("Page"));
71 page->insertObject("Resources", pageDevice->createResourceDict()); 71 page->insertObject("Resources", pageDevice->createResourceDict());
72 page->insertObject("MediaBox", pageDevice->copyMediaBox()); 72 page->insertObject("MediaBox", pageDevice->copyMediaBox());
73 if (SkPDFArray* annots = pageDevice->getAnnotations()) { 73 SkAutoTUnref<SkPDFArray> annotations(new SkPDFArray);
74 SkASSERT(annots->size() > 0); 74 pageDevice->appendAnnotations(annotations);
75 page->insertObject("Annots", SkRef(annots)); 75 if (annotations->size() > 0) {
76 page->insertObject("Annots", annotations.detach());
76 } 77 }
77 page->insertObjRef("Contents", create_pdf_page_content(pageDevice)); 78 page->insertObjRef("Contents", create_pdf_page_content(pageDevice));
78 return page.detach(); 79 return page.detach();
79 } 80 }
80 81
81 static void generate_page_tree(const SkTDArray<SkPDFDict*>& pages, 82 static void generate_page_tree(const SkTDArray<SkPDFDict*>& pages,
82 SkTDArray<SkPDFDict*>* pageTree, 83 SkTDArray<SkPDFDict*>* pageTree,
83 SkPDFDict** rootNode) { 84 SkPDFDict** rootNode) {
84 // PDF wants a tree describing all the pages in the document. We arbitrary 85 // PDF wants a tree describing all the pages in the document. We arbitrary
85 // choose 8 (kNodeSize) as the number of allowed children. The internal 86 // choose 8 (kNodeSize) as the number of allowed children. The internal
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 351
351 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { 352 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
352 SkFILEWStream* stream = new SkFILEWStream(path); 353 SkFILEWStream* stream = new SkFILEWStream(path);
353 if (!stream->isValid()) { 354 if (!stream->isValid()) {
354 delete stream; 355 delete stream;
355 return nullptr; 356 return nullptr;
356 } 357 }
357 auto delete_wstream = [](SkWStream* stream, bool) { delete stream; }; 358 auto delete_wstream = [](SkWStream* stream, bool) { delete stream; };
358 return new SkDocument_PDF(stream, delete_wstream, dpi); 359 return new SkDocument_PDF(stream, delete_wstream, dpi);
359 } 360 }
OLDNEW
« no previous file with comments | « gm/annotated_text.cpp ('k') | src/pdf/SkPDFDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698