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

Unified Diff: gm/bitmappremul.cpp

Issue 1514503004: SkBitmap move (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-12-10 (Thursday) 17:55:13 EST Created 5 years 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
Index: gm/bitmappremul.cpp
diff --git a/gm/bitmappremul.cpp b/gm/bitmappremul.cpp
index 172612ddb09f7d16463d92886ea5329a732353e1..27b98e7998e2d0ac52a49626806474d383ffad02 100644
--- a/gm/bitmappremul.cpp
+++ b/gm/bitmappremul.cpp
@@ -22,15 +22,16 @@ static const int SLIDE_SIZE = 256;
static const int PIXEL_SIZE_8888 = SLIDE_SIZE / 256;
static const int PIXEL_SIZE_4444 = SLIDE_SIZE / 16;
-static void init_bitmap(SkColorType ct, SkBitmap* bitmap) {
- bitmap->allocPixels(SkImageInfo::Make(SLIDE_SIZE, SLIDE_SIZE, ct,
- kPremul_SkAlphaType));
- bitmap->eraseColor(SK_ColorWHITE);
+static SkBitmap make_bitmap(SkColorType ct) {
+ SkBitmap bitmap;
+ bitmap.allocPixels(SkImageInfo::Make(SLIDE_SIZE, SLIDE_SIZE, ct,
+ kPremul_SkAlphaType));
+ bitmap.eraseColor(SK_ColorWHITE);
+ return skstd::move(bitmap);
}
static SkBitmap make_argb8888_gradient() {
- SkBitmap bitmap;
- init_bitmap(kN32_SkColorType, &bitmap);
+ SkBitmap bitmap(make_bitmap(kN32_SkColorType));
uint8_t rowColor = 0;
for (int y = 0; y < SLIDE_SIZE; y++) {
uint32_t* dst = bitmap.getAddr32(0, y);
@@ -42,12 +43,11 @@ static SkBitmap make_argb8888_gradient() {
rowColor++;
}
}
- return bitmap;
+ return skstd::move(bitmap);
}
static SkBitmap make_argb4444_gradient() {
- SkBitmap bitmap;
- init_bitmap(kARGB_4444_SkColorType, &bitmap);
+ SkBitmap bitmap(make_bitmap(kARGB_4444_SkColorType));
uint8_t rowColor = 0;
for (int y = 0; y < SLIDE_SIZE; y++) {
uint16_t* dst = bitmap.getAddr16(0, y);
@@ -59,12 +59,11 @@ static SkBitmap make_argb4444_gradient() {
rowColor++;
}
}
- return bitmap;
+ return skstd::move(bitmap);
}
static SkBitmap make_argb8888_stripes() {
- SkBitmap bitmap;
- init_bitmap(kN32_SkColorType, &bitmap);
+ SkBitmap bitmap(make_bitmap(kN32_SkColorType));
uint8_t rowColor = 0;
for (int y = 0; y < SLIDE_SIZE; y++) {
uint32_t* dst = bitmap.getAddr32(0, y);
@@ -78,12 +77,11 @@ static SkBitmap make_argb8888_stripes() {
rowColor = 0;
}
}
- return bitmap;
+ return skstd::move(bitmap);
}
static SkBitmap make_argb4444_stripes() {
- SkBitmap bitmap;
- init_bitmap(kARGB_4444_SkColorType, &bitmap);
+ SkBitmap bitmap(make_bitmap(kARGB_4444_SkColorType));
uint8_t rowColor = 0;
for (int y = 0; y < SLIDE_SIZE; y++) {
uint16_t* dst = bitmap.getAddr16(0, y);
@@ -97,7 +95,7 @@ static SkBitmap make_argb4444_stripes() {
rowColor = 0;
}
}
- return bitmap;
+ return skstd::move(bitmap);
}
namespace skiagm {
« no previous file with comments | « gm/arithmode.cpp ('k') | include/core/SkBitmap.h » ('j') | src/core/SkBitmap.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698