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

Side by Side Diff: src/utils/SkMultiPictureDocument.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.cpp ('k') | src/xps/SkDocument_XPS.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 2016 Google Inc. 2 * Copyright 2016 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 "SkMultiPictureDocument.h" 8 #include "SkMultiPictureDocument.h"
9 #include "SkMultiPictureDocumentPriv.h" 9 #include "SkMultiPictureDocumentPriv.h"
10 #include "SkPicture.h" 10 #include "SkPicture.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 ~MultiPictureDocument() { this->close(); } 49 ~MultiPictureDocument() { this->close(); }
50 50
51 SkCanvas* onBeginPage(SkScalar w, SkScalar h, const SkRect& c) override { 51 SkCanvas* onBeginPage(SkScalar w, SkScalar h, const SkRect& c) override {
52 fCurrentPageSize.set(w, h); 52 fCurrentPageSize.set(w, h);
53 return trim(fPictureRecorder.beginRecording(w, h), w, h, c); 53 return trim(fPictureRecorder.beginRecording(w, h), w, h, c);
54 } 54 }
55 void onEndPage() override { 55 void onEndPage() override {
56 fSizes.push_back(fCurrentPageSize); 56 fSizes.push_back(fCurrentPageSize);
57 fPages.push_back(fPictureRecorder.finishRecordingAsPicture()); 57 fPages.push_back(fPictureRecorder.finishRecordingAsPicture());
58 } 58 }
59 bool onClose(SkWStream* wStream) override { 59 void onClose(SkWStream* wStream) override {
60 SkASSERT(wStream); 60 SkASSERT(wStream);
61 SkASSERT(wStream->bytesWritten() == 0); 61 SkASSERT(wStream->bytesWritten() == 0);
62 bool good = true; 62 wStream->writeText(SkMultiPictureDocumentProtocol::kMagic);
63 good &= wStream->writeText(SkMultiPictureDocumentProtocol::kMagic); 63 wStream->write32(SkMultiPictureDocumentProtocol::kVersion);
64 good &= wStream->write32(SkMultiPictureDocumentProtocol::kVersion); 64 wStream->write32(SkToU32(fPages.count()));
65 good &= wStream->write32(SkToU32(fPages.count()));
66 for (SkSize s : fSizes) { 65 for (SkSize s : fSizes) {
67 good &= wStream->write(&s, sizeof(s)); 66 wStream->write(&s, sizeof(s));
68 } 67 }
69 SkSize bigsize = SkMultiPictureDocumentProtocol::Join(fSizes); 68 SkSize bigsize = SkMultiPictureDocumentProtocol::Join(fSizes);
70 SkCanvas* c = fPictureRecorder.beginRecording(SkRect::MakeSize(bigsize)) ; 69 SkCanvas* c = fPictureRecorder.beginRecording(SkRect::MakeSize(bigsize)) ;
71 for (const sk_sp<SkPicture>& page : fPages) { 70 for (const sk_sp<SkPicture>& page : fPages) {
72 c->drawPicture(page); 71 c->drawPicture(page);
73 c->drawAnnotation(SkRect::MakeEmpty(), 72 c->drawAnnotation(SkRect::MakeEmpty(),
74 SkMultiPictureDocumentProtocol::kEndPage, 73 SkMultiPictureDocumentProtocol::kEndPage,
75 nullptr); 74 nullptr);
76 } 75 }
77 sk_sp<SkPicture> p = fPictureRecorder.finishRecordingAsPicture(); 76 sk_sp<SkPicture> p = fPictureRecorder.finishRecordingAsPicture();
78 p->serialize(wStream); 77 p->serialize(wStream);
79 fPages.reset(); 78 fPages.reset();
80 fSizes.reset(); 79 fSizes.reset();
81 return good; 80 return;
82 } 81 }
83 void onAbort() override { 82 void onAbort() override {
84 fPages.reset(); 83 fPages.reset();
85 fSizes.reset(); 84 fSizes.reset();
86 } 85 }
87 }; 86 };
88 } 87 }
89 88
90 sk_sp<SkDocument> SkMakeMultiPictureDocument(SkWStream* wStream) { 89 sk_sp<SkDocument> SkMakeMultiPictureDocument(SkWStream* wStream) {
91 return sk_make_sp<MultiPictureDocument>(wStream, nullptr); 90 return sk_make_sp<MultiPictureDocument>(wStream, nullptr);
92 } 91 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDocument.cpp ('k') | src/xps/SkDocument_XPS.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698