SkPicture::SnapshotArray doesn't really stand to benefit from refcounting.
authormtklein <mtklein@chromium.org>
Fri, 21 Nov 2014 20:20:35 +0000 (12:20 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 21 Nov 2014 20:20:35 +0000 (12:20 -0800)
BUG=skia:

Review URL: https://codereview.chromium.org/748803005

include/core/SkPicture.h
src/core/SkPicture.cpp
src/core/SkPictureRecorder.cpp

index d5c07a3..4db64bf 100644 (file)
@@ -199,8 +199,9 @@ public:
      */
     bool hasText() const;
 
-    // A refcounted array of refcounted const SkPicture pointers.
-    struct SnapshotArray : public SkNVRefCnt<SnapshotArray> {
+    // An array of refcounted const SkPicture pointers.
+    class SnapshotArray : ::SkNoncopyable {
+    public:
         SnapshotArray(const SkPicture* pics[], size_t count) : fPics(pics), fCount(count) {}
         ~SnapshotArray() { for (size_t i = 0; i < fCount; i++) { fPics[i]->unref(); } }
 
@@ -263,7 +264,7 @@ private:
     void createHeader(SkPictInfo* info) const;
     static bool IsValidPictInfo(const SkPictInfo& info);
 
-    // Takes ownership of the SkRecord, refs the (optional) SnapshotArray and BBH.
+    // Takes ownership of the SkRecord and (optional) SnapshotArray, refs the (optional) BBH.
     SkPicture(const SkRect& cullRect, SkRecord*, SnapshotArray*, SkBBoxHierarchy*);
 
     static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*);
@@ -277,7 +278,7 @@ private:
     mutable SkTDArray<DeletionListener*> fDeletionListeners;  // pointers are refed
     SkAutoTDelete<const SkRecord>       fRecord;
     SkAutoTUnref<const SkBBoxHierarchy> fBBH;
-    SkAutoTUnref<const SnapshotArray>   fDrawablePicts;
+    SkAutoTDelete<const SnapshotArray>  fDrawablePicts;
 
     // helpers for fDrawablePicts
     int drawableCount() const;
index a8e160f..b24f719 100644 (file)
@@ -523,7 +523,7 @@ SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SnapshotArray* dr
     , fCullRect(cullRect)
     , fRecord(record)
     , fBBH(SkSafeRef(bbh))
-    , fDrawablePicts(SkSafeRef(drawablePicts))
+    , fDrawablePicts(drawablePicts)
     , fAnalysis(*fRecord)
 {}
 
index edee07b..3262938 100644 (file)
@@ -61,7 +61,7 @@ SkPicture* SkPictureRecorder::endRecording() {
     // TODO: we should remember these from our caller
     SkBBHFactory* factory = NULL;
     uint32_t recordFlags = 0;
-    SkAutoTUnref<SkPicture::SnapshotArray> drawablePicts(
+    SkAutoTDelete<SkPicture::SnapshotArray> drawablePicts(
             fRecorder->newDrawableSnapshot(factory, recordFlags));
     SkPicture* pict = SkNEW_ARGS(SkPicture, (fCullRect, fRecord.detach(),
                                              drawablePicts.detach(), fBBH.get()));