Scrub SkPictureData/SkPictureRecord
- replace manual ref fiddling with smart types
- remove unused SkPictureData::fBitmapImageRefs
- remove the preallocation in new_array_from_buffer (to prevent
fuzzer OOMs)
Bug: skia:7937
Change-Id: I50f49fa8e594a138ea09c22f7bf73cf57ec006ff
Reviewed-on: https://skia-review.googlesource.com/128309
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index 17c10d6..9490f53 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -31,26 +31,25 @@
class SkPictureRecord : public SkCanvasVirtualEnforcer<SkCanvas> {
public:
SkPictureRecord(const SkISize& dimensions, uint32_t recordFlags);
- ~SkPictureRecord() override;
- const SkTDArray<const SkPicture* >& getPictureRefs() const {
- return fPictureRefs;
+ const SkTArray<sk_sp<const SkPicture>>& getPictures() const {
+ return fPictures;
}
- const SkTDArray<SkDrawable* >& getDrawableRefs() const {
- return fDrawableRefs;
+ const SkTArray<sk_sp<SkDrawable>>& getDrawables() const {
+ return fDrawables;
}
- const SkTDArray<const SkTextBlob* >& getTextBlobRefs() const {
- return fTextBlobRefs;
+ const SkTArray<sk_sp<const SkTextBlob>>& getTextBlobs() const {
+ return fTextBlobs;
}
- const SkTDArray<const SkVertices* >& getVerticesRefs() const {
- return fVerticesRefs;
+ const SkTArray<sk_sp<const SkVertices>>& getVertices() const {
+ return fVertices;
}
- const SkTDArray<const SkImage* >& getImageRefs() const {
- return fImageRefs;
+ const SkTArray<sk_sp<const SkImage>>& getImages() const {
+ return fImages;
}
sk_sp<SkData> opData() const {
@@ -251,12 +250,11 @@
SkWriter32 fWriter;
- // we ref each item in these arrays
- SkTDArray<const SkImage*> fImageRefs;
- SkTDArray<const SkPicture*> fPictureRefs;
- SkTDArray<SkDrawable*> fDrawableRefs;
- SkTDArray<const SkTextBlob*> fTextBlobRefs;
- SkTDArray<const SkVertices*> fVerticesRefs;
+ SkTArray<sk_sp<const SkImage>> fImages;
+ SkTArray<sk_sp<const SkPicture>> fPictures;
+ SkTArray<sk_sp<SkDrawable>> fDrawables;
+ SkTArray<sk_sp<const SkTextBlob>> fTextBlobs;
+ SkTArray<sk_sp<const SkVertices>> fVertices;
uint32_t fRecordFlags;
int fInitialSaveCount;