bench, samples, etc: s/SkAutoTUnref/sk_sp/
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4437
Change-Id: Ice071684ac8a99e4bb405b4b9be8e8f42c7bac42
Reviewed-on: https://skia-review.googlesource.com/4437
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
diff --git a/bench/GrResourceCacheBench.cpp b/bench/GrResourceCacheBench.cpp
index 295a5bc..903c773 100644
--- a/bench/GrResourceCacheBench.cpp
+++ b/bench/GrResourceCacheBench.cpp
@@ -69,7 +69,7 @@
}
void onDraw(int loops, SkCanvas* canvas) override {
- SkAutoTUnref<GrContext> context(GrContext::CreateMockContext());
+ sk_sp<GrContext> context(GrContext::CreateMockContext());
if (nullptr == context) {
return;
}
@@ -143,14 +143,14 @@
for (int k = 0; k < CACHE_SIZE_COUNT; ++k) {
GrUniqueKey key;
BenchResource::ComputeKey(k, fKeyData32Count, &key);
- SkAutoTUnref<GrGpuResource> resource(cache->findAndRefUniqueResource(key));
+ sk_sp<GrGpuResource> resource(cache->findAndRefUniqueResource(key));
SkASSERT(resource);
}
}
}
private:
- SkAutoTUnref<GrContext> fContext;
+ sk_sp<GrContext> fContext;
SkString fFullName;
int fKeyData32Count;
typedef Benchmark INHERITED;
diff --git a/bench/SKPAnimationBench.h b/bench/SKPAnimationBench.h
index c0bef30..7701595 100644
--- a/bench/SKPAnimationBench.h
+++ b/bench/SKPAnimationBench.h
@@ -40,10 +40,10 @@
void drawPicture() override;
private:
- SkAutoTUnref<Animation> fAnimation;
- WallTimer fAnimationTimer;
- SkString fUniqueName;
- SkIRect fDevBounds;
+ sk_sp<Animation> fAnimation;
+ WallTimer fAnimationTimer;
+ SkString fUniqueName;
+ SkIRect fDevBounds;
typedef SKPBench INHERITED;
};
diff --git a/bench/SKPBench.cpp b/bench/SKPBench.cpp
index add415d..7d92c9e 100644
--- a/bench/SKPBench.cpp
+++ b/bench/SKPBench.cpp
@@ -135,7 +135,7 @@
SkMatrix trans;
trans.setTranslate(-fTileRects[j].fLeft/fScale,
-fTileRects[j].fTop/fScale);
- mpd.add(fSurfaces[j]->getCanvas(), fPic, &trans);
+ mpd.add(fSurfaces[j]->getCanvas(), fPic.get(), &trans);
}
mpd.draw();
@@ -149,7 +149,7 @@
for (int j = 0; j < fTileRects.count(); ++j) {
const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale,
-fTileRects[j].fTop / fScale);
- fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, nullptr);
+ fSurfaces[j]->getCanvas()->drawPicture(fPic.get(), &trans, nullptr);
}
for (int j = 0; j < fTileRects.count(); ++j) {
@@ -190,10 +190,10 @@
context->freeGpuResources();
context->resetContext();
context->getGpu()->resetShaderCacheForTesting();
- draw_pic_for_stats(canvas, context, fPic, keys, values, "first_frame");
+ draw_pic_for_stats(canvas, context, fPic.get(), keys, values, "first_frame");
// draw second frame
- draw_pic_for_stats(canvas, context, fPic, keys, values, "second_frame");
+ draw_pic_for_stats(canvas, context, fPic.get(), keys, values, "second_frame");
#endif
}
diff --git a/bench/SKPBench.h b/bench/SKPBench.h
index 1f34a00..2874bff 100644
--- a/bench/SKPBench.h
+++ b/bench/SKPBench.h
@@ -42,12 +42,12 @@
virtual void drawMPDPicture();
virtual void drawPicture();
- const SkPicture* picture() const { return fPic; }
+ const SkPicture* picture() const { return fPic.get(); }
const SkTDArray<SkSurface*>& surfaces() const { return fSurfaces; }
const SkTDArray<SkIRect>& tileRects() const { return fTileRects; }
private:
- SkAutoTUnref<const SkPicture> fPic;
+ sk_sp<const SkPicture> fPic;
const SkIRect fClip;
const SkScalar fScale;
SkString fName;
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 0651302..25e04bf 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -801,9 +801,9 @@
fCurrentAnimSKP++;
SkString name = SkOSPath::Basename(path.c_str());
- SkAutoTUnref<SKPAnimationBench::Animation> animation(
+ sk_sp<SKPAnimationBench::Animation> animation(
SKPAnimationBench::CreateZoomAnimation(fZoomMax, fZoomPeriodMs));
- return new SKPAnimationBench(name.c_str(), pic.get(), fClip, animation,
+ return new SKPAnimationBench(name.c_str(), pic.get(), fClip, animation.get(),
FLAGS_loopSKP);
}
}
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp
index 7e6f2a0..3b84afc 100644
--- a/debugger/QT/SkDebuggerGUI.cpp
+++ b/debugger/QT/SkDebuggerGUI.cpp
@@ -281,7 +281,7 @@
SkFILEWStream file(filename.c_str());
sk_sp<SkPicture> copy(fDebugger.copyPicture());
- SkAutoTUnref<SkPixelSerializer> serializer(
+ sk_sp<SkPixelSerializer> serializer(
SkImageEncoder::CreatePixelSerializer());
copy->serialize(&file, serializer);
}
diff --git a/debugger/QT/SkGLWidget.h b/debugger/QT/SkGLWidget.h
index 465e099..870b283 100644
--- a/debugger/QT/SkGLWidget.h
+++ b/debugger/QT/SkGLWidget.h
@@ -45,8 +45,8 @@
private:
void createRenderTarget();
- SkAutoTUnref<const GrGLInterface> fCurIntf;
- SkAutoTUnref<GrContext> fCurContext;
+ sk_sp<const GrGLInterface> fCurIntf;
+ sk_sp<GrContext> fCurContext;
sk_sp<SkSurface> fGpuSurface;
SkCanvas* fCanvas;
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index dd54f00..68d1245 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -367,7 +367,7 @@
static void draw_to_canvas(SkCanvas* canvas, const SkImageInfo& info, void* pixels, size_t rowBytes,
SkPMColor* colorPtr, int colorCount, CodecSrc::DstColorType dstColorType,
SkScalar left = 0, SkScalar top = 0) {
- SkAutoTUnref<SkColorTable> colorTable(new SkColorTable(colorPtr, colorCount));
+ sk_sp<SkColorTable> colorTable(new SkColorTable(colorPtr, colorCount));
SkBitmap bitmap;
bitmap.installPixels(info, pixels, rowBytes, colorTable.get(), nullptr, nullptr);
premultiply_if_necessary(bitmap);
@@ -1373,7 +1373,7 @@
Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const {
#if defined(SK_XML)
std::unique_ptr<SkXMLWriter> xmlWriter(new SkXMLStreamWriter(dst));
- SkAutoTUnref<SkCanvas> canvas(SkSVGCanvas::Create(
+ sk_sp<SkCanvas> canvas(SkSVGCanvas::Create(
SkRect::MakeWH(SkIntToScalar(src.size().width()), SkIntToScalar(src.size().height())),
xmlWriter.get()));
return src.draw(canvas);
diff --git a/dm/DMSrcSinkAndroid.cpp b/dm/DMSrcSinkAndroid.cpp
index 77ec1c9..c204b36 100644
--- a/dm/DMSrcSinkAndroid.cpp
+++ b/dm/DMSrcSinkAndroid.cpp
@@ -48,7 +48,7 @@
Error draw(SkCanvas* canvas) const override {
// Pass through HWUI's upper layers to get operational transforms
std::unique_ptr<android::Canvas> ac(android::Canvas::create_canvas(canvas));
- SkAutoTUnref<android::uirenderer::SkiaCanvasProxy> scProxy
+ sk_sp<android::uirenderer::SkiaCanvasProxy> scProxy
(new android::uirenderer::SkiaCanvasProxy(ac.get()));
// Pass through another proxy to get paint transforms
diff --git a/example/SkiaSDLExample.cpp b/example/SkiaSDLExample.cpp
index 0072f0f..3aa42b3 100644
--- a/example/SkiaSDLExample.cpp
+++ b/example/SkiaSDLExample.cpp
@@ -183,15 +183,15 @@
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// setup GrContext
- SkAutoTUnref<const GrGLInterface> interface(GrGLCreateNativeInterface());
+ sk_sp<const GrGLInterface> interface(GrGLCreateNativeInterface());
// To use NVPR, comment this out
interface.reset(GrGLInterfaceRemoveNVPR(interface));
SkASSERT(interface);
// setup contexts
- SkAutoTUnref<GrContext> grContext(GrContext::Create(kOpenGL_GrBackend,
- (GrBackendContext)interface.get()));
+ sk_sp<GrContext> grContext(GrContext::Create(kOpenGL_GrBackend,
+ (GrBackendContext)interface.get()));
SkASSERT(grContext);
// Wrap the frame buffer object attached to the screen in a Skia render target so Skia can
diff --git a/experimental/GLFWTest/glfw_main.cpp b/experimental/GLFWTest/glfw_main.cpp
index 21ec33d..63ea1f1 100644
--- a/experimental/GLFWTest/glfw_main.cpp
+++ b/experimental/GLFWTest/glfw_main.cpp
@@ -76,7 +76,7 @@
init_skia(kWidth, kHeight);
- SkAutoTUnref<SkImage> atlas;
+ sk_sp<SkImage> atlas;
SkRSXform xform[kGrid*kGrid+1];
SkRect tex[kGrid*kGrid+1];
WallTimer timer;
diff --git a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
index c0652bf..fcbf017 100644
--- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
+++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
@@ -1321,14 +1321,15 @@
if (fType == kImprovedNoise_Type) {
GrTextureParams textureParams(SkShader::TileMode::kRepeat_TileMode,
GrTextureParams::FilterMode::kNone_FilterMode);
- SkAutoTUnref<GrTexture> permutationsTexture(
+ sk_sp<GrTexture> permutationsTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getImprovedPermutationsBitmap(),
textureParams, args.fGammaTreatment));
- SkAutoTUnref<GrTexture> gradientTexture(
+ sk_sp<GrTexture> gradientTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getGradientBitmap(),
textureParams, args.fGammaTreatment));
return GrImprovedPerlinNoiseEffect::Make(fNumOctaves, fSeed, paintingData,
- permutationsTexture, gradientTexture, m);
+ permutationsTexture.get(),
+ gradientTexture.get(), m);
}
if (0 == fNumOctaves) {
@@ -1347,10 +1348,10 @@
GrConstColorProcessor::kIgnore_InputMode);
}
- SkAutoTUnref<GrTexture> permutationsTexture(
+ sk_sp<GrTexture> permutationsTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getPermutationsBitmap(),
GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
- SkAutoTUnref<GrTexture> noiseTexture(
+ sk_sp<GrTexture> noiseTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getNoiseBitmap(),
GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
@@ -1360,7 +1361,7 @@
fNumOctaves,
fStitchTiles,
paintingData,
- permutationsTexture, noiseTexture,
+ permutationsTexture.get(), noiseTexture.get(),
m));
return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
}
diff --git a/experimental/SkV8Example/SkV8Example.cpp b/experimental/SkV8Example/SkV8Example.cpp
index 5bfd64d..388ef0e 100644
--- a/experimental/SkV8Example/SkV8Example.cpp
+++ b/experimental/SkV8Example/SkV8Example.cpp
@@ -108,7 +108,7 @@
SkSurface* SkV8ExampleWindow::createSurface() {
if (FLAGS_gpu) {
// Increase the ref count since callers of createSurface put the
- // results in a SkAutoTUnref.
+ // results in a sk_sp.
fCurSurface->ref();
return fCurSurface;
} else {
diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp
index 7aac5da..d6534f1 100644
--- a/fuzz/fuzz.cpp
+++ b/fuzz/fuzz.cpp
@@ -145,7 +145,7 @@
decodeInfo = decodeInfo.makeWH(size.width(), size.height());
// Construct a color table for the decode if necessary
- SkAutoTUnref<SkColorTable> colorTable(nullptr);
+ sk_sp<SkColorTable> colorTable(nullptr);
SkPMColor* colorPtr = nullptr;
int* colorCountPtr = nullptr;
int maxColors = 256;
diff --git a/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.cpp b/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.cpp
index c5d9759..086cd5d 100644
--- a/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.cpp
+++ b/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.cpp
@@ -29,7 +29,7 @@
(JNIEnv* env, jclass clazz, jobject inputStream, jbyteArray buffer) {
JavaInputStream stream(env, buffer, inputStream);
#if 0
- SkAutoTUnref<SkPicture> p(SkPicture::CreateFromStream(&stream));
+ sk_sp<SkPicture> p(SkPicture::CreateFromStream(&stream));
if (!p) { return 0; }
SkPictureRecorder recorder;
SkRect bounds = p->cullRect();
diff --git a/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.cpp b/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.cpp
index de38919..1bdc655 100644
--- a/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.cpp
+++ b/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_GaneshPictureRenderer.cpp
@@ -53,7 +53,7 @@
namespace {
struct GaneshPictureRendererImpl {
- SkAutoTUnref<GrContext> fGrContext;
+ sk_sp<GrContext> fGrContext;
void render(int w, int h, const SkPicture* p, const SkMatrix& m) {
if (!fGrContext) {
// Cache the rendering context between frames.
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 6722429..75827ff 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -241,7 +241,7 @@
fActualColorBits = SkTMax(attachmentInfo.fColorBits, 24);
SkASSERT(nullptr == fCurIntf);
- SkAutoTUnref<const GrGLInterface> glInterface;
+ sk_sp<const GrGLInterface> glInterface;
switch (win->getDeviceType()) {
case kRaster_DeviceType: // fallthrough
case kGPU_DeviceType:
diff --git a/samplecode/SampleLitAtlas.cpp b/samplecode/SampleLitAtlas.cpp
index 149da98..ee639d3 100644
--- a/samplecode/SampleLitAtlas.cpp
+++ b/samplecode/SampleLitAtlas.cpp
@@ -492,7 +492,7 @@
}
void onDrawContent(SkCanvas* canvas) override {
- canvas->drawDrawable(fDrawable);
+ canvas->drawDrawable(fDrawable.get());
this->inval(NULL);
}
@@ -506,7 +506,7 @@
#endif
private:
- SkAutoTUnref<DrawLitAtlasDrawable> fDrawable;
+ sk_sp<DrawLitAtlasDrawable> fDrawable;
typedef SampleView INHERITED;
};
diff --git a/samplecode/SampleXfer.cpp b/samplecode/SampleXfer.cpp
index c0ad000..738541f 100644
--- a/samplecode/SampleXfer.cpp
+++ b/samplecode/SampleXfer.cpp
@@ -153,20 +153,20 @@
};
SkRect fModeRect[N_Modes];
- SkAutoTUnref<CircDrawable> fDrs[N];
+ sk_sp<CircDrawable> fDrs[N];
CircDrawable* fSelected;
void addButtons() {
SkScalar x = 10;
SkScalar y = 10;
for (int i = 0; i < N_Modes; ++i) {
- SkAutoTUnref<SkView> v(new PushButtonWig(gModes[i].fName, (int)gModes[i].fMode));
+ sk_sp<SkView> v(new PushButtonWig(gModes[i].fName, (int)gModes[i].fMode));
v->setSize(70, 25);
v->setLoc(x, y);
v->setVisibleP(true);
v->setEnabledP(true);
v->addListenerID(this->getSinkID());
- this->attachChildToFront(v);
+ this->attachChildToFront(v.get());
fModeRect[i] = SkRect::MakeXYWH(x, y + 28, 70, 2);
x += 80;
}
@@ -227,7 +227,7 @@
fSelected = nullptr;
for (int i = N - 1; i >= 0; --i) {
if (fDrs[i]->hitTest(x, y)) {
- fSelected = fDrs[i];
+ fSelected = fDrs[i].get();
break;
}
}