aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-03-31 09:20:50 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-31 15:39:31 +0000
commit2e491a6a113c5e16a3b7bede5fa6f588deeb928d (patch)
treee8540e14d4ca1dd12ca3b2df5d9ef0b6f48b3a7f /gm
parentf3333c89bf05fc602d9bf8e1e24547668c660383 (diff)
clean up (partially) colortable api
Needs this to land: https://codereview.chromium.org/2789853002/ Bug: skia: Change-Id: I38d916a546b7fa64d000d973e695ddda24a589e7 Reviewed-on: https://skia-review.googlesource.com/10600 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Matt Sarett <msarett@google.com>
Diffstat (limited to 'gm')
-rw-r--r--gm/all_bitmap_configs.cpp3
-rw-r--r--gm/bitmapfilters.cpp5
-rw-r--r--gm/encode-srgb.cpp3
-rw-r--r--gm/image_pict.cpp3
-rw-r--r--gm/tinybitmap.cpp4
5 files changed, 5 insertions, 13 deletions
diff --git a/gm/all_bitmap_configs.cpp b/gm/all_bitmap_configs.cpp
index ea7b73483b..60aec88ddf 100644
--- a/gm/all_bitmap_configs.cpp
+++ b/gm/all_bitmap_configs.cpp
@@ -124,10 +124,9 @@ static SkBitmap indexed_bitmap() {
pmColors[i] = premultiply_color(colors[i]);
}
SkBitmap bm;
- sk_sp<SkColorTable> ctable(new SkColorTable(pmColors, SK_ARRAY_COUNT(pmColors)));
SkImageInfo info = SkImageInfo::Make(SCALE, SCALE, kIndex_8_SkColorType,
kPremul_SkAlphaType);
- bm.allocPixels(info, nullptr, ctable.get());
+ bm.allocPixels(info, SkColorTable::Make(pmColors, SK_ARRAY_COUNT(pmColors)));
SkAutoLockPixels autoLockPixels1(n32bitmap);
SkAutoLockPixels autoLockPixels2(bm);
for (int y = 0; y < SCALE; ++y) {
diff --git a/gm/bitmapfilters.cpp b/gm/bitmapfilters.cpp
index 2cded98236..22e5d0943f 100644
--- a/gm/bitmapfilters.cpp
+++ b/gm/bitmapfilters.cpp
@@ -17,12 +17,9 @@ static void make_bm(SkBitmap* bm) {
for (size_t i = 0; i < SK_ARRAY_COUNT(colors); ++i) {
colorsPM[i] = SkPreMultiplyColor(colors[i]);
}
- SkColorTable* ctable = new SkColorTable(colorsPM, 4);
-
bm->allocPixels(SkImageInfo::Make(2, 2, kIndex_8_SkColorType,
kPremul_SkAlphaType),
- nullptr, ctable);
- ctable->unref();
+ SkColorTable::Make(colorsPM, 4));
*bm->getAddr8(0, 0) = 0;
*bm->getAddr8(1, 0) = 1;
diff --git a/gm/encode-srgb.cpp b/gm/encode-srgb.cpp
index f62d48ae2c..894b0ef8d5 100644
--- a/gm/encode-srgb.cpp
+++ b/gm/encode-srgb.cpp
@@ -67,10 +67,9 @@ static void make_index8(SkBitmap* bitmap, SkAlphaType alphaType, sk_sp<SkColorSp
pmColors[i] = toPMColor(colors[i]);
}
- sk_sp<SkColorTable> colorTable(new SkColorTable(pmColors, SK_ARRAY_COUNT(pmColors)));
SkImageInfo info = SkImageInfo::Make(imageWidth, imageHeight, kIndex_8_SkColorType,
alphaType, colorSpace);
- bitmap->allocPixels(info, nullptr, colorTable.get());
+ bitmap->allocPixels(info, SkColorTable::Make(pmColors, SK_ARRAY_COUNT(pmColors)));
for (int y = 0; y < imageHeight; y++) {
for (int x = 0; x < imageWidth; x++) {
*bitmap->getAddr8(x, y) = (x / div_round_up(imageWidth, 2)) +
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index 792173ce66..f23b89e728 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -199,8 +199,7 @@ static std::unique_ptr<SkImageGenerator> make_ctable_generator(GrContext*, sk_sp
SkImageInfo info = SkImageInfo::Make(100, 100, kIndex_8_SkColorType, kPremul_SkAlphaType);
SkBitmap bm2;
- sk_sp<SkColorTable> ct(new SkColorTable(colors, count));
- bm2.allocPixels(info, nullptr, ct.get());
+ bm2.allocPixels(info, SkColorTable::Make(colors, count));
for (int y = 0; y < info.height(); ++y) {
for (int x = 0; x < info.width(); ++x) {
*bm2.getAddr8(x, y) = find_closest(*bm.getAddr32(x, y), colors, count);
diff --git a/gm/tinybitmap.cpp b/gm/tinybitmap.cpp
index 0f0f1374ea..1640cb23d1 100644
--- a/gm/tinybitmap.cpp
+++ b/gm/tinybitmap.cpp
@@ -15,13 +15,11 @@ namespace skiagm {
static SkBitmap make_bitmap() {
const SkPMColor c[] = { SkPackARGB32(0x80, 0x80, 0, 0) };
- SkColorTable* ctable = new SkColorTable(c, SK_ARRAY_COUNT(c));
SkBitmap bm;
bm.allocPixels(SkImageInfo::Make(1, 1, kIndex_8_SkColorType,
kPremul_SkAlphaType),
- nullptr, ctable);
- ctable->unref();
+ SkColorTable::Make(c, SK_ARRAY_COUNT(c)));
bm.lockPixels();
*bm.getAddr8(0, 0) = 0;