diff options
Diffstat (limited to 'src/pipe')
-rw-r--r-- | src/pipe/SkPipeReader.cpp | 18 | ||||
-rw-r--r-- | src/pipe/SkRefSet.h | 16 |
2 files changed, 16 insertions, 18 deletions
diff --git a/src/pipe/SkPipeReader.cpp b/src/pipe/SkPipeReader.cpp index 312e3da4e8..a37af5532a 100644 --- a/src/pipe/SkPipeReader.cpp +++ b/src/pipe/SkPipeReader.cpp @@ -51,14 +51,14 @@ public: return index ? fFactories->getAt(index - 1) : nullptr; } - bool setImage(int index, SkImage* img) { - return fImages->set(index - 1, img); + bool setImage(int index, sk_sp<SkImage> img) { + return fImages->set(index - 1, std::move(img)); } - bool setPicture(int index, SkPicture* pic) { - return fPictures->set(index - 1, pic); + bool setPicture(int index, sk_sp<SkPicture> pic) { + return fPictures->set(index - 1, std::move(pic)); } - bool setTypeface(int index, SkTypeface* face) { - return fTypefaces->set(index - 1, face); + bool setTypeface(int index, sk_sp<SkTypeface> face) { + return fTypefaces->set(index - 1, std::move(face)); } bool setFactory(int index, SkFlattenable::Factory factory) { SkASSERT(index > 0); @@ -645,7 +645,7 @@ static void defineImage_handler(SkPipeReader& reader, uint32_t packedVerb, SkCan if (!image) { SkDebugf("-- failed to decode\n"); } - inflator->setImage(index, image.get()); + inflator->setImage(index, std::move(image)); } } @@ -671,7 +671,7 @@ static void defineTypeface_handler(SkPipeReader& reader, uint32_t packedVerb, Sk sk_sp<SkData> data = reader.readByteArrayAsData(); // TODO: seems like we could "peek" to see the array, and not need to copy it. sk_sp<SkTypeface> tf = data ? inflator->makeTypeface(data->data(), data->size()) : nullptr; - inflator->setTypeface(index, tf.get()); + inflator->setTypeface(index, std::move(tf)); } } @@ -707,7 +707,7 @@ static void definePicture_handler(SkPipeReader& reader, uint32_t packedVerb, SkC do_playback(reader, recorder.beginRecording(*cull), &pictureIndex); SkASSERT(pictureIndex > 0); sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture(); - inflator->setPicture(pictureIndex, picture.get()); + inflator->setPicture(pictureIndex, std::move(picture)); } } diff --git a/src/pipe/SkRefSet.h b/src/pipe/SkRefSet.h index 5f23ba2191..65fe7af1eb 100644 --- a/src/pipe/SkRefSet.h +++ b/src/pipe/SkRefSet.h @@ -9,24 +9,22 @@ #define SkRefSet_DEFINED #include "SkRefCnt.h" -#include "SkTDArray.h" +#include "SkTArray.h" template <typename T> class SkRefSet { public: - ~SkRefSet() { fArray.unrefAll(); } - T* get(int index) const { SkASSERT((unsigned)index < (unsigned)fArray.count()); - return fArray[index]; + return fArray[index].get(); } - bool set(int index, T* value) { - if ((unsigned)index < (unsigned)fArray.count()) { - SkRefCnt_SafeAssign(fArray[index], value); + bool set(int index, sk_sp<T> value) { + if (index < fArray.count()) { + fArray[index] = std::move(value); return true; } if (fArray.count() == index && value) { - *fArray.append() = SkRef(value); + fArray.emplace_back(std::move(value)); return true; } SkDebugf("SkRefSet: index [%d] out of range %d\n", index, fArray.count()); @@ -34,7 +32,7 @@ public: } private: - SkTDArray<T*> fArray; + SkTArray<sk_sp<T>, true> fArray; }; #endif |