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

Unified Diff: src/doc/SkDocument.cpp

Issue 24811002: Update the SkDocument interface to allow for 1) abort won't emit pdf, 2) close can report success/f… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: move SkPDFDevice in separate files, and various fixes Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: src/doc/SkDocument.cpp
diff --git a/src/doc/SkDocument.cpp b/src/doc/SkDocument.cpp
index 055c749792bb29c4de263c8e55f96d80b4ee08ab..0989c141b8532b58250aefd3bc1fc966455ff501 100644
--- a/src/doc/SkDocument.cpp
+++ b/src/doc/SkDocument.cpp
@@ -22,20 +22,20 @@ SkDocument::~SkDocument() {
SkCanvas* SkDocument::beginPage(SkScalar width, SkScalar height,
const SkRect* content) {
- if (width <= 0 || height <= 0) {
- return NULL;
- }
+ if (width <= 0 || height <= 0) {
vandebo (ex-Chrome) 2013/10/08 23:37:06 nit: extra spaces
+ return NULL;
+ }
- SkRect outer = SkRect::MakeWH(width, height);
- SkRect inner;
- if (content) {
- inner = *content;
- if (!inner.intersect(outer)) {
- return NULL;
- }
- } else {
- inner = outer;
- }
+ SkRect outer = SkRect::MakeWH(width, height);
+ SkRect inner;
+ if (content) {
+ inner = *content;
+ if (!inner.intersect(outer)) {
+ return NULL;
+ }
+ } else {
+ inner = outer;
+ }
for (;;) {
switch (fState) {
@@ -60,12 +60,12 @@ void SkDocument::endPage() {
}
}
-void SkDocument::close() {
+bool SkDocument::close() {
for (;;) {
switch (fState) {
- case kBetweenPages_State:
+ case kBetweenPages_State: {
fState = kClosed_State;
- this->onClose(fStream);
+ bool success = this->onClose(fStream);
if (fDoneProc) {
fDoneProc(fStream);
@@ -73,12 +73,17 @@ void SkDocument::close() {
// we don't own the stream, but we mark it NULL since we can
// no longer write to it.
fStream = NULL;
- return;
+ return success;
+ }
case kInPage_State:
this->endPage();
break;
case kClosed_State:
- return;
+ return false;
}
}
}
+
+void SkDocument::abort() {
+ fState = kClosed_State;
+}

Powered by Google App Engine
This is Rietveld 408576698