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

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: update comments 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..2abbaeccbf6def308c71666160b74f3dcec5c6f5 100644
--- a/src/doc/SkDocument.cpp
+++ b/src/doc/SkDocument.cpp
@@ -20,28 +20,16 @@ SkDocument::~SkDocument() {
this->close();
}
-SkCanvas* SkDocument::beginPage(SkScalar width, SkScalar height,
- const SkRect* content) {
- if (width <= 0 || height <= 0) {
+SkCanvas* SkDocument::beginPage(const SkSize& trimSize, const SkRect* mediaBox) {
+ if (trimSize.width() <= 0 || trimSize.height() <= 0) {
return NULL;
}
- SkRect outer = SkRect::MakeWH(width, height);
- SkRect inner;
- if (content) {
- inner = *content;
- if (!inner.intersect(outer)) {
reed1 2013/10/07 13:24:54 Why do we not check for valid mediaBox anymore?
edisonn 2013/10/07 19:29:06 Done.
- return NULL;
- }
- } else {
- inner = outer;
- }
-
for (;;) {
switch (fState) {
case kBetweenPages_State:
fState = kInPage_State;
- return this->onBeginPage(width, height, inner);
+ return this->onBeginPage(trimSize, mediaBox);
case kInPage_State:
this->endPage();
break;
@@ -60,12 +48,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 +61,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