diff options
author | reed <reed@google.com> | 2016-03-17 10:51:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-17 10:51:11 -0700 |
commit | 9ce9d6772df650ceb0511f275e1a83dffa78ff72 (patch) | |
tree | 1c0d54a75945863947490ec45cccf7c30eaa2ca4 /samplecode/SampleFilterQuality.cpp | |
parent | 42d95a0afb26560586232961445ba36de387ca37 (diff) |
update callsites for Make image factories
not forced yet, as we still have the build-guard. waiting on chrome CL
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1810813003
TBR=
Review URL: https://codereview.chromium.org/1810813003
Diffstat (limited to 'samplecode/SampleFilterQuality.cpp')
-rw-r--r-- | samplecode/SampleFilterQuality.cpp | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/samplecode/SampleFilterQuality.cpp b/samplecode/SampleFilterQuality.cpp index 27c092fc47..9098901959 100644 --- a/samplecode/SampleFilterQuality.cpp +++ b/samplecode/SampleFilterQuality.cpp @@ -28,32 +28,18 @@ static SkSurface* make_surface(SkCanvas* canvas, const SkImageInfo& info) { } static sk_sp<SkShader> make_shader(const SkRect& bounds) { -#if 0 - const SkPoint pts[] = { - { bounds.left(), bounds.top() }, - { bounds.right(), bounds.bottom() }, - }; - const SkColor colors[] = { - SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorBLACK, - SK_ColorCYAN, SK_ColorMAGENTA, SK_ColorYELLOW, - }; - return SkGradientShader::CreateLinear(pts, - colors, nullptr, SK_ARRAY_COUNT(colors), - SkShader::kClamp_TileMode); -#else - SkAutoTUnref<SkImage> image(GetResourceAsImage("mandrill_128.png")); - if (nullptr == image) { + sk_sp<SkImage> image(GetResourceAsImage("mandrill_128.png")); + if (!image) { return nullptr; } return image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); -#endif } #define N 128 #define ANGLE_DELTA 3 #define SCALE_DELTA (SK_Scalar1 / 32) -static SkImage* make_image() { +static sk_sp<SkImage> make_image() { SkImageInfo info = SkImageInfo::MakeN32(N, N, kOpaque_SkAlphaType); SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); SkCanvas* canvas = surface->getCanvas(); @@ -70,10 +56,10 @@ static SkImage* make_image() { paint.setShader(make_shader(SkRect::MakeWH(N, N))); canvas->drawPath(path, paint); - return surface->newImageSnapshot(); + return surface->makeImageSnapshot(); } -static SkImage* zoom_up(SkSurface* origSurf, SkImage* orig) { +static sk_sp<SkImage> zoom_up(SkSurface* origSurf, SkImage* orig) { const SkScalar S = 16; // amount to scale up const int D = 2; // dimension scaling for the offscreen // since we only view the center, don't need to produce the entire thing @@ -100,7 +86,7 @@ static SkImage* zoom_up(SkSurface* origSurf, SkImage* orig) { canvas->drawLine(x, 0, x, SkIntToScalar(orig->height()), paint); } } - return surface->newImageSnapshot(); + return surface->makeImageSnapshot(); } struct AnimValue { @@ -156,12 +142,12 @@ static void draw_box_frame(SkCanvas* canvas, int width, int height) { } class FilterQualityView : public SampleView { - SkAutoTUnref<SkImage> fImage; - AnimValue fScale, fAngle; - SkSize fCell; - SkInterpolator fTrans; - SkMSec fCurrTime; - bool fShowFatBits; + sk_sp<SkImage> fImage; + AnimValue fScale, fAngle; + SkSize fCell; + SkInterpolator fTrans; + SkMSec fCurrTime; + bool fShowFatBits; public: FilterQualityView() : fImage(make_image()), fTrans(2, 2), fShowFatBits(true) { @@ -216,7 +202,7 @@ protected: canvas->translate(SkScalarHalf(size.width()), SkScalarHalf(size.height())); canvas->scale(fScale, fScale); canvas->rotate(fAngle); - canvas->drawImage(fImage, -SkScalarHalf(fImage->width()), -SkScalarHalf(fImage->height()), + canvas->drawImage(fImage.get(), -SkScalarHalf(fImage->width()), -SkScalarHalf(fImage->height()), &paint); if (false) { @@ -247,9 +233,9 @@ protected: this->drawTheImage(canvas, size, filter, dx, dy); if (surface) { - SkAutoTUnref<SkImage> orig(surface->newImageSnapshot()); - SkAutoTUnref<SkImage> zoomed(zoom_up(surface, orig)); - origCanvas->drawImage(zoomed, + sk_sp<SkImage> orig(surface->makeImageSnapshot()); + sk_sp<SkImage> zoomed(zoom_up(surface, orig.get())); + origCanvas->drawImage(zoomed.get(), SkScalarHalf(fCell.width() - zoomed->width()), SkScalarHalf(fCell.height() - zoomed->height())); } |