| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "SkMultiPictureDocument.h" | 10 #include "SkMultiPictureDocument.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 bool write(const void*, size_t n) override { | 53 bool write(const void*, size_t n) override { |
| 54 fN += n; | 54 fN += n; |
| 55 return true; | 55 return true; |
| 56 } | 56 } |
| 57 size_t bytesWritten() const override { return fN; } | 57 size_t bytesWritten() const override { return fN; } |
| 58 size_t fN; | 58 size_t fN; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 struct Page { | 61 struct Page { |
| 62 Page(SkSize s, sk_sp<SkPicture> c) : fSize(s), fContent(std::move(c)) {} | 62 Page(SkSize s, sk_sp<SkPicture> c) : fSize(s), fContent(std::move(c)) {} |
| 63 Page(Page&& that) : fSize(that.fSize), fContent(std::move(that.fContent)) {} | 63 Page(Page&&) = default; |
| 64 Page(const Page&) = default; | 64 Page(const Page&) = default; |
| 65 Page& operator=(const Page&) = default; | 65 Page& operator=(const Page&) = default; |
| 66 Page& operator=(Page&& that) { | 66 Page& operator=(Page&&) = default; |
| 67 fSize = that.fSize; | |
| 68 fContent = std::move(that.fContent); | |
| 69 return *this; | |
| 70 } | |
| 71 SkSize fSize; | 67 SkSize fSize; |
| 72 sk_sp<SkPicture> fContent; | 68 sk_sp<SkPicture> fContent; |
| 73 }; | 69 }; |
| 74 | 70 |
| 75 struct MultiPictureDocument final : public SkDocument { | 71 struct MultiPictureDocument final : public SkDocument { |
| 76 SkPictureRecorder fPictureRecorder; | 72 SkPictureRecorder fPictureRecorder; |
| 77 SkSize fCurrentPageSize; | 73 SkSize fCurrentPageSize; |
| 78 std::vector<Page> fPages; | 74 std::vector<Page> fPages; |
| 79 MultiPictureDocument(SkWStream* s, void (*d)(SkWStream*, bool)) | 75 MultiPictureDocument(SkWStream* s, void (*d)(SkWStream*, bool)) |
| 80 : SkDocument(s, d) {} | 76 : SkDocument(s, d) {} |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 fPages.clear(); | 109 fPages.clear(); |
| 114 return good; | 110 return good; |
| 115 } | 111 } |
| 116 void onAbort() override { fPages.clear(); } | 112 void onAbort() override { fPages.clear(); } |
| 117 }; | 113 }; |
| 118 } | 114 } |
| 119 | 115 |
| 120 sk_sp<SkDocument> SkMakeMultiPictureDocument(SkWStream* wStream) { | 116 sk_sp<SkDocument> SkMakeMultiPictureDocument(SkWStream* wStream) { |
| 121 return sk_make_sp<MultiPictureDocument>(wStream, nullptr); | 117 return sk_make_sp<MultiPictureDocument>(wStream, nullptr); |
| 122 } | 118 } |
| OLD | NEW |