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

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

Issue 2354403002: document.close from bool to void (Closed)
Patch Set: keep endPortfolio returning a bool Created 4 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 | « src/pdf/SkPDFDocument.h ('k') | src/utils/SkMultiPictureDocument.cpp » ('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 "SkMakeUnique.h" 8 #include "SkMakeUnique.h"
9 #include "SkPDFCanon.h" 9 #include "SkPDFCanon.h"
10 #include "SkPDFCanvas.h" 10 #include "SkPDFCanvas.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 outputIntent->insertString("OutputConditionIdentifier", 392 outputIntent->insertString("OutputConditionIdentifier",
393 "Custom"); 393 "Custom");
394 outputIntent->insertString("Info","sRGB IEC61966-2.1"); 394 outputIntent->insertString("Info","sRGB IEC61966-2.1");
395 outputIntent->insertObjRef("DestOutputProfile", 395 outputIntent->insertObjRef("DestOutputProfile",
396 make_srgb_color_profile()); 396 make_srgb_color_profile());
397 auto intentArray = sk_make_sp<SkPDFArray>(); 397 auto intentArray = sk_make_sp<SkPDFArray>();
398 intentArray->appendObject(std::move(outputIntent)); 398 intentArray->appendObject(std::move(outputIntent));
399 return intentArray; 399 return intentArray;
400 } 400 }
401 401
402 bool SkPDFDocument::onClose(SkWStream* stream) { 402 void SkPDFDocument::onClose(SkWStream* stream) {
403 SkASSERT(!fCanvas.get()); 403 SkASSERT(!fCanvas.get());
404 if (fPages.empty()) { 404 if (fPages.empty()) {
405 this->reset(); 405 this->reset();
406 return false; 406 return;
407 } 407 }
408 auto docCatalog = sk_make_sp<SkPDFDict>("Catalog"); 408 auto docCatalog = sk_make_sp<SkPDFDict>("Catalog");
409 if (fPDFA) { 409 if (fPDFA) {
410 SkASSERT(fXMP); 410 SkASSERT(fXMP);
411 docCatalog->insertObjRef("Metadata", fXMP); 411 docCatalog->insertObjRef("Metadata", fXMP);
412 // Don't specify OutputIntents if we are not in PDF/A mode since 412 // Don't specify OutputIntents if we are not in PDF/A mode since
413 // no one has ever asked for this feature. 413 // no one has ever asked for this feature.
414 docCatalog->insertObject("OutputIntents", make_srgb_output_intents()); 414 docCatalog->insertObject("OutputIntents", make_srgb_output_intents());
415 } 415 }
416 SkASSERT(!fPages.empty()); 416 SkASSERT(!fPages.empty());
417 docCatalog->insertObjRef("Pages", generate_page_tree(&fPages)); 417 docCatalog->insertObjRef("Pages", generate_page_tree(&fPages));
418 SkASSERT(fPages.empty()); 418 SkASSERT(fPages.empty());
419 419
420 if (fDests->size() > 0) { 420 if (fDests->size() > 0) {
421 docCatalog->insertObjRef("Dests", std::move(fDests)); 421 docCatalog->insertObjRef("Dests", std::move(fDests));
422 } 422 }
423 423
424 // Build font subsetting info before calling addObjectRecursively(). 424 // Build font subsetting info before calling addObjectRecursively().
425 SkPDFCanon* canon = &fCanon; 425 SkPDFCanon* canon = &fCanon;
426 fFonts.foreach([canon](SkPDFFont* p){ p->getFontSubset(canon); }); 426 fFonts.foreach([canon](SkPDFFont* p){ p->getFontSubset(canon); });
427 fObjectSerializer.addObjectRecursively(docCatalog); 427 fObjectSerializer.addObjectRecursively(docCatalog);
428 fObjectSerializer.serializeObjects(this->getStream()); 428 fObjectSerializer.serializeObjects(this->getStream());
429 fObjectSerializer.serializeFooter(this->getStream(), docCatalog, fID); 429 fObjectSerializer.serializeFooter(this->getStream(), docCatalog, fID);
430 this->reset(); 430 this->reset();
431 return true;
432 } 431 }
433 432
434 /////////////////////////////////////////////////////////////////////////////// 433 ///////////////////////////////////////////////////////////////////////////////
435 434
436 sk_sp<SkDocument> SkPDFMakeDocument(SkWStream* stream, 435 sk_sp<SkDocument> SkPDFMakeDocument(SkWStream* stream,
437 void (*proc)(SkWStream*, bool), 436 void (*proc)(SkWStream*, bool),
438 SkScalar dpi, 437 SkScalar dpi,
439 const SkDocument::PDFMetadata& metadata, 438 const SkDocument::PDFMetadata& metadata,
440 sk_sp<SkPixelSerializer> jpeg, 439 sk_sp<SkPixelSerializer> jpeg,
441 bool pdfa) { 440 bool pdfa) {
(...skipping 13 matching lines...) Expand all
455 } 454 }
456 455
457 sk_sp<SkDocument> SkDocument::MakePDF(SkWStream* stream, 456 sk_sp<SkDocument> SkDocument::MakePDF(SkWStream* stream,
458 SkScalar dpi, 457 SkScalar dpi,
459 const SkDocument::PDFMetadata& metadata, 458 const SkDocument::PDFMetadata& metadata,
460 sk_sp<SkPixelSerializer> jpegEncoder, 459 sk_sp<SkPixelSerializer> jpegEncoder,
461 bool pdfa) { 460 bool pdfa) {
462 return SkPDFMakeDocument(stream, nullptr, dpi, metadata, 461 return SkPDFMakeDocument(stream, nullptr, dpi, metadata,
463 std::move(jpegEncoder), pdfa); 462 std::move(jpegEncoder), pdfa);
464 } 463 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDocument.h ('k') | src/utils/SkMultiPictureDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698