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

Unified Diff: src/utils/SkMultiPictureDocumentReader.h

Issue 2023593002: SkMultiPictureDocument & SkMultiPictureDocumentReader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-06-02 (Thursday) 09:23:50 EDT Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/utils/SkMultiPictureDocumentPriv.h ('k') | src/utils/SkMultiPictureDocumentReader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkMultiPictureDocumentReader.h
diff --git a/src/utils/SkMultiPictureDocumentReader.h b/src/utils/SkMultiPictureDocumentReader.h
new file mode 100644
index 0000000000000000000000000000000000000000..8e0a630e52e3c66f3942d12d4b53259269d1ae58
--- /dev/null
+++ b/src/utils/SkMultiPictureDocumentReader.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef SkMultiPictureDocumentReader_DEFINED
+#define SkMultiPictureDocumentReader_DEFINED
+
+#include "../private/SkTArray.h"
+#include "SkPicture.h"
+#include "SkSize.h"
+#include "SkStream.h"
+
+/** A lightweight helper class for reading a Skia MultiPictureDocument. */
+class SkMultiPictureDocumentReader {
+public:
+ /** Initialize the MultiPictureDocument. Does not take ownership
+ of the SkStreamSeekable. */
+ bool init(SkStreamSeekable*);
+
+ /** Return to factory settings. */
+ void reset() {
+ fSizes.reset();
+ fOffsets.reset();
+ }
+
+ /** Call this after calling init() */
+ int pageCount() const { return fSizes.count(); }
+
+ /** Deserialize a page from the stream. Call init() first. The
+ SkStreamSeekable doesn't need to be the same object, but
+ should point to the same information as before. */
+ sk_sp<SkPicture> readPage(SkStreamSeekable*, int) const;
+
+ /** Fetch the size of the given page, without deserializing the
+ entire page. */
+ SkSize pageSize(int i) const { return fSizes[i]; }
+
+private:
+ SkTArray<SkSize> fSizes;
+ SkTArray<size_t> fOffsets;
+};
+
+#endif // SkMultiPictureDocumentReader_DEFINED
« 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