Chromium Code Reviews| Index: include/core/SkPicture.h |
| diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h |
| index dc522a5c9d9229c771041e5c7a1c98bd0fdfc3da..6f9624ea7504d8cb11c95e56e7e55c310091c05b 100644 |
| --- a/include/core/SkPicture.h |
| +++ b/include/core/SkPicture.h |
| @@ -202,6 +202,19 @@ public: |
| */ |
| bool hasText() const; |
| + // A refcounted array of refcounted const SkPicture pointers. |
| + struct SnapshotArray : public SkNVRefCnt { |
| + explicit SnapshotArray(size_t count) { fArray.setCount(count); } |
| + ~SnapshotArray() { fArray.unrefAll(); } |
| + |
| + const SkPicture*& operator[](size_t i) { return fArray[i]; } |
|
reed1
2014/11/20 20:36:47
this looks tricky, since it allows the receiver to
mtklein
2014/11/21 16:03:50
Went with set(). I don't think we can assert sing
|
| + const SkPicture* operator[](size_t i) const { return fArray[i]; } |
| + size_t count() const { return fArray.count(); } |
| + const SkPicture* const* begin() const { return fArray.begin(); } |
| + private: |
| + SkTDArray<const SkPicture*> fArray; |
| + }; |
| + |
| private: |
| // V2 : adds SkPixelRef's generation ID. |
| // V3 : PictInfo tag at beginning, and EOF tag at the end |
| @@ -255,9 +268,8 @@ private: |
| void createHeader(SkPictInfo* info) const; |
| static bool IsValidPictInfo(const SkPictInfo& info); |
| - // Takes ownership of the SkRecord, refs the (optional) drawablePicts and BBH. |
| - SkPicture(const SkRect& cullRect, SkRecord*, SkData* drawablePicts, |
| - SkBBoxHierarchy*); |
| + // Takes ownership of the SkRecord, refs the (optional) SnapshotArray and BBH. |
| + SkPicture(const SkRect& cullRect, SkRecord*, SnapshotArray*, SkBBoxHierarchy*); |
| static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); |
| static SkPictureData* Backport(const SkRecord&, const SkPictInfo&, |
| @@ -270,7 +282,7 @@ private: |
| mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are refed |
| SkAutoTDelete<SkRecord> fRecord; |
| SkAutoTUnref<SkBBoxHierarchy> fBBH; |
| - SkAutoTUnref<SkData> fDrawablePicts; |
| + SkAutoTUnref<SnapshotArray> fDrawablePicts; |
| // helpers for fDrawablePicts |
| int drawableCount() const; |