| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkDocument.h" | 8 #include "SkDocument.h" |
| 9 #include "SkStream.h" | 9 #include "SkStream.h" |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 return nullptr; | 51 return nullptr; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void SkDocument::endPage() { | 54 void SkDocument::endPage() { |
| 55 if (kInPage_State == fState) { | 55 if (kInPage_State == fState) { |
| 56 fState = kBetweenPages_State; | 56 fState = kBetweenPages_State; |
| 57 this->onEndPage(); | 57 this->onEndPage(); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool SkDocument::close() { | 61 void SkDocument::close() { |
| 62 for (;;) { | 62 for (;;) { |
| 63 switch (fState) { | 63 switch (fState) { |
| 64 case kBetweenPages_State: { | 64 case kBetweenPages_State: { |
| 65 fState = kClosed_State; | 65 fState = kClosed_State; |
| 66 bool success = this->onClose(fStream); | 66 this->onClose(fStream); |
| 67 | 67 |
| 68 if (fDoneProc) { | 68 if (fDoneProc) { |
| 69 fDoneProc(fStream, false); | 69 fDoneProc(fStream, false); |
| 70 } | 70 } |
| 71 // we don't own the stream, but we mark it nullptr since we can | 71 // we don't own the stream, but we mark it nullptr since we can |
| 72 // no longer write to it. | 72 // no longer write to it. |
| 73 fStream = nullptr; | 73 fStream = nullptr; |
| 74 return success; | 74 return; |
| 75 } | 75 } |
| 76 case kInPage_State: | 76 case kInPage_State: |
| 77 this->endPage(); | 77 this->endPage(); |
| 78 break; | 78 break; |
| 79 case kClosed_State: | 79 case kClosed_State: |
| 80 return false; | 80 return; |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 void SkDocument::abort() { | 85 void SkDocument::abort() { |
| 86 this->onAbort(); | 86 this->onAbort(); |
| 87 | 87 |
| 88 fState = kClosed_State; | 88 fState = kClosed_State; |
| 89 if (fDoneProc) { | 89 if (fDoneProc) { |
| 90 fDoneProc(fStream, true); | 90 fDoneProc(fStream, true); |
| 91 } | 91 } |
| 92 // we don't own the stream, but we mark it nullptr since we can | 92 // we don't own the stream, but we mark it nullptr since we can |
| 93 // no longer write to it. | 93 // no longer write to it. |
| 94 fStream = nullptr; | 94 fStream = nullptr; |
| 95 } | 95 } |
| OLD | NEW |