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
diff --git a/gm/SkLinearBitmapPipelineGM.cpp b/gm/SkLinearBitmapPipelineGM.cpp
index e93d2ac..51fd2cf 100644
--- a/gm/SkLinearBitmapPipelineGM.cpp
+++ b/gm/SkLinearBitmapPipelineGM.cpp
@@ -57,8 +57,7 @@
SkImageInfo info = SkImageInfo::MakeN32Premul(ir.width(), ir.height(), kLinear_SkColorProfileType);
- SkAutoTUnref<SkImage> image{SkImage::NewRasterCopy(
- info, pmsrc.addr32(), pmsrc.rowBytes())};
+ sk_sp<SkImage> image(SkImage::MakeRasterCopy(SkPixmap(info, pmsrc.addr32(), pmsrc.rowBytes())));
SkPaint paint;
int32_t storage[300];
paint.setShader(image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode));
diff --git a/gm/all_bitmap_configs.cpp b/gm/all_bitmap_configs.cpp
index 46c5d5e..c533b6f 100644
--- a/gm/all_bitmap_configs.cpp
+++ b/gm/all_bitmap_configs.cpp
@@ -192,7 +192,7 @@
}
// Works on Ganesh, fails on Raster.
-SkImage* make_not_native32_color_wheel() {
+sk_sp<SkImage> make_not_native32_color_wheel() {
SkBitmap n32bitmap, notN32bitmap;
n32bitmap.allocN32Pixels(SCALE, SCALE);
n32bitmap.eraseColor(SK_ColorTRANSPARENT);
@@ -207,12 +207,12 @@
static_assert(ct != kN32_SkColorType, "BRGA!=RGBA");
SkAssertResult(n32bitmap.copyTo(¬N32bitmap, ct));
SkASSERT(notN32bitmap.colorType() == ct);
- return SkImage::NewFromBitmap(notN32bitmap);
+ return SkImage::MakeFromBitmap(notN32bitmap);
}
DEF_SIMPLE_GM(not_native32_bitmap_config, canvas, SCALE, SCALE) {
- SkAutoTUnref<SkImage> notN32image(make_not_native32_color_wheel());
+ sk_sp<SkImage> notN32image(make_not_native32_color_wheel());
SkASSERT(notN32image);
sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8);
- canvas->drawImage(notN32image, 0.0f, 0.0f);
+ canvas->drawImage(notN32image.get(), 0.0f, 0.0f);
}
diff --git a/gm/astcbitmap.cpp b/gm/astcbitmap.cpp
index 211e8da..181cfa4 100644
--- a/gm/astcbitmap.cpp
+++ b/gm/astcbitmap.cpp
@@ -62,7 +62,7 @@
DEF_SIMPLE_GM(astc_image, canvas, kGMDimension, kGMDimension) {
for (int j = 0; j < 4; ++j) {
for (int i = 0; i < 4; ++i) {
- SkAutoTUnref<SkImage> image(GetResourceAsImage(get_astc_filename(j*4+i)));
+ sk_sp<SkImage> image(GetResourceAsImage(get_astc_filename(j*4+i)));
if (image) {
const SkScalar bmX = static_cast<SkScalar>(i*kBitmapDimension);
const SkScalar bmY = static_cast<SkScalar>(j*kBitmapDimension);
diff --git a/gm/bigtileimagefilter.cpp b/gm/bigtileimagefilter.cpp
index f2164e8..84b9816 100644
--- a/gm/bigtileimagefilter.cpp
+++ b/gm/bigtileimagefilter.cpp
@@ -10,7 +10,7 @@
#include "SkTileImageFilter.h"
#include "gm.h"
-static SkImage* create_circle_texture(int size, SkColor color) {
+static sk_sp<SkImage> create_circle_texture(int size, SkColor color) {
SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(size, size));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0xFF000000);
@@ -22,7 +22,7 @@
canvas->drawCircle(SkScalarHalf(size), SkScalarHalf(size), SkScalarHalf(size), paint);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
namespace skiagm {
@@ -44,8 +44,8 @@
}
void onOnceBeforeDraw() override {
- fRedImage.reset(create_circle_texture(kBitmapSize, SK_ColorRED));
- fGreenImage.reset(create_circle_texture(kBitmapSize, SK_ColorGREEN));
+ fRedImage = create_circle_texture(kBitmapSize, SK_ColorRED);
+ fGreenImage = create_circle_texture(kBitmapSize, SK_ColorGREEN);
}
void onDraw(SkCanvas* canvas) override {
@@ -55,11 +55,11 @@
SkPaint p;
SkRect bound = SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight));
- SkAutoTUnref<SkImageFilter> imageSource(SkImageSource::Create(fRedImage));
+ sk_sp<SkImageFilter> imageSource(SkImageSource::Create(fRedImage.get()));
SkAutoTUnref<SkImageFilter> tif(SkTileImageFilter::Create(
SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)),
SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight)),
- imageSource));
+ imageSource.get()));
p.setImageFilter(tif);
canvas->saveLayer(&bound, &p);
@@ -84,7 +84,7 @@
SkRect bound3 = SkRect::MakeXYWH(320, 320,
SkIntToScalar(kBitmapSize),
SkIntToScalar(kBitmapSize));
- canvas->drawImageRect(fGreenImage, bound2, bound3, nullptr,
+ canvas->drawImageRect(fGreenImage.get(), bound2, bound3, nullptr,
SkCanvas::kStrict_SrcRectConstraint);
canvas->restore();
}
@@ -95,8 +95,8 @@
static const int kHeight = 512;
static const int kBitmapSize = 64;
- SkAutoTUnref<SkImage> fRedImage;
- SkAutoTUnref<SkImage> fGreenImage;
+ sk_sp<SkImage> fRedImage;
+ sk_sp<SkImage> fGreenImage;
typedef GM INHERITED;
};
diff --git a/gm/bleed.cpp b/gm/bleed.cpp
index 5a04162..c3d026a 100644
--- a/gm/bleed.cpp
+++ b/gm/bleed.cpp
@@ -27,10 +27,10 @@
kBitmap,
kImage
};
- Type fType;
- SkBitmap fBitmap;
- SkAutoTUnref<SkImage> fImage;
- SkIRect fRect; // The region of the bitmap/image that should be rendered.
+ Type fType;
+ SkBitmap fBitmap;
+ sk_sp<SkImage> fImage;
+ SkIRect fRect; // The region of the bitmap/image that should be rendered.
};
/** Creates a bitmap with two one-pixel rings around a checkerboard. The checkerboard is 2x2
@@ -130,7 +130,7 @@
/** Helper to reuse above functions to produce images rather than bmps */
static void bmp_to_image(TestPixels* result) {
SkASSERT(TestPixels::kBitmap == result->fType);
- result->fImage.reset(SkImage::NewFromBitmap(result->fBitmap));
+ result->fImage = SkImage::MakeFromBitmap(result->fBitmap);
SkASSERT(result->fImage);
result->fType = TestPixels::kImage;
result->fBitmap.reset();
@@ -345,7 +345,7 @@
if (TestPixels::kBitmap == pixels.fType) {
canvas->drawBitmapRect(pixels.fBitmap, src, dst, paint, constraint);
} else {
- canvas->drawImageRect(pixels.fImage, src, dst, paint, constraint);
+ canvas->drawImageRect(pixels.fImage.get(), src, dst, paint, constraint);
}
}
diff --git a/gm/colorfilterimagefilter.cpp b/gm/colorfilterimagefilter.cpp
index fa33a9c..f72108f 100644
--- a/gm/colorfilterimagefilter.cpp
+++ b/gm/colorfilterimagefilter.cpp
@@ -66,7 +66,7 @@
}
static sk_sp<SkShader> sh_make_image() {
- SkAutoTUnref<SkImage> image(GetResourceAsImage("mandrill_128.png"));
+ sk_sp<SkImage> image(GetResourceAsImage("mandrill_128.png"));
if (!image) {
return nullptr;
}
diff --git a/gm/colormatrix.cpp b/gm/colormatrix.cpp
index b6e83d3..de80ebb 100644
--- a/gm/colormatrix.cpp
+++ b/gm/colormatrix.cpp
@@ -37,11 +37,11 @@
}
void onOnceBeforeDraw() override {
- fSolidImg.reset(CreateSolidBitmap(64, 64));
- fTransparentImg.reset(CreateTransparentBitmap(64, 64));
+ fSolidImg = CreateSolidBitmap(64, 64);
+ fTransparentImg = CreateTransparentBitmap(64, 64);
}
- static SkImage* CreateSolidBitmap(int width, int height) {
+ static sk_sp<SkImage> CreateSolidBitmap(int width, int height) {
SkBitmap bm;
bm.allocN32Pixels(width, height);
SkCanvas canvas(bm);
@@ -54,11 +54,11 @@
SkIntToScalar(y), SK_Scalar1, SK_Scalar1), paint);
}
}
- return SkImage::NewFromBitmap(bm);
+ return SkImage::MakeFromBitmap(bm);
}
// creates a bitmap with shades of transparent gray.
- static SkImage* CreateTransparentBitmap(int width, int height) {
+ static sk_sp<SkImage> CreateTransparentBitmap(int width, int height) {
SkBitmap bm;
bm.allocN32Pixels(width, height);
SkCanvas canvas(bm);
@@ -70,7 +70,7 @@
paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2,
SkShader::kClamp_TileMode));
canvas.drawRect(SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)), paint);
- return SkImage::NewFromBitmap(bm);
+ return SkImage::MakeFromBitmap(bm);
}
void onDraw(SkCanvas* canvas) override {
@@ -78,7 +78,7 @@
SkColorMatrix matrix;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- const SkImage* bmps[] = { fSolidImg, fTransparentImg };
+ const SkImage* bmps[] = { fSolidImg.get(), fTransparentImg.get() };
for (size_t i = 0; i < SK_ARRAY_COUNT(bmps); ++i) {
matrix.setIdentity();
@@ -139,8 +139,8 @@
}
private:
- SkAutoTUnref<SkImage> fSolidImg;
- SkAutoTUnref<SkImage> fTransparentImg;
+ sk_sp<SkImage> fSolidImg;
+ sk_sp<SkImage> fTransparentImg;
typedef skiagm::GM INHERITED;
};
diff --git a/gm/colorwheel.cpp b/gm/colorwheel.cpp
index efa3a6b..530e0c2 100644
--- a/gm/colorwheel.cpp
+++ b/gm/colorwheel.cpp
@@ -12,7 +12,7 @@
#include "sk_tool_utils.h"
static void draw_image(SkCanvas* canvas, const char* resource, int x, int y) {
- SkAutoTUnref<SkImage> image(GetResourceAsImage(resource));
+ sk_sp<SkImage> image(GetResourceAsImage(resource));
if (image) {
canvas->drawImage(image, SkIntToScalar(x), SkIntToScalar(y));
} else {
diff --git a/gm/complexclip_blur_tiled.cpp b/gm/complexclip_blur_tiled.cpp
index aac0416..b619e67 100644
--- a/gm/complexclip_blur_tiled.cpp
+++ b/gm/complexclip_blur_tiled.cpp
@@ -58,8 +58,7 @@
tileCanvas->drawRect(rect, paint);
tileCanvas->restore();
tileCanvas->restore();
- SkAutoTUnref<SkImage> tileImage(tileSurface->newImageSnapshot());
- canvas->drawImage(tileImage, x, y);
+ canvas->drawImage(tileSurface->makeImageSnapshot().get(), x, y);
}
}
}
diff --git a/gm/dftext.cpp b/gm/dftext.cpp
index cccca38..545911c 100644
--- a/gm/dftext.cpp
+++ b/gm/dftext.cpp
@@ -201,9 +201,7 @@
SkAutoCanvasRestore acr(inputCanvas, true);
// since we prepended this matrix already, we blit using identity
inputCanvas->resetMatrix();
- SkImage* image = surface->newImageSnapshot();
- inputCanvas->drawImage(image, 0, 0, nullptr);
- image->unref();
+ inputCanvas->drawImage(surface->makeImageSnapshot().get(), 0, 0, nullptr);
}
#endif
}
diff --git a/gm/displacement.cpp b/gm/displacement.cpp
index c5f1837..a3fb9e5 100644
--- a/gm/displacement.cpp
+++ b/gm/displacement.cpp
@@ -30,16 +30,16 @@
SkColor c1 = sk_tool_utils::color_to_565(0xFF244484);
SkColor c2 = sk_tool_utils::color_to_565(0xFF804020);
- fCheckerboard.reset(SkImage::NewFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(80, 80, c1, c2, 8)));
- fSmall.reset(SkImage::NewFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(64, 64, c1, c2, 8)));
- fLarge.reset(SkImage::NewFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(96, 96, c1, c2, 8)));
- fLargeW.reset(
- SkImage::NewFromBitmap(sk_tool_utils::create_checkerboard_bitmap(96, 64, c1, c2, 8)));
- fLargeH.reset(SkImage::NewFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(64, 96, c1, c2, 8)));
+ fCheckerboard = SkImage::MakeFromBitmap(
+ sk_tool_utils::create_checkerboard_bitmap(80, 80, c1, c2, 8));
+ fSmall = SkImage::MakeFromBitmap(
+ sk_tool_utils::create_checkerboard_bitmap(64, 64, c1, c2, 8));
+ fLarge = SkImage::MakeFromBitmap(
+ sk_tool_utils::create_checkerboard_bitmap(96, 96, c1, c2, 8));
+ fLargeW =
+ SkImage::MakeFromBitmap(sk_tool_utils::create_checkerboard_bitmap(96, 64, c1, c2, 8));
+ fLargeH = SkImage::MakeFromBitmap(
+ sk_tool_utils::create_checkerboard_bitmap(64, 96, c1, c2, 8));
}
SkISize onISize() override {
@@ -57,7 +57,7 @@
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
SkPaint paint;
- SkAutoTUnref<SkImageFilter> displ(SkImageSource::Create(fCheckerboard));
+ SkAutoTUnref<SkImageFilter> displ(SkImageSource::Create(fCheckerboard.get()));
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ))->unref();
@@ -161,25 +161,25 @@
this->drawClippedBitmap(canvas, 500, 0, paint);
// Tests for images of different sizes
- displ.reset(SkImageSource::Create(fSmall));
+ displ.reset(SkImageSource::Create(fSmall.get()));
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kG_ChannelSelectorType,
40.0f, displ))->unref();
drawClippedBitmap(canvas, 0, 400, paint);
- displ.reset(SkImageSource::Create(fLarge));
+ displ.reset(SkImageSource::Create(fLarge.get()));
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kB_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
40.0f, displ))->unref();
drawClippedBitmap(canvas, 100, 400, paint);
- displ.reset(SkImageSource::Create(fLargeW));
+ displ.reset(SkImageSource::Create(fLargeW.get()));
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType,
40.0f, displ))->unref();
drawClippedBitmap(canvas, 200, 400, paint);
- displ.reset(SkImageSource::Create(fLargeH));
+ displ.reset(SkImageSource::Create(fLargeH.get()));
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
@@ -198,7 +198,7 @@
private:
SkBitmap fBitmap;
- SkAutoTUnref<SkImage> fCheckerboard, fSmall, fLarge, fLargeW, fLargeH;
+ sk_sp<SkImage> fCheckerboard, fSmall, fLarge, fLargeW, fLargeH;
typedef GM INHERITED;
};
diff --git a/gm/drawatlas.cpp b/gm/drawatlas.cpp
index 858e4bf..4d2f6d4 100644
--- a/gm/drawatlas.cpp
+++ b/gm/drawatlas.cpp
@@ -11,7 +11,7 @@
#include "SkSurface.h"
class DrawAtlasGM : public skiagm::GM {
- static SkImage* MakeAtlas(SkCanvas* caller, const SkRect& target) {
+ static sk_sp<SkImage> MakeAtlas(SkCanvas* caller, const SkRect& target) {
SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
SkAutoTUnref<SkSurface> surface(caller->newSurface(info));
if (nullptr == surface) {
@@ -32,10 +32,10 @@
paint.setColor(SK_ColorBLUE);
paint.setAntiAlias(true);
canvas->drawOval(target, paint);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
- SkAutoTUnref<SkImage> fAtlas;
+ sk_sp<SkImage> fAtlas;
public:
DrawAtlasGM() {}
@@ -53,7 +53,7 @@
void onDraw(SkCanvas* canvas) override {
const SkRect target = { 50, 50, 80, 90 };
if (nullptr == fAtlas) {
- fAtlas.reset(MakeAtlas(canvas, target));
+ fAtlas = MakeAtlas(canvas, target);
}
const struct {
@@ -91,9 +91,9 @@
paint.setFilterQuality(kLow_SkFilterQuality);
paint.setAntiAlias(true);
- canvas->drawAtlas(fAtlas, xform, tex, N, nullptr, &paint);
+ canvas->drawAtlas(fAtlas.get(), xform, tex, N, nullptr, &paint);
canvas->translate(0, 100);
- canvas->drawAtlas(fAtlas, xform, tex, colors, N, SkXfermode::kSrcIn_Mode, nullptr, &paint);
+ canvas->drawAtlas(fAtlas.get(), xform, tex, colors, N, SkXfermode::kSrcIn_Mode, nullptr, &paint);
}
private:
diff --git a/gm/drawatlascolor.cpp b/gm/drawatlascolor.cpp
index b5f9d7a..85a7a94 100644
--- a/gm/drawatlascolor.cpp
+++ b/gm/drawatlascolor.cpp
@@ -15,7 +15,7 @@
// ------------------------------------
// opaque green | transparent black
//
-static SkImage* make_atlas(SkCanvas* caller, int atlasSize) {
+static sk_sp<SkImage> make_atlas(SkCanvas* caller, int atlasSize) {
const int kBlockSize = atlasSize/2;
SkImageInfo info = SkImageInfo::MakeN32Premul(atlasSize, atlasSize);
@@ -48,7 +48,7 @@
SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
canvas->drawRect(r, paint);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
// This GM tests the drawAtlas API with colors, different xfer modes
@@ -73,7 +73,7 @@
const SkRect target = SkRect::MakeWH(SkIntToScalar(kAtlasSize), SkIntToScalar(kAtlasSize));
if (nullptr == fAtlas) {
- fAtlas.reset(make_atlas(canvas, kAtlasSize));
+ fAtlas = make_atlas(canvas, kAtlasSize);
}
const struct {
@@ -151,11 +151,11 @@
canvas->translate(SkIntToScalar(i*(target.height()+kPad)),
SkIntToScalar(kTextPad+kPad));
// w/o a paint
- canvas->drawAtlas(fAtlas, xforms, rects, quadColors, numColors,
+ canvas->drawAtlas(fAtlas.get(), xforms, rects, quadColors, numColors,
gModes[i].fMode, nullptr, nullptr);
canvas->translate(0.0f, numColors*(target.height()+kPad));
// w a paint
- canvas->drawAtlas(fAtlas, xforms, rects, quadColors, numColors,
+ canvas->drawAtlas(fAtlas.get(), xforms, rects, quadColors, numColors,
gModes[i].fMode, nullptr, &paint);
canvas->restore();
}
@@ -169,7 +169,7 @@
static const int kTextPad = 8;
- SkAutoTUnref<SkImage> fAtlas;
+ sk_sp<SkImage> fAtlas;
typedef GM INHERITED;
};
diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp
index 7ee2271..8ec7cee 100644
--- a/gm/drawbitmaprect.cpp
+++ b/gm/drawbitmaprect.cpp
@@ -33,7 +33,7 @@
return bm;
}
-static SkImage* makebm(SkCanvas* origCanvas, SkBitmap* resultBM, 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));
@@ -81,7 +81,7 @@
mat.postScale(SK_Scalar1 / 4, SK_Scalar1 / 4);
}
- SkImage* image = surface->newImageSnapshot();
+ auto image = surface->makeImageSnapshot();
SkBitmap tempBM;
@@ -125,10 +125,10 @@
}
}
- DrawRectRectProc* fProc;
- SkBitmap fLargeBitmap;
- SkAutoTUnref<SkImage> fImage;
- SkString fName;
+ DrawRectRectProc* fProc;
+ SkBitmap fLargeBitmap;
+ sk_sp<SkImage> fImage;
+ SkString fName;
protected:
SkString onShortName() override { return fName; }
@@ -136,7 +136,7 @@
SkISize onISize() override { return SkISize::Make(gSize, gSize); }
void setupImage(SkCanvas* canvas) {
- fImage.reset(makebm(canvas, &fLargeBitmap, gBmpSize, gBmpSize));
+ fImage = makebm(canvas, &fLargeBitmap, gBmpSize, gBmpSize);
}
void onDraw(SkCanvas* canvas) override {
@@ -172,7 +172,7 @@
for (int h = 1; h <= kMaxSrcRectSize; h *= 4) {
SkIRect srcRect = SkIRect::MakeXYWH((gBmpSize - w) / 2, (gBmpSize - h) / 2, w, h);
- fProc(canvas, fImage, fLargeBitmap, srcRect, dstRect);
+ fProc(canvas, fImage.get(), fLargeBitmap, srcRect, dstRect);
SkString label;
label.appendf("%d x %d", w, h);
diff --git a/gm/drawminibitmaprect.cpp b/gm/drawminibitmaprect.cpp
index f0ce1a2..c494605 100644
--- a/gm/drawminibitmaprect.cpp
+++ b/gm/drawminibitmaprect.cpp
@@ -13,7 +13,7 @@
#include "SkShader.h"
#include "SkSurface.h"
-static SkImage* makebm(SkCanvas* caller, int w, int h) {
+static sk_sp<SkImage> makebm(SkCanvas* caller, int w, int h) {
SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
SkAutoTUnref<SkSurface> surface(caller->newSurface(info));
if (nullptr == surface) {
@@ -56,7 +56,7 @@
rect.inset(wScalar / 8, hScalar / 8);
mat.postScale(SK_Scalar1 / 4, SK_Scalar1 / 4);
}
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
static const int gSize = 1024;
@@ -80,7 +80,7 @@
void onDraw(SkCanvas* canvas) override {
if (nullptr == fImage) {
- fImage.reset(makebm(canvas, gSurfaceSize, gSurfaceSize));
+ fImage = makebm(canvas, gSurfaceSize, gSurfaceSize);
}
const SkRect dstRect = { 0, 0, SkIntToScalar(64), SkIntToScalar(64)};
@@ -113,7 +113,7 @@
// rect stays rect
break;
}
- canvas->drawImageRect(fImage, srcRect, dstRect, &paint,
+ canvas->drawImageRect(fImage.get(), srcRect, dstRect, &paint,
SkCanvas::kFast_SrcRectConstraint);
canvas->restore();
@@ -131,9 +131,9 @@
}
private:
- bool fAA;
- SkAutoTUnref<SkImage> fImage;
- SkString fName;
+ bool fAA;
+ sk_sp<SkImage> fImage;
+ SkString fName;
typedef skiagm::GM INHERITED;
};
diff --git a/gm/etc1bitmap.cpp b/gm/etc1bitmap.cpp
index e2f6c2d..51c1f39 100644
--- a/gm/etc1bitmap.cpp
+++ b/gm/etc1bitmap.cpp
@@ -98,13 +98,13 @@
SkBitmap bm;
SkString filename = GetResourcePath("mandrill_128.");
filename.append(this->fileExtension());
- SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str()));
+ sk_sp<SkData> fileData(SkData::MakeFromFileName(filename.c_str()));
if (nullptr == fileData) {
SkDebugf("Could not open the file. Did you forget to set the resourcePath?\n");
return;
}
- SkAutoTUnref<SkImage> image(SkImage::NewFromEncoded(fileData));
+ sk_sp<SkImage> image(SkImage::MakeFromEncoded(std::move(fileData)));
if (nullptr == image) {
SkDebugf("Could not decode the ETC file. ETC may not be included in this platform.\n");
return;
@@ -201,10 +201,8 @@
SkASSERT(124 == height);
size_t dataSz = etc1_get_encoded_data_size(width, height) + ETC_PKM_HEADER_SIZE;
- SkAutoDataUnref nonPOTData(SkData::NewWithCopy(am.get(), dataSz));
-
- SkAutoTUnref<SkImage> image(SkImage::NewFromEncoded(nonPOTData));
- canvas->drawImage(image, 0, 0);
+ sk_sp<SkData> nonPOTData(SkData::MakeWithCopy(am.get(), dataSz));
+ canvas->drawImage(SkImage::MakeFromEncoded(std::move(nonPOTData)).get(), 0, 0);
}
private:
diff --git a/gm/filterfastbounds.cpp b/gm/filterfastbounds.cpp
index 453dded..9623e42 100644
--- a/gm/filterfastbounds.cpp
+++ b/gm/filterfastbounds.cpp
@@ -275,8 +275,8 @@
temp->drawRect(SkRect::MakeLTRB(5, 0, 10, 5), p);
}
- SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
- SkAutoTUnref<SkImageFilter> imageSource(SkImageSource::Create(image));
+ sk_sp<SkImage> image(surface->makeImageSnapshot());
+ SkAutoTUnref<SkImageFilter> imageSource(SkImageSource::Create(image.get()));
SkTArray<SkPaint> bmsPaints;
create_paints(imageSource, &bmsPaints);
diff --git a/gm/grayscalejpg.cpp b/gm/grayscalejpg.cpp
index 70ea72e..bc88ee1 100644
--- a/gm/grayscalejpg.cpp
+++ b/gm/grayscalejpg.cpp
@@ -15,7 +15,7 @@
*/
DEF_SIMPLE_GM(grayscalejpg, canvas, 128, 128) {
const char kResource[] = "grayscale.jpg";
- SkAutoTUnref<SkImage> image(GetResourceAsImage(kResource));
+ sk_sp<SkImage> image(GetResourceAsImage(kResource));
if (image) {
canvas->drawImage(image, 0.0f, 0.0f);
} else {
diff --git a/gm/image.cpp b/gm/image.cpp
index 4e22dd0..d54f1cf 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -22,17 +22,16 @@
// TODO: Make this draw a file that is checked in, so it can
// be exercised on machines other than mike's. Will require a
// rebaseline.
- SkAutoDataUnref data(SkData::NewFromFileName("/Users/mike/Downloads/skia.google.jpeg"));
- if (nullptr == data.get()) {
+ sk_sp<SkData> data(SkData::MakeFromFileName("/Users/mike/Downloads/skia.google.jpeg"));
+ if (nullptr == data) {
return;
}
- SkImage* image = SkImage::NewFromEncoded(data);
+ sk_sp<SkImage> image = SkImage::MakeFromEncoded(std::move(data));
if (image) {
SkAutoCanvasRestore acr(canvas, true);
canvas->scale(size.width() * 1.0f / image->width(),
size.height() * 1.0f / image->height());
canvas->drawImage(image, 0, 0, nullptr);
- image->unref();
}
}
@@ -58,16 +57,15 @@
static void test_surface(SkCanvas* canvas, SkSurface* surf, bool usePaint) {
drawContents(surf, SK_ColorRED);
- SkImage* imgR = surf->newImageSnapshot();
+ sk_sp<SkImage> imgR = surf->makeImageSnapshot();
if (true) {
- SkImage* imgR2 = surf->newImageSnapshot();
+ sk_sp<SkImage> imgR2 = surf->makeImageSnapshot();
SkASSERT(imgR == imgR2);
- imgR2->unref();
}
drawContents(surf, SK_ColorGREEN);
- SkImage* imgG = surf->newImageSnapshot();
+ sk_sp<SkImage> imgG = surf->makeImageSnapshot();
// since we've drawn after we snapped imgR, imgG will be a different obj
SkASSERT(imgR != imgG);
@@ -78,8 +76,8 @@
// paint.setFilterBitmap(true);
// paint.setAlpha(0x80);
- canvas->drawImage(imgR, 0, 0, usePaint ? &paint : nullptr);
- canvas->drawImage(imgG, 0, 80, usePaint ? &paint : nullptr);
+ canvas->drawImage(imgR.get(), 0, 0, usePaint ? &paint : nullptr);
+ canvas->drawImage(imgG.get(), 0, 80, usePaint ? &paint : nullptr);
surf->draw(canvas, 0, 160, usePaint ? &paint : nullptr);
SkRect src1, src2, src3;
@@ -94,13 +92,10 @@
dst3.set(0, 400, 65, 465);
dst4.set(0, 480, 65, 545);
- canvas->drawImageRect(imgR, src1, dst1, usePaint ? &paint : nullptr);
- canvas->drawImageRect(imgG, src2, dst2, usePaint ? &paint : nullptr);
- canvas->drawImageRect(imgR, src3, dst3, usePaint ? &paint : nullptr);
- canvas->drawImageRect(imgG, dst4, usePaint ? &paint : nullptr);
-
- imgG->unref();
- imgR->unref();
+ canvas->drawImageRect(imgR.get(), src1, dst1, usePaint ? &paint : nullptr);
+ canvas->drawImageRect(imgG.get(), src2, dst2, usePaint ? &paint : nullptr);
+ canvas->drawImageRect(imgR.get(), src3, dst3, usePaint ? &paint : nullptr);
+ canvas->drawImageRect(imgG.get(), dst4, usePaint ? &paint : nullptr);
}
class ImageGM : public skiagm::GM {
@@ -242,33 +237,33 @@
canvas->drawCircle(50, 50, 35, paint);
}
-static SkImage* make_raster(const SkImageInfo& info, GrContext*, void (*draw)(SkCanvas*)) {
+static sk_sp<SkImage> make_raster(const SkImageInfo& info, GrContext*, void (*draw)(SkCanvas*)) {
SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
draw(surface->getCanvas());
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
-static SkImage* make_picture(const SkImageInfo& info, GrContext*, void (*draw)(SkCanvas*)) {
+static sk_sp<SkImage> make_picture(const SkImageInfo& info, GrContext*, void (*draw)(SkCanvas*)) {
SkPictureRecorder recorder;
draw(recorder.beginRecording(SkRect::MakeIWH(info.width(), info.height())));
SkAutoTUnref<SkPicture> pict(recorder.endRecording());
- return SkImage::NewFromPicture(pict, info.dimensions(), nullptr, nullptr);
+ return SkImage::MakeFromPicture(sk_ref_sp(pict.get()), info.dimensions(), nullptr, nullptr);
}
-static SkImage* make_codec(const SkImageInfo& info, GrContext*, void (*draw)(SkCanvas*)) {
- SkAutoTUnref<SkImage> image(make_raster(info, nullptr, draw));
- SkAutoTUnref<SkData> data(image->encode());
- return SkImage::NewFromEncoded(data);
+static sk_sp<SkImage> make_codec(const SkImageInfo& info, GrContext*, void (*draw)(SkCanvas*)) {
+ sk_sp<SkImage> image(make_raster(info, nullptr, draw));
+ sk_sp<SkData> data(image->encode());
+ return SkImage::MakeFromEncoded(data);
}
-static SkImage* make_gpu(const SkImageInfo& info, GrContext* ctx, void (*draw)(SkCanvas*)) {
+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));
draw(surface->getCanvas());
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
-typedef SkImage* (*ImageMakerProc)(const SkImageInfo&, GrContext*, void (*)(SkCanvas*));
+typedef sk_sp<SkImage> (*ImageMakerProc)(const SkImageInfo&, GrContext*, void (*)(SkCanvas*));
class ScalePixelsGM : public skiagm::GM {
public:
@@ -290,9 +285,9 @@
make_codec, make_raster, make_picture, make_codec, make_gpu,
};
for (auto& proc : procs) {
- SkAutoTUnref<SkImage> image(proc(info, canvas->getGrContext(), draw_contents));
+ sk_sp<SkImage> image(proc(info, canvas->getGrContext(), draw_contents));
if (image) {
- show_scaled_pixels(canvas, image);
+ show_scaled_pixels(canvas, image.get());
}
canvas->translate(0, 120);
}
@@ -342,8 +337,7 @@
static SkImageGenerator* gen_raster(const SkImageInfo& info) {
SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
draw_opaque_contents(surface->getCanvas());
- SkAutoTUnref<SkImage> img(surface->newImageSnapshot());
- return new ImageGeneratorFromImage(img);
+ return new ImageGeneratorFromImage(surface->makeImageSnapshot().get());
}
static SkImageGenerator* gen_picture(const SkImageInfo& info) {
@@ -354,13 +348,13 @@
}
static SkImageGenerator* gen_png(const SkImageInfo& info) {
- SkAutoTUnref<SkImage> image(make_raster(info, nullptr, draw_opaque_contents));
+ sk_sp<SkImage> image(make_raster(info, nullptr, draw_opaque_contents));
SkAutoTUnref<SkData> data(image->encode(SkImageEncoder::kPNG_Type, 100));
return SkImageGenerator::NewFromEncoded(data);
}
static SkImageGenerator* gen_jpg(const SkImageInfo& info) {
- SkAutoTUnref<SkImage> image(make_raster(info, nullptr, draw_opaque_contents));
+ sk_sp<SkImage> image(make_raster(info, nullptr, draw_opaque_contents));
SkAutoTUnref<SkData> data(image->encode(SkImageEncoder::kJPEG_Type, 100));
return SkImageGenerator::NewFromEncoded(data);
}
@@ -466,16 +460,16 @@
SkCanvas bmpCanvas(bmp);
render_image(&bmpCanvas);
- std::function<SkImage*()> imageFactories[] = {
+ std::function<sk_sp<SkImage>()> imageFactories[] = {
// Create sw raster image.
[bmp] {
- return SkImage::NewFromBitmap(bmp);
+ return SkImage::MakeFromBitmap(bmp);
},
// Create encoded image.
[bmp] {
- SkAutoTUnref<SkData> src(
+ sk_sp<SkData> src(
SkImageEncoder::EncodeData(bmp, SkImageEncoder::kPNG_Type, 100));
- return SkImage::NewFromEncoded(src);
+ return SkImage::MakeFromEncoded(std::move(src));
},
// Create a picture image.
[render_image] {
@@ -483,10 +477,11 @@
SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kSize), SkIntToScalar(kSize));
render_image(canvas);
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
- return SkImage::NewFromPicture(picture, SkISize::Make(kSize, kSize), nullptr, nullptr);
+ return SkImage::MakeFromPicture(sk_ref_sp(picture.get()), SkISize::Make(kSize, kSize),
+ nullptr, nullptr);
},
// Create a texture image
- [context, render_image]() -> SkImage* {
+ [context, render_image]() -> sk_sp<SkImage> {
SkAutoTUnref<SkSurface> surface(
SkSurface::NewRenderTarget(context, SkBudgeted::kYes,
SkImageInfo::MakeN32Premul(kSize, kSize)));
@@ -494,19 +489,19 @@
return nullptr;
}
render_image(surface->getCanvas());
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
};
static const SkScalar kPad = 5.f;
canvas->translate(kPad, kPad);
for (auto factory : imageFactories) {
- SkAutoTUnref<SkImage> image(factory());
+ auto image(factory());
if (!image) {
continue;
}
if (context) {
- SkAutoTUnref<SkImage> texImage(image->newTextureImage(context));
+ sk_sp<SkImage> texImage(image->makeTextureImage(context));
if (texImage) {
canvas->drawImage(texImage, 0, 0);
}
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index 52c9309..fd21d71 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -36,8 +36,8 @@
*/
class ImagePictGM : public skiagm::GM {
SkAutoTUnref<SkPicture> fPicture;
- SkAutoTUnref<SkImage> fImage0;
- SkAutoTUnref<SkImage> fImage1;
+ sk_sp<SkImage> fImage0;
+ sk_sp<SkImage> fImage1;
public:
ImagePictGM() {}
@@ -61,18 +61,18 @@
SkMatrix matrix;
matrix.setTranslate(-100, -100);
- fImage0.reset(SkImage::NewFromPicture(fPicture, size, &matrix, nullptr));
+ fImage0 = SkImage::MakeFromPicture(sk_ref_sp(fPicture.get()), size, &matrix, nullptr);
matrix.postTranslate(-50, -50);
matrix.postRotate(45);
matrix.postTranslate(50, 50);
- fImage1.reset(SkImage::NewFromPicture(fPicture, size, &matrix, nullptr));
+ fImage1 = SkImage::MakeFromPicture(sk_ref_sp(fPicture.get()), size, &matrix, nullptr);
}
void drawSet(SkCanvas* canvas) const {
SkMatrix matrix = SkMatrix::MakeTrans(-100, -100);
canvas->drawPicture(fPicture, &matrix, nullptr);
- canvas->drawImage(fImage0, 150, 0);
- canvas->drawImage(fImage1, 300, 0);
+ canvas->drawImage(fImage0.get(), 150, 0);
+ canvas->drawImage(fImage1.get(), 300, 0);
}
void onDraw(SkCanvas* canvas) override {
@@ -216,7 +216,7 @@
surface->getCanvas()->clear(0);
surface->getCanvas()->translate(-100, -100);
surface->getCanvas()->drawPicture(pic);
- SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
+ sk_sp<SkImage> image(surface->makeImageSnapshot());
fTexture.reset(SkRef(as_IB(image)->peekTexture()));
}
protected:
diff --git a/gm/image_shader.cpp b/gm/image_shader.cpp
index 7ea0202..e7378c4 100644
--- a/gm/image_shader.cpp
+++ b/gm/image_shader.cpp
@@ -24,16 +24,16 @@
canvas->drawOval(bounds, paint);
}
-typedef SkImage* (*ImageMakerProc)(GrContext*, const SkPicture*, const SkImageInfo&);
+typedef sk_sp<SkImage> (*ImageMakerProc)(GrContext*, SkPicture*, const SkImageInfo&);
-static SkImage* make_raster(GrContext*, const SkPicture* pic, const SkImageInfo& info) {
+static sk_sp<SkImage> make_raster(GrContext*, SkPicture* pic, const SkImageInfo& info) {
SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
surface->getCanvas()->clear(0);
surface->getCanvas()->drawPicture(pic);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
-static SkImage* make_texture(GrContext* ctx, const SkPicture* pic, const SkImageInfo& info) {
+static sk_sp<SkImage> make_texture(GrContext* ctx, SkPicture* pic, const SkImageInfo& info) {
if (!ctx) {
return nullptr;
}
@@ -41,23 +41,23 @@
info, 0));
surface->getCanvas()->clear(0);
surface->getCanvas()->drawPicture(pic);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
-static SkImage* make_pict_gen(GrContext*, const SkPicture* pic, const SkImageInfo& info) {
- return SkImage::NewFromPicture(pic, info.dimensions(), nullptr, nullptr);
+static sk_sp<SkImage> make_pict_gen(GrContext*, SkPicture* pic, const SkImageInfo& info) {
+ return SkImage::MakeFromPicture(sk_ref_sp(pic), info.dimensions(), nullptr, nullptr);
}
-static SkImage* make_encode_gen(GrContext* ctx, const SkPicture* pic, const SkImageInfo& info) {
- SkAutoTUnref<SkImage> src(make_raster(ctx, pic, info));
+static sk_sp<SkImage> make_encode_gen(GrContext* ctx, SkPicture* pic, const SkImageInfo& info) {
+ sk_sp<SkImage> src(make_raster(ctx, pic, info));
if (!src) {
return nullptr;
}
- SkAutoTUnref<SkData> encoded(src->encode(SkImageEncoder::kPNG_Type, 100));
+ sk_sp<SkData> encoded(src->encode(SkImageEncoder::kPNG_Type, 100));
if (!encoded) {
return nullptr;
}
- return SkImage::NewFromEncoded(encoded);
+ return SkImage::MakeFromEncoded(std::move(encoded));
}
const ImageMakerProc gProcs[] = {
@@ -113,9 +113,9 @@
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) {
- SkAutoTUnref<SkImage> image(gProcs[i](canvas->getGrContext(), fPicture, info));
+ sk_sp<SkImage> image(gProcs[i](canvas->getGrContext(), fPicture, info));
if (image) {
- this->testImage(canvas, image);
+ this->testImage(canvas, image.get());
}
canvas->translate(120, 0);
}
diff --git a/gm/imagealphathreshold.cpp b/gm/imagealphathreshold.cpp
index ea7185b..eafc32f 100644
--- a/gm/imagealphathreshold.cpp
+++ b/gm/imagealphathreshold.cpp
@@ -102,10 +102,9 @@
surface->getCanvas()->clear(SK_ColorWHITE);
draw_rects(surface->getCanvas());
- SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
SkPaint paint = create_filter_paint();
canvas->clipRect(SkRect::MakeLTRB(100, 100, WIDTH - 100, HEIGHT - 100));
- canvas->drawImage(image, 0, 0, &paint);
+ canvas->drawImage(surface->makeImageSnapshot().get(), 0, 0, &paint);
}
private:
diff --git a/gm/imagefilters.cpp b/gm/imagefilters.cpp
index 951a934..24a08ff 100644
--- a/gm/imagefilters.cpp
+++ b/gm/imagefilters.cpp
@@ -66,14 +66,14 @@
}
}
-static SkImage* make_image(SkCanvas* canvas) {
+static sk_sp<SkImage> make_image(SkCanvas* canvas) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
if (!surface) {
surface.reset(SkSurface::NewRaster(info));
}
surface->getCanvas()->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), SkPaint());
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
// Compare blurs when we're tightly clipped (fast) and not as tightly (slower)
@@ -81,7 +81,7 @@
// Expect the two to draw the same (modulo the extra border of pixels when the clip is larger)
//
DEF_SIMPLE_GM(fast_slow_blurimagefilter, canvas, 620, 260) {
- SkAutoTUnref<SkImage> image(make_image(canvas));
+ sk_sp<SkImage> image(make_image(canvas));
const SkRect r = SkRect::MakeIWH(image->width(), image->height());
canvas->translate(10, 10);
@@ -162,7 +162,7 @@
SkPaint paint;
paint.setFilterQuality(kMedium_SkFilterQuality);
- SkAutoTUnref<SkImage> image(GetResourceAsImage("mandrill_512.png"));
+ sk_sp<SkImage> image(GetResourceAsImage("mandrill_512.png"));
canvas->translate(20, 20);
for (const auto& xform : xforms) {
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp
index 033b806..26ee24b 100644
--- a/gm/imagefiltersclipped.cpp
+++ b/gm/imagefiltersclipped.cpp
@@ -57,7 +57,7 @@
paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(x, y), radius, colors, nullptr,
2, SkShader::kClamp_TileMode));
canvas->drawCircle(x, y, radius, paint);
- fGradientCircle.reset(surface->newImageSnapshot());
+ fGradientCircle = surface->makeImageSnapshot();
}
static void draw_clipped_filter(SkCanvas* canvas, SkImageFilter* filter, size_t i,
@@ -80,16 +80,16 @@
}
void onOnceBeforeDraw() override {
- fCheckerboard.reset(SkImage::NewFromBitmap
- (sk_tool_utils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF404040, 8)));
+ fCheckerboard = SkImage::MakeFromBitmap
+ (sk_tool_utils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF404040, 8));
this->makeGradientCircle(64, 64);
}
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
- SkAutoTUnref<SkImageFilter> gradient(SkImageSource::Create(fGradientCircle));
- SkAutoTUnref<SkImageFilter> checkerboard(SkImageSource::Create(fCheckerboard));
+ SkAutoTUnref<SkImageFilter> gradient(SkImageSource::Create(fGradientCircle.get()));
+ SkAutoTUnref<SkImageFilter> checkerboard(SkImageSource::Create(fCheckerboard.get()));
SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise(
SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0));
SkMatrix resizeMatrix;
@@ -148,7 +148,7 @@
}
private:
- SkAutoTUnref<SkImage> fCheckerboard, fGradientCircle;
+ sk_sp<SkImage> fCheckerboard, fGradientCircle;
typedef GM INHERITED;
};
diff --git a/gm/imagefilterscropexpand.cpp b/gm/imagefilterscropexpand.cpp
index 185bbde..f3ca4d3 100644
--- a/gm/imagefilterscropexpand.cpp
+++ b/gm/imagefilterscropexpand.cpp
@@ -46,12 +46,12 @@
SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)),
SkImageFilter::CropRect::kHasAll_CropEdge);
- SkAutoTUnref<SkImage> gradientCircle(MakeGradientCircle(64, 64));
+ sk_sp<SkImage> gradientCircle(MakeGradientCircle(64, 64));
SkBitmap checkerboard;
MakeCheckerboard(&checkerboard);
SkAutoTUnref<SkImageFilter> gradientCircleSource(
- SkImageSource::Create(gradientCircle));
+ SkImageSource::Create(gradientCircle.get()));
SkAutoTUnref<SkImageFilter> noopCropped(
SkOffsetImageFilter::Create(0, 0, nullptr, &cropRect));
SkScalar sk255 = SkIntToScalar(255);
@@ -141,7 +141,7 @@
}
}
- static SkImage* MakeGradientCircle(int width, int height) {
+ static sk_sp<SkImage> MakeGradientCircle(int width, int height) {
SkScalar x = SkIntToScalar(width / 2);
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = SkMinScalar(x, y) * 0.8f;
@@ -156,7 +156,7 @@
2, SkShader::kClamp_TileMode));
canvas->drawCircle(x, y, radius, paint);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
static void Draw(SkCanvas* canvas, const SkBitmap& bitmap, const SkRect& rect, SkImageFilter* filter) {
diff --git a/gm/imagefiltersgraph.cpp b/gm/imagefiltersgraph.cpp
index 26ebc4d..fa9c512 100644
--- a/gm/imagefiltersgraph.cpp
+++ b/gm/imagefiltersgraph.cpp
@@ -111,14 +111,14 @@
SkISize onISize() override { return SkISize::Make(600, 150); }
void onOnceBeforeDraw() override {
- fImage.reset(SkImage::NewFromBitmap(
- sk_tool_utils::create_string_bitmap(100, 100, SK_ColorWHITE, 20, 70, 96, "e")));
+ fImage = SkImage::MakeFromBitmap(
+ sk_tool_utils::create_string_bitmap(100, 100, SK_ColorWHITE, 20, 70, 96, "e"));
}
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
{
- SkAutoTUnref<SkImageFilter> bitmapSource(SkImageSource::Create(fImage));
+ SkAutoTUnref<SkImageFilter> bitmapSource(SkImageSource::Create(fImage.get()));
SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
SkXfermode::kSrcIn_Mode));
SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(4.0f, 4.0f, bitmapSource));
@@ -146,7 +146,7 @@
SkPaint paint;
paint.setImageFilter(blendColor);
- DrawClippedImage(canvas, fImage, paint);
+ DrawClippedImage(canvas, fImage.get(), paint);
canvas->translate(SkIntToScalar(100), 0);
}
{
@@ -165,7 +165,7 @@
SkPaint paint;
paint.setImageFilter(arithFilter);
- DrawClippedImage(canvas, fImage, paint);
+ DrawClippedImage(canvas, fImage.get(), paint);
canvas->translate(SkIntToScalar(100), 0);
}
{
@@ -179,7 +179,7 @@
SkPaint paint;
paint.setImageFilter(blend);
- DrawClippedImage(canvas, fImage, paint);
+ DrawClippedImage(canvas, fImage.get(), paint);
canvas->translate(SkIntToScalar(100), 0);
}
{
@@ -213,7 +213,7 @@
SkPaint paint;
paint.setImageFilter(convolve);
- DrawClippedImage(canvas, fImage, paint);
+ DrawClippedImage(canvas, fImage.get(), paint);
canvas->translate(SkIntToScalar(100), 0);
}
{
@@ -245,7 +245,7 @@
canvas->restore();
}
- SkAutoTUnref<SkImage> fImage;
+ sk_sp<SkImage> fImage;
typedef GM INHERITED;
};
diff --git a/gm/imagefiltersscaled.cpp b/gm/imagefiltersscaled.cpp
index da44678..391f4e5 100644
--- a/gm/imagefiltersscaled.cpp
+++ b/gm/imagefiltersscaled.cpp
@@ -44,16 +44,16 @@
}
void onOnceBeforeDraw() override {
- fCheckerboard.reset(SkImage::NewFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF404040, 8)));
- fGradientCircle.reset(MakeGradientCircle(64, 64));
+ fCheckerboard = SkImage::MakeFromBitmap(
+ sk_tool_utils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF404040, 8));
+ fGradientCircle = MakeGradientCircle(64, 64);
}
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
- SkAutoTUnref<SkImageFilter> gradient(SkImageSource::Create(fGradientCircle));
- SkAutoTUnref<SkImageFilter> checkerboard(SkImageSource::Create(fCheckerboard));
+ SkAutoTUnref<SkImageFilter> gradient(SkImageSource::Create(fGradientCircle.get()));
+ SkAutoTUnref<SkImageFilter> checkerboard(SkImageSource::Create(fCheckerboard.get()));
SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise(
SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0));
SkPaint noisePaint;
@@ -135,7 +135,7 @@
}
private:
- static SkImage* MakeGradientCircle(int width, int height) {
+ static sk_sp<SkImage> MakeGradientCircle(int width, int height) {
SkScalar x = SkIntToScalar(width / 2);
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = SkScalarMul(SkMinScalar(x, y), SkIntToScalar(4) / SkIntToScalar(5));
@@ -150,10 +150,10 @@
2, SkShader::kClamp_TileMode));
canvas->drawCircle(x, y, radius, paint);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
- SkAutoTUnref<SkImage> fCheckerboard, fGradientCircle;
+ sk_sp<SkImage> fCheckerboard, fGradientCircle;
typedef GM INHERITED;
};
diff --git a/gm/imagefilterstransformed.cpp b/gm/imagefilterstransformed.cpp
index 5b9d702..4243902 100644
--- a/gm/imagefilterstransformed.cpp
+++ b/gm/imagefilterstransformed.cpp
@@ -24,7 +24,7 @@
// It checks that the scale portion of the CTM is correctly extracted
// and applied to the image inputs separately from the non-scale portion.
-static SkImage* make_gradient_circle(int width, int height) {
+static sk_sp<SkImage> make_gradient_circle(int width, int height) {
SkScalar x = SkIntToScalar(width / 2);
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = SkMinScalar(x, y) * 0.8f;
@@ -41,7 +41,7 @@
SkShader::kClamp_TileMode));
canvas->drawCircle(x, y, radius, paint);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
class ImageFiltersTransformedGM : public GM {
@@ -57,14 +57,14 @@
SkISize onISize() override { return SkISize::Make(420, 240); }
void onOnceBeforeDraw() override {
- fCheckerboard.reset(SkImage::NewFromBitmap(
- sk_tool_utils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF404040, 8)));
- fGradientCircle.reset(make_gradient_circle(64, 64));
+ fCheckerboard = SkImage::MakeFromBitmap(
+ sk_tool_utils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF404040, 8));
+ fGradientCircle = make_gradient_circle(64, 64);
}
void onDraw(SkCanvas* canvas) override {
- SkAutoTUnref<SkImageFilter> gradient(SkImageSource::Create(fGradientCircle));
- SkAutoTUnref<SkImageFilter> checkerboard(SkImageSource::Create(fCheckerboard));
+ SkAutoTUnref<SkImageFilter> gradient(SkImageSource::Create(fGradientCircle.get()));
+ SkAutoTUnref<SkImageFilter> checkerboard(SkImageSource::Create(fCheckerboard.get()));
SkImageFilter* filters[] = {
SkBlurImageFilter::Create(12, 0),
SkDropShadowImageFilter::Create(0, 15, 8, 0, SK_ColorGREEN,
@@ -113,8 +113,8 @@
}
private:
- SkAutoTUnref<SkImage> fCheckerboard;
- SkAutoTUnref<SkImage> fGradientCircle;
+ sk_sp<SkImage> fCheckerboard;
+ sk_sp<SkImage> fGradientCircle;
typedef GM INHERITED;
};
diff --git a/gm/imagefromyuvtextures.cpp b/gm/imagefromyuvtextures.cpp
index 6280ae7..0d2637c 100644
--- a/gm/imagefromyuvtextures.cpp
+++ b/gm/imagefromyuvtextures.cpp
@@ -90,7 +90,7 @@
((112 * rgb[0] - 94 * rgb[1] - 18 * rgb[2] + 128) >> 8) + 128);
}
}
- fRGBImage.reset(SkImage::NewRasterCopy(rgbBmp.info(), rgbColors, rgbBmp.rowBytes()));
+ fRGBImage = SkImage::MakeRasterCopy(SkPixmap(rgbBmp.info(), rgbColors, rgbBmp.rowBytes()));
}
void createYUVTextures(GrContext* context, GrBackendObject yuvHandles[3]) {
@@ -141,28 +141,26 @@
{ fYUVBmps[1].width(), fYUVBmps[1].height()},
{ fYUVBmps[2].width(), fYUVBmps[2].height()},
};
- SkTArray<SkImage*> images;
- images.push_back(SkRef(fRGBImage.get()));
+ SkTArray<sk_sp<SkImage>> images;
+ images.push_back(fRGBImage);
for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpace; ++space) {
- images.push_back(SkImage::NewFromYUVTexturesCopy(context,
- static_cast<SkYUVColorSpace>(space),
- yuvHandles, sizes,
- kTopLeft_GrSurfaceOrigin));
+ images.push_back(SkImage::MakeFromYUVTexturesCopy(context,
+ static_cast<SkYUVColorSpace>(space),
+ yuvHandles, sizes,
+ kTopLeft_GrSurfaceOrigin));
}
this->deleteYUVTextures(context, yuvHandles);
for (int i = 0; i < images.count(); ++ i) {
SkScalar y = (i + 1) * kPad + i * fYUVBmps[0].height();
SkScalar x = kPad;
- canvas->drawImage(images[i], x, y);
- images[i]->unref();
- images[i] = nullptr;
+ canvas->drawImage(images[i].get(), x, y);
}
}
private:
- SkAutoTUnref<SkImage> fRGBImage;
- SkBitmap fYUVBmps[3];
+ sk_sp<SkImage> fRGBImage;
+ SkBitmap fYUVBmps[3];
static const int kBmpSize = 32;
diff --git a/gm/imagescalealigned.cpp b/gm/imagescalealigned.cpp
index c9e697c..66ad8b6 100644
--- a/gm/imagescalealigned.cpp
+++ b/gm/imagescalealigned.cpp
@@ -20,11 +20,11 @@
auto& set = fSets.push_back();
set.fVector = vectors[i];
- set.fImages.push_back().reset(MakeImage(vectors[i], SK_ColorGREEN));
+ set.fImages.push_back() = MakeImage(vectors[i], SK_ColorGREEN);
set.fScales.push_back() = 1;
- set.fImages.push_back().reset(MakeImage(vectors[i], SK_ColorRED));
+ set.fImages.push_back() = MakeImage(vectors[i], SK_ColorRED);
set.fScales.push_back() = kStretchFactor;
- set.fImages.push_back().reset(MakeImage(vectors[i], SK_ColorGREEN));
+ set.fImages.push_back() = MakeImage(vectors[i], SK_ColorGREEN);
set.fScales.push_back() = 1;
}
}
@@ -63,12 +63,12 @@
private:
struct ImageSet {
- SkSTArray<3, SkAutoTUnref<SkImage>, true> fImages;
- SkSTArray<3, SkScalar> fScales;
- SkVector fVector;
+ SkSTArray<3, sk_sp<SkImage>, true> fImages;
+ SkSTArray<3, SkScalar> fScales;
+ SkVector fVector;
};
- static SkImage* MakeImage(const SkVector& vec, SkColor color) {
+ static sk_sp<SkImage> MakeImage(const SkVector& vec, SkColor color) {
const SkPoint start = SkPoint::Make(vec.y() * kSegLen / 2, vec.x() * kSegLen / 2);
const SkPoint end = SkPoint::Make(start.x() + vec.x() * (kSegLen - 1),
start.y() + vec.y() * (kSegLen - 1));
@@ -88,7 +88,7 @@
surface->getCanvas()->drawPoint(start.x(), start.y(), color);
surface->getCanvas()->drawPoint(end.x(), end.y(), color);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
void drawSets(SkCanvas* canvas) const {
@@ -131,7 +131,7 @@
img->width() * (1 + (set.fScales[i] - 1) * set.fVector.x()),
img->height() * (1 + (set.fScales[i] - 1) * set.fVector.y()));
- canvas->drawImageRect(img, dst, &paint);
+ canvas->drawImageRect(img.get(), dst, &paint);
pt.offset(dst.width() * set.fVector.x(), dst.height() * set.fVector.y());
}
diff --git a/gm/imagesource.cpp b/gm/imagesource.cpp
index f4574d2..973dc0c 100644
--- a/gm/imagesource.cpp
+++ b/gm/imagesource.cpp
@@ -25,7 +25,7 @@
void onOnceBeforeDraw() override {
SkBitmap bm = sk_tool_utils::create_string_bitmap(100, 100, 0xFFFFFFFF, 20, 70, 96, "e");
- fImage.reset(SkImage::NewFromBitmap(bm));
+ fImage = SkImage::MakeFromBitmap(bm);
}
static void FillRectFiltered(SkCanvas* canvas, const SkRect& clipRect, SkImageFilter* filter) {
@@ -44,13 +44,13 @@
SkRect dstRect = SkRect::MakeXYWH(0, 10, 60, 60);
SkRect clipRect = SkRect::MakeXYWH(0, 0, 100, 100);
SkRect bounds = SkRect::MakeIWH(fImage->width(), fImage->height());
- SkAutoTUnref<SkImageFilter> imageSource(SkImageSource::Create(fImage));
+ SkAutoTUnref<SkImageFilter> imageSource(SkImageSource::Create(fImage.get()));
SkAutoTUnref<SkImageFilter> imageSourceSrcRect(
- SkImageSource::Create(fImage, srcRect, srcRect, kHigh_SkFilterQuality));
+ SkImageSource::Create(fImage.get(), srcRect, srcRect, kHigh_SkFilterQuality));
SkAutoTUnref<SkImageFilter> imageSourceSrcRectDstRect(
- SkImageSource::Create(fImage, srcRect, dstRect, kHigh_SkFilterQuality));
+ SkImageSource::Create(fImage.get(), srcRect, dstRect, kHigh_SkFilterQuality));
SkAutoTUnref<SkImageFilter> imageSourceDstRectOnly(
- SkImageSource::Create(fImage, bounds, dstRect, kHigh_SkFilterQuality));
+ SkImageSource::Create(fImage.get(), bounds, dstRect, kHigh_SkFilterQuality));
// Draw an unscaled bitmap.
FillRectFiltered(canvas, clipRect, imageSource);
@@ -71,7 +71,7 @@
}
private:
- SkAutoTUnref<SkImage> fImage;
+ sk_sp<SkImage> fImage;
typedef GM INHERITED;
};
diff --git a/gm/imagesource2.cpp b/gm/imagesource2.cpp
index 7f9c2b5..46c42f1 100644
--- a/gm/imagesource2.cpp
+++ b/gm/imagesource2.cpp
@@ -56,7 +56,7 @@
curColor = (curColor+1) % SK_ARRAY_COUNT(gColors);
}
- fImage.reset(surface->newImageSnapshot());
+ fImage = surface->makeImageSnapshot();
}
void onDraw(SkCanvas* canvas) override {
@@ -65,7 +65,7 @@
SkRect dstRect = SkRect::MakeLTRB(0.75f, 0.75f, 225.75f, 225.75f);
SkAutoTUnref<SkImageFilter> filter(
- SkImageSource::Create(fImage, srcRect, dstRect, fFilter));
+ SkImageSource::Create(fImage.get(), srcRect, dstRect, fFilter));
SkPaint p;
p.setImageFilter(filter);
@@ -79,7 +79,7 @@
SkString fSuffix;
SkFilterQuality fFilter;
- SkAutoTUnref<SkImage> fImage;
+ sk_sp<SkImage> fImage;
typedef GM INHERITED;
};
diff --git a/gm/imagetoyuvplanes.cpp b/gm/imagetoyuvplanes.cpp
index 87bff8e..ddead1b 100644
--- a/gm/imagetoyuvplanes.cpp
+++ b/gm/imagetoyuvplanes.cpp
@@ -12,7 +12,7 @@
#include "SkGradientShader.h"
#include "SkImage.h"
-static SkImage* create_image(GrContext* context, int width, int height) {
+static sk_sp<SkImage> create_image(GrContext* context, int width, int height) {
SkAutoTUnref<SkSurface> surface;
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
if (context) {
@@ -33,7 +33,7 @@
SkShader::kMirror_TileMode));
surface->getCanvas()->drawPaint(paint);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
DEF_SIMPLE_GM(image_to_yuv_planes, canvas, 120, 525) {
@@ -41,12 +41,12 @@
static const int kImageSize = 32;
GrContext *context = canvas->getGrContext();
- SkAutoTUnref<SkImage> rgbImage(create_image(context, kImageSize, kImageSize));
+ sk_sp<SkImage> rgbImage(create_image(context, kImageSize, kImageSize));
if (!rgbImage) {
return;
}
- canvas->drawImage(rgbImage, kPad, kPad);
+ canvas->drawImage(rgbImage.get(), kPad, kPad);
// Test cases where all three planes are the same size, where just u and v are the same size,
// and where all differ.
static const SkISize kSizes[][3] = {
diff --git a/gm/localmatriximagefilter.cpp b/gm/localmatriximagefilter.cpp
index 64ed6d7..f996558 100644
--- a/gm/localmatriximagefilter.cpp
+++ b/gm/localmatriximagefilter.cpp
@@ -14,7 +14,7 @@
#include "SkOffsetImageFilter.h"
#include "SkSurface.h"
-static SkImage* make_image(SkCanvas* rootCanvas) {
+static sk_sp<SkImage> make_image(SkCanvas* rootCanvas) {
SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
SkAutoTUnref<SkSurface> surface(rootCanvas->newSurface(info));
if (!surface) {
@@ -25,7 +25,7 @@
paint.setAntiAlias(true);
paint.setColor(SK_ColorRED);
surface->getCanvas()->drawCircle(50, 50, 50, paint);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
typedef SkImageFilter* (*ImageFilterFactory)();
@@ -62,7 +62,7 @@
}
void onDraw(SkCanvas* canvas) override {
- SkAutoTUnref<SkImage> image0(make_image(canvas));
+ sk_sp<SkImage> image0(make_image(canvas));
const ImageFilterFactory factories[] = {
IFCCast([]{ return SkBlurImageFilter::Create(8, 8); }),
@@ -84,11 +84,11 @@
SkAutoTUnref<SkImageFilter> filter(factory());
canvas->save();
- show_image(canvas, image0, filter);
+ show_image(canvas, image0.get(), filter);
for (const auto& matrix : matrices) {
SkAutoTUnref<SkImageFilter> localFilter(filter->newWithLocalMatrix(matrix));
canvas->translate(spacer, 0);
- show_image(canvas, image0, localFilter);
+ show_image(canvas, image0.get(), localFilter);
}
canvas->restore();
canvas->translate(0, spacer);
diff --git a/gm/mipmap.cpp b/gm/mipmap.cpp
index b0b0cc4..4b1912a 100644
--- a/gm/mipmap.cpp
+++ b/gm/mipmap.cpp
@@ -11,7 +11,7 @@
#include "SkRandom.h"
#include "SkSurface.h"
-static SkImage* make_image() {
+static sk_sp<SkImage> make_image() {
const SkImageInfo info = SkImageInfo::MakeN32Premul(319, 52);
SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
SkCanvas* canvas = surface->getCanvas();
@@ -25,11 +25,11 @@
canvas->drawCircle(-4, 25, 20, paint);
canvas->translate(25, 0);
}
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
DEF_SIMPLE_GM(mipmap, canvas, 400, 200) {
- SkAutoTUnref<SkImage> img(make_image());//SkImage::NewFromEncoded(data));
+ sk_sp<SkImage> img(make_image());//SkImage::NewFromEncoded(data));
SkPaint paint;
const SkRect dst = SkRect::MakeWH(177, 15);
@@ -42,9 +42,9 @@
canvas->translate(20, 20);
for (int i = 0; i < 4; ++i) {
paint.setFilterQuality(SkFilterQuality(i));
- canvas->drawImageRect(img, dst, &paint);
+ canvas->drawImageRect(img.get(), dst, &paint);
canvas->translate(0, 20);
}
- canvas->drawImage(img, 20, 20, nullptr);
+ canvas->drawImage(img.get(), 20, 20, nullptr);
}
diff --git a/gm/multipicturedraw.cpp b/gm/multipicturedraw.cpp
index 88d6cd7..c3f6b89 100644
--- a/gm/multipicturedraw.cpp
+++ b/gm/multipicturedraw.cpp
@@ -511,9 +511,8 @@
for (int i = 0; i < composeSteps.count(); ++i) {
const ComposeStep& step = composeSteps[i];
- SkAutoTUnref<SkImage> image(step.fSurf->newImageSnapshot());
-
- canvas->drawImage(image, step.fX, step.fY, step.fPaint);
+ canvas->drawImage(step.fSurf->makeImageSnapshot().get(),
+ step.fX, step.fY, step.fPaint);
}
}
diff --git a/gm/ninepatchstretch.cpp b/gm/ninepatchstretch.cpp
index 218b452..f269376 100644
--- a/gm/ninepatchstretch.cpp
+++ b/gm/ninepatchstretch.cpp
@@ -17,7 +17,7 @@
return surface;
}
-static SkImage* make_image(SkCanvas* root, SkIRect* center) {
+static sk_sp<SkImage> make_image(SkCanvas* root, SkIRect* center) {
const int kFixed = 28;
const int kStretchy = 8;
const int kSize = 2*kFixed + kStretchy;
@@ -43,7 +43,7 @@
paint.setColor(0x880000FF);
canvas->drawRect(r, paint);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
static void image_to_bitmap(const SkImage* image, SkBitmap* bm) {
@@ -54,9 +54,9 @@
class NinePatchStretchGM : public skiagm::GM {
public:
- SkAutoTUnref<SkImage> fImage;
- SkBitmap fBitmap;
- SkIRect fCenter;
+ sk_sp<SkImage> fImage;
+ SkBitmap fBitmap;
+ SkIRect fCenter;
NinePatchStretchGM() {}
@@ -71,8 +71,8 @@
void onDraw(SkCanvas* canvas) override {
if (nullptr == fBitmap.pixelRef()) {
- fImage.reset(make_image(canvas, &fCenter));
- image_to_bitmap(fImage, &fBitmap);
+ fImage = make_image(canvas, &fCenter);
+ image_to_bitmap(fImage.get(), &fBitmap);
}
// amount of bm that should not be stretched (unless we have to)
@@ -100,7 +100,7 @@
SkRect r = SkRect::MakeXYWH(x + ix * fixed, y + iy * fixed,
size[i].width(), size[i].height());
canvas->drawBitmapNine(fBitmap, fCenter, r, &paint);
- canvas->drawImageNine(fImage, fCenter, r.makeOffset(360, 0), &paint);
+ canvas->drawImageNine(fImage.get(), fCenter, r.makeOffset(360, 0), &paint);
}
}
}
diff --git a/gm/offsetimagefilter.cpp b/gm/offsetimagefilter.cpp
index eec18cf..15cf045 100644
--- a/gm/offsetimagefilter.cpp
+++ b/gm/offsetimagefilter.cpp
@@ -32,14 +32,14 @@
}
void onOnceBeforeDraw() override {
- fBitmap.reset(SkImage::NewFromBitmap(
- sk_tool_utils::create_string_bitmap(80, 80, 0xD000D000, 15, 65, 96, "e")));
+ fBitmap = SkImage::MakeFromBitmap(
+ sk_tool_utils::create_string_bitmap(80, 80, 0xD000D000, 15, 65, 96, "e"));
- fCheckerboard.reset(SkImage::NewFromBitmap(
+ fCheckerboard = SkImage::MakeFromBitmap(
sk_tool_utils::create_checkerboard_bitmap(80, 80,
sk_tool_utils::color_to_565(0xFFA0A0A0),
sk_tool_utils::color_to_565(0xFF404040),
- 8)));
+ 8));
}
void onDraw(SkCanvas* canvas) override {
@@ -47,7 +47,7 @@
SkPaint paint;
for (int i = 0; i < 4; i++) {
- const SkImage* image = (i & 0x01) ? fCheckerboard : fBitmap;
+ const SkImage* image = (i & 0x01) ? fCheckerboard.get() : fBitmap.get();
SkIRect cropRect = SkIRect::MakeXYWH(i * 12,
i * 8,
image->width() - i * 8,
@@ -67,7 +67,7 @@
SkImageFilter::CropRect rect(SkRect::Make(cropRect));
SkAutoTUnref<SkImageFilter> filter(SkOffsetImageFilter::Create(-5, -10, nullptr, &rect));
paint.setImageFilter(filter);
- DrawClippedImage(canvas, fBitmap, paint, 2, cropRect);
+ DrawClippedImage(canvas, fBitmap.get(), paint, 2, cropRect);
}
private:
static void DrawClippedImage(SkCanvas* canvas, const SkImage* image, const SkPaint& paint,
@@ -92,7 +92,7 @@
}
}
- SkAutoTUnref<SkImage> fBitmap, fCheckerboard;
+ sk_sp<SkImage> fBitmap, fCheckerboard;
typedef skiagm::GM INHERITED;
};
diff --git a/gm/perspshaders.cpp b/gm/perspshaders.cpp
index a29ef52..b2ac328 100644
--- a/gm/perspshaders.cpp
+++ b/gm/perspshaders.cpp
@@ -11,7 +11,7 @@
#include "SkPath.h"
#include "SkSurface.h"
-static SkImage* make_image(SkCanvas* origCanvas, int w, int h) {
+static sk_sp<SkImage> make_image(SkCanvas* origCanvas, int w, int h) {
SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
SkAutoTUnref<SkSurface> surface(origCanvas->newSurface(info));
if (nullptr == surface) {
@@ -20,7 +20,7 @@
SkCanvas* canvas = surface->getCanvas();
sk_tool_utils::draw_checkerboard(canvas, SK_ColorRED, SK_ColorGREEN, w/10);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
namespace skiagm {
@@ -106,7 +106,7 @@
canvas->translate(SkIntToScalar(kCellSize), 0);
canvas->save();
canvas->concat(fPerspMatrix);
- canvas->drawImage(fImage, 0, 0, &filterPaint);
+ canvas->drawImage(fImage.get(), 0, 0, &filterPaint);
canvas->restore();
canvas->translate(SkIntToScalar(kCellSize), 0);
@@ -138,7 +138,7 @@
void onDraw(SkCanvas* canvas) override {
if (!fImage) {
- fImage.reset(make_image(canvas, kCellSize, kCellSize));
+ fImage = make_image(canvas, kCellSize, kCellSize);
}
this->drawRow(canvas, kNone_SkFilterQuality);
@@ -155,14 +155,14 @@
static const int kNumRows = 4;
static const int kNumCols = 6;
- bool fDoAA;
- SkPath fPath;
- sk_sp<SkShader> fBitmapShader;
- sk_sp<SkShader> fLinearGrad1;
- sk_sp<SkShader> fLinearGrad2;
- SkMatrix fPerspMatrix;
- SkAutoTUnref<SkImage> fImage;
- SkBitmap fBitmap;
+ bool fDoAA;
+ SkPath fPath;
+ sk_sp<SkShader> fBitmapShader;
+ sk_sp<SkShader> fLinearGrad1;
+ sk_sp<SkShader> fLinearGrad2;
+ SkMatrix fPerspMatrix;
+ sk_sp<SkImage> fImage;
+ SkBitmap fBitmap;
typedef GM INHERITED;
};
diff --git a/gm/rectangletexture.cpp b/gm/rectangletexture.cpp
index 4bdb4c9..e00afe9 100644
--- a/gm/rectangletexture.cpp
+++ b/gm/rectangletexture.cpp
@@ -54,7 +54,8 @@
SkIntToScalar(width + height) / 5, paint);
}
- SkImage* createRectangleTextureImg(GrContext* context, int width, int height, void* pixels) {
+ sk_sp<SkImage> createRectangleTextureImg(GrContext* context, int width, int height,
+ void* pixels) {
if (!context) {
return nullptr;
}
@@ -111,7 +112,7 @@
desc.fHeight = height;
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
desc.fTextureHandle = reinterpret_cast<GrBackendObject>(&info);
- if (SkImage* image = SkImage::NewFromAdoptedTexture(context, desc)) {
+ if (sk_sp<SkImage> image = SkImage::MakeFromAdoptedTexture(context, desc)) {
return image;
}
GR_GL_CALL(gl, DeleteTextures(1, &id));
@@ -132,8 +133,7 @@
SkPMColor pixels[kWidth * kHeight];
this->fillPixels(kWidth, kHeight, pixels);
- SkAutoTUnref<SkImage> rectImg(this->createRectangleTextureImg(context, kWidth, kHeight,
- pixels));
+ sk_sp<SkImage> rectImg(this->createRectangleTextureImg(context, kWidth, kHeight, pixels));
if (!rectImg) {
SkPaint paint;
@@ -157,24 +157,24 @@
canvas->save();
canvas->scale(s, s);
for (auto q : kQualities) {
- SkPaint plainPaint;
- plainPaint.setFilterQuality(q);
- canvas->drawImage(rectImg, 0, 0, &plainPaint);
- canvas->translate(kWidth + kPad, 0);
+ SkPaint plainPaint;
+ plainPaint.setFilterQuality(q);
+ canvas->drawImage(rectImg.get(), 0, 0, &plainPaint);
+ canvas->translate(kWidth + kPad, 0);
- SkPaint clampPaint;
- clampPaint.setFilterQuality(q);
- clampPaint.setShader(rectImg->makeShader(SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode));
- canvas->drawRect(SkRect::MakeWH(1.5f * kWidth, 1.5f * kHeight), clampPaint);
- canvas->translate(kWidth * 1.5f + kPad, 0);
+ SkPaint clampPaint;
+ clampPaint.setFilterQuality(q);
+ clampPaint.setShader(rectImg->makeShader(SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode));
+ canvas->drawRect(SkRect::MakeWH(1.5f * kWidth, 1.5f * kHeight), clampPaint);
+ canvas->translate(kWidth * 1.5f + kPad, 0);
- SkPaint repeatPaint;
- repeatPaint.setFilterQuality(q);
- repeatPaint.setShader(rectImg->makeShader(SkShader::kRepeat_TileMode,
- SkShader::kMirror_TileMode));
- canvas->drawRect(SkRect::MakeWH(1.5f * kWidth, 1.5f * kHeight), repeatPaint);
- canvas->translate(1.5f * kWidth + kPad, 0);
+ SkPaint repeatPaint;
+ repeatPaint.setFilterQuality(q);
+ repeatPaint.setShader(rectImg->makeShader(SkShader::kRepeat_TileMode,
+ SkShader::kMirror_TileMode));
+ canvas->drawRect(SkRect::MakeWH(1.5f * kWidth, 1.5f * kHeight), repeatPaint);
+ canvas->translate(1.5f * kWidth + kPad, 0);
}
canvas->restore();
canvas->translate(0, kPad + 1.5f * kHeight * s);
diff --git a/gm/repeated_bitmap.cpp b/gm/repeated_bitmap.cpp
index 39eeb4e..a659e78 100644
--- a/gm/repeated_bitmap.cpp
+++ b/gm/repeated_bitmap.cpp
@@ -35,11 +35,9 @@
}
DEF_SIMPLE_GM(repeated_bitmap, canvas, 576, 576) {
- SkAutoTUnref<SkImage> image(GetResourceAsImage("randPixels.png"));
- draw_rotated_image(canvas, image);
+ draw_rotated_image(canvas, GetResourceAsImage("randPixels.png").get());
}
DEF_SIMPLE_GM(repeated_bitmap_jpg, canvas, 576, 576) {
- SkAutoTUnref<SkImage> image(GetResourceAsImage("color_wheel.jpg"));
- draw_rotated_image(canvas, image);
+ draw_rotated_image(canvas, GetResourceAsImage("color_wheel.jpg").get());
}
diff --git a/gm/resizeimagefilter.cpp b/gm/resizeimagefilter.cpp
index 9a684a2..2236b76 100644
--- a/gm/resizeimagefilter.cpp
+++ b/gm/resizeimagefilter.cpp
@@ -97,11 +97,11 @@
ovalRect.inset(SkIntToScalar(2)/3, SkIntToScalar(2)/3);
surfaceCanvas->drawOval(ovalRect, paint);
}
- SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
+ 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, inRect, outRect, kHigh_SkFilterQuality));
+ SkImageSource::Create(image.get(), inRect, outRect, kHigh_SkFilterQuality));
canvas->translate(srcRect.width() + SkIntToScalar(10), 0);
draw(canvas,
srcRect,
diff --git a/gm/surface.cpp b/gm/surface.cpp
index 6874b5b..c817f8d 100644
--- a/gm/surface.cpp
+++ b/gm/surface.cpp
@@ -140,7 +140,7 @@
}
drawInto(surf->getCanvas());
- SkAutoTUnref<SkImage> image(surf->newImageSnapshot());
+ sk_sp<SkImage> image(surf->makeImageSnapshot());
canvas->drawImage(image, 10, 10, nullptr);
SkAutoTUnref<SkSurface> surf2(surf->newSurface(info));
@@ -149,8 +149,8 @@
// Assert that the props were communicated transitively through the first image
SkASSERT(equal(surf->props(), surf2->props()));
- SkAutoTUnref<SkImage> image2(surf2->newImageSnapshot());
- canvas->drawImage(image2, 10 + SkIntToScalar(image->width()) + 10, 10, nullptr);
+ sk_sp<SkImage> image2(surf2->makeImageSnapshot());
+ canvas->drawImage(image2.get(), 10 + SkIntToScalar(image->width()) + 10, 10, nullptr);
}
private:
diff --git a/gm/textblobmixedsizes.cpp b/gm/textblobmixedsizes.cpp
index 86ab0ac..7923489 100644
--- a/gm/textblobmixedsizes.cpp
+++ b/gm/textblobmixedsizes.cpp
@@ -171,9 +171,7 @@
SkAutoCanvasRestore acr(inputCanvas, true);
// since we prepended this matrix already, we blit using identity
inputCanvas->resetMatrix();
- SkImage* image = surface->newImageSnapshot();
- inputCanvas->drawImage(image, 0, 0, nullptr);
- image->unref();
+ inputCanvas->drawImage(surface->makeImageSnapshot().get(), 0, 0, nullptr);
}
#endif
}
diff --git a/gm/tileimagefilter.cpp b/gm/tileimagefilter.cpp
index eb0ad09..b03af44 100644
--- a/gm/tileimagefilter.cpp
+++ b/gm/tileimagefilter.cpp
@@ -35,14 +35,14 @@
}
void onOnceBeforeDraw() override {
- fBitmap.reset(SkImage::NewFromBitmap(
- sk_tool_utils::create_string_bitmap(50, 50, 0xD000D000, 10, 45, 50, "e")));
+ fBitmap = SkImage::MakeFromBitmap(
+ sk_tool_utils::create_string_bitmap(50, 50, 0xD000D000, 10, 45, 50, "e"));
- fCheckerboard.reset(SkImage::NewFromBitmap(
+ fCheckerboard = SkImage::MakeFromBitmap(
sk_tool_utils::create_checkerboard_bitmap(80, 80,
sk_tool_utils::color_to_565(0xFFA0A0A0),
sk_tool_utils::color_to_565(0xFF404040),
- 8)));
+ 8));
}
void onDraw(SkCanvas* canvas) override {
@@ -56,7 +56,7 @@
int x = 0, y = 0;
for (size_t i = 0; i < 4; i++) {
- const SkImage* image = (i & 0x01) ? fCheckerboard : fBitmap;
+ const SkImage* image = (i & 0x01) ? fCheckerboard.get() : fBitmap.get();
SkRect srcRect = SkRect::MakeXYWH(SkIntToScalar(image->width()/4),
SkIntToScalar(image->height()/4),
SkIntToScalar(image->width()/(i+1)),
@@ -72,7 +72,7 @@
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
SkPaint paint;
paint.setImageFilter(filter);
- canvas->drawImage(fBitmap, 0, 0, &paint);
+ canvas->drawImage(fBitmap.get(), 0, 0, &paint);
canvas->drawRect(srcRect, red);
canvas->drawRect(dstRect, blue);
canvas->restore();
@@ -102,14 +102,14 @@
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
canvas->clipRect(dstRect);
canvas->saveLayer(&dstRect, &paint);
- canvas->drawImage(fBitmap, 0, 0);
+ canvas->drawImage(fBitmap.get(), 0, 0);
canvas->restore();
canvas->drawRect(srcRect, red);
canvas->drawRect(dstRect, blue);
canvas->restore();
}
private:
- SkAutoTUnref<SkImage> fBitmap, fCheckerboard;
+ sk_sp<SkImage> fBitmap, fCheckerboard;
typedef GM INHERITED;
};
diff --git a/gm/verylargebitmap.cpp b/gm/verylargebitmap.cpp
index ab6821d..4ce5b7b 100644
--- a/gm/verylargebitmap.cpp
+++ b/gm/verylargebitmap.cpp
@@ -22,25 +22,25 @@
canvas->drawPaint(paint);
}
-static SkImage* make_raster_image(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));
draw(surface->getCanvas(), width, height, colors);
- return surface->newImageSnapshot();
+ return surface->makeImageSnapshot();
}
-static SkImage* make_picture_image(int width, int height, SkColor colors[2]) {
+static sk_sp<SkImage> make_picture_image(int width, int height, SkColor colors[2]) {
SkPictureRecorder recorder;
draw(recorder.beginRecording(SkRect::MakeIWH(width, height)), width, height, colors);
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
- return SkImage::NewFromPicture(picture, SkISize::Make(width, height),
- nullptr, nullptr);
+ return SkImage::MakeFromPicture(sk_ref_sp(picture.get()), SkISize::Make(width, height),
+ nullptr, nullptr);
}
-typedef SkImage* (*ImageMakerProc)(int width, int height, SkColor colors[2]);
+typedef sk_sp<SkImage> (*ImageMakerProc)(int width, int height, SkColor colors[2]);
static void show_image(SkCanvas* canvas, int width, int height, SkColor colors[2],
ImageMakerProc proc) {
- SkAutoTUnref<SkImage> image(proc(width, height, colors));
+ sk_sp<SkImage> image(proc(width, height, colors));
SkPaint paint;
SkRect r;
diff --git a/gm/xfermodeimagefilter.cpp b/gm/xfermodeimagefilter.cpp
index 85bbf44..805e220 100644
--- a/gm/xfermodeimagefilter.cpp
+++ b/gm/xfermodeimagefilter.cpp
@@ -37,11 +37,11 @@
void onOnceBeforeDraw() override {
fBitmap = sk_tool_utils::create_string_bitmap(80, 80, 0xD000D000, 15, 65, 96, "e");
- fCheckerboard.reset(SkImage::NewFromBitmap(
+ fCheckerboard = SkImage::MakeFromBitmap(
sk_tool_utils::create_checkerboard_bitmap(80, 80,
sk_tool_utils::color_to_565(0xFFA0A0A0),
sk_tool_utils::color_to_565(0xFF404040),
- 8)));
+ 8));
}
void onDraw(SkCanvas* canvas) override {
@@ -85,7 +85,7 @@
};
int x = 0, y = 0;
- SkAutoTUnref<SkImageFilter> background(SkImageSource::Create(fCheckerboard));
+ SkAutoTUnref<SkImageFilter> background(SkImageSource::Create(fCheckerboard.get()));
for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) {
SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(gModes[i].fMode));
SkAutoTUnref<SkImageFilter> filter(SkXfermodeImageFilter::Create(mode, background));
@@ -119,8 +119,8 @@
SkRect clipRect = SkRect::MakeWH(SkIntToScalar(fBitmap.width() + 4),
SkIntToScalar(fBitmap.height() + 4));
// Test offsets on SrcMode (uses fixed-function blend)
- SkAutoTUnref<SkImage> bitmapImage(SkImage::NewFromBitmap(fBitmap));
- SkAutoTUnref<SkImageFilter> foreground(SkImageSource::Create(bitmapImage));
+ sk_sp<SkImage> bitmapImage(SkImage::MakeFromBitmap(fBitmap));
+ SkAutoTUnref<SkImageFilter> foreground(SkImageSource::Create(bitmapImage.get()));
SkAutoTUnref<SkImageFilter> offsetForeground(SkOffsetImageFilter::Create(
SkIntToScalar(4), SkIntToScalar(-4), foreground));
SkAutoTUnref<SkImageFilter> offsetBackground(SkOffsetImageFilter::Create(
@@ -213,8 +213,8 @@
canvas->restore();
}
- SkBitmap fBitmap;
- SkAutoTUnref<SkImage> fCheckerboard;
+ SkBitmap fBitmap;
+ sk_sp<SkImage> fCheckerboard;
typedef GM INHERITED;
};