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

Unified Diff: gm/rectangletexture.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/perspshaders.cpp ('k') | gm/repeated_bitmap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/rectangletexture.cpp
diff --git a/gm/rectangletexture.cpp b/gm/rectangletexture.cpp
index 4bdb4c9f1193ad38646240557ff0e318b76df16b..e00afe97d1b8b7d0b5448c072453ac085bd22066 100644
--- a/gm/rectangletexture.cpp
+++ b/gm/rectangletexture.cpp
@@ -54,7 +54,8 @@ protected:
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 @@ protected:
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 @@ protected:
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 @@ protected:
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 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 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 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);
« no previous file with comments | « gm/perspshaders.cpp ('k') | gm/repeated_bitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698