Remove SkAutoTDelete.
authorBen Wagner <bungeman@google.com>
Thu, 3 Nov 2016 18:40:50 +0000 (14:40 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Thu, 3 Nov 2016 19:03:40 +0000 (19:03 +0000)
Replace with std::unique_ptr.

Change-Id: I5806cfbb30515fcb20e5e66ce13fb5f3b8728176
Reviewed-on: https://skia-review.googlesource.com/4381
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
135 files changed:
bench/AndroidCodecBench.cpp
bench/BitmapRegionDecoderBench.h
bench/CodecBench.cpp
bench/ColorCodecBench.cpp
bench/GrMemoryPoolBench.cpp
bench/PDFBench.cpp
bench/PicturePlaybackBench.cpp
bench/RectanizerBench.cpp
bench/nanobench.cpp
debugger/QT/SkDebuggerGUI.cpp
dm/DM.cpp
dm/DMSrcSink.cpp
dm/DMSrcSink.h
dm/DMSrcSinkAndroid.cpp
dm/DMSrcSinkAndroid.h
fuzz/fuzz.cpp
gm/encode-platform.cpp
gm/fontscalerdistortable.cpp
gm/gamut.cpp
gm/image.cpp
gm/image_pict.cpp
gm/pictureimagegenerator.cpp
gm/reveal.cpp
include/private/SkTemplates.h
samplecode/DecodeFile.h
samplecode/SampleApp.h
samplecode/SamplePdfFileViewer.cpp
samplecode/SamplePictFile.cpp
src/android/SkBitmapRegionCodec.h
src/android/SkBitmapRegionDecoder.cpp
src/animator/SkDisplayApply.cpp
src/animator/SkSnapshot.cpp
src/codec/SkAndroidCodec.cpp
src/codec/SkBmpCodec.cpp
src/codec/SkBmpMaskCodec.cpp
src/codec/SkBmpMaskCodec.h
src/codec/SkBmpRLECodec.cpp
src/codec/SkBmpRLECodec.h
src/codec/SkBmpStandardCodec.h
src/codec/SkCodec.cpp
src/codec/SkCodecImageGenerator.h
src/codec/SkIcoCodec.cpp
src/codec/SkIcoCodec.h
src/codec/SkJpegCodec.cpp
src/codec/SkJpegCodec.h
src/codec/SkPngCodec.cpp
src/codec/SkPngCodec.h
src/codec/SkRawCodec.cpp
src/codec/SkRawCodec.h
src/codec/SkWbmpCodec.cpp
src/codec/SkWbmpCodec.h
src/codec/SkWebpCodec.cpp
src/core/SkBigPicture.h
src/core/SkColorTable.cpp
src/core/SkPaint.cpp
src/core/SkPicture.cpp
src/core/SkPictureData.cpp
src/core/SkPicturePlayback.cpp
src/core/SkRecordedDrawable.cpp
src/core/SkStream.cpp
src/fonts/SkFontMgr_indirect.cpp
src/gpu/GrDrawingManager.h
src/gpu/GrGpu.h
src/gpu/GrPathRenderingRenderTargetContext.h
src/gpu/GrRenderTargetOpList.cpp
src/gpu/GrRenderTargetOpList.h
src/gpu/SkGr.cpp
src/gpu/gl/GrGLProgram.h
src/gpu/instanced/InstanceProcessor.cpp
src/gpu/text/GrAtlasTextBlob.h
src/gpu/text/GrStencilAndCoverTextContext.cpp
src/gpu/vk/GrVkExtensions.h
src/gpu/vk/GrVkGpu.h
src/gpu/vk/GrVkMemory.cpp
src/gpu/vk/GrVkMemory.h
src/gpu/vk/GrVkPipelineState.cpp
src/gpu/vk/GrVkPipelineState.h
src/image/SkImage_Gpu.cpp
src/images/SkImageEncoder.cpp
src/ports/SkFontHost_win.cpp
src/ports/SkFontMgr_FontConfigInterface.cpp
src/ports/SkFontMgr_android_parser.cpp
src/ports/SkFontMgr_win_dw.cpp
src/ports/SkTypeface_win_dw.cpp
src/svg/SkSVGDevice.cpp
src/svg/SkSVGDevice.h
src/utils/SkCanvasStateUtils.cpp
src/utils/SkFrontBufferedStream.cpp
src/utils/win/SkDWriteFontFileStream.cpp
src/utils/win/SkDWriteFontFileStream.h
src/views/SkEvent.cpp
src/xps/SkDocument_XPS.cpp
src/xps/SkXPSDevice.cpp
tests/BadIcoTest.cpp
tests/CodecPartialTest.cpp
tests/CodecPriv.h
tests/CodecTest.cpp
tests/ColorSpaceTest.cpp
tests/DataRefTest.cpp
tests/DiscardableMemoryPoolTest.cpp
tests/EGLImageTest.cpp
tests/ExifTest.cpp
tests/FontHostStreamTest.cpp
tests/FontHostTest.cpp
tests/FrontBufferedStreamTest.cpp
tests/GifTest.cpp
tests/GpuSampleLocationsTest.cpp
tests/GrMemoryPoolTest.cpp
tests/ImageTest.cpp
tests/Matrix44Test.cpp
tests/PDFDeflateWStreamTest.cpp
tests/PathOpsSkpClipTest.cpp
tests/PictureTest.cpp
tests/SerializationTest.cpp
tests/SkResourceCacheTest.cpp
tests/StreamTest.cpp
tests/YUVTest.cpp
tools/Resources.cpp
tools/debugger/SkDrawCommand.cpp
tools/flags/SkCommonFlagsConfig.h
tools/get_images_from_skps.cpp
tools/gpu/GrContextFactory.cpp
tools/gpu/GrContextFactory.h
tools/gpu/TestContext.h
tools/gpu/gl/GLTestContext.cpp
tools/gpu/gl/GLTestContext.h
tools/gpu/gl/angle/GLTestContext_angle.cpp
tools/gpu/gl/angle/GLTestContext_angle.h
tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp
tools/gpu/vk/VkTestContext.cpp
tools/skdiff/skdiff_utils.cpp
tools/skiaserve/Request.cpp
tools/viewer/ImageSlide.cpp
tools/viewer/Viewer.cpp
tools/visualize_color_gamut.cpp

index 97e1176..e0680bd 100644 (file)
@@ -29,7 +29,7 @@ bool AndroidCodecBench::isSuitableFor(Backend backend) {
 }
 
 void AndroidCodecBench::onDelayedSetup() {
-    SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(fData));
+    std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(fData));
     SkISize scaledSize = codec->getSampledDimensions(fSampleSize);
 
     fInfo = codec->getInfo().makeWH(scaledSize.width(), scaledSize.height())
@@ -42,7 +42,7 @@ void AndroidCodecBench::onDelayedSetup() {
 }
 
 void AndroidCodecBench::onDraw(int n, SkCanvas* canvas) {
-    SkAutoTDelete<SkAndroidCodec> codec;
+    std::unique_ptr<SkAndroidCodec> codec;
     SkAndroidCodec::AndroidOptions options;
     options.fSampleSize = fSampleSize;
     for (int i = 0; i < n; i++) {
index 2fb56ad..3099055 100644 (file)
@@ -35,7 +35,7 @@ protected:
 
 private:
     SkString                                       fName;
-    SkAutoTDelete<SkBitmapRegionDecoder>           fBRD;
+    std::unique_ptr<SkBitmapRegionDecoder>         fBRD;
     sk_sp<SkData>                                  fData;
     const SkColorType                              fColorType;
     const uint32_t                                 fSampleSize;
index 9bd404d..a1788ee 100644 (file)
@@ -26,7 +26,7 @@ CodecBench::CodecBench(SkString baseName, SkData* encoded, SkColorType colorType
             alpha_type_to_str(alphaType));
 #ifdef SK_DEBUG
     // Ensure that we can create an SkCodec from this data.
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fData));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(fData));
     SkASSERT(codec);
 #endif
 }
@@ -40,7 +40,7 @@ bool CodecBench::isSuitableFor(Backend backend) {
 }
 
 void CodecBench::onDelayedSetup() {
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fData));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(fData));
 
     fInfo = codec->getInfo().makeColorType(fColorType)
                             .makeAlphaType(fAlphaType)
@@ -50,7 +50,7 @@ void CodecBench::onDelayedSetup() {
 }
 
 void CodecBench::onDraw(int n, SkCanvas* canvas) {
-    SkAutoTDelete<SkCodec> codec;
+    std::unique_ptr<SkCodec> codec;
     SkPMColor colorTable[256];
     int colorCount;
     SkCodec::Options options;
index 8df7e65..50727c7 100644 (file)
@@ -34,7 +34,7 @@ bool ColorCodecBench::isSuitableFor(Backend backend) {
 }
 
 void ColorCodecBench::decodeAndXform() {
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fEncoded));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(fEncoded));
     SkASSERT(codec);
 
 #ifdef SK_DEBUG
@@ -61,7 +61,7 @@ void ColorCodecBench::xformOnly() {
 }
 
 void ColorCodecBench::onDelayedSetup() {
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fEncoded));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(fEncoded));
     fSrcInfo = codec->getInfo().makeColorType(kRGBA_8888_SkColorType);
     fDstInfo = fSrcInfo;
 
index 9b60c3c..55ba3e6 100644 (file)
@@ -110,7 +110,7 @@ protected:
         enum {
             kMaxObjects = 4 * (1 << 10),
         };
-        SkAutoTDelete<B> objects[kMaxObjects];
+        std::unique_ptr<B> objects[kMaxObjects];
 
         for (int i = 0; i < loops; i++) {
             uint32_t idx = r.nextRangeU(0, kMaxObjects-1);
index 1010f74..573353f 100644 (file)
@@ -144,7 +144,7 @@ protected:
     }
 
 private:
-    SkAutoTDelete<SkStreamAsset> fAsset;
+    std::unique_ptr<SkStreamAsset> fAsset;
 };
 
 // Test speed of SkPDFUtils::FloatToDecimal for typical floats that
