OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 #ifndef SkMultiPictureDocumentReader_DEFINED |
| 8 #define SkMultiPictureDocumentReader_DEFINED |
| 9 |
| 10 #include "../private/SkTArray.h" |
| 11 #include "SkPicture.h" |
| 12 #include "SkSize.h" |
| 13 #include "SkStream.h" |
| 14 |
| 15 /** A lightweight helper class for reading a Skia MultiPictureDocument. */ |
| 16 class SkMultiPictureDocumentReader { |
| 17 public: |
| 18 /** Initialize the MultiPictureDocument. Does not take ownership |
| 19 of the SkStreamSeekable. */ |
| 20 bool init(SkStreamSeekable*); |
| 21 |
| 22 /** Return to factory settings. */ |
| 23 void reset() { |
| 24 fSizes.reset(); |
| 25 fOffsets.reset(); |
| 26 } |
| 27 |
| 28 /** Call this after calling init() */ |
| 29 int pageCount() const { return fSizes.count(); } |
| 30 |
| 31 /** Deserialize a page from the stream. Call init() first. The |
| 32 SkStreamSeekable doesn't need to be the same object, but |
| 33 should point to the same information as before. */ |
| 34 sk_sp<SkPicture> readPage(SkStreamSeekable*, int) const; |
| 35 |
| 36 /** Fetch the size of the given page, without deserializing the |
| 37 entire page. */ |
| 38 SkSize pageSize(int i) const { return fSizes[i]; } |
| 39 |
| 40 private: |
| 41 SkTArray<SkSize> fSizes; |
| 42 SkTArray<size_t> fOffsets; |
| 43 }; |
| 44 |
| 45 #endif // SkMultiPictureDocumentReader_DEFINED |
OLD | NEW |