aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bench/BitmapBench.cpp57
-rw-r--r--bench/RepeatTileBench.cpp61
-rw-r--r--gm/all_bitmap_configs.cpp47
-rw-r--r--gn/samples.gni3
-rw-r--r--include/core/SkBitmap.h7
-rw-r--r--samplecode/DecodeFile.h1
-rw-r--r--samplecode/SampleBlur.cpp37
-rw-r--r--samplecode/SampleDitherBitmap.cpp144
-rw-r--r--samplecode/SampleFilter.cpp119
-rw-r--r--samplecode/SampleTinyBitmap.cpp72
-rw-r--r--src/image/SkImage_Raster.cpp10
-rw-r--r--tests/ImageTest.cpp43
-rw-r--r--tests/ReadPixelsTest.cpp3
-rw-r--r--tests/SwizzlerTest.cpp7
14 files changed, 8 insertions, 603 deletions
diff --git a/bench/BitmapBench.cpp b/bench/BitmapBench.cpp
index 2fd480bb7a..1fd2f696b8 100644
--- a/bench/BitmapBench.cpp
+++ b/bench/BitmapBench.cpp
@@ -14,48 +14,6 @@
#include "SkString.h"
#include "sk_tool_utils.h"
-static int conv6ToByte(int x) {
- return x * 0xFF / 5;
-}
-
-static int convByteTo6(int x) {
- return x * 5 / 255;
-}
-
-static uint8_t compute666Index(SkPMColor c) {
- int r = SkGetPackedR32(c);
- int g = SkGetPackedG32(c);
- int b = SkGetPackedB32(c);
-
- return convByteTo6(r) * 36 + convByteTo6(g) * 6 + convByteTo6(b);
-}
-
-static void convertToIndex666(const SkBitmap& src, SkBitmap* dst, SkAlphaType aType) {
- SkPMColor storage[216];
- SkPMColor* colors = storage;
- // rrr ggg bbb
- for (int r = 0; r < 6; r++) {
- int rr = conv6ToByte(r);
- for (int g = 0; g < 6; g++) {
- int gg = conv6ToByte(g);
- for (int b = 0; b < 6; b++) {
- int bb = conv6ToByte(b);
- *colors++ = SkPreMultiplyARGB(0xFF, rr, gg, bb);
- }
- }
- }
- dst->allocPixels(SkImageInfo::Make(src.width(), src.height(), kIndex_8_SkColorType, aType),
- SkColorTable::Make(storage, 216));
-
- for (int y = 0; y < src.height(); y++) {
- const SkPMColor* srcP = src.getAddr32(0, y);
- uint8_t* dstP = dst->getAddr8(0, y);
- for (int x = src.width() - 1; x >= 0; --x) {
- *dstP++ = compute666Index(*srcP++);
- }
- }
-}
-
/* Variants for bitmaps
- src depth (32 w+w/o alpha), 565, 4444, index, a8
@@ -108,21 +66,12 @@ protected:
void onDelayedSetup() override {
SkBitmap bm;
- if (kIndex_8_SkColorType == fColorType) {
- bm.allocPixels(SkImageInfo::MakeN32(W, H, fAlphaType));
- } else {
- bm.allocPixels(SkImageInfo::Make(W, H, fColorType, fAlphaType));
- }
+ bm.allocPixels(SkImageInfo::Make(W, H, fColorType, fAlphaType));
bm.eraseColor(kOpaque_SkAlphaType == fAlphaType ? SK_ColorBLACK : 0);
this->onDrawIntoBitmap(bm);
- if (kIndex_8_SkColorType == fColorType) {
- convertToIndex666(bm, &fBitmap, fAlphaType);
- } else {
- fBitmap = bm;
- }
-
+ fBitmap = bm;
fBitmap.setIsVolatile(fIsVolatile);
}
@@ -355,8 +304,6 @@ DEF_BENCH( return new BitmapBench(kN32_SkColorType, kPremul_SkAlphaType, false,
DEF_BENCH( return new BitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, false, false, false); )
DEF_BENCH( return new BitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, false, false, true); )
DEF_BENCH( return new BitmapBench(kRGB_565_SkColorType, kOpaque_SkAlphaType, false, false, false); )
-DEF_BENCH( return new BitmapBench(kIndex_8_SkColorType, kPremul_SkAlphaType, false, false, false); )
-DEF_BENCH( return new BitmapBench(kIndex_8_SkColorType, kOpaque_SkAlphaType, false, false, false); )
DEF_BENCH( return new BitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, true, true, false); )
DEF_BENCH( return new BitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, true, false, false); )
diff --git a/bench/RepeatTileBench.cpp b/bench/RepeatTileBench.cpp
index 550603143d..83ba3f12aa 100644
--- a/bench/RepeatTileBench.cpp
+++ b/bench/RepeatTileBench.cpp
@@ -32,67 +32,17 @@ static void draw_into_bitmap(const SkBitmap& bm) {
canvas.drawRect(r, p);
}
-static int conv_6_to_byte(int x) {
- return x * 0xFF / 5;
-}
-
-static int conv_byte_to_6(int x) {
- return x * 5 / 255;
-}
-
-static uint8_t compute_666_index(SkPMColor c) {
- int r = SkGetPackedR32(c);
- int g = SkGetPackedG32(c);
- int b = SkGetPackedB32(c);
-
- return conv_byte_to_6(r) * 36 + conv_byte_to_6(g) * 6 + conv_byte_to_6(b);
-}
-
-static void convert_to_index666(const SkBitmap& src, SkBitmap* dst) {
- SkPMColor storage[216];
- SkPMColor* colors = storage;
- // rrr ggg bbb
- for (int r = 0; r < 6; r++) {
- int rr = conv_6_to_byte(r);
- for (int g = 0; g < 6; g++) {
- int gg = conv_6_to_byte(g);
- for (int b = 0; b < 6; b++) {
- int bb = conv_6_to_byte(b);
- *colors++ = SkPreMultiplyARGB(0xFF, rr, gg, bb);
- }
- }
- }
- dst->allocPixels(SkImageInfo::Make(src.width(), src.height(),
- kIndex_8_SkColorType, kOpaque_SkAlphaType),
- SkColorTable::Make(storage, 216));
-
- for (int y = 0; y < src.height(); y++) {
- const SkPMColor* srcP = src.getAddr32(0, y);
- uint8_t* dstP = dst->getAddr8(0, y);
- for (int x = src.width() - 1; x >= 0; --x) {
- *dstP++ = compute_666_index(*srcP++);
- }
- }
-}
-
class RepeatTileBench : public Benchmark {
- const SkColorType fColorType;
const SkAlphaType fAlphaType;
SkPaint fPaint;
SkString fName;
SkBitmap fBitmap;
public:
- RepeatTileBench(SkColorType ct, SkAlphaType at = kPremul_SkAlphaType)
- : fColorType(ct), fAlphaType(at)
- {
+ RepeatTileBench(SkColorType ct, SkAlphaType at = kPremul_SkAlphaType) : fAlphaType(at) {
const int w = 50;
const int h = 50;
- if (kIndex_8_SkColorType == ct) {
- fBitmap.setInfo(SkImageInfo::MakeN32(w, h, at));
- } else {
- fBitmap.setInfo(SkImageInfo::Make(w, h, ct, at));
- }
+ fBitmap.setInfo(SkImageInfo::Make(w, h, ct, at));
fName.printf("repeatTile_%s_%c",
sk_tool_utils::colortype_name(ct), kOpaque_SkAlphaType == at ? 'X' : 'A');
}
@@ -108,12 +58,6 @@ protected:
draw_into_bitmap(fBitmap);
- if (kIndex_8_SkColorType == fColorType) {
- SkBitmap tmp;
- convert_to_index666(fBitmap, &tmp);
- fBitmap = tmp;
- }
-
fPaint.setShader(SkShader::MakeBitmapShader(fBitmap,
SkShader::kRepeat_TileMode,
SkShader::kRepeat_TileMode));
@@ -136,4 +80,3 @@ private:
DEF_BENCH(return new RepeatTileBench(kN32_SkColorType, kOpaque_SkAlphaType))
DEF_BENCH(return new RepeatTileBench(kN32_SkColorType, kPremul_SkAlphaType))
DEF_BENCH(return new RepeatTileBench(kRGB_565_SkColorType, kOpaque_SkAlphaType))
-DEF_BENCH(return new RepeatTileBench(kIndex_8_SkColorType, kPremul_SkAlphaType))
diff --git a/gm/all_bitmap_configs.cpp b/gm/all_bitmap_configs.cpp
index 4c8ea359f1..d9735b2d3d 100644
--- a/gm/all_bitmap_configs.cpp
+++ b/gm/all_bitmap_configs.cpp
@@ -102,47 +102,6 @@ int find(T* array, int N, T item) {
return -1;
}
-static SkPMColor premultiply_color(SkColor c) {
- return SkPremultiplyARGBInline(SkColorGetA(c), SkColorGetR(c),
- SkColorGetG(c), SkColorGetB(c));
-}
-
-static SkBitmap indexed_bitmap() {
- SkBitmap n32bitmap;
- n32bitmap.allocN32Pixels(SCALE, SCALE);
- n32bitmap.eraseColor(SK_ColorTRANSPARENT);
-
- SkCanvas canvas(n32bitmap);
- color_wheel_native(&canvas);
- const SkColor colors[] = {
- SK_ColorTRANSPARENT,
- SK_ColorWHITE,
- SK_ColorBLACK,
- SK_ColorRED,
- SK_ColorGREEN,
- SK_ColorBLUE,
- SK_ColorCYAN,
- SK_ColorMAGENTA,
- SK_ColorYELLOW,
- };
- SkPMColor pmColors[SK_ARRAY_COUNT(colors)];
- for (size_t i = 0; i < SK_ARRAY_COUNT(colors); ++i) {
- pmColors[i] = premultiply_color(colors[i]);
- }
- SkBitmap bm;
- SkImageInfo info = SkImageInfo::Make(SCALE, SCALE, kIndex_8_SkColorType,
- kPremul_SkAlphaType);
- bm.allocPixels(info, SkColorTable::Make(pmColors, SK_ARRAY_COUNT(pmColors)));
- for (int y = 0; y < SCALE; ++y) {
- for (int x = 0; x < SCALE; ++x) {
- SkPMColor c = *n32bitmap.getAddr32(x, y);
- int idx = find(pmColors, SK_ARRAY_COUNT(pmColors), c);
- *bm.getAddr8(x, y) = SkClampMax(idx, SK_ARRAY_COUNT(pmColors) - 1);
- }
- }
- return bm;
-}
-
static void draw(SkCanvas* canvas,
const SkPaint& p,
const SkBitmap& src,
@@ -153,7 +112,7 @@ static void draw(SkCanvas* canvas,
canvas->drawString(text, 0.0f, 12.0f, p);
}
-DEF_SIMPLE_GM(all_bitmap_configs, canvas, SCALE, 6 * SCALE) {
+DEF_SIMPLE_GM(all_bitmap_configs, canvas, SCALE, 5 * SCALE) {
SkAutoCanvasRestore autoCanvasRestore(canvas, true);
SkPaint p;
p.setColor(SK_ColorBLACK);
@@ -181,10 +140,6 @@ DEF_SIMPLE_GM(all_bitmap_configs, canvas, SCALE, 6 * SCALE) {
}
canvas->translate(0.0f, SkIntToScalar(SCALE));
- SkBitmap bitmapIndexed = indexed_bitmap();
- draw(canvas, p, bitmapIndexed, kIndex_8_SkColorType, "Index 8");
-
- canvas->translate(0.0f, SkIntToScalar(SCALE));
SkBitmap bitmapA8 = make_bitmap(kAlpha_8_SkColorType);
draw(canvas, p, bitmapA8, kAlpha_8_SkColorType, "Alpha 8");
diff --git a/gn/samples.gni b/gn/samples.gni
index 80e0663bf5..f388e791e0 100644
--- a/gn/samples.gni
+++ b/gn/samples.gni
@@ -38,12 +38,10 @@ samples_sources = [
"$_samplecode/SampleConcavePaths.cpp",
"$_samplecode/SampleDegenerateTwoPtRadials.cpp",
"$_samplecode/SampleDither.cpp",
- "$_samplecode/SampleDitherBitmap.cpp",
"$_samplecode/SampleEffects.cpp",
"$_samplecode/SampleEmboss.cpp",
"$_samplecode/SampleFatBits.cpp",
"$_samplecode/SampleFillType.cpp",
- "$_samplecode/SampleFilter.cpp",
"$_samplecode/SampleFilter2.cpp",
"$_samplecode/SampleFilterFuzz.cpp",
"$_samplecode/SampleFilterQuality.cpp",
@@ -98,7 +96,6 @@ samples_sources = [
"$_samplecode/SampleTextOnPath.cpp",
"$_samplecode/SampleTextureDomain.cpp",
"$_samplecode/SampleTiling.cpp",
- "$_samplecode/SampleTinyBitmap.cpp",
"$_samplecode/SampleUnpremul.cpp",
"$_samplecode/SampleVertices.cpp",
"$_samplecode/SampleWritePixels.cpp",
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 00a68dad4f..7a0130eb7a 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -121,12 +121,7 @@ public:
/** Return true iff drawing this bitmap has no effect.
*/
bool drawsNothing() const {
-#ifndef SK_SUPPORT_LEGACY_INDEX_8
- if (this->colorType() == kIndex_8_SkColorType) {
- return true;
- }
-#endif
- return this->empty() || this->isNull();
+ return this->colorType() == kIndex_8_SkColorType || this->empty() || this->isNull();
}
/** Return the number of bytes between subsequent rows of the bitmap. */
diff --git a/samplecode/DecodeFile.h b/samplecode/DecodeFile.h
index 450c1fb3d7..1ae98a4a72 100644
--- a/samplecode/DecodeFile.h
+++ b/samplecode/DecodeFile.h
@@ -16,7 +16,6 @@
static inline bool decode_file(const char* filename, SkBitmap* bitmap,
SkColorType colorType = kN32_SkColorType,
bool requireUnpremul = false) {
- SkASSERT(kIndex_8_SkColorType != colorType);
sk_sp<SkData> data(SkData::MakeFromFileName(filename));
std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data));
if (!codec) {
diff --git a/samplecode/SampleBlur.cpp b/samplecode/SampleBlur.cpp
index a2f90a7746..507c57e29d 100644
--- a/samplecode/SampleBlur.cpp
+++ b/samplecode/SampleBlur.cpp
@@ -14,45 +14,10 @@
#include "SkUtils.h"
#include "SkView.h"
-static SkBitmap make_bitmap() {
- SkPMColor c[256];
- for (int i = 0; i < 256; i++) {
- c[i] = SkPackARGB32(255 - i, 0, 0, 0);
- }
-
- SkBitmap bm;
- bm.allocPixels(SkImageInfo::Make(256, 256, kIndex_8_SkColorType,
- kPremul_SkAlphaType),
- SkColorTable::Make(c, 256));
-
- const float cx = bm.width() * 0.5f;
- const float cy = bm.height() * 0.5f;
- for (int y = 0; y < bm.height(); y++) {
- float dy = y - cy;
- dy *= dy;
- uint8_t* p = bm.getAddr8(0, y);
- for (int x = 0; x < 256; x++) {
- float dx = x - cx;
- dx *= dx;
- float d = (dx + dy) / (cx/2);
- int id = (int)d;
- if (id > 255) {
- id = 255;
- }
- p[x] = id;
- }
- }
- return bm;
-}
-
class BlurView : public SampleView {
SkBitmap fBM;
public:
- BlurView() {
- if (false) { // avoid bit rot, suppress warning
- fBM = make_bitmap();
- }
- }
+ BlurView() {}
protected:
// overrides from SkEventSink
diff --git a/samplecode/SampleDitherBitmap.cpp b/samplecode/SampleDitherBitmap.cpp
deleted file mode 100644
index 2f3de35fd6..0000000000
--- a/samplecode/SampleDitherBitmap.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SampleCode.h"
-#include "SkCanvas.h"
-#include "SkColorPriv.h"
-#include "SkGradientShader.h"
-#include "SkPath.h"
-#include "SkRegion.h"
-#include "SkUtils.h"
-#include "SkView.h"
-#include "sk_tool_utils.h"
-
-static void draw_rect(SkCanvas* canvas, const SkRect& r, const SkPaint& p) {
- canvas->drawRect(r, p);
-
- SkPaint frame(p);
- frame.setShader(nullptr);
- frame.setStyle(SkPaint::kStroke_Style);
- canvas->drawRect(r, frame);
-}
-
-static void draw_gradient(SkCanvas* canvas) {
- SkRect r = { 0, 0, SkIntToScalar(256), SkIntToScalar(32) };
- SkPoint pts[] = { { r.fLeft, r.fTop }, { r.fRight, r.fTop } };
- SkColor colors[] = { 0xFF000000, 0xFFFF0000 };
- SkPaint p;
- p.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode));
- draw_rect(canvas, r, p);
-
- canvas->translate(0, SkIntToScalar(40));
- p.setDither(true);
- draw_rect(canvas, r, p);
-}
-
-static bool test_pathregion() {
- SkPath path;
- SkRegion region;
- path.moveTo(25071800.f, -141823808.f);
- path.lineTo(25075500.f, -141824000.f);
- path.lineTo(25075400.f, -141827712.f);
- path.lineTo(25071810.f, -141827600.f);
- path.close();
-
- SkIRect bounds;
- path.getBounds().round(&bounds);
- SkRegion clip(bounds);
- return region.setPath(path, clip); // <-- !! DOWN !!
-}
-
-static SkBitmap make_bitmap() {
- SkPMColor c[256];
- for (int i = 0; i < 256; i++) {
- c[i] = SkPackARGB32(0xFF, i, 0, 0);
- }
- SkBitmap bm;
- bm.allocPixels(SkImageInfo::Make(256, 32, kIndex_8_SkColorType, kPremul_SkAlphaType),
- SkColorTable::Make(c, 256));
-
- for (int y = 0; y < bm.height(); y++) {
- uint8_t* p = bm.getAddr8(0, y);
- for (int x = 0; x < 256; x++) {
- p[x] = x;
- }
- }
- return bm;
-}
-
-class DitherBitmapView : public SampleView {
- SkBitmap fBM8;
- SkBitmap fBM32;
- bool fResult;
-public:
- DitherBitmapView() {
- fResult = test_pathregion();
- fBM8 = make_bitmap();
- sk_tool_utils::copy_to(&fBM32, kN32_SkColorType, fBM8);
-
- this->setBGColor(0xFFDDDDDD);
- }
-
-protected:
- // overrides from SkEventSink
- virtual bool onQuery(SkEvent* evt) {
- if (SampleCode::TitleQ(*evt)) {
- SampleCode::TitleR(evt, "DitherBitmap");
- return true;
- }
- return this->INHERITED::onQuery(evt);
- }
-
- static void setBitmapOpaque(SkBitmap* bm, bool isOpaque) {
- bm->setAlphaType(isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
- }
-
- static void draw2(SkCanvas* canvas, const SkBitmap& bm) {
- SkPaint paint;
- SkBitmap bitmap(bm);
-
- setBitmapOpaque(&bitmap, false);
- paint.setDither(false);
- canvas->drawBitmap(bitmap, 0, 0, &paint);
- paint.setDither(true);
- canvas->drawBitmap(bitmap, 0, SkIntToScalar(bm.height() + 10), &paint);
-
- setBitmapOpaque(&bitmap, true);
- SkScalar x = SkIntToScalar(bm.width() + 10);
- paint.setDither(false);
- canvas->drawBitmap(bitmap, x, 0, &paint);
- paint.setDither(true);
- canvas->drawBitmap(bitmap, x, SkIntToScalar(bm.height() + 10), &paint);
- }
-
- virtual void onDrawContent(SkCanvas* canvas) {
- canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
-
- draw2(canvas, fBM8);
- canvas->translate(0, SkIntToScalar(fBM8.height() *3));
- draw2(canvas, fBM32);
-
- canvas->translate(0, SkIntToScalar(fBM8.height() *3));
- draw_gradient(canvas);
-
- char resultTrue[] = "SkRegion::setPath returned true";
- char resultFalse[] = "SkRegion::setPath returned false";
- SkPaint p;
- if (fResult)
- canvas->drawText(resultTrue, sizeof(resultTrue) - 1, 0, 50, p);
- else
- canvas->drawText(resultFalse, sizeof(resultFalse) - 1, 0, 50, p);
- }
-
-private:
- typedef SampleView INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static SkView* MyFactory() { return new DitherBitmapView; }
-static SkViewRegister reg(MyFactory);
diff --git a/samplecode/SampleFilter.cpp b/samplecode/SampleFilter.cpp
deleted file mode 100644
index 60dd7e090d..0000000000
--- a/samplecode/SampleFilter.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "SampleCode.h"
-#include "SkView.h"
-#include "SkCanvas.h"
-#include "SkGradientShader.h"
-#include "SkPath.h"
-#include "SkRegion.h"
-#include "SkShader.h"
-#include "SkUtils.h"
-#include "Sk1DPathEffect.h"
-#include "SkCornerPathEffect.h"
-#include "SkPathMeasure.h"
-#include "SkRandom.h"
-#include "SkColorPriv.h"
-#include "SkColorFilter.h"
-#include "SkDither.h"
-#include "sk_tool_utils.h"
-
-static void make_bm(SkBitmap* bm) {
- const SkPMColor colors[] = {
- SkPreMultiplyColor(SK_ColorRED), SkPreMultiplyColor(SK_ColorGREEN),
- SkPreMultiplyColor(SK_ColorBLUE), SkPreMultiplyColor(SK_ColorWHITE)
- };
- bm->allocPixels(SkImageInfo::Make(2, 2, kIndex_8_SkColorType,
- kOpaque_SkAlphaType),
- SkColorTable::Make(colors, 4));
-
- *bm->getAddr8(0, 0) = 0;
- *bm->getAddr8(1, 0) = 1;
- *bm->getAddr8(0, 1) = 2;
- *bm->getAddr8(1, 1) = 3;
-}
-
-static SkScalar draw_bm(SkCanvas* canvas, const SkBitmap& bm,
- SkScalar x, SkScalar y, SkPaint* paint) {
- canvas->drawBitmap(bm, x, y, paint);
- return SkIntToScalar(bm.width()) * 5/4;
-}
-
-static SkScalar draw_set(SkCanvas* c, const SkBitmap& bm, SkScalar x, SkPaint* p) {
- x += draw_bm(c, bm, x, 0, p);
- p->setFilterQuality(kLow_SkFilterQuality);
- x += draw_bm(c, bm, x, 0, p);
- p->setDither(true);
- return x + draw_bm(c, bm, x, 0, p);
-}
-
-static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) {
- SkAutoCanvasRestore acr(canvas, true);
-
- SkPaint paint;
- SkScalar x = 0;
- const int scale = 32;
-
- paint.setAntiAlias(true);
- const char* name = sk_tool_utils::colortype_name(bm.colorType());
- canvas->drawString(name, x, SkIntToScalar(bm.height())*scale*5/8,
- paint);
- canvas->translate(SkIntToScalar(48), 0);
-
- canvas->scale(SkIntToScalar(scale), SkIntToScalar(scale));
-
- x += draw_set(canvas, bm, 0, &paint);
- paint.reset();
- paint.setAlpha(0x80);
- draw_set(canvas, bm, x, &paint);
- return x * scale / 3;
-}
-
-class FilterView : public SampleView {
-public:
- SkBitmap fBM8, fBM4444, fBM16, fBM32;
-
- FilterView() {
- make_bm(&fBM8);
- sk_tool_utils::copy_to(&fBM4444, kARGB_4444_SkColorType, fBM8);
- sk_tool_utils::copy_to(&fBM16, kRGB_565_SkColorType, fBM8);
- sk_tool_utils::copy_to(&fBM32, kN32_SkColorType, fBM8);
-
- this->setBGColor(0xFFDDDDDD);
- }
-
-protected:
- // overrides from SkEventSink
- virtual bool onQuery(SkEvent* evt) {
- if (SampleCode::TitleQ(*evt)) {
- SampleCode::TitleR(evt, "Filter");
- return true;
- }
- return this->INHERITED::onQuery(evt);
- }
-
- virtual void onDrawContent(SkCanvas* canvas) {
- SkScalar x = SkIntToScalar(10);
- SkScalar y = SkIntToScalar(10);
-
- canvas->translate(x, y);
- y = draw_row(canvas, fBM8);
- canvas->translate(0, y);
- y = draw_row(canvas, fBM4444);
- canvas->translate(0, y);
- y = draw_row(canvas, fBM16);
- canvas->translate(0, y);
- draw_row(canvas, fBM32);
- }
-
-private:
- typedef SampleView INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static SkView* MyFactory() { return new FilterView; }
-static SkViewRegister reg(MyFactory);
diff --git a/samplecode/SampleTinyBitmap.cpp b/samplecode/SampleTinyBitmap.cpp
deleted file mode 100644
index 2212cbec23..0000000000
--- a/samplecode/SampleTinyBitmap.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SampleCode.h"
-#include "SkColorPriv.h"
-#include "SkShader.h"
-#include "SkView.h"
-#include "SkCanvas.h"
-#include "SkUtils.h"
-
-static SkBitmap make_bitmap() {
- const int N = 1;
-
- SkPMColor c[N];
- for (int i = 0; i < N; i++) {
- c[i] = SkPackARGB32(0x80, 0x80, 0, 0);
- }
-
- SkBitmap bm;
- bm.allocPixels(SkImageInfo::Make(1, 1, kIndex_8_SkColorType,
- kPremul_SkAlphaType),
- SkColorTable::Make(c, N));
-
- for (int y = 0; y < bm.height(); y++) {
- uint8_t* p = bm.getAddr8(0, y);
- for (int x = 0; x < bm.width(); x++) {
- p[x] = 0;
- }
- }
- return bm;
-}
-
-class TinyBitmapView : public SampleView {
- SkBitmap fBM;
-public:
- TinyBitmapView() {
- fBM = make_bitmap();
- this->setBGColor(0xFFDDDDDD);
- }
-
-protected:
- bool onQuery(SkEvent* evt) override {
- if (SampleCode::TitleQ(*evt)) {
- SampleCode::TitleR(evt, "TinyBitmap");
- return true;
- }
- return this->INHERITED::onQuery(evt);
- }
-
- static void setBitmapOpaque(SkBitmap* bm, bool isOpaque) {
- bm->setAlphaType(isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
- }
-
- void onDrawContent(SkCanvas* canvas) override {
- SkPaint paint;
- paint.setShader(SkShader::MakeBitmapShader(fBM, SkShader::kRepeat_TileMode,
- SkShader::kMirror_TileMode));
- canvas->drawPaint(paint);
- }
-
-private:
- typedef SkView INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static SkView* MyFactory() { return new TinyBitmapView; }
-static SkViewRegister reg(MyFactory);
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index f0338de4c8..c69e5ff7f9 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -57,17 +57,9 @@ public:
if (kUnknown_SkColorType == info.colorType()) {
return false;
}
-
- const bool needsCT = kIndex_8_SkColorType == info.colorType();
-#ifdef SK_SUPPORT_LEGACY_INDEX_8
- if (needsCT != hasColorTable) {
- return false;
- }
-#else
- if (needsCT) {
+ if (kIndex_8_SkColorType == info.colorType()) {
return false;
}
-#endif
if (rowBytes < info.minRowBytes()) {
return false;
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index c57cafa9a3..0b62b00c73 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -296,35 +296,6 @@ DEF_TEST(Image_Serialize_Encoding_Failure, reporter) {
}
}
-#ifdef SK_SUPPORT_LEGACY_INDEX_8
-DEF_TEST(Image_NewRasterCopy, reporter) {
- const SkPMColor red = SkPackARGB32(0xFF, 0xFF, 0, 0);
- const SkPMColor green = SkPackARGB32(0xFF, 0, 0xFF, 0);
- const SkPMColor blue = SkPackARGB32(0xFF, 0, 0, 0xFF);
- SkPMColor colors[] = { red, green, blue, 0 };
- sk_sp<SkColorTable> ctable(new SkColorTable(colors, SK_ARRAY_COUNT(colors)));
- // The colortable made a copy, so we can trash the original colors
- memset(colors, 0xFF, sizeof(colors));
-
- const SkImageInfo srcInfo = SkImageInfo::Make(2, 2, kIndex_8_SkColorType, kPremul_SkAlphaType);
- const size_t srcRowBytes = 2 * sizeof(uint8_t);
- uint8_t indices[] = { 0, 1, 2, 3 };
- auto image = SkImage::MakeRasterCopy(SkPixmap(srcInfo, indices, srcRowBytes, ctable.get()));
- // The image made a copy, so we can trash the original indices
- memset(indices, 0xFF, sizeof(indices));
-
- const SkImageInfo dstInfo = SkImageInfo::MakeN32Premul(2, 2);
- const size_t dstRowBytes = 2 * sizeof(SkPMColor);
- SkPMColor pixels[4];
- memset(pixels, 0xFF, sizeof(pixels)); // init with values we don't expect
- image->readPixels(dstInfo, pixels, dstRowBytes, 0, 0);
- REPORTER_ASSERT(reporter, red == pixels[0]);
- REPORTER_ASSERT(reporter, green == pixels[1]);
- REPORTER_ASSERT(reporter, blue == pixels[2]);
- REPORTER_ASSERT(reporter, 0 == pixels[3]);
-}
-#endif
-
// Test that a draw that only partially covers the drawing surface isn't
// interpreted as covering the entire drawing surface (i.e., exercise one of the
// conditions of SkCanvas::wouldOverwriteEntireSurface()).
@@ -557,20 +528,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_drawAbandonedGpuImage, reporter, c
#endif
-
-#ifdef SK_SUPPORT_LEGACY_INDEX_8
-// https://bug.skia.org/4390
-DEF_TEST(ImageFromIndex8Bitmap, r) {
- SkPMColor pmColors[1] = {SkPreMultiplyColor(SK_ColorWHITE)};
- SkBitmap bm;
- SkImageInfo info = SkImageInfo::Make(1, 1, kIndex_8_SkColorType, kPremul_SkAlphaType);
- bm.allocPixels(info, SkColorTable::Make(pmColors, SK_ARRAY_COUNT(pmColors)));
- *bm.getAddr8(0, 0) = 0;
- sk_sp<SkImage> img(SkImage::MakeFromBitmap(bm));
- REPORTER_ASSERT(r, img != nullptr);
-}
-#endif
-
class EmptyGenerator : public SkImageGenerator {
public:
EmptyGenerator() : SkImageGenerator(SkImageInfo::MakeN32Premul(0, 0)) {}
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index ce13fcf9d4..a30576f74c 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -589,9 +589,6 @@ DEF_TEST(ReadPixels_ValidConversion, reporter) {
kARGB_4444_SkColorType,
kRGBA_8888_SkColorType,
kBGRA_8888_SkColorType,
-#ifdef SK_SUPPORT_LEGACY_INDEX_8
- kIndex_8_SkColorType,
-#endif
kGray_8_SkColorType,
kRGBA_F16_SkColorType,
};
diff --git a/tests/SwizzlerTest.cpp b/tests/SwizzlerTest.cpp
index 4626a47662..655c97eadd 100644
--- a/tests/SwizzlerTest.cpp
+++ b/tests/SwizzlerTest.cpp
@@ -11,7 +11,6 @@
#include "SkOpts.h"
// These are the values that we will look for to indicate that the fill was successful
-static const uint8_t kFillIndex = 0x11;
static const uint8_t kFillGray = 0x22;
static const uint16_t kFill565 = 0x3344;
static const uint32_t kFillColor = 0x55667788;
@@ -49,9 +48,6 @@ static void check_fill(skiatest::Reporter* r,
for (uint32_t y = startRow; y <= endRow; y++) {
for (int32_t x = 0; x < imageInfo.width(); x++) {
switch (imageInfo.colorType()) {
- case kIndex_8_SkColorType:
- REPORTER_ASSERT(r, kFillIndex == indexPtr[x]);
- break;
case kN32_SkColorType:
REPORTER_ASSERT(r, kFillColor == colorPtr[x]);
break;
@@ -90,7 +86,6 @@ DEF_TEST(SwizzlerFill, r) {
// Create image info objects
const SkImageInfo colorInfo = SkImageInfo::MakeN32(width, height, kUnknown_SkAlphaType);
const SkImageInfo grayInfo = colorInfo.makeColorType(kGray_8_SkColorType);
- const SkImageInfo indexInfo = colorInfo.makeColorType(kIndex_8_SkColorType);
const SkImageInfo color565Info = colorInfo.makeColorType(kRGB_565_SkColorType);
for (uint32_t padding : paddings) {
@@ -113,8 +108,6 @@ DEF_TEST(SwizzlerFill, r) {
// Test fill with each color type
check_fill(r, colorInfo, startRow, endRow, colorRowBytes, offset,
kFillColor);
- check_fill(r, indexInfo, startRow, endRow, indexRowBytes, offset,
- kFillIndex);
check_fill(r, grayInfo, startRow, endRow, grayRowBytes, offset,
kFillGray);
check_fill(r, color565Info, startRow, endRow, color565RowBytes, offset,