index 2b2b6ad..54ecd3c 100644 (file)
@@ -163,14 +163,14 @@ public:
     SkIPoint onGetSize() override { return SkIPoint::Make(1024,1024); }
 
     void onDelayedSetup() override {
-        SkAutoTDelete<SkBBHFactory> factory;
+        std::unique_ptr<SkBBHFactory> factory;
         switch (fBBH) {
             case kNone:                                                 break;
             case kRTree:    factory.reset(new SkRTreeFactory);          break;
         }
 
         SkPictureRecorder recorder;
-        SkCanvas* canvas = recorder.beginRecording(1024, 1024, factory);
+        SkCanvas* canvas = recorder.beginRecording(1024, 1024, factory.get());
             SkRandom rand;
             for (int i = 0; i < 10000; i++) {
                 SkScalar x = rand.nextRangeScalar(0, 1024),
index 5bc6f11..b282313 100644 (file)
@@ -115,7 +115,7 @@ private:
     SkString                    fName;
     RectanizerType              fRectanizerType;
     RectType                    fRectType;
-    SkAutoTDelete<GrRectanizer> fRectanizer;
+    std::unique_ptr<GrRectanizer> fRectanizer;
 
     typedef Benchmark INHERITED;
 };
index 37e3f06..0651302 100644 (file)
@@ -63,7 +63,7 @@
     #include "gl/GrGLUtil.h"
     using sk_gpu_test::GrContextFactory;
     using sk_gpu_test::TestContext;
-    SkAutoTDelete<GrContextFactory> gGrFactory;
+    std::unique_ptr<GrContextFactory> gGrFactory;
 #endif
 
     struct GrContextOptions;
@@ -481,7 +481,7 @@ void create_configs(SkTArray<Config>* configs) {
     SkCommandLineConfigArray array;
     ParseConfigs(FLAGS_config, &array);
     for (int i = 0; i < array.count(); ++i) {
-        create_config(array[i], configs);
+        create_config(array[i].get(), configs);
     }
 }
 
@@ -531,7 +531,7 @@ static Target* is_enabled(Benchmark* bench, const Config& config) {
 
 static bool valid_brd_bench(sk_sp<SkData> encoded, SkColorType colorType, uint32_t sampleSize,
         uint32_t minOutputSize, int* width, int* height) {
-    SkAutoTDelete<SkBitmapRegionDecoder> brd(
+    std::unique_ptr<SkBitmapRegionDecoder> brd(
             SkBitmapRegionDecoder::Create(encoded, SkBitmapRegionDecoder::kAndroidCodec_Strategy));
     if (nullptr == brd.get()) {
         // This is indicates that subset decoding is not supported for a particular image format.
@@ -683,7 +683,7 @@ public:
     }
 
     Benchmark* next() {
-        SkAutoTDelete<Benchmark> bench;
+        std::unique_ptr<Benchmark> bench;
         do {
             bench.reset(this->rawNext());
             if (!bench) {
@@ -704,7 +704,7 @@ public:
         }
 
         while (fGMs) {
-            SkAutoTDelete<skiagm::GM> gm(fGMs->factory()(nullptr));
+            std::unique_ptr<skiagm::GM> gm(fGMs->factory()(nullptr));
             fGMs = fGMs->next();
             if (gm->runAsBench()) {
                 fSourceType = "gm";
@@ -816,7 +816,7 @@ public:
                 continue;
             }
             sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
-            SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
+            std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(encoded));
             if (!codec) {
                 // Nothing to time.
                 SkDebugf("Cannot find codec for %s\n", path.c_str());
@@ -900,7 +900,7 @@ public:
                 continue;
             }
             sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
-            SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(encoded));
+            std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(encoded));
             if (!codec) {
                 // Nothing to time.
                 SkDebugf("Cannot find codec for %s\n", path.c_str());
@@ -1137,7 +1137,7 @@ int nanobench_main() {
         }
     }
 
-    SkAutoTDelete<ResultsWriter> log(new ResultsWriter);
+    std::unique_ptr<ResultsWriter> log(new ResultsWriter);
     if (!FLAGS_outResultsFile.isEmpty()) {
 #if defined(SK_RELEASE)
         log.reset(new NanoJSONResultsWriter(FLAGS_outResultsFile[0]));
@@ -1204,7 +1204,7 @@ int nanobench_main() {
     int runs = 0;
     BenchmarkStream benchStream;
     while (Benchmark* b = benchStream.next()) {
-        SkAutoTDelete<Benchmark> bench(b);
+        std::unique_ptr<Benchmark> bench(b);
         if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName())) {
             continue;
         }
@@ -1249,12 +1249,12 @@ int nanobench_main() {
                 samples.reset();
                 auto stop = now_ms() + FLAGS_ms;
                 do {
-                    samples.push_back(time(loops, bench, target) / loops);
+                    samples.push_back(time(loops, bench.get(), target) / loops);
                 } while (now_ms() < stop);
             } else {
                 samples.reset(FLAGS_samples);
                 for (int s = 0; s < FLAGS_samples; s++) {
-                    samples[s] = time(loops, bench, target) / loops;
+                    samples[s] = time(loops, bench.get(), target) / loops;
                 }
             }
 
index 348b366..7e6f2a0 100644 (file)
@@ -672,7 +672,7 @@ void SkDebuggerGUI::populateDirectoryWidget() {
 void SkDebuggerGUI::loadPicture(const SkString& fileName) {
     fFileName = fileName;
     fLoading = true;
-    SkAutoTDelete<SkStream> stream(new SkFILEStream(fileName.c_str()));
+    std::unique_ptr<SkStream> stream(new SkFILEStream(fileName.c_str()));
 
     auto picture = SkPicture::MakeFromStream(stream);
 
index 150b994..5f4203c 100644 (file)
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -334,12 +334,12 @@ static void gather_uninteresting_hashes() {
 
 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
-struct TaggedSrc : public SkAutoTDelete<Src> {
+struct TaggedSrc : public std::unique_ptr<Src> {
     SkString tag;
     SkString options;
 };
 
-struct TaggedSink : public SkAutoTDelete<Sink> {
+struct TaggedSink : public std::unique_ptr<Sink> {
     SkString tag;
 };
 
@@ -354,7 +354,7 @@ static bool in_shard() {
 }
 
 static void push_src(const char* tag, ImplicitString options, Src* s) {
-    SkAutoTDelete<Src> src(s);
+    std::unique_ptr<Src> src(s);
     if (in_shard() &&
         FLAGS_src.contains(tag) &&
         !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) {
@@ -510,7 +510,7 @@ static void push_codec_srcs(Path path) {
         info("Couldn't read %s.", path.c_str());
         return;
     }
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(encoded));
     if (nullptr == codec.get()) {
         info("Couldn't create codec for %s.", path.c_str());
         return;
@@ -803,7 +803,7 @@ static bool gather_srcs() {
 }
 
 static void push_sink(const SkCommandLineConfig& config, Sink* s) {
-    SkAutoTDelete<Sink> sink(s);
+    std::unique_ptr<Sink> sink(s);
 
     // Try a simple Src as a canary.  If it fails, skip this sink.
     struct : public Src {
@@ -1079,7 +1079,7 @@ struct Task {
             // We're likely switching threads here, so we must capture by value, [=] or [foo,bar].
             SkStreamAsset* data = stream.detachAsStream();
             gDefinitelyThreadSafeWork.add([task,name,bitmap,data]{
-                SkAutoTDelete<SkStreamAsset> ownedData(data);
+                std::unique_ptr<SkStreamAsset> ownedData(data);
 
                 // Why doesn't the copy constructor do this when we have pre-locked pixels?
                 bitmap.lockPixels();
@@ -1331,7 +1331,7 @@ int dm_main() {
     gPending = gSrcs.count() * gSinks.count() + gParallelTests.count() + gSerialTests.count();
     info("%d srcs * %d sinks + %d tests == %d tasks",
          gSrcs.count(), gSinks.count(), gParallelTests.count() + gSerialTests.count(), gPending);
-    SkAutoTDelete<SkThread> statusThread(start_status_thread());
+    std::unique_ptr<SkThread> statusThread(start_status_thread());
 
     // Kick off as much parallel work as we can, making note of any serial work we'll need to do.
     SkTaskGroup parallel;
index d519860..ae7c6a1 100644 (file)
@@ -61,24 +61,24 @@ namespace DM {
 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {}
 
 Error GMSrc::draw(SkCanvas* canvas) const {
-    SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr));
+    std::unique_ptr<skiagm::GM> gm(fFactory(nullptr));
     canvas->concat(gm->getInitialTransform());
     gm->draw(canvas);
     return "";
 }
 
 SkISize GMSrc::size() const {
-    SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr));
+    std::unique_ptr<skiagm::GM> gm(fFactory(nullptr));
     return gm->getISize();
 }
 
 Name GMSrc::name() const {
-    SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr));
+    std::unique_ptr<skiagm::GM> gm(fFactory(nullptr));
     return gm->getName();
 }
 
 void GMSrc::modifyGrContextOptions(GrContextOptions* options) const {
-    SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr));
+    std::unique_ptr<skiagm::GM> gm(fFactory(nullptr));
     gm->modifyGrContextOptions(options);
 }
 
@@ -125,7 +125,7 @@ Error BRDSrc::draw(SkCanvas* canvas) const {
             break;
     }
 
-    SkAutoTDelete<SkBitmapRegionDecoder> brd(create_brd(fPath));
+    std::unique_ptr<SkBitmapRegionDecoder> brd(create_brd(fPath));
     if (nullptr == brd.get()) {
         return Error::Nonfatal(SkStringPrintf("Could not create brd for %s.", fPath.c_str()));
     }
@@ -227,7 +227,7 @@ Error BRDSrc::draw(SkCanvas* canvas) const {
 }
 
 SkISize BRDSrc::size() const {
-    SkAutoTDelete<SkBitmapRegionDecoder> brd(create_brd(fPath));
+    std::unique_ptr<SkBitmapRegionDecoder> brd(create_brd(fPath));
     if (brd) {
         return SkISize::Make(SkTMax(1, brd->width() / (int) fSampleSize),
                 SkTMax(1, brd->height() / (int) fSampleSize));
@@ -381,7 +381,7 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
         return SkStringPrintf("Couldn't read %s.", fPath.c_str());
     }
 
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(encoded));
     if (nullptr == codec.get()) {
         return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str());
     }
@@ -718,7 +718,7 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
 
 SkISize CodecSrc::size() const {
     sk_sp<SkData> encoded(SkData::MakeFromFileName(fPath.c_str()));
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(encoded));
     if (nullptr == codec) {
         return SkISize::Make(0, 0);
     }
@@ -771,7 +771,7 @@ Error AndroidCodecSrc::draw(SkCanvas* canvas) const {
     if (!encoded) {
         return SkStringPrintf("Couldn't read %s.", fPath.c_str());
     }
-    SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(encoded));
+    std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(encoded));
     if (nullptr == codec.get()) {
         return SkStringPrintf("Couldn't create android codec for %s.", fPath.c_str());
     }
@@ -824,7 +824,7 @@ Error AndroidCodecSrc::draw(SkCanvas* canvas) const {
 
 SkISize AndroidCodecSrc::size() const {
     sk_sp<SkData> encoded(SkData::MakeFromFileName(fPath.c_str()));
-    SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(encoded));
+    std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(encoded));
     if (nullptr == codec) {
         return SkISize::Make(0, 0);
     }
@@ -876,7 +876,7 @@ Error ImageGenSrc::draw(SkCanvas* canvas) const {
     }
 #endif
 
-    SkAutoTDelete<SkImageGenerator> gen(nullptr);
+    std::unique_ptr<SkImageGenerator> gen(nullptr);
     switch (fMode) {
         case kCodec_Mode:
             gen.reset(SkCodecImageGenerator::NewFromEncodedCodec(encoded.get()));
@@ -931,7 +931,7 @@ Error ImageGenSrc::draw(SkCanvas* canvas) const {
 
 SkISize ImageGenSrc::size() const {
     sk_sp<SkData> encoded(SkData::MakeFromFileName(fPath.c_str()));
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(encoded));
     if (nullptr == codec) {
         return SkISize::Make(0, 0);
     }
@@ -972,7 +972,7 @@ Error ColorCodecSrc::draw(SkCanvas* canvas) const {
         return SkStringPrintf("Couldn't read %s.", fPath.c_str());
     }
 
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(encoded));
     if (nullptr == codec.get()) {
         return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str());
     }
@@ -1039,7 +1039,7 @@ Error ColorCodecSrc::draw(SkCanvas* canvas) const {
 
 SkISize ColorCodecSrc::size() const {
     sk_sp<SkData> encoded(SkData::MakeFromFileName(fPath.c_str()));
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(encoded));
     if (nullptr == codec) {
         return SkISize::Make(0, 0);
     }
@@ -1194,8 +1194,8 @@ Name MSKPSrc::name() const { return SkOSPath::Basename(fPath.c_str()); }
 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
 Error NullSink::draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const {
-    SkAutoTDelete<SkCanvas> canvas(SkCreateNullCanvas());
-    return src.draw(canvas);
+    std::unique_ptr<SkCanvas> canvas(SkCreateNullCanvas());
+    return src.draw(canvas.get());
 }
 
 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -1372,7 +1372,7 @@ SVGSink::SVGSink() {}
 
 Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const {
 #if defined(SK_XML)
-    SkAutoTDelete<SkXMLWriter> xmlWriter(new SkXMLStreamWriter(dst));
+    std::unique_ptr<SkXMLWriter> xmlWriter(new SkXMLStreamWriter(dst));
     SkAutoTUnref<SkCanvas> canvas(SkSVGCanvas::Create(
         SkRect::MakeWH(SkIntToScalar(src.size().width()), SkIntToScalar(src.size().height())),
         xmlWriter));
@@ -1470,7 +1470,7 @@ ViaMatrix::ViaMatrix(SkMatrix matrix, Sink* sink) : Via(sink), fMatrix(matrix) {
 Error ViaMatrix::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
     SkMatrix matrix = fMatrix;
     SkISize size = auto_compute_translate(&matrix, src.size().width(), src.size().height());
-    return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) {
+    return draw_to_canvas(fSink.get(), bitmap, stream, log, size, [&](SkCanvas* canvas) {
         canvas->concat(matrix);
         return src.draw(canvas);
     });
@@ -1528,9 +1528,9 @@ Error ViaSerialization::draw(
     // Serialize it and then deserialize it.
     sk_sp<SkPicture> deserialized(SkPicture::MakeFromData(pic->serialize().get()));
 
-    return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) {
+    return draw_to_canvas(fSink.get(), bitmap, stream, log, size, [&](SkCanvas* canvas) {
         canvas->drawPicture(deserialized);
-        return check_against_reference(bitmap, src, fSink);
+        return check_against_reference(bitmap, src, fSink.get());
     });
 }
 
@@ -1553,7 +1553,7 @@ Error ViaTiles::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri
     }
     sk_sp<SkPicture> pic(recorder.finishRecordingAsPicture());
 
-    return draw_to_canvas(fSink, bitmap, stream, log, src.size(), [&](SkCanvas* canvas) {
+    return draw_to_canvas(fSink.get(), bitmap, stream, log, src.size(), [&](SkCanvas* canvas) {
         const int xTiles = (size.width()  + fW - 1) / fW,
                   yTiles = (size.height() + fH - 1) / fH;
         SkMultiPictureDraw mpd(xTiles*yTiles);
@@ -1591,7 +1591,7 @@ Error ViaTiles::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri
 
 Error ViaPicture::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
     auto size = src.size();
-    return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
+    return draw_to_canvas(fSink.get(), bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
         SkPictureRecorder recorder;
         sk_sp<SkPicture> pic;
         Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()),
@@ -1601,7 +1601,7 @@ Error ViaPicture::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkSt
         }
         pic = recorder.finishRecordingAsPicture();
         canvas->drawPicture(pic);
-        return check_against_reference(bitmap, src, fSink);
+        return check_against_reference(bitmap, src, fSink.get());
     });
 }
 
@@ -1609,7 +1609,7 @@ Error ViaPicture::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkSt
 
 Error ViaDefer::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
     auto size = src.size();
-    return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
+    return draw_to_canvas(fSink.get(), bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
         SkDeferredCanvas deferred(canvas);
         return src.draw(&deferred);
     });
@@ -1619,7 +1619,7 @@ Error ViaDefer::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri
 
 Error ViaPipe::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
     auto size = src.size();
-    return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
+    return draw_to_canvas(fSink.get(), bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
         SkDynamicMemoryWStream tmpStream;
         Error err = src.draw(SkPipeSerializer().beginWrite(SkRect::Make(size), &tmpStream));
         if (!err.isEmpty()) {
@@ -1627,7 +1627,7 @@ Error ViaPipe::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStrin
         }
         sk_sp<SkData> data = tmpStream.detachAsData();
         SkPipeDeserializer().playback(data->data(), data->size(), canvas);
-        return check_against_reference(bitmap, src, fSink);
+        return check_against_reference(bitmap, src, fSink.get());
     });
 }
 
@@ -1638,7 +1638,7 @@ Error ViaPipe::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStrin
 Error ViaSecondPicture::draw(
         const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
     auto size = src.size();
-    return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
+    return draw_to_canvas(fSink.get(), bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
         SkPictureRecorder recorder;
         sk_sp<SkPicture> pic;
         for (int i = 0; i < 2; i++) {
@@ -1650,7 +1650,7 @@ Error ViaSecondPicture::draw(
             pic = recorder.finishRecordingAsPicture();
         }
         canvas->drawPicture(pic);
-        return check_against_reference(bitmap, src, fSink);
+        return check_against_reference(bitmap, src, fSink.get());
     });
 }
 
@@ -1658,7 +1658,7 @@ Error ViaSecondPicture::draw(
 
 // Draw the Src twice.  This can help exercise caching.
 Error ViaTwice::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
-    return draw_to_canvas(fSink, bitmap, stream, log, src.size(), [&](SkCanvas* canvas) -> Error {
+    return draw_to_canvas(fSink.get(), bitmap, stream, log, src.size(), [&](SkCanvas* canvas) -> Error {
         for (int i = 0; i < 2; i++) {
             SkAutoCanvasRestore acr(canvas, true/*save now*/);
             canvas->clear(SK_ColorTRANSPARENT);
@@ -1667,7 +1667,7 @@ Error ViaTwice::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri
                 return err;
             }
         }
-        return check_against_reference(bitmap, src, fSink);
+        return check_against_reference(bitmap, src, fSink.get());
     });
 }
 
@@ -1711,7 +1711,7 @@ struct DrawsAsSingletonPictures {
 Error ViaSingletonPictures::draw(
         const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
     auto size = src.size();
-    return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
+    return draw_to_canvas(fSink.get(), bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
         // Use low-level (Skia-private) recording APIs so we can read the SkRecord.
         SkRecord skr;
         SkRecorder recorder(&skr, size.width(), size.height());
@@ -1739,7 +1739,7 @@ Error ViaSingletonPictures::draw(
         sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture());
 
         canvas->drawPicture(macroPic);
-        return check_against_reference(bitmap, src, fSink);
+        return check_against_reference(bitmap, src, fSink.get());
     });
 }
 
@@ -1748,7 +1748,7 @@ Error ViaSingletonPictures::draw(
 Error ViaLite::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
     auto size = src.size();
     SkRect bounds = {0,0, (SkScalar)size.width(), (SkScalar)size.height()};
-    return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
+    return draw_to_canvas(fSink.get(), bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
         sk_sp<SkLiteDL> dl = SkLiteDL::New(bounds);
 
         SkLiteRecorder rec;
@@ -1759,7 +1759,7 @@ Error ViaLite::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStrin
             return err;
         }
         dl->draw(canvas);
-        return check_against_reference(bitmap, src, fSink);
+        return check_against_reference(bitmap, src, fSink.get());
     });
 }
 
index 237f5d1..bb60115 100644 (file)
@@ -399,7 +399,7 @@ public:
         return flags;
     }
 protected:
-    SkAutoTDelete<Sink> fSink;
+    std::unique_ptr<Sink> fSink;
 };
 
 class ViaMatrix : public Via {
@@ -448,7 +448,7 @@ public:
     Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
 private:
     const int                   fW, fH;
-    SkAutoTDelete<SkBBHFactory> fFactory;
+    std::unique_ptr<SkBBHFactory> fFactory;
 };
 
 class ViaSecondPicture : public Via {
index 3958e48..77ec1c9 100644 (file)
@@ -47,9 +47,9 @@ Error ViaAndroidSDK::draw(const Src& src,
 
         Error draw(SkCanvas* canvas) const override {
             // Pass through HWUI's upper layers to get operational transforms
-            SkAutoTDelete<android::Canvas> ac (android::Canvas::create_canvas(canvas));
+            std::unique_ptr<android::Canvas> ac(android::Canvas::create_canvas(canvas));
             SkAutoTUnref<android::uirenderer::SkiaCanvasProxy> scProxy
-                (new android::uirenderer::SkiaCanvasProxy(ac));
+                (new android::uirenderer::SkiaCanvasProxy(ac.get()));
 
             // Pass through another proxy to get paint transforms
             SkAndroidSDKCanvas fc;
index 2d7ad65..6717df6 100644 (file)
@@ -46,7 +46,7 @@ public:
     }
 
 private:
-    SkAutoTDelete<Sink> fSink;
+    std::unique_ptr<Sink> fSink;
 };
 
 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
index e6b95fd..7aac5da 100644 (file)
@@ -133,7 +133,7 @@ int fuzz_img(sk_sp<SkData> bytes, uint8_t scale, uint8_t mode) {
 
     // This is mostly copied from DMSrcSink's CodecSrc::draw method.
     SkDebugf("Decoding\n");
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(bytes));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(bytes));
     if (nullptr == codec.get()) {
         SkDebugf("[terminated] Couldn't create codec.\n");
         return 3;
index 90f6aa9..09b64cc 100644 (file)
@@ -96,7 +96,7 @@ protected:
         make_unpremul_256(&unpremulBm);
 
         for (SkImageEncoder::Type type : kTypes) {
-            SkAutoTDelete<SkImageEncoder> encoder(make_encoder(type));
+            std::unique_ptr<SkImageEncoder> encoder(make_encoder(type));
             sk_sp<SkData> opaqueData(encoder->encodeData(opaqueBm, 100));
             sk_sp<SkData> premulData(encoder->encodeData(premulBm, 100));
             sk_sp<SkData> unpremulData(encoder->encodeData(unpremulBm, 100));
index be6a7eb..712400c 100644 (file)
@@ -35,7 +35,7 @@ protected:
         paint.setLCDRenderText(true);
         SkAutoTUnref<SkFontMgr> fontMgr(SkFontMgr::RefDefault());
 
-        SkAutoTDelete<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Distortable.ttf"));
+        std::unique_ptr<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Distortable.ttf"));
         if (!distortable) {
             return;
         }
index 9f45d6e..21312ce 100644 (file)
@@ -113,7 +113,7 @@ protected:
     SkColor fColors[4];
 };
 
-static void draw_gamut_grid(SkCanvas* canvas, SkTArray<SkAutoTDelete<CellRenderer>>& renderers) {
+static void draw_gamut_grid(SkCanvas* canvas, SkTArray<std::unique_ptr<CellRenderer>>& renderers) {
     // We want our colors in our wide gamut to be obviously visibly distorted from sRGB, so we use
     // Wide Gamut RGB (with sRGB gamma, for HW acceleration) as the working space for this test:
     const float gWideGamutRGB_toXYZD50[]{
@@ -199,35 +199,35 @@ static void draw_gamut_grid(SkCanvas* canvas, SkTArray<SkAutoTDelete<CellRendere
 }
 
 DEF_SIMPLE_GM_BG(gamut, canvas, gTestWidth, gTestHeight, SK_ColorBLACK) {
-    SkTArray<SkAutoTDelete<CellRenderer>> renderers;
+    SkTArray<std::unique_ptr<CellRenderer>> renderers;
 
     // sRGB primaries, rendered as paint color
-    renderers.push_back(new PaintColorCellRenderer(SK_ColorRED));
-    renderers.push_back(new PaintColorCellRenderer(SK_ColorGREEN));
+    renderers.emplace_back(new PaintColorCellRenderer(SK_ColorRED));
+    renderers.emplace_back(new PaintColorCellRenderer(SK_ColorGREEN));
 
     // sRGB primaries, rendered as bitmaps
-    renderers.push_back(new BitmapCellRenderer(SK_ColorRED, kNone_SkFilterQuality));
-    renderers.push_back(new BitmapCellRenderer(SK_ColorGREEN, kLow_SkFilterQuality));
+    renderers.emplace_back(new BitmapCellRenderer(SK_ColorRED, kNone_SkFilterQuality));
+    renderers.emplace_back(new BitmapCellRenderer(SK_ColorGREEN, kLow_SkFilterQuality));
     // Larger bitmap to trigger mipmaps
-    renderers.push_back(new BitmapCellRenderer(SK_ColorRED, kMedium_SkFilterQuality, 2.0f));
+    renderers.emplace_back(new BitmapCellRenderer(SK_ColorRED, kMedium_SkFilterQuality, 2.0f));
     // Smaller bitmap to trigger bicubic
-    renderers.push_back(new BitmapCellRenderer(SK_ColorGREEN, kHigh_SkFilterQuality, 0.5f));
+    renderers.emplace_back(new BitmapCellRenderer(SK_ColorGREEN, kHigh_SkFilterQuality, 0.5f));
 
     // Various gradients involving sRGB primaries and white/black
 
     // First with just two stops (implemented with uniforms on GPU)
-    renderers.push_back(new GradientCellRenderer(SK_ColorRED, SK_ColorGREEN, false));
-    renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorBLACK, false));
-    renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorWHITE, false));
+    renderers.emplace_back(new GradientCellRenderer(SK_ColorRED, SK_ColorGREEN, false));
+    renderers.emplace_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorBLACK, false));
+    renderers.emplace_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorWHITE, false));
 
     // ... and then with four stops (implemented with textures on GPU)
-    renderers.push_back(new GradientCellRenderer(SK_ColorRED, SK_ColorGREEN, true));
-    renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorBLACK, true));
-    renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorWHITE, true));
+    renderers.emplace_back(new GradientCellRenderer(SK_ColorRED, SK_ColorGREEN, true));
+    renderers.emplace_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorBLACK, true));
+    renderers.emplace_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorWHITE, true));
 
     // Vertex colors
-    renderers.push_back(new VerticesCellRenderer(SK_ColorRED, SK_ColorRED));
-    renderers.push_back(new VerticesCellRenderer(SK_ColorRED, SK_ColorGREEN));
+    renderers.emplace_back(new VerticesCellRenderer(SK_ColorRED, SK_ColorRED));
+    renderers.emplace_back(new VerticesCellRenderer(SK_ColorRED, SK_ColorGREEN));
 
     draw_gamut_grid(canvas, renderers);
 }
index f1bb5a4..d15919e 100644 (file)
@@ -412,9 +412,9 @@ protected:
             gen_raster, gen_picture, gen_png, gen_jpg,
         };
         for (auto& proc : procs) {
-            SkAutoTDelete<SkImageGenerator> gen(proc(info));
+            std::unique_ptr<SkImageGenerator> gen(proc(info));
             if (gen) {
-                show_scaled_generator(canvas, gen);
+                show_scaled_generator(canvas, gen.get());
             }
             canvas->translate(0, 120);
         }
index f88a20b..2e2c284 100644 (file)
@@ -260,8 +260,8 @@ class ImageCacheratorGM : public skiagm::GM {
     SkString                         fName;
     SkImageGenerator*                (*fFactory)(GrContext*, SkPicture*);
     sk_sp<SkPicture>                 fPicture;
-    SkAutoTDelete<SkImageCacherator> fCache;
-    SkAutoTDelete<SkImageCacherator> fCacheSubset;
+    std::unique_ptr<SkImageCacherator> fCache;
+    std::unique_ptr<SkImageCacherator> fCacheSubset;
 
 public:
     ImageCacheratorGM(const char suffix[], SkImageGenerator* (*factory)(GrContext*, SkPicture*))
@@ -346,11 +346,11 @@ protected:
         // Draw the tex first, so it doesn't hit a lucky cache from the raster version. This
         // way we also can force the generateTexture call.
 
-        draw_as_tex(canvas, fCache, 310, 0);
-        draw_as_tex(canvas, fCacheSubset, 310+101, 0);
+        draw_as_tex(canvas, fCache.get(), 310, 0);
+        draw_as_tex(canvas, fCacheSubset.get(), 310+101, 0);
 
-        draw_as_bitmap(canvas, fCache, 150, 0);
-        draw_as_bitmap(canvas, fCacheSubset, 150+101, 0);
+        draw_as_bitmap(canvas, fCache.get(), 150, 0);
+        draw_as_bitmap(canvas, fCacheSubset.get(), 150+101, 0);
     }
 
     void onDraw(SkCanvas* canvas) override {
index 95efbb2..c340d1f 100644 (file)
@@ -152,7 +152,7 @@ protected:
             if (configs[i].scaleY < 0) {
                 m.postTranslate(0, SkIntToScalar(configs[i].size.height()));
             }
-            SkAutoTDelete<SkImageGenerator> gen(
+            std::unique_ptr<SkImageGenerator> gen(
                 SkImageGenerator::NewFromPicture(configs[i].size, fPicture.get(), &m,
                                                  p.getAlpha() != 255 ? &p : nullptr));
             SkBitmap bm;
index b88e7fe..3c7de7d 100644 (file)
@@ -380,8 +380,8 @@ protected:
                                                          clipCenter.fX + curSize,
                                                          clipCenter.fY + curSize);
 
-                SkAutoTDelete<Object> clipObj((*clipMakes[x])(clipRect));
-                SkAutoTDelete<Object> drawObj((*drawMakes[y])(cell));
+                std::unique_ptr<Object> clipObj((*clipMakes[x])(clipRect));
+                std::unique_ptr<Object> drawObj((*drawMakes[y])(cell));
 
                 // The goal is to replace this clipped draw (which clips the 
                 // shadow) with a draw using the geometric clip
index 4c72897..5c6403d 100644 (file)
@@ -81,28 +81,6 @@ public:
     operator T*() const { return this->get(); }
 };
 
-/** \class SkAutoTDelete
-  An SkAutoTDelete<T> is like a T*, except that the destructor of SkAutoTDelete<T>
-  automatically deletes the pointer it holds (if any).  That is, SkAutoTDelete<T>
-  owns the T object that it points to.  Like a T*, an SkAutoTDelete<T> may hold
-  either NULL or a pointer to a T object.  Also like T*, SkAutoTDelete<T> is
-  thread-compatible, and once you dereference it, you get the threadsafety
-  guarantees of T.
-
-  The size of a SkAutoTDelete is small: sizeof(SkAutoTDelete<T>) == sizeof(T*)
-*/
-template <typename T> class SkAutoTDelete : public std::unique_ptr<T> {
-public:
-    SkAutoTDelete(T* obj = NULL) : std::unique_ptr<T>(obj) {}
-
-    operator T*() const { return this->get(); }
-
-#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
-    // Need to update graphics/BitmapRegionDecoder.cpp.
-    T* detach() { return this->release(); }
-#endif
-};
-
 /** Allocate an array of T elements, and free the array in the destructor
  */
 template <typename T> class SkAutoTArray : SkNoncopyable {
index b954af6..95f3e39 100644 (file)
@@ -15,7 +15,7 @@ static inline bool decode_file(const char* filename, SkBitmap* bitmap,
                                bool requireUnpremul = false) {
     SkASSERT(kIndex_8_SkColorType != colorType);
     sk_sp<SkData> data(SkData::MakeFromFileName(filename));
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data));
     if (!codec) {
         return false;
     }
