aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-09-22 14:12:46 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-22 14:12:47 -0700
commitd14df7c700bf77c8c42c791ca7a865c1bbc96679 (patch)
tree553e6ab4662bc2737c7fccc8f90ba780726c853b
parentae6e4869c94596eb3bf5069888b32ab06199aec0 (diff)
document.close from bool to void
Nothing meaningful is returned, it is inconsistent with the bulk of the rest of skia's api. The C api is waiting on this change as well. Required chrome CL: https://codereview.chromium.org/2355343003/ BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2354403002 Review-Url: https://codereview.chromium.org/2354403002
-rw-r--r--dm/DMSrcSink.cpp4
-rw-r--r--include/core/SkDocument.h5
-rw-r--r--src/core/SkDocument.cpp8
-rw-r--r--src/pdf/SkPDFDocument.cpp5
-rw-r--r--src/pdf/SkPDFDocument.h2
-rw-r--r--src/utils/SkMultiPictureDocument.cpp13
-rw-r--r--src/xps/SkDocument_XPS.cpp4
-rw-r--r--tests/AnnotationTest.cpp4
-rw-r--r--tests/CanvasTest.cpp2
9 files changed, 20 insertions, 27 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 3c2ee324ff..0565ee97d6 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -1263,9 +1263,7 @@ static Error draw_skdocument(const Src& src, SkDocument* doc, SkWStream* dst) {
}
doc->endPage();
}
- if (!doc->close()) {
- return "SkDocument::close() returned false";
- }
+ doc->close();
dst->flush();
return "";
}
diff --git a/include/core/SkDocument.h b/include/core/SkDocument.h
index ba870120c2..418a837437 100644
--- a/include/core/SkDocument.h
+++ b/include/core/SkDocument.h
@@ -175,9 +175,8 @@ public:
* or stream holding the document's contents. After close() the document
* can no longer add new pages. Deleting the document will automatically
* call close() if need be.
- * Returns true on success or false on failure.
*/
- bool close();
+ void close();
/**
* Call abort() to stop producing the document immediately.
@@ -195,7 +194,7 @@ protected:
virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height,
const SkRect& content) = 0;
virtual void onEndPage() = 0;
- virtual bool onClose(SkWStream*) = 0;
+ virtual void onClose(SkWStream*) = 0;
virtual void onAbort() = 0;
// Allows subclasses to write to the stream as pages are written.
diff --git a/src/core/SkDocument.cpp b/src/core/SkDocument.cpp
index fa25e44f86..29db7f05e1 100644
--- a/src/core/SkDocument.cpp
+++ b/src/core/SkDocument.cpp
@@ -58,12 +58,12 @@ void SkDocument::endPage() {
}
}
-bool SkDocument::close() {
+void SkDocument::close() {
for (;;) {
switch (fState) {
case kBetweenPages_State: {
fState = kClosed_State;
- bool success = this->onClose(fStream);
+ this->onClose(fStream);
if (fDoneProc) {
fDoneProc(fStream, false);
@@ -71,13 +71,13 @@ bool SkDocument::close() {
// we don't own the stream, but we mark it nullptr since we can
// no longer write to it.
fStream = nullptr;
- return success;
+ return;
}
case kInPage_State:
this->endPage();
break;
case kClosed_State:
- return false;
+ return;
}
}
}
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index 8734927901..ab5f465971 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -399,11 +399,11 @@ static sk_sp<SkPDFArray> make_srgb_output_intents() {
return intentArray;
}
-bool SkPDFDocument::onClose(SkWStream* stream) {
+void SkPDFDocument::onClose(SkWStream* stream) {
SkASSERT(!fCanvas.get());
if (fPages.empty()) {
this->reset();
- return false;
+ return;
}
auto docCatalog = sk_make_sp<SkPDFDict>("Catalog");
if (fPDFA) {
@@ -428,7 +428,6 @@ bool SkPDFDocument::onClose(SkWStream* stream) {
fObjectSerializer.serializeObjects(this->getStream());
fObjectSerializer.serializeFooter(this->getStream(), docCatalog, fID);
this->reset();
- return true;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/pdf/SkPDFDocument.h b/src/pdf/SkPDFDocument.h
index eeafbca624..b62a7a59a2 100644
--- a/src/pdf/SkPDFDocument.h
+++ b/src/pdf/SkPDFDocument.h
@@ -53,7 +53,7 @@ public:
virtual ~SkPDFDocument();
SkCanvas* onBeginPage(SkScalar, SkScalar, const SkRect&) override;
void onEndPage() override;
- bool onClose(SkWStream*) override;
+ void onClose(SkWStream*) override;
void onAbort() override;
/**
diff --git a/src/utils/SkMultiPictureDocument.cpp b/src/utils/SkMultiPictureDocument.cpp
index c40f1c900b..217e7a3007 100644
--- a/src/utils/SkMultiPictureDocument.cpp
+++ b/src/utils/SkMultiPictureDocument.cpp
@@ -56,15 +56,14 @@ struct MultiPictureDocument final : public SkDocument {
fSizes.push_back(fCurrentPageSize);
fPages.push_back(fPictureRecorder.finishRecordingAsPicture());
}
- bool onClose(SkWStream* wStream) override {
+ void onClose(SkWStream* wStream) override {
SkASSERT(wStream);
SkASSERT(wStream->bytesWritten() == 0);
- bool good = true;
- good &= wStream->writeText(SkMultiPictureDocumentProtocol::kMagic);
- good &= wStream->write32(SkMultiPictureDocumentProtocol::kVersion);
- good &= wStream->write32(SkToU32(fPages.count()));
+ wStream->writeText(SkMultiPictureDocumentProtocol::kMagic);
+ wStream->write32(SkMultiPictureDocumentProtocol::kVersion);
+ wStream->write32(SkToU32(fPages.count()));
for (SkSize s : fSizes) {
- good &= wStream->write(&s, sizeof(s));
+ wStream->write(&s, sizeof(s));
}
SkSize bigsize = SkMultiPictureDocumentProtocol::Join(fSizes);
SkCanvas* c = fPictureRecorder.beginRecording(SkRect::MakeSize(bigsize));
@@ -78,7 +77,7 @@ struct MultiPictureDocument final : public SkDocument {
p->serialize(wStream);
fPages.reset();
fSizes.reset();
- return good;
+ return;
}
void onAbort() override {
fPages.reset();
diff --git a/src/xps/SkDocument_XPS.cpp b/src/xps/SkDocument_XPS.cpp
index e1222c92bc..4a977aeaee 100644
--- a/src/xps/SkDocument_XPS.cpp
+++ b/src/xps/SkDocument_XPS.cpp
@@ -49,9 +49,9 @@ protected:
fDevice.endSheet();
}
- bool onClose(SkWStream*) override {
+ void onClose(SkWStream*) override {
SkASSERT(!fCanvas.get());
- return fDevice.endPortfolio();
+ (void)fDevice.endPortfolio();
}
void onAbort() override {}
diff --git a/tests/AnnotationTest.cpp b/tests/AnnotationTest.cpp
index 0a9dfeac18..cc2fd1f912 100644
--- a/tests/AnnotationTest.cpp
+++ b/tests/AnnotationTest.cpp
@@ -50,7 +50,7 @@ DEF_TEST(Annotation_PdfLink, reporter) {
sk_sp<SkData> data(SkData::MakeWithCString("http://www.gooogle.com"));
SkAnnotateRectWithURL(canvas, r, data.get());
- REPORTER_ASSERT(reporter, doc->close());
+ doc->close();
sk_sp<SkData> out = outStream.detachAsData();
const char* rawOutput = (const char*)out->data();
@@ -68,7 +68,7 @@ DEF_TEST(Annotation_NamedDestination, reporter) {
sk_sp<SkData> data(SkData::MakeWithCString("example"));
SkAnnotateNamedDestination(canvas, p, data.get());
- REPORTER_ASSERT(reporter, doc->close());
+ doc->close();
sk_sp<SkData> out = outStream.detachAsData();
const char* rawOutput = (const char*)out->data();
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 59642975b4..2be83f3d2f 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -515,8 +515,6 @@ static void TestPdfDevice(skiatest::Reporter* reporter, const TestData& d, Canva
REPORTER_ASSERT(reporter, canvas);
step->setAssertMessageFormat(kPdfAssertMessageFormat);
step->draw(canvas, d, reporter);
-
- REPORTER_ASSERT(reporter, doc->close());
}
/*