Chromium Code Reviews| 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; |
| +} |