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

Unified Diff: gm/image_shader.cpp

Issue 1810813003: update callsites for Make image factories (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: start to take advantage of sk_sp drawImage 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/image_pict.cpp ('k') | gm/imagealphathreshold.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/image_shader.cpp
diff --git a/gm/image_shader.cpp b/gm/image_shader.cpp
index 7ea020229611b796daa1318c0568ac51c94d3be2..e7378c447059a6ce5bb132bc2f3701bca378af88 100644
--- a/gm/image_shader.cpp
+++ b/gm/image_shader.cpp
@@ -24,16 +24,16 @@ static void draw_something(SkCanvas* canvas, const SkRect& bounds) {
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 @@ static SkImage* make_texture(GrContext* ctx, const SkPicture* pic, const SkImage
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 @@ protected:
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);
}
« no previous file with comments | « gm/image_pict.cpp ('k') | gm/imagealphathreshold.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698