aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-23 18:59:25 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-23 18:59:25 -0700
commite8f3062a36d3682f4019309a32b5b84dc9eddf8c (patch)
treeff5cd50c65edb6e3b77f77327165ad0162557137 /gm
parent041c870425eb0a3e2b0cbc46581b3da2f50571d9 (diff)
switch surface to sk_sp
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1817383002 CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac-Clang-x86_64-Release-CMake-Trybot Review URL: https://codereview.chromium.org/1817383002
Diffstat (limited to 'gm')
-rw-r--r--gm/bigtileimagefilter.cpp2
-rw-r--r--gm/color4f.cpp2
-rw-r--r--gm/complexclip_blur_tiled.cpp6
-rw-r--r--gm/dftext.cpp5
-rw-r--r--gm/discard.cpp4
-rw-r--r--gm/drawatlas.cpp4
-rw-r--r--gm/drawatlascolor.cpp4
-rw-r--r--gm/drawbitmaprect.cpp4
-rw-r--r--gm/drawminibitmaprect.cpp4
-rw-r--r--gm/fatpathfill.cpp8
-rw-r--r--gm/filterfastbounds.cpp2
-rw-r--r--gm/image.cpp27
-rw-r--r--gm/image_pict.cpp3
-rw-r--r--gm/image_shader.cpp5
-rw-r--r--gm/imagealphathreshold.cpp4
-rw-r--r--gm/imagefilters.cpp4
-rw-r--r--gm/imagefiltersclipped.cpp2
-rw-r--r--gm/imagefilterscropexpand.cpp2
-rw-r--r--gm/imagefiltersscaled.cpp2
-rw-r--r--gm/imagefilterstransformed.cpp2
-rw-r--r--gm/imagescalealigned.cpp2
-rw-r--r--gm/imagesource2.cpp2
-rw-r--r--gm/imagetoyuvplanes.cpp6
-rw-r--r--gm/lcdblendmodes.cpp4
-rw-r--r--gm/localmatriximagefilter.cpp4
-rw-r--r--gm/mipmap.cpp2
-rw-r--r--gm/multipicturedraw.cpp12
-rw-r--r--gm/ninepatchstretch.cpp8
-rw-r--r--gm/perspshaders.cpp4
-rw-r--r--gm/resizeimagefilter.cpp2
-rw-r--r--gm/srcmode.cpp9
-rw-r--r--gm/surface.cpp19
-rw-r--r--gm/textblobgeometrychange.cpp2
-rw-r--r--gm/textblobmixedsizes.cpp5
-rw-r--r--gm/textblobrandomfont.cpp2
-rw-r--r--gm/transparency.cpp2
-rw-r--r--gm/verylargebitmap.cpp2
-rw-r--r--gm/xfermodes3.cpp10
38 files changed, 91 insertions, 102 deletions
diff --git a/gm/bigtileimagefilter.cpp b/gm/bigtileimagefilter.cpp
index 84b9816a83..7d3d3afeed 100644
--- a/gm/bigtileimagefilter.cpp
+++ b/gm/bigtileimagefilter.cpp
@@ -11,7 +11,7 @@
#include "gm.h"
static sk_sp<SkImage> create_circle_texture(int size, SkColor color) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(size, size));
+ auto surface(SkSurface::MakeRasterN32Premul(size, size));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0xFF000000);
diff --git a/gm/color4f.cpp b/gm/color4f.cpp
index ec9bbcbfba..7704dee458 100644
--- a/gm/color4f.cpp
+++ b/gm/color4f.cpp
@@ -77,7 +77,7 @@ DEF_SIMPLE_GM(color4f, canvas, 1024, 260) {
for (auto profile : profiles) {
const SkImageInfo info = SkImageInfo::Make(1024, 100, kN32_SkColorType, kPremul_SkAlphaType,
profile);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ auto surface(SkSurface::MakeRaster(info));
surface->getCanvas()->drawPaint(bg);
draw_into_canvas(surface->getCanvas());
surface->draw(canvas, 0, 0, nullptr);
diff --git a/gm/complexclip_blur_tiled.cpp b/gm/complexclip_blur_tiled.cpp
index b619e67e14..9413e64e07 100644
--- a/gm/complexclip_blur_tiled.cpp
+++ b/gm/complexclip_blur_tiled.cpp
@@ -40,9 +40,9 @@ protected:
}
int ts = SkScalarCeilToInt(tile_size);
SkImageInfo info = SkImageInfo::MakeN32Premul(ts, ts);
- SkAutoTUnref<SkSurface> tileSurface(canvas->newSurface(info));
- if (!tileSurface.get()) {
- tileSurface.reset(SkSurface::NewRaster(info));
+ auto tileSurface(canvas->makeSurface(info));
+ if (!tileSurface) {
+ tileSurface = SkSurface::MakeRaster(info);
}
SkCanvas* tileCanvas = tileSurface->getCanvas();
for (SkScalar y = bounds.top(); y < bounds.bottom(); y += tile_size) {
diff --git a/gm/dftext.cpp b/gm/dftext.cpp
index 545911c26c..0d5b1ff4e9 100644
--- a/gm/dftext.cpp
+++ b/gm/dftext.cpp
@@ -51,9 +51,8 @@ protected:
SkImageInfo info = SkImageInfo::MakeN32Premul(onISize());
SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
SkSurfaceProps::kLegacyFontHost_InitType);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo,
- info, 0, &props));
- SkCanvas* canvas = surface.get() ? surface->getCanvas() : inputCanvas;
+ auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props));
+ SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas;
// init our new canvas with the old canvas's matrix
canvas->setMatrix(inputCanvas->getTotalMatrix());
#else
diff --git a/gm/discard.cpp b/gm/discard.cpp
index 6f64b9c0b9..d75f0ab141 100644
--- a/gm/discard.cpp
+++ b/gm/discard.cpp
@@ -45,8 +45,7 @@ protected:
size.fWidth /= 10;
size.fHeight /= 10;
SkImageInfo info = SkImageInfo::MakeN32Premul(size);
- SkSurface* surface = SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info);
-
+ auto surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
if (nullptr == surface) {
return;
}
@@ -78,7 +77,6 @@ protected:
}
surface->getCanvas()->discard();
- surface->unref();
}
private:
diff --git a/gm/drawatlas.cpp b/gm/drawatlas.cpp
index 4d2f6d46f3..334aba7af1 100644
--- a/gm/drawatlas.cpp
+++ b/gm/drawatlas.cpp
@@ -13,9 +13,9 @@
class DrawAtlasGM : public skiagm::GM {
static sk_sp<SkImage> MakeAtlas(SkCanvas* caller, const SkRect& target) {
SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- SkAutoTUnref<SkSurface> surface(caller->newSurface(info));
+ auto surface(caller->makeSurface(info));
if (nullptr == surface) {
- surface.reset(SkSurface::NewRaster(info));
+ surface = SkSurface::MakeRaster(info);
}
SkCanvas* canvas = surface->getCanvas();
// draw red everywhere, but we don't expect to see it in the draw, testing the notion
diff --git a/gm/drawatlascolor.cpp b/gm/drawatlascolor.cpp
index 85a7a9473a..e8fd23608c 100644
--- a/gm/drawatlascolor.cpp
+++ b/gm/drawatlascolor.cpp
@@ -19,9 +19,9 @@ static sk_sp<SkImage> make_atlas(SkCanvas* caller, int atlasSize) {
const int kBlockSize = atlasSize/2;
SkImageInfo info = SkImageInfo::MakeN32Premul(atlasSize, atlasSize);
- SkAutoTUnref<SkSurface> surface(caller->newSurface(info));
+ auto surface(caller->makeSurface(info));
if (nullptr == surface) {
- surface.reset(SkSurface::NewRaster(info));
+ surface = SkSurface::MakeRaster(info);
}
SkCanvas* canvas = surface->getCanvas();
diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp
index 8ec7cee28e..883e81b417 100644
--- a/gm/drawbitmaprect.cpp
+++ b/gm/drawbitmaprect.cpp
@@ -36,10 +36,10 @@ static SkBitmap make_chessbm(int w, int h) {
static sk_sp<SkImage> makebm(SkCanvas* origCanvas, SkBitmap* resultBM, int w, int h) {
SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
- SkAutoTUnref<SkSurface> surface(origCanvas->newSurface(info));
+ auto surface(origCanvas->makeSurface(info));
if (nullptr == surface) {
// picture canvas will return null, so fall-back to raster
- surface.reset(SkSurface::NewRaster(info));
+ surface = SkSurface::MakeRaster(info);
}
SkCanvas* canvas = surface->getCanvas();
diff --git a/gm/drawminibitmaprect.cpp b/gm/drawminibitmaprect.cpp
index c494605daf..f5164f78de 100644
--- a/gm/drawminibitmaprect.cpp
+++ b/gm/drawminibitmaprect.cpp
@@ -15,9 +15,9 @@
static sk_sp<SkImage> makebm(SkCanvas* caller, int w, int h) {
SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
- SkAutoTUnref<SkSurface> surface(caller->newSurface(info));
+ auto surface(caller->makeSurface(info));
if (nullptr == surface) {
- surface.reset(SkSurface::NewRaster(info));
+ surface = SkSurface::MakeRaster(info);
}
SkCanvas* canvas = surface->getCanvas();
diff --git a/gm/fatpathfill.cpp b/gm/fatpathfill.cpp
index d76cd463ad..46e810eeb0 100644
--- a/gm/fatpathfill.cpp
+++ b/gm/fatpathfill.cpp
@@ -15,8 +15,8 @@
#define SMALL_H 3
#define REPEAT_LOOP 5
-static SkSurface* new_surface(int width, int height) {
- return SkSurface::NewRasterN32Premul(width, height);
+static sk_sp<SkSurface> new_surface(int width, int height) {
+ return SkSurface::MakeRasterN32Premul(width, height);
}
static void draw_pixel_centers(SkCanvas* canvas) {
@@ -49,7 +49,7 @@ static void draw_fatpath(SkCanvas* canvas, SkSurface* surface, const SkPath& pat
DEF_SIMPLE_GM(fatpathfill, canvas,
SMALL_W * ZOOM,
SMALL_H * ZOOM * REPEAT_LOOP) {
- SkAutoTUnref<SkSurface> surface(new_surface(SMALL_W, SMALL_H));
+ auto surface(new_surface(SMALL_W, SMALL_H));
canvas->scale(ZOOM, ZOOM);
@@ -62,7 +62,7 @@ DEF_SIMPLE_GM(fatpathfill, canvas,
line.moveTo(1, 2);
line.lineTo(SkIntToScalar(4 + i), 1);
paint.getFillPath(line, &path);
- draw_fatpath(canvas, surface, path);
+ draw_fatpath(canvas, surface.get(), path);
canvas->translate(0, SMALL_H);
}
diff --git a/gm/filterfastbounds.cpp b/gm/filterfastbounds.cpp
index 9dabdcb7df..1de30e5826 100644
--- a/gm/filterfastbounds.cpp
+++ b/gm/filterfastbounds.cpp
@@ -264,7 +264,7 @@ protected:
//-----------
// Paints with a SkImageSource as a source
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10));
+ auto surface(SkSurface::MakeRasterN32Premul(10, 10));
{
SkPaint p;
SkCanvas* temp = surface->getCanvas();
diff --git a/gm/image.cpp b/gm/image.cpp
index b32e430e91..8cc3023edf 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -167,21 +167,20 @@ protected:
sk_bzero(fBuffer, fBufferSize);
SkImageInfo info = SkImageInfo::MakeN32Premul(W, H);
- SkAutoTUnref<SkSurface> surf0(SkSurface::NewRasterDirect(info, fBuffer, RB));
- SkAutoTUnref<SkSurface> surf1(SkSurface::NewRaster(info));
- SkAutoTUnref<SkSurface> surf2; // gpu
+ sk_sp<SkSurface> surf0(SkSurface::MakeRasterDirect(info, fBuffer, RB));
+ sk_sp<SkSurface> surf1(SkSurface::MakeRaster(info));
+ sk_sp<SkSurface> surf2; // gpu
#if SK_SUPPORT_GPU
- surf2.reset(SkSurface::NewRenderTarget(canvas->getGrContext(),
- SkBudgeted::kNo, info));
+ surf2 = SkSurface::MakeRenderTarget(canvas->getGrContext(), SkBudgeted::kNo, info);
#endif
- test_surface(canvas, surf0, true);
+ test_surface(canvas, surf0.get(), true);
canvas->translate(80, 0);
- test_surface(canvas, surf1, true);
+ test_surface(canvas, surf1.get(), true);
if (surf2) {
canvas->translate(80, 0);
- test_surface(canvas, surf2, true);
+ test_surface(canvas, surf2.get(), true);
}
}
@@ -238,7 +237,7 @@ static void draw_contents(SkCanvas* canvas) {
}
static sk_sp<SkImage> make_raster(const SkImageInfo& info, GrContext*, void (*draw)(SkCanvas*)) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ auto surface(SkSurface::MakeRaster(info));
draw(surface->getCanvas());
return surface->makeImageSnapshot();
}
@@ -258,7 +257,7 @@ static sk_sp<SkImage> make_codec(const SkImageInfo& info, GrContext*, void (*dra
static sk_sp<SkImage> make_gpu(const SkImageInfo& info, GrContext* ctx, void (*draw)(SkCanvas*)) {
if (!ctx) { return nullptr; }
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo, info));
+ auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
draw(surface->getCanvas());
return surface->makeImageSnapshot();
}
@@ -335,7 +334,7 @@ static void draw_opaque_contents(SkCanvas* canvas) {
}
static SkImageGenerator* gen_raster(const SkImageInfo& info) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ auto surface(SkSurface::MakeRaster(info));
draw_opaque_contents(surface->getCanvas());
return new ImageGeneratorFromImage(surface->makeImageSnapshot().get());
}
@@ -481,9 +480,9 @@ DEF_SIMPLE_GM(new_texture_image, canvas, 225, 60) {
},
// Create a texture image
[context, render_image]() -> sk_sp<SkImage> {
- SkAutoTUnref<SkSurface> surface(
- SkSurface::NewRenderTarget(context, SkBudgeted::kYes,
- SkImageInfo::MakeN32Premul(kSize, kSize)));
+ auto surface(
+ SkSurface::MakeRenderTarget(context, SkBudgeted::kYes,
+ SkImageInfo::MakeN32Premul(kSize, kSize)));
if (!surface) {
return nullptr;
}
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index b5eb522dfa..32092213dc 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -211,8 +211,7 @@ public:
: SkImageGenerator(info)
, fCtx(SkRef(ctx))
{
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo,
- info, 0));
+ auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
surface->getCanvas()->clear(0);
surface->getCanvas()->translate(-100, -100);
surface->getCanvas()->drawPicture(pic);
diff --git a/gm/image_shader.cpp b/gm/image_shader.cpp
index 061539013e..5fed7d1344 100644
--- a/gm/image_shader.cpp
+++ b/gm/image_shader.cpp
@@ -27,7 +27,7 @@ static void draw_something(SkCanvas* canvas, const SkRect& bounds) {
typedef sk_sp<SkImage> (*ImageMakerProc)(GrContext*, SkPicture*, const SkImageInfo&);
static sk_sp<SkImage> make_raster(GrContext*, SkPicture* pic, const SkImageInfo& info) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ auto surface(SkSurface::MakeRaster(info));
surface->getCanvas()->clear(0);
surface->getCanvas()->drawPicture(pic);
return surface->makeImageSnapshot();
@@ -37,8 +37,7 @@ static sk_sp<SkImage> make_texture(GrContext* ctx, SkPicture* pic, const SkImage
if (!ctx) {
return nullptr;
}
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo,
- info, 0));
+ auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
surface->getCanvas()->clear(0);
surface->getCanvas()->drawPicture(pic);
return surface->makeImageSnapshot();
diff --git a/gm/imagealphathreshold.cpp b/gm/imagealphathreshold.cpp
index eafc32f8d6..8d65cf8ee7 100644
--- a/gm/imagealphathreshold.cpp
+++ b/gm/imagealphathreshold.cpp
@@ -95,9 +95,9 @@ protected:
void onDraw(SkCanvas* canvas) override {
SkImageInfo info = SkImageInfo::MakeN32(WIDTH, HEIGHT, kOpaque_SkAlphaType);
- SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
+ auto surface(canvas->makeSurface(info));
if (nullptr == surface) {
- surface.reset(SkSurface::NewRaster(info));
+ surface = SkSurface::MakeRaster(info);
}
surface->getCanvas()->clear(SK_ColorWHITE);
draw_rects(surface->getCanvas());
diff --git a/gm/imagefilters.cpp b/gm/imagefilters.cpp
index 21ce0fef97..ab9ddf4098 100644
--- a/gm/imagefilters.cpp
+++ b/gm/imagefilters.cpp
@@ -68,9 +68,9 @@ DEF_SIMPLE_GM(imagefilters_xfermodes, canvas, 480, 480) {
static sk_sp<SkImage> make_image(SkCanvas* canvas) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
+ auto surface(canvas->makeSurface(info));
if (!surface) {
- surface.reset(SkSurface::NewRaster(info));
+ surface = SkSurface::MakeRaster(info);
}
surface->getCanvas()->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), SkPaint());
return surface->makeImageSnapshot();
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp
index 26ee24b1d4..01b0a43fcb 100644
--- a/gm/imagefiltersclipped.cpp
+++ b/gm/imagefiltersclipped.cpp
@@ -47,7 +47,7 @@ protected:
SkScalar x = SkIntToScalar(width / 2);
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = SkMinScalar(x, y) * 0.8f;
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, height));
+ auto surface(SkSurface::MakeRasterN32Premul(width, height));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0x00000000);
SkColor colors[2];
diff --git a/gm/imagefilterscropexpand.cpp b/gm/imagefilterscropexpand.cpp
index ada206cea4..450610aded 100644
--- a/gm/imagefilterscropexpand.cpp
+++ b/gm/imagefilterscropexpand.cpp
@@ -143,7 +143,7 @@ private:
SkScalar x = SkIntToScalar(width / 2);
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = SkMinScalar(x, y) * 0.8f;
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, height));
+ auto surface(SkSurface::MakeRasterN32Premul(width, height));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0x00000000);
SkColor colors[2];
diff --git a/gm/imagefiltersscaled.cpp b/gm/imagefiltersscaled.cpp
index 391f4e5c1c..9c0150001c 100644
--- a/gm/imagefiltersscaled.cpp
+++ b/gm/imagefiltersscaled.cpp
@@ -139,7 +139,7 @@ private:
SkScalar x = SkIntToScalar(width / 2);
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = SkScalarMul(SkMinScalar(x, y), SkIntToScalar(4) / SkIntToScalar(5));
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, height));
+ auto surface(SkSurface::MakeRasterN32Premul(width, height));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0x00000000);
SkColor colors[2];
diff --git a/gm/imagefilterstransformed.cpp b/gm/imagefilterstransformed.cpp
index 4243902efe..e9a6a5da6d 100644
--- a/gm/imagefilterstransformed.cpp
+++ b/gm/imagefilterstransformed.cpp
@@ -29,7 +29,7 @@ static sk_sp<SkImage> make_gradient_circle(int width, int height) {
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = SkMinScalar(x, y) * 0.8f;
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, height));
+ auto surface(SkSurface::MakeRasterN32Premul(width, height));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0x00000000);
diff --git a/gm/imagescalealigned.cpp b/gm/imagescalealigned.cpp
index 66ad8b62f4..474490fd24 100644
--- a/gm/imagescalealigned.cpp
+++ b/gm/imagescalealigned.cpp
@@ -73,7 +73,7 @@ private:
const SkPoint end = SkPoint::Make(start.x() + vec.x() * (kSegLen - 1),
start.y() + vec.y() * (kSegLen - 1));
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(kSegLen, kSegLen));
+ auto surface(SkSurface::MakeRasterN32Premul(kSegLen, kSegLen));
surface->getCanvas()->clear(SK_ColorTRANSPARENT);
SkPaint paint;
diff --git a/gm/imagesource2.cpp b/gm/imagesource2.cpp
index 46c42f1d18..db8a9f69c4 100644
--- a/gm/imagesource2.cpp
+++ b/gm/imagesource2.cpp
@@ -41,7 +41,7 @@ protected:
SK_ColorWHITE, SK_ColorGRAY,
};
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(kImageSize, kImageSize));
+ auto surface(SkSurface::MakeRasterN32Premul(kImageSize, kImageSize));
SkCanvas* canvas = surface->getCanvas();
int curColor = 0;
diff --git a/gm/imagetoyuvplanes.cpp b/gm/imagetoyuvplanes.cpp
index ddead1be42..63d3fa92da 100644
--- a/gm/imagetoyuvplanes.cpp
+++ b/gm/imagetoyuvplanes.cpp
@@ -13,12 +13,12 @@
#include "SkImage.h"
static sk_sp<SkImage> create_image(GrContext* context, int width, int height) {
- SkAutoTUnref<SkSurface> surface;
+ sk_sp<SkSurface> surface;
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
if (context) {
- surface.reset(SkSurface::NewRenderTarget(context, SkBudgeted::kYes, info, 0));
+ surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info);
} else {
- surface.reset(SkSurface::NewRaster(info));
+ surface = SkSurface::MakeRaster(info);
}
if (!surface) {
return nullptr;
diff --git a/gm/lcdblendmodes.cpp b/gm/lcdblendmodes.cpp
index c3fe9ff149..874714b7fc 100644
--- a/gm/lcdblendmodes.cpp
+++ b/gm/lcdblendmodes.cpp
@@ -61,9 +61,9 @@ protected:
canvas->drawRect(r, p);
SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
- SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
+ auto surface(canvas->makeSurface(info));
if (nullptr == surface) {
- surface.reset(SkSurface::NewRaster(info));
+ surface = SkSurface::MakeRaster(info);
}
SkCanvas* surfCanvas = surface->getCanvas();
diff --git a/gm/localmatriximagefilter.cpp b/gm/localmatriximagefilter.cpp
index f99655863e..dd86c967f9 100644
--- a/gm/localmatriximagefilter.cpp
+++ b/gm/localmatriximagefilter.cpp
@@ -16,9 +16,9 @@
static sk_sp<SkImage> make_image(SkCanvas* rootCanvas) {
SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- SkAutoTUnref<SkSurface> surface(rootCanvas->newSurface(info));
+ auto surface(rootCanvas->makeSurface(info));
if (!surface) {
- surface.reset(SkSurface::NewRaster(info));
+ surface = SkSurface::MakeRaster(info);
}
SkPaint paint;
diff --git a/gm/mipmap.cpp b/gm/mipmap.cpp
index 4b1912a99c..9a0f060162 100644
--- a/gm/mipmap.cpp
+++ b/gm/mipmap.cpp
@@ -13,7 +13,7 @@
static sk_sp<SkImage> make_image() {
const SkImageInfo info = SkImageInfo::MakeN32Premul(319, 52);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ auto surface(SkSurface::MakeRaster(info));
SkCanvas* canvas = surface->getCanvas();
canvas->drawColor(sk_tool_utils::color_to_565(0xFFF8F8F8));
diff --git a/gm/multipicturedraw.cpp b/gm/multipicturedraw.cpp
index a4b09b2c2f..03934a601d 100644
--- a/gm/multipicturedraw.cpp
+++ b/gm/multipicturedraw.cpp
@@ -241,15 +241,14 @@ static sk_sp<SkPicture> make_sierpinski_picture() {
return recorder.finishRecordingAsPicture();
}
-static SkSurface* create_compat_surface(SkCanvas* canvas, int width, int height) {
+static sk_sp<SkSurface> create_compat_surface(SkCanvas* canvas, int width, int height) {
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
- SkSurface* surface = canvas->newSurface(info);
+ auto surface = canvas->makeSurface(info);
if (nullptr == surface) {
// picture canvas returns nullptr so fall back to raster
- surface = SkSurface::NewRaster(info);
+ surface = SkSurface::MakeRaster(info);
}
-
return surface;
}
@@ -257,13 +256,12 @@ static SkSurface* create_compat_surface(SkCanvas* canvas, int width, int height)
// fragments potentially generated by the MultiPictureDraw object
class ComposeStep {
public:
- ComposeStep() : fSurf(nullptr), fX(0.0f), fY(0.0f), fPaint(nullptr) { }
+ ComposeStep() : fX(0.0f), fY(0.0f), fPaint(nullptr) { }
~ComposeStep() {
- SkSafeUnref(fSurf);
delete fPaint;
}
- SkSurface* fSurf;
+ sk_sp<SkSurface> fSurf;
SkScalar fX;
SkScalar fY;
SkPaint* fPaint;
diff --git a/gm/ninepatchstretch.cpp b/gm/ninepatchstretch.cpp
index f269376bb0..9b0b94ec27 100644
--- a/gm/ninepatchstretch.cpp
+++ b/gm/ninepatchstretch.cpp
@@ -8,11 +8,11 @@
#include "gm.h"
#include "SkSurface.h"
-static SkSurface* make_surface(SkCanvas* root, int N) {
+static sk_sp<SkSurface> make_surface(SkCanvas* root, int N) {
SkImageInfo info = SkImageInfo::MakeN32Premul(N, N);
- SkSurface* surface = root->newSurface(info);
+ auto surface = root->makeSurface(info);
if (!surface) {
- surface = SkSurface::NewRaster(info);
+ surface = SkSurface::MakeRaster(info);
}
return surface;
}
@@ -22,7 +22,7 @@ static sk_sp<SkImage> make_image(SkCanvas* root, SkIRect* center) {
const int kStretchy = 8;
const int kSize = 2*kFixed + kStretchy;
- SkAutoTUnref<SkSurface> surface(make_surface(root, kSize));
+ auto surface(make_surface(root, kSize));
SkCanvas* canvas = surface->getCanvas();
SkRect r = SkRect::MakeWH(SkIntToScalar(kSize), SkIntToScalar(kSize));
diff --git a/gm/perspshaders.cpp b/gm/perspshaders.cpp
index b2ac3287f2..2b09cc64e0 100644
--- a/gm/perspshaders.cpp
+++ b/gm/perspshaders.cpp
@@ -13,9 +13,9 @@
static sk_sp<SkImage> make_image(SkCanvas* origCanvas, int w, int h) {
SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
- SkAutoTUnref<SkSurface> surface(origCanvas->newSurface(info));
+ auto surface(origCanvas->makeSurface(info));
if (nullptr == surface) {
- surface.reset(SkSurface::NewRaster(info));
+ surface = SkSurface::MakeRaster(info);
}
SkCanvas* canvas = surface->getCanvas();
diff --git a/gm/resizeimagefilter.cpp b/gm/resizeimagefilter.cpp
index 2236b76b3e..b8ed100548 100644
--- a/gm/resizeimagefilter.cpp
+++ b/gm/resizeimagefilter.cpp
@@ -87,7 +87,7 @@ protected:
deviceSize,
kHigh_SkFilterQuality);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(16, 16));
+ auto surface(SkSurface::MakeRasterN32Premul(16, 16));
SkCanvas* surfaceCanvas = surface->getCanvas();
surfaceCanvas->clear(0x000000);
{
diff --git a/gm/srcmode.cpp b/gm/srcmode.cpp
index 28bb04bd4e..93a9bc7f05 100644
--- a/gm/srcmode.cpp
+++ b/gm/srcmode.cpp
@@ -115,7 +115,7 @@ protected:
}
}
- static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size, bool skipGPU) {
+ static sk_sp<SkSurface> compat_surface(SkCanvas* canvas, const SkISize& size, bool skipGPU) {
SkImageInfo info = SkImageInfo::MakeN32Premul(size);
bool callNewSurface = true;
@@ -124,17 +124,16 @@ protected:
callNewSurface = false;
}
#endif
- SkSurface* surface = callNewSurface ? canvas->newSurface(info) : nullptr;
+ sk_sp<SkSurface> surface = callNewSurface ? canvas->makeSurface(info) : nullptr;
if (nullptr == surface) {
// picture canvas will return null, so fall-back to raster
- surface = SkSurface::NewRaster(info);
+ surface = SkSurface::MakeRaster(info);
}
return surface;
}
virtual void onDraw(SkCanvas* canvas) {
- SkAutoTUnref<SkSurface> surf(compat_surface(canvas, this->getISize(),
- this->isCanvasDeferred()));
+ auto surf(compat_surface(canvas, this->getISize(), this->isCanvasDeferred()));
surf->getCanvas()->drawColor(SK_ColorWHITE);
this->drawContent(surf->getCanvas());
surf->draw(canvas, 0, 0, nullptr);
diff --git a/gm/surface.cpp b/gm/surface.cpp
index c817f8d63a..436ea95286 100644
--- a/gm/surface.cpp
+++ b/gm/surface.cpp
@@ -21,8 +21,8 @@ static sk_sp<SkShader> make_shader() {
return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
}
-static SkSurface* make_surface(GrContext* ctx, const SkImageInfo& info, SkPixelGeometry geo,
- int disallowAA, int disallowDither) {
+static sk_sp<SkSurface> make_surface(GrContext* ctx, const SkImageInfo& info, SkPixelGeometry geo,
+ int disallowAA, int disallowDither) {
uint32_t flags = 0;
if (disallowAA) {
flags |= SkSurfaceProps::kDisallowAntiAlias_Flag;
@@ -33,9 +33,9 @@ static SkSurface* make_surface(GrContext* ctx, const SkImageInfo& info, SkPixelG
SkSurfaceProps props(flags, geo);
if (ctx) {
- return SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props);
+ return SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props);
} else {
- return SkSurface::NewRaster(info, &props);
+ return SkSurface::MakeRaster(info, &props);
}
}
@@ -92,8 +92,7 @@ protected:
for (int disallowDither = 0; disallowDither <= 1; ++disallowDither) {
SkScalar y = 0;
for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) {
- SkAutoTUnref<SkSurface> surface(make_surface(ctx, info, rec[i].fGeo,
- disallowAA, disallowDither));
+ auto surface(make_surface(ctx, info, rec[i].fGeo, disallowAA, disallowDither));
test_draw(surface->getCanvas(), rec[i].fLabel);
surface->draw(canvas, x, y, nullptr);
y += H;
@@ -134,16 +133,16 @@ protected:
void onDraw(SkCanvas* canvas) override {
SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, nullptr));
- if (!surf.get()) {
- surf.reset(SkSurface::NewRaster(info));
+ auto surf(canvas->makeSurface(info, nullptr));
+ if (!surf) {
+ surf = SkSurface::MakeRaster(info);
}
drawInto(surf->getCanvas());
sk_sp<SkImage> image(surf->makeImageSnapshot());
canvas->drawImage(image, 10, 10, nullptr);
- SkAutoTUnref<SkSurface> surf2(surf->newSurface(info));
+ auto surf2(surf->makeSurface(info));
drawInto(surf2->getCanvas());
// Assert that the props were communicated transitively through the first image
diff --git a/gm/textblobgeometrychange.cpp b/gm/textblobgeometrychange.cpp
index bae2381b65..0632908dfb 100644
--- a/gm/textblobgeometrychange.cpp
+++ b/gm/textblobgeometrychange.cpp
@@ -44,7 +44,7 @@ protected:
SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200);
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
- SkAutoTUnref<SkSurface> surface(canvas->newSurface(info, &props));
+ auto surface(canvas->makeSurface(info, &props));
if (surface) {
SkCanvas* c = surface->getCanvas();
diff --git a/gm/textblobmixedsizes.cpp b/gm/textblobmixedsizes.cpp
index 7923489370..b2697a8cf4 100644
--- a/gm/textblobmixedsizes.cpp
+++ b/gm/textblobmixedsizes.cpp
@@ -98,7 +98,7 @@ protected:
void onDraw(SkCanvas* inputCanvas) override {
SkCanvas* canvas = inputCanvas;
- SkAutoTUnref<SkSurface> surface;
+ sk_sp<SkSurface> surface;
if (fUseDFT) {
#if SK_SUPPORT_GPU
// Create a new Canvas to enable DFT
@@ -106,8 +106,7 @@ protected:
SkImageInfo info = SkImageInfo::MakeN32Premul(onISize());
SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
SkSurfaceProps::kLegacyFontHost_InitType);
- surface.reset(SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo, info, 0,
- &props));
+ surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props);
canvas = surface.get() ? surface->getCanvas() : inputCanvas;
// init our new canvas with the old canvas's matrix
canvas->setMatrix(inputCanvas->getTotalMatrix());
diff --git a/gm/textblobrandomfont.cpp b/gm/textblobrandomfont.cpp
index f21380ee38..ce726f2e86 100644
--- a/gm/textblobrandomfont.cpp
+++ b/gm/textblobrandomfont.cpp
@@ -102,7 +102,7 @@ protected:
SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
- SkAutoTUnref<SkSurface> surface(canvas->newSurface(info, &props));
+ auto surface(canvas->makeSurface(info, &props));
if (surface) {
SkPaint paint;
paint.setAntiAlias(true);
diff --git a/gm/transparency.cpp b/gm/transparency.cpp
index 5e057617d4..5f324605d8 100644
--- a/gm/transparency.cpp
+++ b/gm/transparency.cpp
@@ -62,7 +62,7 @@ DEF_SIMPLE_GM(transparency_check, canvas, 1792, 1080) {
sk_tool_utils::color_to_565(0xFF666666), 8);
{
SkAutoCanvasRestore autoCanvasRestore(canvas, true);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(256, 9));
+ auto surface(SkSurface::MakeRasterN32Premul(256, 9));
make_transparency(surface->getCanvas(), 256.0f, 9.0f);
canvas->scale(7.0f, 120.0f);
surface->draw(canvas, 0, 0, nullptr);
diff --git a/gm/verylargebitmap.cpp b/gm/verylargebitmap.cpp
index b3ed5603a6..78f8f59c8a 100644
--- a/gm/verylargebitmap.cpp
+++ b/gm/verylargebitmap.cpp
@@ -23,7 +23,7 @@ static void draw(SkCanvas* canvas, int width, int height, SkColor colors[2]) {
}
static sk_sp<SkImage> make_raster_image(int width, int height, SkColor colors[2]) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, height));
+ auto surface(SkSurface::MakeRasterN32Premul(width, height));
draw(surface->getCanvas(), width, height, colors);
return surface->makeImageSnapshot();
}
diff --git a/gm/xfermodes3.cpp b/gm/xfermodes3.cpp
index 4cd05df5c4..84bc1e2218 100644
--- a/gm/xfermodes3.cpp
+++ b/gm/xfermodes3.cpp
@@ -60,7 +60,7 @@ protected:
0x80,
};
- SkAutoTUnref<SkSurface> tempSurface(this->possiblyCreateTempSurface(canvas, kSize, kSize));
+ auto tempSurface(this->possiblyCreateTempSurface(canvas, kSize, kSize));
int test = 0;
int x = 0, y = 0;
@@ -83,7 +83,7 @@ protected:
modePaint.setStyle(kStrokes[s].fStyle);
modePaint.setStrokeWidth(kStrokes[s].fWidth);
- this->drawMode(canvas, x, y, kSize, kSize, modePaint, tempSurface);
+ this->drawMode(canvas, x, y, kSize, kSize, modePaint, tempSurface.get());
++test;
x += kSize + 10;
@@ -100,7 +100,7 @@ protected:
modePaint.setStyle(kStrokes[s].fStyle);
modePaint.setStrokeWidth(kStrokes[s].fWidth);
- this->drawMode(canvas, x, y, kSize, kSize, modePaint, tempSurface);
+ this->drawMode(canvas, x, y, kSize, kSize, modePaint, tempSurface.get());
++test;
x += kSize + 10;
@@ -122,13 +122,13 @@ private:
* So when running on a GPU canvas we explicitly create a temporary canvas using a texture with
* dimensions exactly matching the layer size.
*/
- SkSurface* possiblyCreateTempSurface(SkCanvas* baseCanvas, int w, int h) {
+ sk_sp<SkSurface> possiblyCreateTempSurface(SkCanvas* baseCanvas, int w, int h) {
#if SK_SUPPORT_GPU
GrContext* context = baseCanvas->getGrContext();
SkImageInfo baseInfo = baseCanvas->imageInfo();
SkImageInfo info = SkImageInfo::Make(w, h, baseInfo.colorType(), baseInfo.alphaType(),
baseInfo.profileType());
- return SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info, 0, nullptr);
+ return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0, nullptr);
#else
return nullptr;
#endif