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

Side by Side Diff: src/utils/SkMultiPictureDocumentReader.h

Issue 2255333003: SkMultiSKP: version 2 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-08-23 (Tuesday) 11:53:05 EDT Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/utils/SkMultiPictureDocumentPriv.h ('k') | src/utils/SkMultiPictureDocumentReader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef SkMultiPictureDocumentReader_DEFINED 7 #ifndef SkMultiPictureDocumentReader_DEFINED
8 #define SkMultiPictureDocumentReader_DEFINED 8 #define SkMultiPictureDocumentReader_DEFINED
9 9
10 #include "../private/SkTArray.h" 10 #include "../private/SkTArray.h"
11 #include "SkPicture.h" 11 #include "SkPicture.h"
12 #include "SkSize.h" 12 #include "SkSize.h"
13 #include "SkStream.h" 13 #include "SkStream.h"
14 14
15 /** A lightweight helper class for reading a Skia MultiPictureDocument. */ 15 /** A lightweight helper class for reading a Skia MultiPictureDocument. */
16 class SkMultiPictureDocumentReader { 16 class SkMultiPictureDocumentReader {
17 public: 17 public:
18 /** Initialize the MultiPictureDocument. Does not take ownership 18 /** Initialize the MultiPictureDocument. Does not take ownership
19 of the SkStreamSeekable. */ 19 of the SkStreamSeekable. */
20 bool init(SkStreamSeekable*); 20 bool init(SkStreamSeekable*);
21 21
22 /** Return to factory settings. */ 22 /** Return to factory settings. */
23 void reset() { 23 void reset() {
24 fSizes.reset(); 24 fSizes.reset();
25 fOffsets.reset(); 25 fPages.reset();
26 } 26 }
27 27
28 /** Call this after calling init() */ 28 /** Call this after calling init() (otherwise you'll always get zero). */
29 int pageCount() const { return fSizes.count(); } 29 int pageCount() const { return fSizes.count(); }
30 30
31 /** Deserialize a page from the stream. Call init() first. The 31 /** Deserialize a page from the stream. Call init() first. The
32 SkStreamSeekable doesn't need to be the same object, but 32 SkStreamSeekable doesn't need to be the same object, but
33 should point to the same information as before. */ 33 should point to the same information as before. */
34 sk_sp<SkPicture> readPage(SkStreamSeekable*, int) const; 34 sk_sp<SkPicture> readPage(SkStreamSeekable*, int) const;
35 35
36 /** Fetch the size of the given page, without deserializing the 36 /** Fetch the size of the given page, without deserializing the
37 entire page. */ 37 entire page. */
38 SkSize pageSize(int i) const { return fSizes[i]; } 38 SkSize pageSize(int i) const { return fSizes[i]; }
39 39
40 private: 40 private:
41 SkTArray<SkSize> fSizes; 41 SkTArray<SkSize> fSizes;
42 SkTArray<size_t> fOffsets; 42 size_t fOffset;
43 mutable SkTArray<sk_sp<SkPicture>> fPages;
43 }; 44 };
44 45
45 #endif // SkMultiPictureDocumentReader_DEFINED 46 #endif // SkMultiPictureDocumentReader_DEFINED
OLDNEW
« no previous file with comments | « src/utils/SkMultiPictureDocumentPriv.h ('k') | src/utils/SkMultiPictureDocumentReader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698