index 3011f5f..c52541d 100644 (file)
@@ -175,7 +175,7 @@ private:
     SkPipeDeserializer      fPipeDeserializer;
 
     SkPictureRecorder fRecorder;
-    SkAutoTDelete<SkCanvas> fFlagsFilterCanvas;
+    std::unique_ptr<SkCanvas> fFlagsFilterCanvas;
     SkPath fClipPath;
 
     SkTouchGesture fGesture;
index a36b29f..110aa58 100644 (file)
@@ -36,7 +36,7 @@ private:
     SkPicture*  fPicture;  // TODO(edisonn): multiple pages, one page / picture, make it an array
 
     static SkPicture* LoadPdf(const char path[]) {
-        SkAutoTDelete<SkPdfRenderer> renderer(SkPdfRenderer::CreateFromFile(path));
+        std::unique_ptr<SkPdfRenderer> renderer(SkPdfRenderer::CreateFromFile(path));
         if (nullptr == renderer.get()) {
             return nullptr;
         }
index 8548328..a826edd 100644 (file)
@@ -199,7 +199,7 @@ private:
             return nullptr;
         }
 
-        SkAutoTDelete<SkBBHFactory> factory;
+        std::unique_ptr<SkBBHFactory> factory;
         switch (bbox) {
         case kNo_BBoxType:
             // no bbox playback necessary
index 7977417..5c59d52 100644 (file)
@@ -30,7 +30,7 @@ public:
 
 private:
 
-    SkAutoTDelete<SkAndroidCodec> fCodec;
+    std::unique_ptr<SkAndroidCodec> fCodec;
 
     typedef SkBitmapRegionDecoder INHERITED;
 
index 6dd48c5..15a530e 100644 (file)
@@ -19,11 +19,11 @@ SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create(
 
 SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create(
         SkStreamRewindable* stream, Strategy strategy) {
-    SkAutoTDelete<SkStreamRewindable> streamDeleter(stream);
+    std::unique_ptr<SkStreamRewindable> streamDeleter(stream);
     switch (strategy) {
         case kAndroidCodec_Strategy: {
-            SkAutoTDelete<SkAndroidCodec> codec =
-                    SkAndroidCodec::NewFromStream(streamDeleter.release());
+            std::unique_ptr<SkAndroidCodec> codec(
+                    SkAndroidCodec::NewFromStream(streamDeleter.release()));
             if (nullptr == codec) {
                 SkCodecPrintf("Error: Failed to create codec.\n");
                 return NULL;
index 0d5f09d..776d08f 100644 (file)
@@ -463,7 +463,7 @@ void SkApply::endSave(int index) {
     int count = (int) (size / sizeof(SkScalar));
     int activeIndex = fActive->fDrawIndex + index;
     SkOperand* last = new SkOperand[count];
-    SkAutoTDelete<SkOperand> autoLast(last);
+    std::unique_ptr<SkOperand> autoLast(last);
     if (type != SkType_MemberProperty) {
         info->getValue(target, last, count);
         SkOperand* saveOperand = fActive->fSaveRestore[activeIndex];
index 4d35432..fbaedff 100644 (file)
@@ -42,7 +42,7 @@ bool SkSnapshot::draw(SkAnimateMaker& maker) {
     if (!encoder) {
         return false;
     }
-    SkAutoTDelete<SkImageEncoder> ad(encoder);
+    std::unique_ptr<SkImageEncoder> ad(encoder);
 
     SkString name(filename);
     if (sequence) {
index 0a4172f..01605b2 100644 (file)
@@ -23,7 +23,7 @@ SkAndroidCodec::SkAndroidCodec(SkCodec* codec)
 {}
 
 SkAndroidCodec* SkAndroidCodec::NewFromStream(SkStream* stream, SkPngChunkReader* chunkReader) {
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream, chunkReader));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream, chunkReader));
     if (nullptr == codec) {
         return nullptr;
     }
index b0ef8ad..b3a8010 100644 (file)
@@ -503,7 +503,7 @@ bool SkBmpCodec::ReadHeader(SkStream* stream, bool inIco, SkCodec** codecOut) {
 
             if (codecOut) {
                 // Check that input bit masks are valid and create the masks object
-                SkAutoTDelete<SkMasks> masks(SkMasks::CreateMasks(inputMasks, bitsPerPixel));
+                std::unique_ptr<SkMasks> masks(SkMasks::CreateMasks(inputMasks, bitsPerPixel));
                 if (nullptr == masks) {
                     SkCodecPrintf("Error: invalid input masks.\n");
                     return false;
@@ -569,7 +569,7 @@ bool SkBmpCodec::ReadHeader(SkStream* stream, bool inIco, SkCodec** codecOut) {
  * Reads enough of the stream to determine the image format
  */
 SkCodec* SkBmpCodec::NewFromStream(SkStream* stream, bool inIco) {
-    SkAutoTDelete<SkStream> streamDeleter(stream);
+    std::unique_ptr<SkStream> streamDeleter(stream);
     SkCodec* codec = nullptr;
     if (ReadHeader(stream, inIco, &codec)) {
         // codec has taken ownership of stream, so we do not need to
index 5b28252..a5705ee 100644 (file)
@@ -60,7 +60,7 @@ SkCodec::Result SkBmpMaskCodec::onGetPixels(const SkImageInfo& dstInfo,
 SkCodec::Result SkBmpMaskCodec::prepareToDecode(const SkImageInfo& dstInfo,
         const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputColorCount) {
     // Initialize the mask swizzler
-    fMaskSwizzler.reset(SkMaskSwizzler::CreateMaskSwizzler(dstInfo, this->getInfo(), fMasks,
+    fMaskSwizzler.reset(SkMaskSwizzler::CreateMaskSwizzler(dstInfo, this->getInfo(), fMasks.get(),
             this->bitsPerPixel(), options));
     SkASSERT(fMaskSwizzler);
 
index 4cfd4d2..a1927f8 100644 (file)
@@ -46,15 +46,15 @@ private:
 
     SkSampler* getSampler(bool createIfNecessary) override {
         SkASSERT(fMaskSwizzler);
-        return fMaskSwizzler;
+        return fMaskSwizzler.get();
     }
 
     int decodeRows(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes,
             const Options& opts) override;
 
-    SkAutoTDelete<SkMasks>              fMasks;        // owned
-    SkAutoTDelete<SkMaskSwizzler>       fMaskSwizzler;
-    std::unique_ptr<uint8_t[]>          fSrcBuffer;
+    std::unique_ptr<SkMasks>        fMasks;
+    std::unique_ptr<SkMaskSwizzler> fMaskSwizzler;
+    std::unique_ptr<uint8_t[]>      fSrcBuffer;
 
     typedef SkBmpCodec INHERITED;
 };
index 33ba851..6e7bac9 100644 (file)
@@ -548,7 +548,7 @@ SkSampler* SkBmpRLECodec::getSampler(bool /*createIfNecessary*/) {
         fSampler.reset(new SkBmpRLESampler(this));
     }
 
-    return fSampler;
+    return fSampler.get();
 }
 
 int SkBmpRLECodec::setSampleX(int sampleX){
index 1291e9f..ff1a274 100644 (file)
@@ -104,7 +104,7 @@ private:
     const size_t                        fOrigRLEBytes;
     uint32_t                            fCurrRLEByte;
     int                                 fSampleX;
-    SkAutoTDelete<SkSampler>            fSampler;
+    std::unique_ptr<SkSampler>          fSampler;
 
     // Scanline decodes allow the client to ask for a single scanline at a time.
     // This can be tricky when the RLE encoding instructs the decoder to jump down
index edb88ac..20665db 100644 (file)
@@ -61,7 +61,7 @@ protected:
 
     SkSampler* getSampler(bool createIfNecessary) override {
         SkASSERT(fSwizzler);
-        return fSwizzler;
+        return fSwizzler.get();
     }
 
 private:
@@ -89,7 +89,7 @@ private:
     const uint32_t                      fNumColors;
     const uint32_t                      fBytesPerColor;
     const uint32_t                      fOffset;
-    SkAutoTDelete<SkSwizzler>           fSwizzler;
+    std::unique_ptr<SkSwizzler>         fSwizzler;
     std::unique_ptr<uint8_t[]>          fSrcBuffer;
     const bool                          fIsOpaque;
     const bool                          fInIco;
index 31323f0..2673d2e 100644 (file)
@@ -53,7 +53,7 @@ SkCodec* SkCodec::NewFromStream(SkStream* stream,
         return nullptr;
     }
 
-    SkAutoTDelete<SkStream> streamDeleter(stream);
+    std::unique_ptr<SkStream> streamDeleter(stream);
 
     // 14 is enough to read all of the supported types.
     const size_t bytesToRead = 14;
index 22a39aa..3abc908 100644 (file)
@@ -36,7 +36,7 @@ private:
      */
     SkCodecImageGenerator(SkCodec* codec, sk_sp<SkData>);
 
-    SkAutoTDelete<SkCodec> fCodec;
+    std::unique_ptr<SkCodec> fCodec;
     sk_sp<SkData> fData;
 
     typedef SkImageGenerator INHERITED;
index e4fce4c..b5e399d 100644 (file)
@@ -33,7 +33,7 @@ bool SkIcoCodec::IsIco(const void* buffer, size_t bytesRead) {
  */
 SkCodec* SkIcoCodec::NewFromStream(SkStream* stream) {
     // Ensure that we do not leak the input stream
-    SkAutoTDelete<SkStream> inputStream(stream);
+    std::unique_ptr<SkStream> inputStream(stream);
 
     // Header size constants
     static const uint32_t kIcoDirectoryBytes = 6;
@@ -107,8 +107,8 @@ SkCodec* SkIcoCodec::NewFromStream(SkStream* stream) {
 
     // Now will construct a candidate codec for each of the embedded images
     uint32_t bytesRead = kIcoDirectoryBytes + numImages * kIcoDirEntryBytes;
-    SkAutoTDelete<SkTArray<SkAutoTDelete<SkCodec>, true>> codecs(
-            new (SkTArray<SkAutoTDelete<SkCodec>, true>)(numImages));
+    std::unique_ptr<SkTArray<std::unique_ptr<SkCodec>, true>> codecs(
+            new (SkTArray<std::unique_ptr<SkCodec>, true>)(numImages));
     for (uint32_t i = 0; i < numImages; i++) {
         uint32_t offset = directoryEntries.get()[i].offset;
         uint32_t size = directoryEntries.get()[i].size;
@@ -133,7 +133,7 @@ SkCodec* SkIcoCodec::NewFromStream(SkStream* stream) {
             SkCodecPrintf("Warning: could not create embedded stream.\n");
             break;
         }
-        SkAutoTDelete<SkMemoryStream> embeddedStream(new SkMemoryStream(data));
+        std::unique_ptr<SkMemoryStream> embeddedStream(new SkMemoryStream(data));
         bytesRead += size;
 
         // Check if the embedded codec is bmp or png and create the codec
@@ -183,7 +183,7 @@ SkCodec* SkIcoCodec::NewFromStream(SkStream* stream) {
  * Called only by NewFromStream
  */
 SkIcoCodec::SkIcoCodec(int width, int height, const SkEncodedInfo& info,
-                       SkTArray<SkAutoTDelete<SkCodec>, true>* codecs,
+                       SkTArray<std::unique_ptr<SkCodec>, true>* codecs,
                        sk_sp<SkColorSpace> colorSpace)
     : INHERITED(width, height, info, nullptr, std::move(colorSpace))
     , fEmbeddedCodecs(codecs)
@@ -255,10 +255,8 @@ SkCodec::Result SkIcoCodec::onGetPixels(const SkImageInfo& dstInfo,
             break;
         }
 
-        SkCodec* embeddedCodec = fEmbeddedCodecs->operator[](index);
-        result = embeddedCodec->getPixels(dstInfo, dst, dstRowBytes, &opts, colorTable,
-                colorCount);
-
+        SkCodec* embeddedCodec = fEmbeddedCodecs->operator[](index).get();
+        result = embeddedCodec->getPixels(dstInfo, dst, dstRowBytes, &opts, colorTable, colorCount);
         switch (result) {
             case kSuccess:
             case kIncompleteInput:
@@ -288,7 +286,7 @@ SkCodec::Result SkIcoCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
             break;
         }
 
-        SkCodec* embeddedCodec = fEmbeddedCodecs->operator[](index);
+        SkCodec* embeddedCodec = fEmbeddedCodecs->operator[](index).get();
         result = embeddedCodec->startScanlineDecode(dstInfo, &options, colorTable, colorCount);
         if (kSuccess == result) {
             fCurrScanlineCodec = embeddedCodec;
@@ -323,7 +321,7 @@ SkCodec::Result SkIcoCodec::onStartIncrementalDecode(const SkImageInfo& dstInfo,
             break;
         }
 
-        SkCodec* embeddedCodec = fEmbeddedCodecs->operator[](index);
+        SkCodec* embeddedCodec = fEmbeddedCodecs->operator[](index).get();
         switch (embeddedCodec->startIncrementalDecode(dstInfo,
                 pixels, rowBytes, &options, colorTable, colorCount)) {
             case kSuccess:
index b9ed823..0c4e504 100644 (file)
@@ -77,16 +77,16 @@ private:
      * @param embeddedCodecs codecs for the embedded images, takes ownership
      */
     SkIcoCodec(int width, int height, const SkEncodedInfo& info,
-            SkTArray<SkAutoTDelete<SkCodec>, true>* embeddedCodecs, sk_sp<SkColorSpace> colorSpace);
+            SkTArray<std::unique_ptr<SkCodec>, true>* embeddedCodecs, sk_sp<SkColorSpace> colorSpace);
 
-    SkAutoTDelete<SkTArray<SkAutoTDelete<SkCodec>, true>> fEmbeddedCodecs; // owned
+    std::unique_ptr<SkTArray<std::unique_ptr<SkCodec>, true>> fEmbeddedCodecs;
 
     // Only used by the scanline decoder.  onStartScanlineDecode() will set
     // fCurrScanlineCodec to one of the fEmbeddedCodecs, if it can find a
     // codec of the appropriate size.  We will use fCurrScanlineCodec for
     // subsequent calls to onGetScanlines() or onSkipScanlines().
     // fCurrScanlineCodec is owned by this class, but should not be an
-    // SkAutoTDelete.  It will be deleted by the destructor of fEmbeddedCodecs.
+    // std::unique_ptr.  It will be deleted by the destructor of fEmbeddedCodecs.
     SkCodec* fCurrScanlineCodec;
 
     // Only used by incremental decoder.  onStartIncrementalDecode() will set
@@ -94,7 +94,7 @@ private:
     // codec of the appropriate size.  We will use fCurrIncrementalCodec for
     // subsequent calls to incrementalDecode().
     // fCurrIncrementalCodec is owned by this class, but should not be an
-    // SkAutoTDelete.  It will be deleted by the destructor of fEmbeddedCodecs.
+    // std::unique_ptr.  It will be deleted by the destructor of fEmbeddedCodecs.
     SkCodec* fCurrIncrementalCodec;
 
     typedef SkCodec INHERITED;
index 1c8ace5..e762483 100644 (file)
@@ -192,7 +192,7 @@ bool SkJpegCodec::ReadHeader(SkStream* stream, SkCodec** codecOut,
         JpegDecoderMgr** decoderMgrOut) {
 
     // Create a JpegDecoderMgr to own all of the decompress information
-    SkAutoTDelete<JpegDecoderMgr> decoderMgr(new JpegDecoderMgr(stream));
+    std::unique_ptr<JpegDecoderMgr> decoderMgr(new JpegDecoderMgr(stream));
 
     // libjpeg errors will be caught and reported here
     if (setjmp(decoderMgr->getJmpBuf())) {
@@ -251,7 +251,7 @@ bool SkJpegCodec::ReadHeader(SkStream* stream, SkCodec** codecOut,
 }
 
 SkCodec* SkJpegCodec::NewFromStream(SkStream* stream) {
-    SkAutoTDelete<SkStream> streamDeleter(stream);
+    std::unique_ptr<SkStream> streamDeleter(stream);
     SkCodec* codec = nullptr;
     if (ReadHeader(stream,  &codec, nullptr)) {
         // Codec has taken ownership of the stream, we do not need to delete it
@@ -635,12 +635,12 @@ void SkJpegCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options&
 SkSampler* SkJpegCodec::getSampler(bool createIfNecessary) {
     if (!createIfNecessary || fSwizzler) {
         SkASSERT(!fSwizzler || (fSwizzleSrcRow && fStorage.get() == fSwizzleSrcRow));
-        return fSwizzler;
+        return fSwizzler.get();
     }
 
     this->initializeSwizzler(this->dstInfo(), this->options());
     this->allocateStorage(this->dstInfo());
-    return fSwizzler;
+    return fSwizzler.get();
 }
 
 SkCodec::Result SkJpegCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
index a889a4a..9e08c86 100644 (file)
@@ -116,7 +116,7 @@ private:
     int onGetScanlines(void* dst, int count, size_t rowBytes) override;
     bool onSkipScanlines(int count) override;
 
-    SkAutoTDelete<JpegDecoderMgr>      fDecoderMgr;
+    std::unique_ptr<JpegDecoderMgr>    fDecoderMgr;
 
     // We will save the state of the decompress struct after reading the header.
     // This allows us to safely call onGetScaledDimensions() at any time.
@@ -132,7 +132,7 @@ private:
     // to further subset the output from libjpeg-turbo.
     SkIRect                            fSwizzlerSubset;
 
-    SkAutoTDelete<SkSwizzler>          fSwizzler;
+    std::unique_ptr<SkSwizzler>        fSwizzler;
 
     typedef SkCodec INHERITED;
 };
index ae11048..da6e062 100644 (file)
@@ -1144,11 +1144,11 @@ void SkPngCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& o
 
 SkSampler* SkPngCodec::getSampler(bool createIfNecessary) {
     if (fSwizzler || !createIfNecessary) {
-        return fSwizzler;
+        return fSwizzler.get();
     }
 
     this->initializeSwizzler(this->dstInfo(), this->options());
-    return fSwizzler;
+    return fSwizzler.get();
 }
 
 bool SkPngCodec::onRewind() {
@@ -1249,7 +1249,7 @@ uint64_t SkPngCodec::onGetFillValue(const SkImageInfo& dstInfo) const {
 }
 
 SkCodec* SkPngCodec::NewFromStream(SkStream* stream, SkPngChunkReader* chunkReader) {
-    SkAutoTDelete<SkStream> streamDeleter(stream);
+    std::unique_ptr<SkStream> streamDeleter(stream);
 
     SkCodec* outCodec = nullptr;
     if (read_header(streamDeleter.get(), chunkReader, &outCodec, nullptr, nullptr)) {
index c10f174..2c427ca 100644 (file)
@@ -61,7 +61,7 @@ protected:
     voidp png_ptr() { return fPng_ptr; }
     voidp info_ptr() { return fInfo_ptr; }
 
-    SkSwizzler* swizzler() { return fSwizzler; }
+    SkSwizzler* swizzler() { return fSwizzler.get(); }
 
     // Initialize variables used by applyXformRow.
     void initializeXformParams();
@@ -97,7 +97,7 @@ protected:
 
     // These are stored here so they can be used both by normal decoding and scanline decoding.
     SkAutoTUnref<SkColorTable>         fColorTable;    // May be unpremul.
-    SkAutoTDelete<SkSwizzler>          fSwizzler;
+    std::unique_ptr<SkSwizzler>        fSwizzler;
     SkAutoTMalloc<uint8_t>             fStorage;
     uint32_t*                          fColorXformSrcRow;
     const int                          fBitDepth;
index 5ae44d1..26519e6 100644 (file)
@@ -322,7 +322,7 @@ private:
         return fStreamBuffer.write(tempBuffer.get(), bytesRead);
     }
 
-    SkAutoTDelete<SkStream> fStream;
+    std::unique_ptr<SkStream> fStream;
     bool fWholeStreamRead;
 
     // Use a size-limited stream to avoid holding too huge buffer.
@@ -396,7 +396,7 @@ public:
         }
     }
 private:
-    SkAutoTDelete<SkStream> fStream;
+    std::unique_ptr<SkStream> fStream;
 };
 
 class SkPiexStream : public ::piex::StreamInterface {
@@ -446,7 +446,7 @@ public:
      * Note: this will take the ownership of the stream.
      */
     static SkDngImage* NewFromStream(SkRawStream* stream) {
-        SkAutoTDelete<SkDngImage> dngImage(new SkDngImage(stream));
+        std::unique_ptr<SkDngImage> dngImage(new SkDngImage(stream));
         if (!dngImage->isTiffHeaderValid()) {
             return nullptr;
         }
@@ -479,10 +479,10 @@ public:
         const int preferredSize = SkTMax(width, height);
         try {
             // render() takes ownership of fHost, fInfo, fNegative and fDngStream when available.
-            SkAutoTDelete<dng_host> host(fHost.release());
-            SkAutoTDelete<dng_info> info(fInfo.release());
-            SkAutoTDelete<dng_negative> negative(fNegative.release());
-            SkAutoTDelete<dng_stream> dngStream(fDngStream.release());
+            std::unique_ptr<dng_host> host(fHost.release());
+            std::unique_ptr<dng_info> info(fInfo.release());
+            std::unique_ptr<dng_negative> negative(fNegative.release());
+            std::unique_ptr<dng_stream> dngStream(fDngStream.release());
 
             host->SetPreferredSize(preferredSize);
             host->ValidateSizes();
@@ -588,7 +588,7 @@ private:
             // Due to the limit of DNG SDK, we need to reset host and info.
             fHost.reset(new SkDngHost(&fAllocator));
             fInfo.reset(new dng_info);
-            fDngStream.reset(new SkDngStream(fStream));
+            fDngStream.reset(new SkDngStream(fStream.get()));
 
             fHost->ValidateSizes();
             fInfo->Parse(*fHost, *fDngStream);
@@ -622,11 +622,11 @@ private:
     {}
 
     SkDngMemoryAllocator fAllocator;
-    SkAutoTDelete<SkRawStream> fStream;
-    SkAutoTDelete<dng_host> fHost;
-    SkAutoTDelete<dng_info> fInfo;
-    SkAutoTDelete<dng_negative> fNegative;
-    SkAutoTDelete<dng_stream> fDngStream;
+    std::unique_ptr<SkRawStream> fStream;
+    std::unique_ptr<dng_host> fHost;
+    std::unique_ptr<dng_info> fInfo;
+    std::unique_ptr<dng_negative> fNegative;
+    std::unique_ptr<dng_stream> fDngStream;
 
     int fWidth;
     int fHeight;
@@ -641,7 +641,7 @@ private:
  * fallback to create SkRawCodec for DNG images.
  */
 SkCodec* SkRawCodec::NewFromStream(SkStream* stream) {
-    SkAutoTDelete<SkRawStream> rawStream;
+    std::unique_ptr<SkRawStream> rawStream;
     if (is_asset_stream(*stream)) {
         rawStream.reset(new SkRawAssetStream(stream));
     } else {
@@ -671,7 +671,7 @@ SkCodec* SkRawCodec::NewFromStream(SkStream* stream) {
     }
 
     // Takes the ownership of the rawStream.
-    SkAutoTDelete<SkDngImage> dngImage(SkDngImage::NewFromStream(rawStream.release()));
+    std::unique_ptr<SkDngImage> dngImage(SkDngImage::NewFromStream(rawStream.release()));
     if (!dngImage) {
         return nullptr;
     }
@@ -688,13 +688,13 @@ SkCodec::Result SkRawCodec::onGetPixels(const SkImageInfo& requestedInfo, void*
         return kInvalidConversion;
     }
 
-    SkAutoTDelete<SkSwizzler> swizzler(SkSwizzler::CreateSwizzler(
+    std::unique_ptr<SkSwizzler> swizzler(SkSwizzler::CreateSwizzler(
             this->getEncodedInfo(), nullptr, requestedInfo, options));
     SkASSERT(swizzler);
 
     const int width = requestedInfo.width();
     const int height = requestedInfo.height();
-    SkAutoTDelete<dng_image> image(fDngImage->render(width, height));
+    std::unique_ptr<dng_image> image(fDngImage->render(width, height));
     if (!image) {
         return kInvalidInput;
     }
index 3ca7b9c..75654c7 100644 (file)
@@ -53,7 +53,7 @@ private:
      */
     SkRawCodec(SkDngImage* dngImage);
 
-    SkAutoTDelete<SkDngImage> fDngImage;
+    std::unique_ptr<SkDngImage> fDngImage;
 
     typedef SkCodec INHERITED;
 };
index 45296d8..4102bf2 100644 (file)
@@ -136,7 +136,7 @@ SkCodec::Result SkWbmpCodec::onGetPixels(const SkImageInfo& info,
     setup_color_table(info.colorType(), ctable, ctableCount);
 
     // Initialize the swizzler
-    SkAutoTDelete<SkSwizzler> swizzler(this->initializeSwizzler(info, ctable, options));
+    std::unique_ptr<SkSwizzler> swizzler(this->initializeSwizzler(info, ctable, options));
     SkASSERT(swizzler);
 
     // Perform the decode
@@ -160,7 +160,7 @@ bool SkWbmpCodec::IsWbmp(const void* buffer, size_t bytesRead) {
 }
 
 SkCodec* SkWbmpCodec::NewFromStream(SkStream* stream) {
-    SkAutoTDelete<SkStream> streamDeleter(stream);
+    std::unique_ptr<SkStream> streamDeleter(stream);
     SkISize size;
     if (!read_header(stream, &size)) {
         return nullptr;
index 9f29237..3c8df02 100644 (file)
@@ -36,7 +36,7 @@ private:
                                    const Options& opts);
     SkSampler* getSampler(bool createIfNecessary) override {
         SkASSERT(fSwizzler || !createIfNecessary);
-        return fSwizzler;
+        return fSwizzler.get();
     }
 
     /*
@@ -49,7 +49,7 @@ private:
     const size_t                 fSrcRowBytes;
 
     // Used for scanline decodes:
-    SkAutoTDelete<SkSwizzler>    fSwizzler;
+    std::unique_ptr<SkSwizzler>  fSwizzler;
     SkAutoTUnref<SkColorTable>   fColorTable;
     SkAutoTMalloc<uint8_t>       fSrcBuffer;
 
index ca42093..09913c7 100644 (file)
@@ -36,7 +36,7 @@ bool SkWebpCodec::IsWebp(const void* buf, size_t bytesRead) {
 // bytes again.
 // Returns an SkWebpCodec on success;
 SkCodec* SkWebpCodec::NewFromStream(SkStream* stream) {
-    SkAutoTDelete<SkStream> streamDeleter(stream);
+    std::unique_ptr<SkStream> streamDeleter(stream);
 
     // Webp demux needs a contiguous data buffer.
     sk_sp<SkData> data = nullptr;
index c5dfda9..3dde147 100644 (file)
@@ -77,7 +77,7 @@ private:
     mutable SkOnce                        fAnalysisOnce;
     mutable Analysis                      fAnalysis;
     SkAutoTUnref<const SkRecord>          fRecord;
-    SkAutoTDelete<const SnapshotArray>    fDrawablePicts;
+    std::unique_ptr<const SnapshotArray>  fDrawablePicts;
     SkAutoTUnref<const SkBBoxHierarchy>   fBBH;
 };
 
index 296b31c..9710346 100644 (file)
@@ -101,8 +101,8 @@ SkColorTable* SkColorTable::Create(SkReadBuffer& buffer) {
     }
 
     const size_t allocSize = count * sizeof(SkPMColor);
-    SkAutoTDelete<SkPMColor> colors((SkPMColor*)sk_malloc_throw(allocSize));
-    if (!buffer.readColorArray(colors, count)) {
+    std::unique_ptr<SkPMColor> colors((SkPMColor*)sk_malloc_throw(allocSize));
+    if (!buffer.readColorArray(colors.get(), count)) {
         return nullptr;
     }
 
index 04f1251..a72309a 100644 (file)
@@ -2047,10 +2047,10 @@ void SkPaint::toString(SkString* str) const {
     if (typeface) {
         SkDynamicMemoryWStream ostream;
         typeface->serialize(&ostream);
-        SkAutoTDelete<SkStreamAsset> istream(ostream.detachAsStream());
+        std::unique_ptr<SkStreamAsset> istream(ostream.detachAsStream());
 
         SkFontDescriptor descriptor;
-        if (!SkFontDescriptor::Deserialize(istream, &descriptor)) {
+        if (!SkFontDescriptor::Deserialize(istream.get(), &descriptor)) {
             str->append("<dt>FontDescriptor deserialization failed</dt>");
         } else {
             str->append("<dt>Font Family Name:</dt><dd>");
index ae3b704..039efc8 100644 (file)
@@ -171,9 +171,9 @@ sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream, SkImageDeserializer
     if (!InternalOnly_StreamIsSKP(stream, &info) || !stream->readBool()) {
         return nullptr;
     }
-    SkAutoTDelete<SkPictureData> data(
+    std::unique_ptr<SkPictureData> data(
             SkPictureData::CreateFromStream(stream, info, factory, typefaces));
-    return Forwardport(info, data, nullptr);
+    return Forwardport(info, data.get(), nullptr);
 }
 
 sk_sp<SkPicture> SkPicture::MakeFromBuffer(SkReadBuffer& buffer) {
@@ -181,8 +181,8 @@ sk_sp<SkPicture> SkPicture::MakeFromBuffer(SkReadBuffer& buffer) {
     if (!InternalOnly_BufferIsSKP(&buffer, &info) || !buffer.readBool()) {
         return nullptr;
     }
-    SkAutoTDelete<SkPictureData> data(SkPictureData::CreateFromBuffer(buffer, info));
-    return Forwardport(info, data, &buffer);
+    std::unique_ptr<SkPictureData> data(SkPictureData::CreateFromBuffer(buffer, info));
+    return Forwardport(info, data.get(), &buffer);
 }
 
 SkPictureData* SkPicture::backport() const {
@@ -208,7 +208,7 @@ void SkPicture::serialize(SkWStream* stream,
                           SkPixelSerializer* pixelSerializer,
                           SkRefCntSet* typefaceSet) const {
     SkPictInfo info = this->createHeader();
-    SkAutoTDelete<SkPictureData> data(this->backport());
+    std::unique_ptr<SkPictureData> data(this->backport());
 
     stream->write(&info, sizeof(info));
     if (data) {
@@ -221,7 +221,7 @@ void SkPicture::serialize(SkWStream* stream,
 
 void SkPicture::flatten(SkWriteBuffer& buffer) const {
     SkPictInfo info = this->createHeader();
-    SkAutoTDelete<SkPictureData> data(this->backport());
+    std::unique_ptr<SkPictureData> data(this->backport());
 
     buffer.writeByteArray(&info.fMagic, sizeof(info.fMagic));
     buffer.writeUInt(info.getVersion());
index cc529e3..5f9cb71 100644 (file)
@@ -577,7 +577,7 @@ SkPictureData* SkPictureData::CreateFromStream(SkStream* stream,
                                                const SkPictInfo& info,
                                                SkImageDeserializer* factory,
                                                SkTypefacePlayback* topLevelTFPlayback) {
-    SkAutoTDelete<SkPictureData> data(new SkPictureData(info));
+    std::unique_ptr<SkPictureData> data(new SkPictureData(info));
     if (!topLevelTFPlayback) {
         topLevelTFPlayback = &data->fTFPlayback;
     }
@@ -590,7 +590,7 @@ SkPictureData* SkPictureData::CreateFromStream(SkStream* stream,
 
 SkPictureData* SkPictureData::CreateFromBuffer(SkReadBuffer& buffer,
                                                const SkPictInfo& info) {
-    SkAutoTDelete<SkPictureData> data(new SkPictureData(info));
+    std::unique_ptr<SkPictureData> data(new SkPictureData(info));
     buffer.setVersion(info.getVersion());
 
     if (!data->parseBuffer(buffer)) {
index 51e1c98..0b3dd0e 100644 (file)
@@ -86,7 +86,7 @@ void SkPicturePlayback::draw(SkCanvas* canvas,
     AutoResetOpID aroi(this);
     SkASSERT(0 == fCurOffset);
 
-    SkAutoTDelete<SkReadBuffer> reader;
+    std::unique_ptr<SkReadBuffer> reader;
     if (buffer) {
         reader.reset(buffer->clone(fPictureData->opData()->bytes(),
                                    fPictureData->opData()->size()));
@@ -107,12 +107,12 @@ void SkPicturePlayback::draw(SkCanvas* canvas,
 
         fCurOffset = reader->offset();
         uint32_t size;
-        DrawType op = ReadOpAndSize(reader, &size);
+        DrawType op = ReadOpAndSize(reader.get(), &size);
         if (!reader->validate(op > UNUSED && op <= LAST_DRAWTYPE_ENUM)) {
             return;
         }
 
-        this->handleOp(reader, op, size, canvas, initialMatrix);
+        this->handleOp(reader.get(), op, size, canvas, initialMatrix);
     }
 
     // need to propagate invalid state to the parent reader
index 62a9339..3e31166 100644 (file)
@@ -81,13 +81,13 @@ sk_sp<SkFlattenable> SkRecordedDrawable::CreateProc(SkReadBuffer& buffer) {
     info.setVersion(buffer.getVersion());
     info.fCullRect = bounds;
     info.fFlags = 0;    // ???
-    SkAutoTDelete<SkPictureData> pictureData(SkPictureData::CreateFromBuffer(buffer, info));
+    std::unique_ptr<SkPictureData> pictureData(SkPictureData::CreateFromBuffer(buffer, info));
     if (!pictureData) {
         return nullptr;
     }
 
     // Create a drawable.
-    SkPicturePlayback playback(pictureData);
+    SkPicturePlayback playback(pictureData.get());
     SkPictureRecorder recorder;
     playback.draw(recorder.beginRecording(bounds), nullptr, &buffer);
     return recorder.finishRecordingAsDrawable();
index fc2ba12..41d1a86 100644 (file)
@@ -233,7 +233,7 @@ SkStreamAsset* SkFILEStream::duplicate() const {
     }
 
     if (!fName.isEmpty()) {
-        SkAutoTDelete<SkFILEStream> that(new SkFILEStream(fName.c_str()));
+        std::unique_ptr<SkFILEStream> that(new SkFILEStream(fName.c_str()));
         if (sk_fidentical(that->fFILE, this->fFILE)) {
             return that.release();
         }
@@ -259,7 +259,7 @@ bool SkFILEStream::move(long offset) {
 }
 
 SkStreamAsset* SkFILEStream::fork() const {
-    SkAutoTDelete<SkStreamAsset> that(this->duplicate());
+    std::unique_ptr<SkStreamAsset> that(this->duplicate());
     that->seek(this->getPosition());
     return that.release();
 }
@@ -381,7 +381,7 @@ bool SkMemoryStream::move(long offset) {
 }
 
 SkMemoryStream* SkMemoryStream::fork() const {
-    SkAutoTDelete<SkMemoryStream> that(this->duplicate());
+    std::unique_ptr<SkMemoryStream> that(this->duplicate());
     that->seek(fOffset);
     return that.release();
 }
@@ -767,7 +767,7 @@ public:
     }
 
     SkBlockMemoryStream* fork() const override {
-        SkAutoTDelete<SkBlockMemoryStream> that(this->duplicate());
+        std::unique_ptr<SkBlockMemoryStream> that(this->duplicate());
         that->fCurrent = this->fCurrent;
         that->fOffset = this->fOffset;
         that->fCurrentOffset = this->fCurrentOffset;
index 070c0aa..41447ac 100644 (file)
@@ -123,14 +123,14 @@ SkTypeface* SkFontMgr_Indirect::createTypefaceFromFontId(const SkFontIdentity& i
 
     // No exact match, but did find a data match.
     if (dataTypeface.get() != nullptr) {
-        SkAutoTDelete<SkStreamAsset> stream(dataTypeface->openStream(nullptr));
+        std::unique_ptr<SkStreamAsset> stream(dataTypeface->openStream(nullptr));
         if (stream.get() != nullptr) {
             return fImpl->createFromStream(stream.release(), dataTypefaceIndex);
         }
     }
 
     // No data match, request data and add entry.
-    SkAutoTDelete<SkStreamAsset> stream(fProxy->getData(id.fDataId));
+    std::unique_ptr<SkStreamAsset> stream(fProxy->getData(id.fDataId));
     if (stream.get() == nullptr) {
         return nullptr;
     }
index 3945fe5..fa275d2 100644 (file)
@@ -103,7 +103,7 @@ private:
     bool                              fAbandoned;
     SkTDArray<GrOpList*>              fOpLists;
 
-    SkAutoTDelete<GrAtlasTextContext> fAtlasTextContext;
+    std::unique_ptr<GrAtlasTextContext> fAtlasTextContext;
 
     GrPathRendererChain*              fPathRendererChain;
     GrSoftwarePathRenderer*           fSoftwarePathRenderer;
index 475950a..9a74560 100644 (file)
@@ -513,10 +513,10 @@ protected:
     // Handles cases where a surface will be updated without a call to flushRenderTarget
     void didWriteToSurface(GrSurface* surface, const SkIRect* bounds, uint32_t mipLevels = 1) const;
 
-    Stats                                   fStats;
-    SkAutoTDelete<GrPathRendering>          fPathRendering;
+    Stats                            fStats;
+    std::unique_ptr<GrPathRendering> fPathRendering;
     // Subclass must initialize this in its constructor.
-    SkAutoTUnref<const GrCaps>    fCaps;
+    SkAutoTUnref<const GrCaps>       fCaps;
 
     typedef SkTArray<SkPoint, true> SamplePattern;
 
index a4353e1..1ad3a0b 100644 (file)
@@ -34,7 +34,7 @@ protected:
         : INHERITED(ctx, mgr, std::move(rtp), std::move(colorSpace), surfaceProps, at, so) {}
 
 private:
-    SkAutoTDelete<GrStencilAndCoverTextContext> fStencilAndCoverTextContext;
+    std::unique_ptr<GrStencilAndCoverTextContext> fStencilAndCoverTextContext;
 
     friend class GrDrawingManager; // for ctor
 
index 37c469a..b4e6870 100644 (file)
@@ -185,7 +185,7 @@ bool GrRenderTargetOpList::drawBatches(GrBatchFlushState* flushState) {
     // Draw all the generated geometry.
     SkRandom random;
     GrRenderTarget* currentRT = nullptr;
-    SkAutoTDelete<GrGpuCommandBuffer> commandBuffer;
+    std::unique_ptr<GrGpuCommandBuffer> commandBuffer;
     for (int i = 0; i < fRecordedBatches.count(); ++i) {
         if (!fRecordedBatches[i].fBatch) {
             continue;
@@ -205,7 +205,7 @@ bool GrRenderTargetOpList::drawBatches(GrBatchFlushState* flushState) {
                                                               kBasicLoadStoreInfo,   // Color
                                                               kBasicLoadStoreInfo)); // Stencil
             }
-            flushState->setCommandBuffer(commandBuffer);
+            flushState->setCommandBuffer(commandBuffer.get());
         }
         if (fDrawBatchBounds) {
             const SkRect& bounds = fRecordedBatches[i].fClippedBounds;
index e4b2bf6..62f86d1 100644 (file)
@@ -125,7 +125,7 @@ public:
 
     gr_instanced::InstancedRendering* instancedRendering() const {
         SkASSERT(fInstancedRendering);
-        return fInstancedRendering;
+        return fInstancedRendering.get();
     }
 
     SkDEBUGCODE(void dump() const override;)
@@ -167,7 +167,7 @@ private:
     int                                             fMaxBatchLookback;
     int                                             fMaxBatchLookahead;
 
-    SkAutoTDelete<gr_instanced::InstancedRendering> fInstancedRendering;
+    std::unique_ptr<gr_instanced::InstancedRendering> fInstancedRendering;
 
     int32_t                                         fLastClipStackGenID;
     SkIRect                                         fLastClipStackRect;
index d0a35b5..679ba8c 100644 (file)
@@ -378,7 +378,7 @@ GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b
         sk_throw();
     }
 
-    SkAutoTDelete<SkMipMap> mipmaps(SkMipMap::Build(pixmap, gammaTreatment, nullptr));
+    std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(pixmap, gammaTreatment, nullptr));
     if (!mipmaps) {
         return nullptr;
     }
index 34037a2..157f404 100644 (file)
@@ -136,8 +136,8 @@ protected:
     GrGLuint fProgramID;
 
     // the installed effects
-    SkAutoTDelete<GrGLSLPrimitiveProcessor> fGeometryProcessor;
-    SkAutoTDelete<GrGLSLXferProcessor> fXferProcessor;
+    std::unique_ptr<GrGLSLPrimitiveProcessor> fGeometryProcessor;
+    std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
     GrGLSLFragProcs fFragmentProcessors;
 
     GrProgramDesc fDesc;
index 475b020..bcf4864 100644 (file)
@@ -242,7 +242,7 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
                        inputs.attr(Attrib::kInstanceInfo));
     }
 
-    SkAutoTDelete<Backend> backend(Backend::Create(pipeline, ip.batchInfo(), inputs));
+    std::unique_ptr<Backend> backend(Backend::Create(pipeline, ip.batchInfo(), inputs));
     backend->init(varyingHandler, v);
 
     int usedShapeDefinitions = 0;
index 5aaf210..c8e2008 100644 (file)
@@ -490,7 +490,7 @@ private:
         // though the distance field text and the coloremoji may share the same run, they
         // will have different descriptors.  If fOverrideDescriptor is non-nullptr, then it
         // will be used in place of the run's descriptor to regen texture coords
-        SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; // df properties
+        std::unique_ptr<SkAutoDescriptor> fOverrideDescriptor; // df properties
         bool fInitialized;
         bool fDrawAsPaths;
     };
index 1d46fc6..b3a7eef 100644 (file)
@@ -351,7 +351,7 @@ private:
 
     void flush();
 
-    SkAutoTDelete<SkTextBlobBuilder>   fBuilder;
+    std::unique_ptr<SkTextBlobBuilder> fBuilder;
     SkPaint                            fFont;
     int                                fBuffIdx;
     int                                fCount;
index 6c395fd..2decd15 100644 (file)
@@ -37,10 +37,10 @@ public:
     void print(const char* sep = "\n") const;
 
 private:
-    SkAutoTDelete<SkTArray<SkString> >  fInstanceExtensionStrings;
-    SkAutoTDelete<SkTArray<SkString> >  fDeviceExtensionStrings;
-    SkAutoTDelete<SkTArray<SkString> >  fInstanceLayerStrings;
-    SkAutoTDelete<SkTArray<SkString> >  fDeviceLayerStrings;
+    std::unique_ptr<SkTArray<SkString>>  fInstanceExtensionStrings;
+    std::unique_ptr<SkTArray<SkString>>  fDeviceExtensionStrings;
+    std::unique_ptr<SkTArray<SkString>>  fInstanceLayerStrings;
+    std::unique_ptr<SkTArray<SkString>>  fDeviceLayerStrings;
 };
 
 #endif
index 6f03803..50f7471 100644 (file)
@@ -168,7 +168,7 @@ public:
     };
     static const int kHeapCount = kLastHeap + 1;
 
-    GrVkHeap* getHeap(Heap heap) const { return fHeaps[heap]; }
+    GrVkHeap* getHeap(Heap heap) const { return fHeaps[heap].get(); }
 
 private:
     GrVkGpu(GrContext* context, const GrContextOptions& options,
@@ -269,7 +269,7 @@ private:
     GrVkPrimaryCommandBuffer*              fCurrentCmdBuffer;
     VkPhysicalDeviceMemoryProperties       fPhysDevMemProps;
 
-    SkAutoTDelete<GrVkHeap>                fHeaps[kHeapCount];
+    std::unique_ptr<GrVkHeap>              fHeaps[kHeapCount];
 
     GrVkCopyManager                        fCopyManager;
 
index 2853c89..2764102 100644 (file)
@@ -561,7 +561,7 @@ bool GrVkHeap::subAlloc(VkDeviceSize size, VkDeviceSize alignment,
     }
 
     // need to allocate a new subheap
-    SkAutoTDelete<GrVkSubHeap>& subHeap = fSubHeaps.push_back();
+    std::unique_ptr<GrVkSubHeap>& subHeap = fSubHeaps.push_back();
     subHeap.reset(new GrVkSubHeap(fGpu, memoryTypeIndex, heapIndex, fSubHeapSize, alignment));
     // try to recover from failed allocation by only allocating what we need
     if (subHeap->size() == 0) {
@@ -609,7 +609,7 @@ bool GrVkHeap::singleAlloc(VkDeviceSize size, VkDeviceSize alignment,
     }
 
     // need to allocate a new subheap
-    SkAutoTDelete<GrVkSubHeap>& subHeap = fSubHeaps.push_back();
+    std::unique_ptr<GrVkSubHeap>& subHeap = fSubHeaps.push_back();
     subHeap.reset(new GrVkSubHeap(fGpu, memoryTypeIndex, heapIndex, alignedSize, alignment));
     fAllocSize += alignedSize;
     if (subHeap->alloc(size, alloc)) {
index a1d4392..77267ab 100644 (file)
@@ -162,6 +162,6 @@ private:
     VkDeviceSize           fAllocSize;
     VkDeviceSize           fUsedSize;
     AllocFunc              fAllocFunc;
-    SkTArray<SkAutoTDelete<GrVkSubHeap>> fSubHeaps;
+    SkTArray<std::unique_ptr<GrVkSubHeap>> fSubHeaps;
 };
 #endif
index abb95f6..ba4f95f 100644 (file)
@@ -226,8 +226,11 @@ void GrVkPipelineState::setData(GrVkGpu* gpu,
     }
 
     if (fVertexUniformBuffer.get() || fFragmentUniformBuffer.get()) {
-        if (fDataManager.uploadUniformBuffers(gpu, fVertexUniformBuffer, fFragmentUniformBuffer) ||
-            !fUniformDescriptorSet) {
+        if (fDataManager.uploadUniformBuffers(gpu,
+                                              fVertexUniformBuffer.get(),
+                                              fFragmentUniformBuffer.get())
+            || !fUniformDescriptorSet)
+        {
             if (fUniformDescriptorSet) {
                 fUniformDescriptorSet->recycle(gpu);
             }
index ba8a21f..63277c0 100644 (file)
@@ -208,8 +208,8 @@ private:
     int fStartDS;
     int fDSCount;
 
-    SkAutoTDelete<GrVkUniformBuffer> fVertexUniformBuffer;
-    SkAutoTDelete<GrVkUniformBuffer> fFragmentUniformBuffer;
+    std::unique_ptr<GrVkUniformBuffer> fVertexUniformBuffer;
+    std::unique_ptr<GrVkUniformBuffer> fFragmentUniformBuffer;
 
     // GrVkResources used for sampling textures
     SkTDArray<GrVkSampler*> fSamplers;
@@ -221,8 +221,8 @@ private:
     BuiltinUniformHandles fBuiltinUniformHandles;
 
     // Processors in the GrVkPipelineState
-    SkAutoTDelete<GrGLSLPrimitiveProcessor> fGeometryProcessor;
-    SkAutoTDelete<GrGLSLXferProcessor> fXferProcessor;
+    std::unique_ptr<GrGLSLPrimitiveProcessor> fGeometryProcessor;
+    std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
     GrGLSLFragProcs fFragmentProcessors;
 
     Desc fDesc;
index d80b187..e993002 100644 (file)
@@ -616,7 +616,7 @@ size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox
         static_assert(std::is_standard_layout<MipMapLevelData>::value,
                       "offsetof, which we use below, requires the type have a standard layout");
 
-        SkAutoTDelete<SkMipMap> mipmaps(SkMipMap::Build(pixmap, gammaTreatment, nullptr));
+        std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(pixmap, gammaTreatment, nullptr));
         // SkMipMap holds only the mipmap levels it generates.
         // A programmer can use the data they provided to SkMipMap::Build as level 0.
         // So the SkMipMap provides levels 1-x but it stores them in its own
index 023885f..787ff8e 100644 (file)
@@ -38,18 +38,18 @@ SkData* SkImageEncoder::encodeData(const SkBitmap& bm, int quality) {
 
 bool SkImageEncoder::EncodeFile(const char file[], const SkBitmap& bm, Type t,
                                 int quality) {
-    SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t));
+    std::unique_ptr<SkImageEncoder> enc(SkImageEncoder::Create(t));
     return enc.get() && enc.get()->encodeFile(file, bm, quality);
 }
 
 bool SkImageEncoder::EncodeStream(SkWStream* stream, const SkBitmap& bm, Type t,
                                   int quality) {
-    SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t));
+    std::unique_ptr<SkImageEncoder> enc(SkImageEncoder::Create(t));
     return enc.get() && enc.get()->encodeStream(stream, bm, quality);
 }
 
 SkData* SkImageEncoder::EncodeData(const SkBitmap& bm, Type t, int quality) {
-    SkAutoTDelete<SkImageEncoder> enc(SkImageEncoder::Create(t));
+    std::unique_ptr<SkImageEncoder> enc(SkImageEncoder::Create(t));
     return enc.get() ? enc.get()->encodeData(bm, quality) : nullptr;
 }
 
index 19eff6f..83fbd1d 100644 (file)
@@ -2454,8 +2454,8 @@ protected:
     }
 
     SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) const override {
-        SkAutoTDelete<SkStreamAsset> stream(bareStream);
-        return create_from_stream(stream);
+        std::unique_ptr<SkStreamAsset> stream(bareStream);
+        return create_from_stream(stream.get());
     }
 
     SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override {
index d4c7569..404ae98 100644 (file)
@@ -113,7 +113,7 @@ private:
         const char* getCategory() const override { return "request_cache"; }
         SkDiscardableMemory* diagnostic_only_getDiscardable() const override { return nullptr; }
 
-        SkAutoTDelete<Request> fRequest;
+        std::unique_ptr<Request> fRequest;
         SkAutoTUnref<SkTypeface> fFace;
     };
 
@@ -267,8 +267,8 @@ protected:
 
         // Check if this request is already in the request cache.
         using Request = SkFontRequestCache::Request;
-        SkAutoTDelete<Request> request(Request::Create(requestedFamilyName, requestedStyle));
-        SkTypeface* face = fCache.findAndRef(request);
+        std::unique_ptr<Request> request(Request::Create(requestedFamilyName, requestedStyle));
+        SkTypeface* face = fCache.findAndRef(request.get());
         if (face) {
             return face;
         }
index 306c6ff..e5fdcd0 100644 (file)
@@ -100,18 +100,18 @@ struct FamilyData {
         , fHandler(&topLevelHandler, 1)
     { }
 
-    XML_Parser fParser;                       // The expat parser doing the work, owned by caller
-    SkTDArray<FontFamily*>& fFamilies;        // The array to append families, owned by caller
-    SkAutoTDelete<FontFamily> fCurrentFamily; // The family being created, owned by this
-    FontFileInfo* fCurrentFontInfo;           // The fontInfo being created, owned by fCurrentFamily
-    int fVersion;                             // The version of the file parsed.
-    const SkString& fBasePath;                // The current base path.
-    const bool fIsFallback;                   // Indicates the file being parsed is a fallback file
-    const char* fFilename;                    // The name of the file currently being parsed.
-
-    int fDepth;                               // The current element depth of the parse.
-    int fSkip;                                // The depth to stop skipping, 0 if not skipping.
-    SkTDArray<const TagHandler*> fHandler;    // The stack of current tag handlers.
+    XML_Parser fParser;                         // The expat parser doing the work, owned by caller
+    SkTDArray<FontFamily*>& fFamilies;          // The array to append families, owned by caller
+    std::unique_ptr<FontFamily> fCurrentFamily; // The family being created, owned by this
+    FontFileInfo* fCurrentFontInfo;             // The info being created, owned by fCurrentFamily
+    int fVersion;                               // The version of the file parsed.
+    const SkString& fBasePath;                  // The current base path.
+    const bool fIsFallback;                     // The file being parsed is a fallback file
+    const char* fFilename;                      // The name of the file currently being parsed.
+
+    int fDepth;                                 // The current element depth of the parse.
+    int fSkip;                                  // The depth to stop skipping, 0 if not skipping.
+    SkTDArray<const TagHandler*> fHandler;      // The stack of current tag handlers.
 };
 
 static bool memeq(const char* s1, const char* s2, size_t n1, size_t n2) {
index 33ae767..cd0b665 100644 (file)
@@ -51,7 +51,7 @@ public:
         return S_OK;
     }
 
-    SkAutoTDelete<SkStreamAsset> fStream;
+    std::unique_ptr<SkStreamAsset> fStream;
 
 private:
     StreamFontFileLoader(SkStreamAsset* stream) : fStream(stream), fRefCount(1) { }
index dc87218..e955665 100644 (file)
@@ -193,8 +193,8 @@ int DWriteFontTypeface::onGetTableTags(SkFontTableTag tags[]) const {
     }
 
     int ttcIndex;
-    SkAutoTDelete<SkStream> stream(this->openStream(&ttcIndex));
-    return stream.get() ? SkFontStream::GetTableTags(stream, ttcIndex, tags) : 0;
+    std::unique_ptr<SkStream> stream(this->openStream(&ttcIndex));
+    return stream.get() ? SkFontStream::GetTableTags(stream.get(), ttcIndex, tags) : 0;
 }
 
 size_t DWriteFontTypeface::onGetTableData(SkFontTableTag tag, size_t offset,
index b07e0aa..4496c0a 100644 (file)
@@ -342,7 +342,7 @@ private:
 
     SkXMLWriter*               fWriter;
     ResourceBucket*            fResourceBucket;
-    SkAutoTDelete<AutoElement> fClipGroup;
+    std::unique_ptr<AutoElement> fClipGroup;
 };
 
 void SkSVGDevice::AutoElement::addPaint(const SkPaint& paint, const Resources& resources) {
@@ -592,7 +592,7 @@ SkSVGDevice::~SkSVGDevice() {
 }
 
 void SkSVGDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
-    AutoElement rect("rect", fWriter, fResourceBucket, draw, paint);
+    AutoElement rect("rect", fWriter, fResourceBucket.get(), draw, paint);
     rect.addRectAttributes(SkRect::MakeWH(SkIntToScalar(this->width()),
                                           SkIntToScalar(this->height())));
 }
@@ -612,7 +612,7 @@ void SkSVGDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_
                 path.rewind();
                 path.moveTo(pts[i]);
                 path.lineTo(pts[i+1]);
-                AutoElement elem("path", fWriter, fResourceBucket, draw, paint);
+                AutoElement elem("path", fWriter, fResourceBucket.get(), draw, paint);
                 elem.addPathAttributes(path);
             }
             break;
@@ -620,7 +620,7 @@ void SkSVGDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_
             if (count > 1) {
                 path.addPoly(pts, SkToInt(count), false);
                 path.moveTo(pts[0]);
-                AutoElement elem("path", fWriter, fResourceBucket, draw, paint);
+                AutoElement elem("path", fWriter, fResourceBucket.get(), draw, paint);
                 elem.addPathAttributes(path);
             }
             break;
@@ -628,12 +628,12 @@ void SkSVGDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_
 }
 
 void SkSVGDevice::drawRect(const SkDraw& draw, const SkRect& r, const SkPaint& paint) {
-    AutoElement rect("rect", fWriter, fResourceBucket, draw, paint);
+    AutoElement rect("rect", fWriter, fResourceBucket.get(), draw, paint);
     rect.addRectAttributes(r);
 }
 
 void SkSVGDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint& paint) {
-    AutoElement ellipse("ellipse", fWriter, fResourceBucket, draw, paint);
+    AutoElement ellipse("ellipse", fWriter, fResourceBucket.get(), draw, paint);
     ellipse.addAttribute("cx", oval.centerX());
     ellipse.addAttribute("cy", oval.centerY());
     ellipse.addAttribute("rx", oval.width() / 2);
@@ -644,13 +644,13 @@ void SkSVGDevice::drawRRect(const SkDraw& draw, const SkRRect& rr, const SkPaint
     SkPath path;
     path.addRRect(rr);
 
-    AutoElement elem("path", fWriter, fResourceBucket, draw, paint);
+    AutoElement elem("path", fWriter, fResourceBucket.get(), draw, paint);
     elem.addPathAttributes(path);
 }
 
 void SkSVGDevice::drawPath(const SkDraw& draw, const SkPath& path, const SkPaint& paint,
                            const SkMatrix* prePathMatrix, bool pathIsMutable) {
-    AutoElement elem("path", fWriter, fResourceBucket, draw, paint);
+    AutoElement elem("path", fWriter, fResourceBucket.get(), draw, paint);
     elem.addPathAttributes(path);
 
     // TODO: inverse fill types?
@@ -687,7 +687,7 @@ void SkSVGDevice::drawBitmapCommon(const SkDraw& draw, const SkBitmap& bm,
     }
 
     {
-        AutoElement imageUse("use", fWriter, fResourceBucket, draw, paint);
+        AutoElement imageUse("use", fWriter, fResourceBucket.get(), draw, paint);
         imageUse.addAttribute("xlink:href", SkStringPrintf("#%s", imageID.c_str()));
     }
 }
@@ -737,7 +737,7 @@ void SkSVGDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bm, const S
 
 void SkSVGDevice::drawText(const SkDraw& draw, const void* text, size_t len,
                            SkScalar x, SkScalar y, const SkPaint& paint) {
-    AutoElement elem("text", fWriter, fResourceBucket, draw, paint);
+    AutoElement elem("text", fWriter, fResourceBucket.get(), draw, paint);
     elem.addTextAttributes(paint);
 
     SVGTextBuilder builder(text, len, paint, SkPoint::Make(x, y), 0);
@@ -751,7 +751,7 @@ void SkSVGDevice::drawPosText(const SkDraw& draw, const void* text, size_t len,
                               const SkPaint& paint) {
     SkASSERT(scalarsPerPos == 1 || scalarsPerPos == 2);
 
-    AutoElement elem("text", fWriter, fResourceBucket, draw, paint);
+    AutoElement elem("text", fWriter, fResourceBucket.get(), draw, paint);
     elem.addTextAttributes(paint);
 
     SVGTextBuilder builder(text, len, paint, offset, scalarsPerPos, pos);
index d0b9a24..ccd18c4 100644 (file)
@@ -63,9 +63,9 @@ private:
     class AutoElement;
     class ResourceBucket;
 
-    SkXMLWriter*                  fWriter;
-    SkAutoTDelete<AutoElement>    fRootElement;
-    SkAutoTDelete<ResourceBucket> fResourceBucket;
+    SkXMLWriter*                    fWriter;
+    std::unique_ptr<AutoElement>    fRootElement;
+    std::unique_ptr<ResourceBucket> fResourceBucket;
 
     typedef SkBaseDevice INHERITED;
 };
index 60484a4..3426126 100644 (file)
@@ -204,7 +204,7 @@ SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas* canvas) {
         return nullptr;
     }
 
-    SkAutoTDelete<SkCanvasState_v1> canvasState(new SkCanvasState_v1(canvas));
+    std::unique_ptr<SkCanvasState_v1> canvasState(new SkCanvasState_v1(canvas));
 
     // decompose the total matrix and clip
     setup_MC_state(&canvasState->mcState, canvas->getTotalMatrix(),
index 2dfb8ab..42b86f0 100644 (file)
@@ -29,19 +29,19 @@ public:
     SkStreamRewindable* duplicate() const override { return nullptr; }
 
 private:
-    SkAutoTDelete<SkStream> fStream;
-    const bool              fHasLength;
-    const size_t            fLength;
+    std::unique_ptr<SkStream> fStream;
+    const bool                fHasLength;
+    const size_t              fLength;
     // Current offset into the stream. Always >= 0.
-    size_t                  fOffset;
+    size_t                    fOffset;
     // Amount that has been buffered by calls to read. Will always be less than
     // fBufferSize.
-    size_t                  fBufferedSoFar;
+    size_t                    fBufferedSoFar;
     // Total size of the buffer.
-    const size_t            fBufferSize;
+    const size_t              fBufferSize;
     // FIXME: SkAutoTMalloc throws on failure. Instead, Create should return a
     // nullptr stream.
-    SkAutoTMalloc<char>     fBuffer;
+    SkAutoTMalloc<char>       fBuffer;
 
     // Read up to size bytes from already buffered data, and copy to
     // dst, if non-nullptr. Updates fOffset. Assumes that fOffset is less
index 6c73441..2bb7d0f 100644 (file)
@@ -105,7 +105,7 @@ bool SkDWriteFontFileStream::move(long offset) {
 }
 
 SkDWriteFontFileStream* SkDWriteFontFileStream::fork() const {
-    SkAutoTDelete<SkDWriteFontFileStream> that(this->duplicate());
+    std::unique_ptr<SkDWriteFontFileStream> that(this->duplicate());
     that->seek(fPos);
     return that.release();
 }
index e78b621..25322c5 100644 (file)
@@ -73,7 +73,7 @@ private:
     virtual ~SkDWriteFontFileStreamWrapper() { }
 
     ULONG fRefCount;
-    SkAutoTDelete<SkStreamAsset> fStream;
+    std::unique_ptr<SkStreamAsset> fStream;
     SkMutex fStreamMutex;
 };
 #endif
index 7b658c8..57e165f 100644 (file)
@@ -415,9 +415,8 @@ SkMSec SkEvent::EnqueueTime(SkEvent* evt, SkMSec time) {
 #include "SkEventSink.h"
 
 bool SkEvent::ProcessEvent() {
-    SkEvent*                evt = SkEvent::Dequeue();
-    SkAutoTDelete<SkEvent>  autoDelete(evt);
-    bool                    again = false;
+    std::unique_ptr<SkEvent> evt(SkEvent::Dequeue());
+    bool                     again = false;
 
     EVENT_LOGN("ProcessEvent", (int32_t)evt);
 
index 4a977ae..cb4938b 100644 (file)
@@ -72,7 +72,7 @@ sk_sp<SkDocument> SkDocument::MakeXPS(SkWStream* stream, SkScalar dpi) {
 static void delete_wstream(SkWStream* stream, bool aborted) { delete stream; }
 
 sk_sp<SkDocument> SkDocument::MakeXPS(const char path[], SkScalar dpi) {
-    SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(path));
+    std::unique_ptr<SkFILEWStream> stream(new SkFILEWStream(path));
     if (!stream->isValid()) {
         return nullptr;
     }
index 7eb1587..07dcd45 100644 (file)
@@ -428,7 +428,7 @@ static HRESULT subset_typeface(SkXPSDevice::TypefaceUse* current) {
         fontPackageBuffer.realloc(bytesWritten);
     }
 
-    SkAutoTDelete<SkMemoryStream> newStream(new SkMemoryStream());
+    std::unique_ptr<SkMemoryStream> newStream(new SkMemoryStream());
     newStream->setMemoryOwned(fontPackageBuffer.release(), bytesWritten + extra);
 
     SkTScopedComPtr<IStream> newIStream;
index 4affa85..a0664f1 100644 (file)
@@ -28,8 +28,8 @@ DEF_TEST(BadImage, reporter) {
 
     for (size_t i = 0; i < SK_ARRAY_COUNT(badImages); ++i) {
         SkString resourcePath = SkOSPath::Join(badImagesFolder, badImages[i]);
-        SkAutoTDelete<SkStream> stream(GetResourceAsStream(resourcePath.c_str()));
-        SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
+        std::unique_ptr<SkStream> stream(GetResourceAsStream(resourcePath.c_str()));
+        std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
 
         // These images are corrupt.  It's not important whether we succeed/fail in codec
         // creation or decoding.  We just want to make sure that we don't crash.
index 22d4e7b..ba1a51f 100644 (file)
@@ -28,12 +28,12 @@ static SkImageInfo standardize_info(SkCodec* codec) {
 }
 
 static bool create_truth(sk_sp<SkData> data, SkBitmap* dst) {
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(std::move(data)));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(std::move(data)));
     if (!codec) {
         return false;
     }
 
-    const SkImageInfo info = standardize_info(codec);
+    const SkImageInfo info = standardize_info(codec.get());
     dst->allocPixels(info);
     return SkCodec::kSuccess == codec->getPixels(info, dst->getPixels(), dst->rowBytes());
 }
@@ -108,7 +108,7 @@ static void test_partial(skiatest::Reporter* r, const char* name) {
 
     // Note that we cheat and hold on to a pointer to stream, though it is owned by
     // partialCodec.
-    SkAutoTDelete<SkCodec> partialCodec(SkCodec::NewFromStream(stream));
+    std::unique_ptr<SkCodec> partialCodec(SkCodec::NewFromStream(stream));
     if (!partialCodec) {
         // Technically, this could be a small file where half the file is not
         // enough.
@@ -116,7 +116,7 @@ static void test_partial(skiatest::Reporter* r, const char* name) {
         return;
     }
 
-    const SkImageInfo info = standardize_info(partialCodec);
+    const SkImageInfo info = standardize_info(partialCodec.get());
     SkASSERT(info == truth.info());
     SkBitmap incremental;
     incremental.allocPixels(info);
@@ -284,14 +284,14 @@ static void test_interleaved(skiatest::Reporter* r, const char* name) {
         return;
     }
     const size_t halfSize = file->size() / 2;
-    SkAutoTDelete<SkCodec> partialCodec(SkCodec::NewFromStream(
+    std::unique_ptr<SkCodec> partialCodec(SkCodec::NewFromStream(
             new HaltingStream(std::move(file), halfSize)));
     if (!partialCodec) {
         ERRORF(r, "Failed to create codec for %s", name);
         return;
     }
 
-    const SkImageInfo info = standardize_info(partialCodec);
+    const SkImageInfo info = standardize_info(partialCodec.get());
     SkBitmap incremental;
     incremental.allocPixels(info);
 
index a5afb09..e9ea242 100644 (file)
@@ -10,7 +10,7 @@
 #include "SkData.h"
 
 inline bool decode_memory(const void* mem, size_t size, SkBitmap* bm) {
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(SkData::MakeWithoutCopy(mem, size)));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(SkData::MakeWithoutCopy(mem, size)));
     if (!codec) {
         return false;
     }
index c171a7e..c8b573a 100644 (file)
@@ -260,16 +260,16 @@ static void check(skiatest::Reporter* r,
                   bool supportsIncomplete,
                   bool supportsNewScanlineDecoding = false) {
 
-    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
+    std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
     if (!stream) {
         return;
     }
 
-    SkAutoTDelete<SkCodec> codec(nullptr);
+    std::unique_ptr<SkCodec> codec(nullptr);
     bool isIncomplete = supportsIncomplete;
     if (isIncomplete) {
         size_t size = stream->getLength();
-        sk_sp<SkData> data((SkData::MakeFromStream(stream, 2 * size / 3)));
+        sk_sp<SkData> data((SkData::MakeFromStream(stream.get(), 2 * size / 3)));
         codec.reset(SkCodec::NewFromData(data));
     } else {
         codec.reset(SkCodec::NewFromStream(stream.release()));
@@ -289,12 +289,12 @@ static void check(skiatest::Reporter* r,
     // Scanline decoding follows.
 
     if (supportsNewScanlineDecoding && !isIncomplete) {
-        test_incremental_decode(r, codec, info, codecDigest);
+        test_incremental_decode(r, codec.get(), info, codecDigest);
         // This is only supported by codecs that use incremental decoding to
         // support subset decodes - png and jpeg (once SkJpegCodec is
         // converted).
         if (SkStrEndsWith(path, "png") || SkStrEndsWith(path, "PNG")) {
-            test_in_stripes(r, codec, info, codecDigest);
+            test_in_stripes(r, codec.get(), info, codecDigest);
         }
     }
 
@@ -397,15 +397,15 @@ static void check(skiatest::Reporter* r,
     // SkAndroidCodec tests
     if (supportsScanlineDecoding || supportsSubsetDecoding || supportsNewScanlineDecoding) {
 
-        SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
+        std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
         if (!stream) {
             return;
         }
 
-        SkAutoTDelete<SkAndroidCodec> androidCodec(nullptr);
+        std::unique_ptr<SkAndroidCodec> androidCodec(nullptr);
         if (isIncomplete) {
             size_t size = stream->getLength();
-            sk_sp<SkData> data((SkData::MakeFromStream(stream, 2 * size / 3)));
+            sk_sp<SkData> data((SkData::MakeFromStream(stream.get(), 2 * size / 3)));
             androidCodec.reset(SkAndroidCodec::NewFromData(data));
         } else {
             androidCodec.reset(SkAndroidCodec::NewFromStream(stream.release()));
@@ -423,9 +423,9 @@ static void check(skiatest::Reporter* r,
 
     if (!isIncomplete) {
         // Test SkCodecImageGenerator
-        SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
-        sk_sp<SkData> fullData(SkData::MakeFromStream(stream, stream->getLength()));
-        SkAutoTDelete<SkImageGenerator> gen(
+        std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
+        sk_sp<SkData> fullData(SkData::MakeFromStream(stream.get(), stream->getLength()));
+        std::unique_ptr<SkImageGenerator> gen(
                 SkCodecImageGenerator::NewFromEncodedCodec(fullData.get()));
         SkBitmap bm;
         bm.allocPixels(info);
@@ -560,11 +560,11 @@ DEF_TEST(Codec_null, r) {
 
 static void test_dimensions(skiatest::Reporter* r, const char path[]) {
     // Create the codec from the resource file
-    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
+    std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
     if (!stream) {
         return;
     }
-    SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
+    std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
     if (!codec) {
         ERRORF(r, "Unable to create codec '%s'", path);
         return;
@@ -624,11 +624,11 @@ DEF_TEST(Codec_Dimensions, r) {
 }
 
 static void test_invalid(skiatest::Reporter* r, const char path[]) {
-    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
+    std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
     if (!stream) {
         return;
     }
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
     REPORTER_ASSERT(r, nullptr == codec);
 }
 
@@ -649,11 +649,11 @@ DEF_TEST(Codec_Empty, r) {
 }
 
 static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) {
-    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
+    std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
     if (!stream) {
         return;
     }
-    SkAutoTDelete<SkCodec> decoder(SkCodec::NewFromStream(stream.release()));
+    std::unique_ptr<SkCodec> decoder(SkCodec::NewFromStream(stream.release()));
     if (!decoder) {
         SkDebugf("Missing codec for %s\n", path);
         return;
@@ -818,7 +818,7 @@ DEF_TEST(Codec_pngChunkReader, r) {
     ChunkReader chunkReader(r);
 
     // Now read the file with SkCodec.
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(wStream.detachAsData(), &chunkReader));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(wStream.detachAsData(), &chunkReader));
     REPORTER_ASSERT(r, codec);
     if (!codec) {
         return;
@@ -922,7 +922,7 @@ DEF_TEST(Codec_raw_notseekable, r) {
         return;
     }
 
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(new NotAssetMemStream(std::move(data))));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(new NotAssetMemStream(std::move(data))));
     REPORTER_ASSERT(r, codec);
 
     test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr);
@@ -941,7 +941,7 @@ DEF_TEST(Codec_webp_peek, r) {
     }
 
     // The limit is less than webp needs to peek or read.
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(
                                  new LimitedPeekingMemStream(data, 25)));
     REPORTER_ASSERT(r, codec);
 
@@ -960,18 +960,18 @@ DEF_TEST(Codec_webp_peek, r) {
 // Test that SkCodec now supports an image with these bits set.
 DEF_TEST(Codec_wbmp, r) {
     const char* path = "mandrill.wbmp";
-    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
+    std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
     if (!stream) {
         return;
     }
 
     // Modify the stream to contain a second byte with some bits set.
-    auto data = SkCopyStreamToData(stream);
+    auto data = SkCopyStreamToData(stream.get());
     uint8_t* writeableData = static_cast<uint8_t*>(data->writable_data());
     writeableData[1] = static_cast<uint8_t>(~0x9F);
 
     // SkCodec should support this.
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data));
     REPORTER_ASSERT(r, codec);
     if (!codec) {
         return;
@@ -988,8 +988,8 @@ DEF_TEST(Codec_wbmp_max_size, r) {
     const unsigned char maxSizeWbmp[] = { 0x00, 0x00,           // Header
                                           0x83, 0xFF, 0x7F,     // W: 65535
                                           0x83, 0xFF, 0x7F };   // H: 65535
-    SkAutoTDelete<SkStream> stream(new SkMemoryStream(maxSizeWbmp, sizeof(maxSizeWbmp), false));
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
+    std::unique_ptr<SkStream> stream(new SkMemoryStream(maxSizeWbmp, sizeof(maxSizeWbmp), false));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
 
     REPORTER_ASSERT(r, codec);
     if (!codec) return;
@@ -1010,11 +1010,11 @@ DEF_TEST(Codec_wbmp_max_size, r) {
 
 DEF_TEST(Codec_jpeg_rewind, r) {
     const char* path = "mandrill_512_q075.jpg";
-    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
+    std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
     if (!stream) {
         return;
     }
-    SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
+    std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
     if (!codec) {
         ERRORF(r, "Unable to create codec '%s'.", path);
         return;
@@ -1037,7 +1037,7 @@ DEF_TEST(Codec_jpeg_rewind, r) {
 }
 
 static void check_color_xform(skiatest::Reporter* r, const char* path) {
-    SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(GetResourceAsStream(path)));
+    std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(GetResourceAsStream(path)));
 
     SkAndroidCodec::AndroidOptions opts;
     opts.fSampleSize = 3;
@@ -1104,7 +1104,7 @@ static void check_round_trip(skiatest::Reporter* r, SkCodec* origCodec, const Sk
     sk_sp<SkData> data =
             sk_sp<SkData>(SkImageEncoder::EncodeData(bm1, SkImageEncoder::kPNG_Type, 100));
 
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data));
     REPORTER_ASSERT(r, color_type_match(info.colorType(), codec->getInfo().colorType()));
     REPORTER_ASSERT(r, alpha_type_match(info.alphaType(), codec->getInfo().alphaType()));
 
@@ -1123,8 +1123,8 @@ static void check_round_trip(skiatest::Reporter* r, SkCodec* origCodec, const Sk
 
 DEF_TEST(Codec_PngRoundTrip, r) {
     const char* path = "mandrill_512_q075.jpg";
-    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
+    std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
 
     SkColorType colorTypesOpaque[] = {
             kRGB_565_SkColorType, kRGBA_8888_SkColorType, kBGRA_8888_SkColorType
@@ -1173,8 +1173,8 @@ DEF_TEST(Codec_PngRoundTrip, r) {
 static void test_conversion_possible(skiatest::Reporter* r, const char* path,
                                      bool supportsScanlineDecoder,
                                      bool supportsIncrementalDecoder) {
-    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
+    std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
     SkImageInfo infoF16 = codec->getInfo().makeColorType(kRGBA_F16_SkColorType);
 
     SkBitmap bm;
@@ -1314,9 +1314,9 @@ public:
     }
 
 private:
-    SkAutoTDelete<SkStream> fStream;
-    const size_t            fLimit;
-    size_t                  fPosition;
+    std::unique_ptr<SkStream> fStream;
+    const size_t              fLimit;
+    size_t                    fPosition;
 
     LimitedRewindingStream(SkStream* stream, size_t limit)
         : fStream(stream)
@@ -1346,7 +1346,7 @@ DEF_TEST(Codec_fallBack, r) {
             return;
         }
 
-        SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream));
+        std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream));
         if (!codec) {
             ERRORF(r, "Failed to create codec for %s,", file);
             continue;
index ca08563..e1ff160 100644 (file)
@@ -46,13 +46,13 @@ static void test_space(skiatest::Reporter* r, SkColorSpace* space,
 static void test_path(skiatest::Reporter* r, const char* path,
                       const float red[], const float green[], const float blue[],
                       const SkGammaNamed expectedGamma) {
-    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
+    std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
     REPORTER_ASSERT(r, nullptr != stream);
     if (!stream) {
         return;
     }
 
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
     REPORTER_ASSERT(r, nullptr != codec);
     if (!codec) {
         return;
index 391124e..72bad6f 100644 (file)
@@ -365,7 +365,7 @@ DEF_TEST(RWBuffer_noAppend, r) {
         REPORTER_ASSERT(r, !iter.next());
     }
 
-    SkAutoTDelete<SkStream> stream(buffer.newStreamSnapshot());
+    std::unique_ptr<SkStream> stream(buffer.newStreamSnapshot());
     REPORTER_ASSERT(r, stream);
     if (stream) {
         REPORTER_ASSERT(r, stream->hasLength());
index cabd14b..d1ba38a 100644 (file)
@@ -14,7 +14,7 @@ DEF_TEST(DiscardableMemoryPool, reporter) {
     pool->setRAMBudget(3);
     REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
 
-    SkAutoTDelete<SkDiscardableMemory> dm1(pool->create(100));
+    std::unique_ptr<SkDiscardableMemory> dm1(pool->create(100));
     REPORTER_ASSERT(reporter, dm1->data() != nullptr);
     REPORTER_ASSERT(reporter, 100 == pool->getRAMUsed());
     dm1->unlock();
@@ -22,7 +22,7 @@ DEF_TEST(DiscardableMemoryPool, reporter) {
     REPORTER_ASSERT(reporter, !dm1->lock());
 
 
-    SkAutoTDelete<SkDiscardableMemory> dm2(pool->create(200));
+    std::unique_ptr<SkDiscardableMemory> dm2(pool->create(200));
     REPORTER_ASSERT(reporter, 200 == pool->getRAMUsed());
     pool->setRAMBudget(400);
     dm2->unlock();
index de305c7..3d2ee05 100644 (file)
@@ -96,7 +96,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
         return;
     }
 
-    SkAutoTDelete<GLTestContext> glCtx1 = glCtx0->createNew();
+    std::unique_ptr<GLTestContext> glCtx1 = glCtx0->makeNew();
     if (!glCtx1) {
         return;
     }
@@ -107,13 +107,13 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
     externalTexture.fID = 0;
 
     if (!context1) {
-        cleanup(glCtx0, externalTexture.fID, glCtx1, context1, backendTexture1, image);
+        cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, backendTexture1, image);
         return;
     }
 
     if (!glCtx1->gl()->hasExtension("EGL_KHR_image") ||
         !glCtx1->gl()->hasExtension("EGL_KHR_gl_texture_2D_image")) {
-        cleanup(glCtx0, externalTexture.fID, glCtx1, context1, backendTexture1, image);
+        cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, backendTexture1, image);
         return;
     }
 
@@ -127,12 +127,12 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
         gpu1->createTestingOnlyBackendTexture(nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig));
     if (!backendTexture1 || !backendTexture1->fID) {
         ERRORF(reporter, "Error creating texture for EGL Image");
-        cleanup(glCtx0, externalTexture.fID, glCtx1, context1, backendTexture1, image);
+        cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, backendTexture1, image);
         return;
     }
     if (GR_GL_TEXTURE_2D != backendTexture1->fTarget) {
         ERRORF(reporter, "Expected backend texture to be 2D");
-        cleanup(glCtx0, externalTexture.fID, glCtx1, context1, backendTexture1, image);
+        cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, backendTexture1, image);
         return;
     }
 
@@ -140,7 +140,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
     image = glCtx1->texture2DToEGLImage(backendTexture1->fID);
     if (GR_EGL_NO_IMAGE == image) {
         ERRORF(reporter, "Error creating EGL Image from texture");
-        cleanup(glCtx0, externalTexture.fID, glCtx1, context1, backendTexture1, image);
+        cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, backendTexture1, image);
         return;
     }
 
@@ -177,7 +177,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
         context0->textureProvider()->wrapBackendTexture(externalDesc));
     if (!externalTextureObj) {
         ERRORF(reporter, "Error wrapping external texture in GrTexture.");
-        cleanup(glCtx0, externalTexture.fID, glCtx1, context1, backendTexture1, image);
+        cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, backendTexture1, image);
         return;
     }
 
@@ -205,7 +205,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
 
     test_copy_surface(reporter, context0, externalTextureObj.get(), pixels.get());
 
-    cleanup(glCtx0, externalTexture.fID, glCtx1, context1, backendTexture1, image);
+    cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, backendTexture1, image);
 }
 
 #endif
index 4aac487..4fed2b0 100644 (file)
 #include "Test.h"
 
 DEF_TEST(ExifOrientation, r) {
-    SkAutoTDelete<SkStream> stream(GetResourceAsStream("exif-orientation-2-ur.jpg"));
+    std::unique_ptr<SkStream> stream(GetResourceAsStream("exif-orientation-2-ur.jpg"));
     REPORTER_ASSERT(r, nullptr != stream);
     if (!stream) {
         return;
     }
 
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
     REPORTER_ASSERT(r, nullptr != codec);
     SkCodec::Origin origin = codec->getOrigin();
     REPORTER_ASSERT(r, SkCodec::kTopRight_Origin == origin);
index 66908bc..efb1453 100644 (file)
@@ -90,7 +90,7 @@ DEF_TEST(FontHostStream, reporter) {
         sk_sp<SkTypeface> typeface(SkToBool(paint.getTypeface()) ? sk_ref_sp(paint.getTypeface())
                                                                  : SkTypeface::MakeDefault());
         int ttcIndex;
-        SkAutoTDelete<SkStreamAsset> fontData(typeface->openStream(&ttcIndex));
+        std::unique_ptr<SkStreamAsset> fontData(typeface->openStream(&ttcIndex));
         sk_sp<SkTypeface> streamTypeface(SkTypeface::MakeFromStream(fontData.release()));
 
         SkFontDescriptor desc;
index 811b4b3..55c5244 100644 (file)
@@ -138,18 +138,18 @@ static void test_fontstream(skiatest::Reporter* reporter, SkStream* stream, int
 }
 
 static void test_fontstream(skiatest::Reporter* reporter) {
-    SkAutoTDelete<SkStreamAsset> stream(GetResourceAsStream("/fonts/test.ttc"));
+    std::unique_ptr<SkStreamAsset> stream(GetResourceAsStream("/fonts/test.ttc"));
     if (!stream) {
         SkDebugf("Skipping FontHostTest::test_fontstream\n");
         return;
     }
 
-    int count = SkFontStream::CountTTCEntries(stream);
+    int count = SkFontStream::CountTTCEntries(stream.get());
 #ifdef DUMP_TTC_TABLES
     SkDebugf("CountTTCEntries %d\n", count);
 #endif
     for (int i = 0; i < count; ++i) {
-        test_fontstream(reporter, stream, i);
+        test_fontstream(reporter, stream.get(), i);
     }
 }
 
index 445f0bf..a386274 100644 (file)
@@ -56,70 +56,70 @@ static void test_incremental_buffering(skiatest::Reporter* reporter, size_t buff
     // deleted yet (and we only call const methods in it).
     SkMemoryStream* memStream = new SkMemoryStream(gAbcs, strlen(gAbcs), false);
 
-    SkAutoTDelete<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
-    test_hasLength(reporter, *bufferedStream.get(), *memStream);
+    std::unique_ptr<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
+    test_hasLength(reporter, *bufferedStream, *memStream);
 
     // First, test reading less than the max buffer size.
-    test_read(reporter, bufferedStream, gAbcs, bufferSize / 2);
+    test_read(reporter, bufferedStream.get(), gAbcs, bufferSize / 2);
 
     // Now test rewinding back to the beginning and reading less than what was
     // already buffered.
-    test_rewind(reporter, bufferedStream, true);
-    test_read(reporter, bufferedStream, gAbcs, bufferSize / 4);
+    test_rewind(reporter, bufferedStream.get(), true);
+    test_read(reporter, bufferedStream.get(), gAbcs, bufferSize / 4);
 
     // Now test reading part of what was buffered, and buffering new data.
-    test_read(reporter, bufferedStream, gAbcs + bufferSize / 4, bufferSize / 2);
+    test_read(reporter, bufferedStream.get(), gAbcs + bufferSize / 4, bufferSize / 2);
 
     // Now test reading what was buffered, buffering new data, and
     // reading directly from the stream.
-    test_rewind(reporter, bufferedStream, true);
-    test_read(reporter, bufferedStream, gAbcs, bufferSize << 1);
+    test_rewind(reporter, bufferedStream.get(), true);
+    test_read(reporter, bufferedStream.get(), gAbcs, bufferSize << 1);
 
     // We have reached the end of the buffer, so rewinding will fail.
     // This test assumes that the stream is larger than the buffer; otherwise the
     // result of rewind should be true.
-    test_rewind(reporter, bufferedStream, false);
+    test_rewind(reporter, bufferedStream.get(), false);
 }
 
 static void test_perfectly_sized_buffer(skiatest::Reporter* reporter, size_t bufferSize) {
     SkMemoryStream* memStream = new SkMemoryStream(gAbcs, strlen(gAbcs), false);
-    SkAutoTDelete<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
-    test_hasLength(reporter, *bufferedStream.get(), *memStream);
+    std::unique_ptr<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
+    test_hasLength(reporter, *bufferedStream, *memStream);
 
     // Read exactly the amount that fits in the buffer.
-    test_read(reporter, bufferedStream, gAbcs, bufferSize);
+    test_read(reporter, bufferedStream.get(), gAbcs, bufferSize);
 
     // Rewinding should succeed.
-    test_rewind(reporter, bufferedStream, true);
+    test_rewind(reporter, bufferedStream.get(), true);
 
     // Once again reading buffered info should succeed
-    test_read(reporter, bufferedStream, gAbcs, bufferSize);
+    test_read(reporter, bufferedStream.get(), gAbcs, bufferSize);
 
     // Read past the size of the buffer. At this point, we cannot return.
-    test_read(reporter, bufferedStream, gAbcs + memStream->getPosition(), 1);
-    test_rewind(reporter, bufferedStream, false);
+    test_read(reporter, bufferedStream.get(), gAbcs + memStream->getPosition(), 1);
+    test_rewind(reporter, bufferedStream.get(), false);
 }
 
 static void test_skipping(skiatest::Reporter* reporter, size_t bufferSize) {
     SkMemoryStream* memStream = new SkMemoryStream(gAbcs, strlen(gAbcs), false);
-    SkAutoTDelete<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
-    test_hasLength(reporter, *bufferedStream.get(), *memStream);
+    std::unique_ptr<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
+    test_hasLength(reporter, *bufferedStream, *memStream);
 
     // Skip half the buffer.
     bufferedStream->skip(bufferSize / 2);
 
     // Rewind, then read part of the buffer, which should have been read.
-    test_rewind(reporter, bufferedStream, true);
-    test_read(reporter, bufferedStream, gAbcs, bufferSize / 4);
+    test_rewind(reporter, bufferedStream.get(), true);
+    test_read(reporter, bufferedStream.get(), gAbcs, bufferSize / 4);
 
     // Now skip beyond the buffered piece, but still within the total buffer.
     bufferedStream->skip(bufferSize / 2);
 
     // Test that reading will still work.
-    test_read(reporter, bufferedStream, gAbcs + memStream->getPosition(), bufferSize / 4);
+    test_read(reporter, bufferedStream.get(), gAbcs + memStream->getPosition(), bufferSize / 4);
 
-    test_rewind(reporter, bufferedStream, true);
-    test_read(reporter, bufferedStream, gAbcs, bufferSize);
+    test_rewind(reporter, bufferedStream.get(), true);
+    test_read(reporter, bufferedStream.get(), gAbcs, bufferSize);
 }
 
 // A custom class whose isAtEnd behaves the way Android's stream does - since it is an adaptor to a
@@ -156,7 +156,7 @@ static void test_read_beyond_buffer(skiatest::Reporter* reporter, size_t bufferS
             new AndroidLikeMemoryStream((void*)gAbcs, bufferSize, false);
 
     // Create a buffer that matches the length of the stream.
-    SkAutoTDelete<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
+    std::unique_ptr<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
     test_hasLength(reporter, *bufferedStream.get(), *memStream);
 
     // Attempt to read one more than the bufferSize
@@ -164,7 +164,7 @@ static void test_read_beyond_buffer(skiatest::Reporter* reporter, size_t bufferS
     test_rewind(reporter, bufferedStream.get(), true);
 
     // Ensure that the initial read did not invalidate the buffer.
-    test_read(reporter, bufferedStream, gAbcs, bufferSize);
+    test_read(reporter, bufferedStream.get(), gAbcs, bufferSize);
 }
 
 // Dummy stream that optionally has a length and/or position. Tests that FrontBufferedStream's
@@ -203,7 +203,7 @@ static void test_length_combos(skiatest::Reporter* reporter, size_t bufferSize)
         for (int hasPos = 0; hasPos <= 1; hasPos++) {
             LengthOptionalStream* stream =
                     new LengthOptionalStream(SkToBool(hasLen), SkToBool(hasPos));
-            SkAutoTDelete<SkStream> buffered(SkFrontBufferedStream::Create(stream, bufferSize));
+            std::unique_ptr<SkStream> buffered(SkFrontBufferedStream::Create(stream, bufferSize));
             test_hasLength(reporter, *buffered.get(), *stream);
         }
     }
@@ -217,7 +217,7 @@ static void test_initial_offset(skiatest::Reporter* reporter, size_t bufferSize)
     // the stream it wraps.
     const size_t arbitraryOffset = 17;
     memStream->skip(arbitraryOffset);
-    SkAutoTDelete<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
+    std::unique_ptr<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize));
 
     // Since SkMemoryStream has a length, bufferedStream must also.
     REPORTER_ASSERT(reporter, bufferedStream->hasLength());
@@ -231,7 +231,7 @@ static void test_initial_offset(skiatest::Reporter* reporter, size_t bufferSize)
     // Importantly, the end should not have been reached until currentPosition == bufferedLength.
     while (currentPosition < bufferedLength) {
         REPORTER_ASSERT(reporter, !bufferedStream->isAtEnd());
-        test_read(reporter, bufferedStream, gAbcs + arbitraryOffset + currentPosition,
+        test_read(reporter, bufferedStream.get(), gAbcs + arbitraryOffset + currentPosition,
                   amountToRead);
         currentPosition = SkTMin(currentPosition + amountToRead, bufferedLength);
         REPORTER_ASSERT(reporter, memStream->getPosition() - arbitraryOffset == currentPosition);
@@ -281,9 +281,9 @@ private:
 
 DEF_TEST(ShortFrontBufferedStream, reporter) {
     FailingStream* failingStream = new FailingStream;
-    SkAutoTDelete<SkStreamRewindable> stream(SkFrontBufferedStream::Create(failingStream, 64));
+    std::unique_ptr<SkStreamRewindable> stream(SkFrontBufferedStream::Create(failingStream, 64));
 
     // This will fail to create a codec.  However, what we really want to test is that we
     // won't read past the end of the stream.
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
 }
index 51cd85d..4e8fa2b 100644 (file)
@@ -191,14 +191,14 @@ DEF_TEST(Gif, reporter) {
 // Regression test for decoding a gif image with sampleSize of 4, which was
 // previously crashing.
 DEF_TEST(Gif_Sampled, r) {
-    SkAutoTDelete<SkFILEStream> stream(
+    std::unique_ptr<SkFILEStream> stream(
             new SkFILEStream(GetResourcePath("test640x479.gif").c_str()));
     REPORTER_ASSERT(r, stream->isValid());
     if (!stream->isValid()) {
         return;
     }
 
-    SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
+    std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
     REPORTER_ASSERT(r, codec);
     if (!codec) {
         return;
index 2a57ccb..275951b 100644 (file)
@@ -199,7 +199,7 @@ public:
     }
 
 private:
-    SkAutoTDelete<sk_gpu_test::GLTestContext>   fTestContext;
+    std::unique_ptr<sk_gpu_test::GLTestContext> fTestContext;
     SamplePattern                               fSamplePattern;
 };
 
index 4a0a4c6..863574a 100644 (file)
@@ -55,11 +55,11 @@ public:
     }
 
 private:
-    static SkAutoTDelete<GrMemoryPool> gPool;
+    static std::unique_ptr<GrMemoryPool> gPool;
     char fChar;
 };
 
-SkAutoTDelete<GrMemoryPool> A::gPool;
+std::unique_ptr<GrMemoryPool> A::gPool;
 
 class B : public A {
 public:
index 5857625..f348ac4 100644 (file)
@@ -295,8 +295,8 @@ DEF_TEST(Image_Serialize_Encoding_Failure, reporter) {
         picture->serialize(&wstream, serializers[i]);
         REPORTER_ASSERT(reporter, serializers[i]->didEncode());
 
-        SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
-        sk_sp<SkPicture> deserialized(SkPicture::MakeFromStream(rstream));
+        std::unique_ptr<SkStream> rstream(wstream.detachAsStream());
+        sk_sp<SkPicture> deserialized(SkPicture::MakeFromStream(rstream.get()));
         REPORTER_ASSERT(reporter, deserialized);
         REPORTER_ASSERT(reporter, deserialized->approximateOpCount() > 0);
     }
index 75086b6..382cd21 100644 (file)
@@ -78,7 +78,7 @@ static bool bits_isonly(int value, int mask) {
 static void test_constructor(skiatest::Reporter* reporter) {
     // Allocate a matrix on the heap
     SkMatrix44* placeholderMatrix = new SkMatrix44(SkMatrix44::kUninitialized_Constructor);
-    SkAutoTDelete<SkMatrix44> deleteMe(placeholderMatrix);
+    std::unique_ptr<SkMatrix44> deleteMe(placeholderMatrix);
 
     for (int row = 0; row < 4; ++row) {
         for (int col = 0; col < 4; ++col) {
index eedcaaf..11d2370 100644 (file)
@@ -125,9 +125,8 @@ DEF_TEST(SkPDF_DeflateWStream, r) {
             }
             REPORTER_ASSERT(r, deflateWStream.bytesWritten() == size);
         }
-        SkAutoTDelete<SkStreamAsset> compressed(
-                dynamicMemoryWStream.detachAsStream());
-        SkAutoTDelete<SkStreamAsset> decompressed(stream_inflate(r, compressed));
+        std::unique_ptr<SkStreamAsset> compressed(dynamicMemoryWStream.detachAsStream());
+        std::unique_ptr<SkStreamAsset> decompressed(stream_inflate(r, compressed.get()));
 
         if (!decompressed) {
             ERRORF(r, "Decompression failed.");
index e16be4c..3cbe7ef 100644 (file)
@@ -1074,7 +1074,7 @@ int tool_main(int argc, char** argv) {
     Iter iter;
     Test* test;
     while ((test = iter.next()) != nullptr) {
-        SkAutoTDelete<Test> owned(test);
+        std::unique_ptr<Test> owned(test);
         if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) {
             test->run();
         }
index 8c7312e..8fdf92a 100644 (file)
@@ -1087,8 +1087,8 @@ DEF_TEST(Picture_preserveCullRect, r) {
     SkDynamicMemoryWStream wstream;
     picture->serialize(&wstream);
 
-    SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
-    sk_sp<SkPicture> deserializedPicture(SkPicture::MakeFromStream(rstream));
+    std::unique_ptr<SkStream> rstream(wstream.detachAsStream());
+    sk_sp<SkPicture> deserializedPicture(SkPicture::MakeFromStream(rstream.get()));
 
     REPORTER_ASSERT(r, deserializedPicture != nullptr);
     REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1);
index 82db03e..0e5e8ec 100644 (file)
@@ -357,7 +357,7 @@ static void serialize_and_compare_typeface(sk_sp<SkTypeface> typeface, const cha
     // Serlialize picture and create its clone from stream.
     SkDynamicMemoryWStream stream;
     picture->serialize(&stream);
-    SkAutoTDelete<SkStream> inputStream(stream.detachAsStream());
+    std::unique_ptr<SkStream> inputStream(stream.detachAsStream());
     sk_sp<SkPicture> loadedPicture(SkPicture::MakeFromStream(inputStream.get()));
 
     // Draw both original and clone picture and compare bitmaps -- they should be identical.
@@ -648,8 +648,8 @@ DEF_TEST(Serialization, reporter) {
 static sk_sp<SkPicture> copy_picture_via_serialization(SkPicture* src) {
     SkDynamicMemoryWStream wstream;
     src->serialize(&wstream);
-    SkAutoTDelete<SkStreamAsset> rstream(wstream.detachAsStream());
-    return SkPicture::MakeFromStream(rstream);
+    std::unique_ptr<SkStreamAsset> rstream(wstream.detachAsStream());
+    return SkPicture::MakeFromStream(rstream.get());
 }
 
 struct AnnotationRec {
index f363fb7..615c7b4 100644 (file)
@@ -38,7 +38,7 @@ DEF_TEST(BitmapCache_add_rect, reporter) {
     SkResourceCache::DiscardableFactory factory = SkResourceCache::GetDiscardableFactory();
     SkBitmap::Allocator* allocator = SkBitmapCache::GetAllocator();
 
-    SkAutoTDelete<SkResourceCache> cache;
+    std::unique_ptr<SkResourceCache> cache;
     if (factory) {
         cache.reset(new SkResourceCache(factory));
     } else {
@@ -55,18 +55,18 @@ DEF_TEST(BitmapCache_add_rect, reporter) {
     SkPixelRef* cachedPR = cachedBitmap.pixelRef();
 
     // Wrong subset size
-    REPORTER_ASSERT(reporter, !SkBitmapCache::Add(cachedPR, SkIRect::MakeWH(4, 6), cachedBitmap, cache));
-    REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedID, rect, &bm, cache));
+    REPORTER_ASSERT(reporter, !SkBitmapCache::Add(cachedPR, SkIRect::MakeWH(4, 6), cachedBitmap, cache.get()));
+    REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedID, rect, &bm, cache.get()));
     // Wrong offset value
-    REPORTER_ASSERT(reporter, !SkBitmapCache::Add(cachedPR, SkIRect::MakeXYWH(-1, 0, 5, 5), cachedBitmap, cache));
-    REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedID, rect, &bm, cache));
+    REPORTER_ASSERT(reporter, !SkBitmapCache::Add(cachedPR, SkIRect::MakeXYWH(-1, 0, 5, 5), cachedBitmap, cache.get()));
+    REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedID, rect, &bm, cache.get()));
 
     // Should not be in the cache
-    REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedID, rect, &bm, cache));
+    REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedID, rect, &bm, cache.get()));
 
-    REPORTER_ASSERT(reporter, SkBitmapCache::Add(cachedPR, rect, cachedBitmap, cache));
+    REPORTER_ASSERT(reporter, SkBitmapCache::Add(cachedPR, rect, cachedBitmap, cache.get()));
     // Should be in the cache, we just added it
-    REPORTER_ASSERT(reporter, SkBitmapCache::Find(cachedID, rect, &bm, cache));
+    REPORTER_ASSERT(reporter, SkBitmapCache::Find(cachedID, rect, &bm, cache.get()));
 }
 
 #include "SkMipMap.h"
index 74e6055..ca750d1 100644 (file)
@@ -61,7 +61,7 @@ static void test_filestreams(skiatest::Reporter* reporter, const char* tmpDir) {
         REPORTER_ASSERT(reporter, stream.isValid());
         test_loop_stream(reporter, &stream, s, 26, 100);
 
-        SkAutoTDelete<SkStreamAsset> stream2(stream.duplicate());
+        std::unique_ptr<SkStreamAsset> stream2(stream.duplicate());
         test_loop_stream(reporter, stream2.get(), s, 26, 100);
     }
 
@@ -71,7 +71,7 @@ static void test_filestreams(skiatest::Reporter* reporter, const char* tmpDir) {
         REPORTER_ASSERT(reporter, stream.isValid());
         test_loop_stream(reporter, &stream, s, 26, 100);
 
-        SkAutoTDelete<SkStreamAsset> stream2(stream.duplicate());
+        std::unique_ptr<SkStreamAsset> stream2(stream.duplicate());
         test_loop_stream(reporter, stream2.get(), s, 26, 100);
     }
 }
@@ -94,15 +94,15 @@ static void TestWStream(skiatest::Reporter* reporter) {
     }
 
     {
-        SkAutoTDelete<SkStreamAsset> stream(ds.detachAsStream());
+        std::unique_ptr<SkStreamAsset> stream(ds.detachAsStream());
         REPORTER_ASSERT(reporter, 100 * 26 == stream->getLength());
         REPORTER_ASSERT(reporter, ds.getOffset() == 0);
         test_loop_stream(reporter, stream.get(), s, 26, 100);
 
-        SkAutoTDelete<SkStreamAsset> stream2(stream->duplicate());
+        std::unique_ptr<SkStreamAsset> stream2(stream->duplicate());
         test_loop_stream(reporter, stream2.get(), s, 26, 100);
 
-        SkAutoTDelete<SkStreamAsset> stream3(stream->fork());
+        std::unique_ptr<SkStreamAsset> stream3(stream->fork());
         REPORTER_ASSERT(reporter, stream3->isAtEnd());
         char tmp;
         size_t bytes = stream->read(&tmp, 1);
@@ -124,11 +124,11 @@ static void TestWStream(skiatest::Reporter* reporter) {
 
     {
         // Test that this works after a snapshot.
-        SkAutoTDelete<SkStreamAsset> stream(ds.detachAsStream());
+        std::unique_ptr<SkStreamAsset> stream(ds.detachAsStream());
         REPORTER_ASSERT(reporter, ds.getOffset() == 0);
         test_loop_stream(reporter, stream.get(), s, 26, 100);
 
-        SkAutoTDelete<SkStreamAsset> stream2(stream->duplicate());
+        std::unique_ptr<SkStreamAsset> stream2(stream->duplicate());
         test_loop_stream(reporter, stream2.get(), s, 26, 100);
     }
     delete[] dst;
@@ -234,12 +234,12 @@ static void test_peeking_front_buffered_stream(skiatest::Reporter* r,
                                                size_t bufferSize) {
     SkStream* dupe = original.duplicate();
     REPORTER_ASSERT(r, dupe != nullptr);
-    SkAutoTDelete<SkStream> bufferedStream(SkFrontBufferedStream::Create(dupe, bufferSize));
+    std::unique_ptr<SkStream> bufferedStream(SkFrontBufferedStream::Create(dupe, bufferSize));
     REPORTER_ASSERT(r, bufferedStream != nullptr);
 
     size_t peeked = 0;
     for (size_t i = 1; !bufferedStream->isAtEnd(); i++) {
-        const size_t unpeekableBytes = compare_peek_to_read(r, bufferedStream, i);
+        const size_t unpeekableBytes = compare_peek_to_read(r, bufferedStream.get(), i);
         if (unpeekableBytes > 0) {
             // This could not have returned a number greater than i.
             REPORTER_ASSERT(r, unpeekableBytes <= i);
@@ -359,7 +359,7 @@ DEF_TEST(StreamPeek_BlockMemoryStream, rep) {
         }
         dynamicMemoryWStream.write(buffer, size);
     }
-    SkAutoTDelete<SkStreamAsset> asset(dynamicMemoryWStream.detachAsStream());
+    std::unique_ptr<SkStreamAsset> asset(dynamicMemoryWStream.detachAsStream());
     sk_sp<SkData> expected(SkData::MakeUninitialized(asset->getLength()));
     uint8_t* expectedPtr = static_cast<uint8_t*>(expected->writable_data());
     valueSource.setSeed(kSeed);  // reseed.
@@ -369,7 +369,7 @@ DEF_TEST(StreamPeek_BlockMemoryStream, rep) {
     for (size_t i = 0; i < asset->getLength(); ++i) {
         expectedPtr[i] = valueSource.nextU() & 0xFF;
     }
-    stream_peek_test(rep, asset, expected.get());
+    stream_peek_test(rep, asset.get(), expected.get());
 }
 
 namespace {
@@ -429,6 +429,6 @@ DEF_TEST(StreamCopy, reporter) {
 
 DEF_TEST(StreamEmptyStreamMemoryBase, r) {
     SkDynamicMemoryWStream tmp;
-    SkAutoTDelete<SkStreamAsset> asset(tmp.detachAsStream());
+    std::unique_ptr<SkStreamAsset> asset(tmp.detachAsStream());
     REPORTER_ASSERT(r, nullptr == asset->getMemoryBase());
 }
index d3b9167..913997b 100644 (file)
 static void codec_yuv(skiatest::Reporter* reporter,
                   const char path[],
                   SkISize expectedSizes[3]) {
-    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
+    std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
     if (!stream) {
         return;
     }
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
     REPORTER_ASSERT(reporter, codec);
     if (!codec) {
         return;
index 9c12a67..dcca202 100644 (file)
@@ -28,7 +28,7 @@ void SetResourcePath(const char* resource) {
 bool GetResourceAsBitmap(const char* resource, SkBitmap* dst) {
     SkString resourcePath = GetResourcePath(resource);
     sk_sp<SkData> resourceData(SkData::MakeFromFileName(resourcePath.c_str()));
-    SkAutoTDelete<SkImageGenerator> gen(SkImageGenerator::NewFromEncoded(resourceData.get()));
+    std::unique_ptr<SkImageGenerator> gen(SkImageGenerator::NewFromEncoded(resourceData.get()));
     return gen && gen->tryGenerateBitmap(dst);
 }
 
@@ -40,7 +40,7 @@ sk_sp<SkImage> GetResourceAsImage(const char* resource) {
 
 SkStreamAsset* GetResourceAsStream(const char* resource) {
     SkString resourcePath = GetResourcePath(resource);
-    SkAutoTDelete<SkFILEStream> stream(new SkFILEStream(resourcePath.c_str()));
+    std::unique_ptr<SkFILEStream> stream(new SkFILEStream(resourcePath.c_str()));
     if (!stream->isValid()) {
         SkDebugf("Resource %s not found.\n", resource);
         return nullptr;
@@ -49,7 +49,7 @@ SkStreamAsset* GetResourceAsStream(const char* resource) {
 }
 
 sk_sp<SkTypeface> MakeResourceAsTypeface(const char* resource) {
-    SkAutoTDelete<SkStreamAsset> stream(GetResourceAsStream(resource));
+    std::unique_ptr<SkStreamAsset> stream(GetResourceAsStream(resource));
     if (!stream) {
         return nullptr;
     }
index 4c34b87..3ee5cdb 100644 (file)
@@ -847,9 +847,9 @@ static SkBitmap* load_bitmap(const Json::Value& jsonBitmap, UrlDataManager& urlD
     sk_sp<SkData> encoded(SkData::MakeWithoutCopy(data, size));
     sk_sp<SkImage> image(SkImage::MakeFromEncoded(std::move(encoded), nullptr));
 
-    SkAutoTDelete<SkBitmap> bitmap(new SkBitmap());
+    std::unique_ptr<SkBitmap> bitmap(new SkBitmap());
     if (nullptr != image) {
-        if (!image->asLegacyBitmap(bitmap, SkImage::kRW_LegacyBitmapMode)) {
+        if (!image->asLegacyBitmap(bitmap.get(), SkImage::kRW_LegacyBitmapMode)) {
             SkDebugf("image decode failed\n");
             return nullptr;
         }
@@ -2791,18 +2791,18 @@ SkDrawTextBlobCommand::SkDrawTextBlobCommand(sk_sp<SkTextBlob> blob, SkScalar x,
     , fYPos(y)
     , fPaint(paint) {
 
-    SkAutoTDelete<SkString> runsStr(new SkString);
+    std::unique_ptr<SkString> runsStr(new SkString);
     fInfo.push(SkObjectParser::ScalarToString(x, "XPOS: "));
     fInfo.push(SkObjectParser::ScalarToString(y, "YPOS: "));
     fInfo.push(SkObjectParser::RectToString(fBlob->bounds(), "Bounds: "));
-    fInfo.push(runsStr);
+    fInfo.push(runsStr.get());
     fInfo.push(SkObjectParser::PaintToString(paint));
 
     unsigned runs = 0;
     SkPaint runPaint(paint);
     SkTextBlobRunIterator iter(fBlob.get());
     while (!iter.done()) {
-        SkAutoTDelete<SkString> tmpStr(new SkString);
+        std::unique_ptr<SkString> tmpStr(new SkString);
         tmpStr->printf("==== Run [%d] ====", runs++);
         fInfo.push(tmpStr.release());
 
index 9abf4cb..2b80397 100644 (file)
@@ -75,7 +75,7 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
 };
 #endif
 
-typedef SkTArray<SkAutoTDelete<SkCommandLineConfig>, true> SkCommandLineConfigArray;
+typedef SkTArray<std::unique_ptr<SkCommandLineConfig>, true> SkCommandLineConfigArray;
 void ParseConfigs(const SkCommandLineFlags::StringArray& configList,
                   SkCommandLineConfigArray* outResult);
 
index e38a245..b8a8930 100644 (file)
@@ -54,7 +54,7 @@ struct Sniffer : public SkPixelSerializer {
         gSeen.add(digest);
 
         sk_sp<SkData> data(SkData::MakeWithoutCopy(ptr, len));
-        SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
+        std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data));
         if (!codec) {
             // FIXME: This code is currently unreachable because we create an empty generator when
             //        we fail to create a codec.
index 4f18994..79489f4 100644 (file)
@@ -101,7 +101,7 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
             return ContextInfo(context.fBackend, context.fTestContext, context.fGrContext);
         }
     }
-    SkAutoTDelete<TestContext> testCtx;
+    std::unique_ptr<TestContext> testCtx;
     sk_sp<GrContext> grCtx;
     GrBackendContext backendContext = 0;
     sk_sp<const GrGLInterface> glInterface;
index d6baffc..54b6611 100644 (file)
@@ -162,7 +162,7 @@ private:
         bool            fAbandoned;
     };
     SkTArray<Context, true>         fContexts;
-    SkAutoTDelete<GLTestContext>    fSentinelGLContext;
+    std::unique_ptr<GLTestContext>  fSentinelGLContext;
     const GrContextOptions          fGlobalOptions;
 };
 }  // namespace sk_gpu_test
index 8722a33..ecb61e3 100644 (file)
@@ -28,10 +28,10 @@ public:
     virtual bool isValid() const = 0;
 
     bool fenceSyncSupport() const { return fFenceSync != nullptr; }
-    FenceSync* fenceSync() { SkASSERT(fFenceSync); return fFenceSync; }
+    FenceSync* fenceSync() { SkASSERT(fFenceSync); return fFenceSync.get(); }
 
     bool gpuTimingSupport() const { return fGpuTimer != nullptr; }
-    GpuTimer* gpuTimer() const { SkASSERT(fGpuTimer); return fGpuTimer; }
+    GpuTimer* gpuTimer() const { SkASSERT(fGpuTimer); return fGpuTimer.get(); }
 
     bool getMaxGpuFrameLag(int *maxFrameLag) const {
         if (!fFenceSync) {
@@ -81,8 +81,8 @@ public:
     virtual void finish() = 0;
 
 protected:
-    SkAutoTDelete<FenceSync>   fFenceSync;
-    SkAutoTDelete<GpuTimer>    fGpuTimer;
+    std::unique_ptr<FenceSync> fFenceSync;
+    std::unique_ptr<GpuTimer>  fGpuTimer;
 
     TestContext();
 
index 20a9908..e6d0e40 100644 (file)
@@ -14,7 +14,7 @@ namespace {
 
 class GLFenceSync : public sk_gpu_test::FenceSync {
 public:
-    static GLFenceSync* CreateIfSupported(const sk_gpu_test::GLTestContext*);
+    static std::unique_ptr<GLFenceSync> MakeIfSupported(const sk_gpu_test::GLTestContext*);
 
     sk_gpu_test::PlatformFence SK_WARN_UNUSED_RESULT insertFence() const override;
     bool waitFence(sk_gpu_test::PlatformFence fence) const override;
@@ -43,8 +43,8 @@ private:
     typedef FenceSync INHERITED;
 };
 
-GLFenceSync* GLFenceSync::CreateIfSupported(const sk_gpu_test::GLTestContext* ctx) {
-    SkAutoTDelete<GLFenceSync> ret;
+std::unique_ptr<GLFenceSync> GLFenceSync::MakeIfSupported(const sk_gpu_test::GLTestContext* ctx) {
+    std::unique_ptr<GLFenceSync> ret;
     if (kGL_GrGLStandard == ctx->gl()->fStandard) {
         if (GrGLGetVersion(ctx->gl()) < GR_GL_VER(3,2) && !ctx->gl()->hasExtension("GL_ARB_sync")) {
             return nullptr;
@@ -56,7 +56,10 @@ GLFenceSync* GLFenceSync::CreateIfSupported(const sk_gpu_test::GLTestContext* ct
         }
         ret.reset(new GLFenceSync(ctx, "APPLE"));
     }
-    return ret->validate() ? ret.release() : nullptr;
+    if (!ret->validate()) {
+        ret = nullptr;
+    }
+    return ret;
 }
 
 GLFenceSync::GLFenceSync(const sk_gpu_test::GLTestContext* ctx, const char* ext) {
@@ -82,7 +85,7 @@ void GLFenceSync::deleteFence(sk_gpu_test::PlatformFence fence) const {
 
 class GLGpuTimer : public sk_gpu_test::GpuTimer {
 public:
-    static GLGpuTimer* CreateIfSupported(const sk_gpu_test::GLTestContext*);
+    static std::unique_ptr<GLGpuTimer> MakeIfSupported(const sk_gpu_test::GLTestContext*);
 
     QueryStatus checkQueryStatus(sk_gpu_test::PlatformTimerQuery) override;
     std::chrono::nanoseconds getTimeElapsed(sk_gpu_test::PlatformTimerQuery) override;
@@ -121,8 +124,8 @@ private:
     typedef sk_gpu_test::GpuTimer INHERITED;
 };
 
-GLGpuTimer* GLGpuTimer::CreateIfSupported(const sk_gpu_test::GLTestContext* ctx) {
-    SkAutoTDelete<GLGpuTimer> ret;
+std::unique_ptr<GLGpuTimer> GLGpuTimer::MakeIfSupported(const sk_gpu_test::GLTestContext* ctx) {
+    std::unique_ptr<GLGpuTimer> ret;
     const GrGLInterface* gl = ctx->gl();
     if (gl->fExtensions.has("GL_EXT_disjoint_timer_query")) {
         ret.reset(new GLGpuTimer(true, ctx, "EXT"));
@@ -132,7 +135,10 @@ GLGpuTimer* GLGpuTimer::CreateIfSupported(const sk_gpu_test::GLTestContext* ctx)
     } else if (gl->fExtensions.has("GL_EXT_timer_query")) {
         ret.reset(new GLGpuTimer(false, ctx, "EXT"));
     }
-    return ret && ret->validate() ? ret.release() : nullptr;
+    if (ret && !ret->validate()) {
+        ret = nullptr;
+    }
+    return ret;
 }
 
 GLGpuTimer::GLGpuTimer(bool disjointSupport, const sk_gpu_test::GLTestContext* ctx, const char* ext)
@@ -219,11 +225,11 @@ GLTestContext::~GLTestContext() {
     SkASSERT(nullptr == fGL.get());
 }
 
-void GLTestContext::init(const GrGLInterface* gl, FenceSync* fenceSync) {
+void GLTestContext::init(const GrGLInterface* gl, std::unique_ptr<FenceSync> fenceSync) {
     SkASSERT(!fGL.get());
     fGL.reset(gl);
-    fFenceSync = fenceSync ? fenceSync : GLFenceSync::CreateIfSupported(this);
-    fGpuTimer = GLGpuTimer::CreateIfSupported(this);
+    fFenceSync = fenceSync ? std::move(fenceSync) : GLFenceSync::MakeIfSupported(this);
+    fGpuTimer = GLGpuTimer::MakeIfSupported(this);
 }
 
 void GLTestContext::teardown() {
index 0cd9762..a2b0455 100644 (file)
@@ -57,7 +57,7 @@ public:
      * Creates a new GL context of the same type and makes the returned context current
      * (if not null).
      */
-    virtual GLTestContext *createNew() const { return nullptr; }
+    virtual std::unique_ptr<GLTestContext> makeNew() const { return nullptr; }
 
     template<typename Ret, typename... Args>
     void getGLProcAddress(Ret(GR_GL_FUNCTION_TYPE** out)(Args...),
@@ -81,7 +81,7 @@ protected:
     /*
      * Methods that sublcasses must call from their constructors and destructors.
      */
-    void init(const GrGLInterface *, FenceSync* = nullptr);
+    void init(const GrGLInterface *, std::unique_ptr<FenceSync> = nullptr);
 
     void teardown() override;
 
index 449e14c..aa55bf3 100644 (file)
@@ -82,7 +82,7 @@ public:
     GrEGLImage texture2DToEGLImage(GrGLuint texID) const override;
     void destroyEGLImage(GrEGLImage) const override;
     GrGLuint eglImageToExternalTexture(GrEGLImage) const override;
-    sk_gpu_test::GLTestContext* createNew() const override;
+    std::unique_ptr<sk_gpu_test::GLTestContext> makeNew() const override;
 
 private:
     void destroyGLContext();
@@ -216,8 +216,9 @@ GrGLuint ANGLEGLContext::eglImageToExternalTexture(GrEGLImage image) const {
     return texID;
 }
 
-sk_gpu_test::GLTestContext* ANGLEGLContext::createNew() const {
-    sk_gpu_test::GLTestContext* ctx = sk_gpu_test::CreateANGLETestContext(fType, fVersion);
+std::unique_ptr<sk_gpu_test::GLTestContext> ANGLEGLContext::makeNew() const {
+    std::unique_ptr<sk_gpu_test::GLTestContext> ctx =
+        sk_gpu_test::MakeANGLETestContext(fType, fVersion);
     if (ctx) {
         ctx->makeCurrent();
     }
@@ -286,12 +287,10 @@ const GrGLInterface* CreateANGLEGLInterface() {
     return GrGLAssembleGLESInterface(&gLibs, angle_get_gl_proc);
 }
 
-GLTestContext* CreateANGLETestContext(ANGLEBackend type,
-                                      ANGLEContextVersion version) {
-    ANGLEGLContext* ctx = new ANGLEGLContext(type, version);
+std::unique_ptr<GLTestContext> MakeANGLETestContext(ANGLEBackend type, ANGLEContextVersion version){
+    std::unique_ptr<ANGLEGLContext> ctx(new ANGLEGLContext(type, version));
     if (!ctx->isValid()) {
-        delete ctx;
-        return NULL;
+        return nullptr;
     }
     return ctx;
 }
index 0da747f..9314710 100644 (file)
@@ -30,7 +30,7 @@ enum class ANGLEContextVersion {
 };
 
 /** Creates a GLTestContext backed by ANGLE. */
-GLTestContext* CreateANGLETestContext(ANGLEBackend, ANGLEContextVersion);
+std::unique_ptr<GLTestContext> MakeANGLETestContext(ANGLEBackend, ANGLEContextVersion);
 
 }  // namespace sk_gpu_test
 #endif
index 06bd70f..b2517f0 100644 (file)
@@ -22,7 +22,7 @@ namespace {
 // TODO: Share this class with ANGLE if/when it gets support for EGL_KHR_fence_sync.
 class EGLFenceSync : public sk_gpu_test::FenceSync {
 public:
-    static EGLFenceSync* CreateIfSupported(EGLDisplay);
+    static std::unique_ptr<EGLFenceSync> MakeIfSupported(EGLDisplay);
 
     sk_gpu_test::PlatformFence SK_WARN_UNUSED_RESULT insertFence() const override;
     bool waitFence(sk_gpu_test::PlatformFence fence) const override;
@@ -44,7 +44,7 @@ public:
     GrEGLImage texture2DToEGLImage(GrGLuint texID) const override;
     void destroyEGLImage(GrEGLImage) const override;
     GrGLuint eglImageToExternalTexture(GrEGLImage) const override;
-    sk_gpu_test::GLTestContext* createNew() const override;
+    std::unique_ptr<sk_gpu_test::GLTestContext> makeNew() const override;
 
 private:
     void destroyGLContext();
@@ -180,7 +180,7 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI)
             continue;
         }
 
-        this->init(gl.release(), EGLFenceSync::CreateIfSupported(fDisplay));
+        this->init(gl.release(), EGLFenceSync::MakeIfSupported(fDisplay));
         break;
     }
 }
@@ -255,8 +255,8 @@ GrGLuint EGLGLTestContext::eglImageToExternalTexture(GrEGLImage image) const {
     return texID;
 }
 
-sk_gpu_test::GLTestContext* EGLGLTestContext::createNew() const {
-    sk_gpu_test::GLTestContext* ctx = new EGLGLTestContext(this->gl()->fStandard);
+std::unique_ptr<sk_gpu_test::GLTestContext> EGLGLTestContext::makeNew() const {
+    std::unique_ptr<sk_gpu_test::GLTestContext> ctx(new EGLGLTestContext(this->gl()->fStandard));
     if (ctx) {
         ctx->makeCurrent();
     }
@@ -294,11 +294,11 @@ static bool supports_egl_extension(EGLDisplay display, const char* extension) {
     return false;
 }
 
-EGLFenceSync* EGLFenceSync::CreateIfSupported(EGLDisplay display) {
+std::unique_ptr<EGLFenceSync> EGLFenceSync::MakeIfSupported(EGLDisplay display) {
     if (!display || !supports_egl_extension(display, "EGL_KHR_fence_sync")) {
         return nullptr;
     }
-    return new EGLFenceSync(display);
+    return std::unique_ptr<EGLFenceSync>(new EGLFenceSync(display));
 }
 
 sk_gpu_test::PlatformFence EGLFenceSync::insertFence() const {
index 92bef7c..502dea8 100644 (file)
@@ -134,8 +134,8 @@ protected:
 private:
     VkTestContextImpl(sk_sp<const GrVkBackendContext> backendContext)
             : VkTestContext(std::move(backendContext)) {
-        fFenceSync = new VkFenceSync(sk_ref_sp(fVk->fInterface.get()), fVk->fDevice, fVk->fQueue,
-                                     fVk->fGraphicsQueueIndex);
+        fFenceSync.reset(new VkFenceSync(fVk->fInterface, fVk->fDevice, fVk->fQueue,
+                                         fVk->fGraphicsQueueIndex));
     }
 
     void onPlatformMakeCurrent() const override {}
index 609d75d..f788ec8 100644 (file)
@@ -34,7 +34,7 @@ sk_sp<SkData> read_file(const char* file_path) {
 }
 
 bool get_bitmap(sk_sp<SkData> fileBits, DiffResource& resource, bool sizeOnly) {
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fileBits));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(fileBits));
     if (!codec) {
         SkDebugf("ERROR: could not create codec for <%s>\n", resource.fFullPath.c_str());
         resource.fStatus = DiffResource::kCouldNotDecode_Status;
index 9da9f0f..134fdf0 100644 (file)
@@ -55,7 +55,7 @@ SkBitmap* Request::getBitmapFromCanvas(SkCanvas* canvas) {
 
 sk_sp<SkData> Request::writeCanvasToPng(SkCanvas* canvas) {
     // capture pixels
-    SkAutoTDelete<SkBitmap> bmp(this->getBitmapFromCanvas(canvas));
+    std::unique_ptr<SkBitmap> bmp(this->getBitmapFromCanvas(canvas));
     SkASSERT(bmp);
 
     // Convert to format suitable for PNG output
@@ -302,7 +302,7 @@ sk_sp<SkData> Request::getJsonInfo(int n) {
 SkColor Request::getPixel(int x, int y) {
     SkCanvas* canvas = this->getCanvas();
     canvas->flush();
-    SkAutoTDelete<SkBitmap> bitmap(this->getBitmapFromCanvas(canvas));
+    std::unique_ptr<SkBitmap> bitmap(this->getBitmapFromCanvas(canvas));
     SkASSERT(bitmap);
 
     // Convert to format suitable for inspection
index e70f618..0ffd4ea 100644 (file)
@@ -37,7 +37,7 @@ void ImageSlide::draw(SkCanvas* canvas) {
 
 void ImageSlide::load(SkScalar, SkScalar) {
     sk_sp<SkData> encoded = SkData::MakeFromFileName(fPath.c_str());
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(encoded));
     if (!codec) {
         return;
     }
index 739882d..d92b801 100644 (file)
@@ -252,7 +252,7 @@ void Viewer::initSlides() {
 
     const skiagm::GMRegistry* gms(skiagm::GMRegistry::Head());
     while (gms) {
-        SkAutoTDelete<skiagm::GM> gm(gms->factory()(nullptr));
+        std::unique_ptr<skiagm::GM> gm(gms->factory()(nullptr));
 
         if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, gm->getName())) {
             sk_sp<Slide> slide(new GMSlide(gm.release()));
index 9e9ed96..ee4c2a5 100644 (file)
@@ -124,7 +124,7 @@ int main(int argc, char** argv) {
         SkDebugf("Cannot find input image.\n");
         return -1;
     }
-    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
+    std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data));
     if (!codec) {
         SkDebugf("Invalid input image.\n");
         return -1;