aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/surface.cpp
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/surface.cpp
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/surface.cpp')
-rw-r--r--gm/surface.cpp19
1 files changed, 9 insertions, 10 deletions
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