aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-11-21 11:06:04 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-21 11:06:04 -0800
commitb7ee349f108040fbd5cb71d891d5b74a1843b0bc (patch)
tree4fc9e878e6aa5a7ef76b000cd226ff565b3e7014 /include/core
parent3f10b9dd2c9d256b77111e9669806785a54c7f54 (diff)
SkData -> SkPicture::SnapshotArray
Restores type safety with all the same features. (Also note, less code: 29 insertions, 50 deletions.) BUG=skia: Review URL: https://codereview.chromium.org/746553002
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkPicture.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index e9500b25c5..ea3db8e7d1 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -199,6 +199,18 @@ public:
*/
bool hasText() const;
+ // A refcounted array of refcounted const SkPicture pointers.
+ struct SnapshotArray : public SkNVRefCnt {
+ SnapshotArray(const SkPicture* pics[], size_t count) : fPics(pics), fCount(count) {}
+ ~SnapshotArray() { for (size_t i = 0; i < fCount; i++) { fPics[i]->unref(); } }
+
+ const SkPicture* const* begin() const { return fPics; }
+ size_t count() const { return fCount; }
+ private:
+ SkAutoTMalloc<const SkPicture*> fPics;
+ size_t fCount;
+ };
+
private:
// V2 : adds SkPixelRef's generation ID.
// V3 : PictInfo tag at beginning, and EOF tag at the end
@@ -251,9 +263,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&,
@@ -266,7 +277,7 @@ private:
mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are refed
SkAutoTDelete<const SkRecord> fRecord;
SkAutoTUnref<const SkBBoxHierarchy> fBBH;
- SkAutoTUnref<SkData> fDrawablePicts;
+ SkAutoTUnref<const SnapshotArray> fDrawablePicts;
// helpers for fDrawablePicts
int drawableCount() const;