Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Unified Diff: gm/resizeimagefilter.cpp

Issue 1842243002: Update SkImageSource to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/offsetimagefilter.cpp ('k') | gm/tileimagefilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/resizeimagefilter.cpp
diff --git a/gm/resizeimagefilter.cpp b/gm/resizeimagefilter.cpp
index b8ed100548e0d3dc048006e9ee6de9927b19fa09..28508fdb33c8c4265931233c29e61035e5aae242 100644
--- a/gm/resizeimagefilter.cpp
+++ b/gm/resizeimagefilter.cpp
@@ -20,7 +20,7 @@ public:
}
protected:
- virtual SkString onShortName() {
+ SkString onShortName() override {
return SkString("resizeimagefilter");
}
@@ -28,7 +28,7 @@ protected:
const SkRect& rect,
const SkSize& deviceSize,
SkFilterQuality filterQuality,
- SkImageFilter* input = nullptr) {
+ sk_sp<SkImageFilter> input) {
SkRect dstRect;
canvas->getTotalMatrix().mapRect(&dstRect, rect);
canvas->save();
@@ -38,12 +38,12 @@ protected:
canvas->scale(deviceScaleX, deviceScaleY);
canvas->translate(-rect.x(), -rect.y());
SkMatrix matrix;
- matrix.setScale(SkScalarInvert(deviceScaleX),
- SkScalarInvert(deviceScaleY));
- SkAutoTUnref<SkImageFilter> imageFilter(
- SkImageFilter::CreateMatrixFilter(matrix, filterQuality, input));
+ matrix.setScale(SkScalarInvert(deviceScaleX), SkScalarInvert(deviceScaleY));
+ sk_sp<SkImageFilter> filter(SkImageFilter::CreateMatrixFilter(matrix,
+ filterQuality,
+ input.get()));
SkPaint filteredPaint;
- filteredPaint.setImageFilter(imageFilter.get());
+ filteredPaint.setImageFilter(std::move(filter));
canvas->saveLayer(&rect, &filteredPaint);
SkPaint paint;
paint.setColor(0xFF00FF00);
@@ -54,40 +54,44 @@ protected:
canvas->restore();
}
- virtual SkISize onISize() {
+ SkISize onISize() override {
return SkISize::Make(520, 100);
}
- virtual void onDraw(SkCanvas* canvas) {
+ void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
SkRect srcRect = SkRect::MakeWH(96, 96);
SkSize deviceSize = SkSize::Make(16, 16);
- draw(canvas,
- srcRect,
- deviceSize,
- kNone_SkFilterQuality);
+ this->draw(canvas,
+ srcRect,
+ deviceSize,
+ kNone_SkFilterQuality,
+ nullptr);
canvas->translate(srcRect.width() + SkIntToScalar(10), 0);
- draw(canvas,
- srcRect,
- deviceSize,
- kLow_SkFilterQuality);
+ this->draw(canvas,
+ srcRect,
+ deviceSize,
+ kLow_SkFilterQuality,
+ nullptr);
canvas->translate(srcRect.width() + SkIntToScalar(10), 0);
- draw(canvas,
- srcRect,
- deviceSize,
- kMedium_SkFilterQuality);
+ this->draw(canvas,
+ srcRect,
+ deviceSize,
+ kMedium_SkFilterQuality,
+ nullptr);
canvas->translate(srcRect.width() + SkIntToScalar(10), 0);
- draw(canvas,
- srcRect,
- deviceSize,
- kHigh_SkFilterQuality);
+ this->draw(canvas,
+ srcRect,
+ deviceSize,
+ kHigh_SkFilterQuality,
+ nullptr);
- auto surface(SkSurface::MakeRasterN32Premul(16, 16));
+ sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(16, 16));
SkCanvas* surfaceCanvas = surface->getCanvas();
surfaceCanvas->clear(0x000000);
{
@@ -100,14 +104,14 @@ protected:
sk_sp<SkImage> image(surface->makeImageSnapshot());
SkRect inRect = SkRect::MakeXYWH(-4, -4, 20, 20);
SkRect outRect = SkRect::MakeXYWH(-24, -24, 120, 120);
- SkAutoTUnref<SkImageFilter> source(
- SkImageSource::Create(image.get(), inRect, outRect, kHigh_SkFilterQuality));
+ sk_sp<SkImageFilter> source(
+ SkImageSource::Make(std::move(image), inRect, outRect, kHigh_SkFilterQuality));
canvas->translate(srcRect.width() + SkIntToScalar(10), 0);
- draw(canvas,
- srcRect,
- deviceSize,
- kHigh_SkFilterQuality,
- source.get());
+ this->draw(canvas,
+ srcRect,
+ deviceSize,
+ kHigh_SkFilterQuality,
+ std::move(source));
}
private:
@@ -116,7 +120,6 @@ private:
//////////////////////////////////////////////////////////////////////////////
-static GM* MyFactory(void*) { return new ResizeGM; }
-static GMRegistry reg(MyFactory);
+DEF_GM(return new ResizeGM; )
}
« no previous file with comments | « gm/offsetimagefilter.cpp ('k') | gm/tileimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698