remove references to kIndex_8_SkColorType from our tools/tests
Bug: skia:6828 Change-Id: Ib5049c28c11b7320bece20f5a0a886de8b2a4343 Reviewed-on: https://skia-review.googlesource.com/22728 Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
7da6ba2d63
commit
304a07c6c9
@ -18,9 +18,6 @@ inline const char* color_type_to_str(SkColorType colorType) {
|
||||
return "565";
|
||||
case kGray_8_SkColorType:
|
||||
return "Gray8";
|
||||
case kIndex_8_SkColorType:
|
||||
SkASSERT(false);
|
||||
return "Index8";
|
||||
case kAlpha_8_SkColorType:
|
||||
return "Alpha8";
|
||||
default:
|
||||
|
@ -171,8 +171,6 @@ Error BRDSrc::draw(SkCanvas* canvas) const {
|
||||
}
|
||||
alpha8_to_gray8(&bitmap);
|
||||
|
||||
// Verify that we no longer support kIndex8 from this API.
|
||||
SkASSERT(kIndex_8_SkColorType != bitmap.colorType());
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
return "";
|
||||
}
|
||||
@ -229,7 +227,6 @@ Error BRDSrc::draw(SkCanvas* canvas) const {
|
||||
}
|
||||
|
||||
alpha8_to_gray8(&bitmap);
|
||||
SkASSERT(kIndex_8_SkColorType != bitmap.colorType());
|
||||
canvas->drawBitmapRect(bitmap,
|
||||
SkRect::MakeXYWH((SkScalar) scaledBorder, (SkScalar) scaledBorder,
|
||||
(SkScalar) (subsetWidth / fSampleSize),
|
||||
@ -343,9 +340,6 @@ static void premultiply_if_necessary(SkBitmap& bitmap) {
|
||||
SkOpts::RGBA_to_rgbA(row, row, bitmap.width());
|
||||
}
|
||||
break;
|
||||
case kIndex_8_SkColorType:
|
||||
SkASSERT(false);
|
||||
break;
|
||||
default:
|
||||
// No need to premultiply kGray or k565 outputs.
|
||||
break;
|
||||
@ -531,10 +525,9 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
|
||||
break;
|
||||
}
|
||||
case SkCodec::kInvalidConversion:
|
||||
if (i > 0 && (decodeInfo.colorType() == kRGB_565_SkColorType
|
||||
|| decodeInfo.colorType() == kIndex_8_SkColorType)) {
|
||||
if (i > 0 && (decodeInfo.colorType() == kRGB_565_SkColorType)) {
|
||||
return Error::Nonfatal(SkStringPrintf(
|
||||
"Cannot decode frame %i to 565/Index8 (%s).", i, fPath.c_str()));
|
||||
"Cannot decode frame %i to 565 (%s).", i, fPath.c_str()));
|
||||
}
|
||||
// Fall through.
|
||||
default:
|
||||
|
@ -17,14 +17,12 @@ static void make_bm(SkBitmap* bm) {
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(colors); ++i) {
|
||||
colorsPM[i] = SkPreMultiplyColor(colors[i]);
|
||||
}
|
||||
bm->allocPixels(SkImageInfo::Make(2, 2, kIndex_8_SkColorType,
|
||||
kOpaque_SkAlphaType),
|
||||
SkColorTable::Make(colorsPM, 4));
|
||||
bm->allocN32Pixels(2, 2, true);
|
||||
|
||||
*bm->getAddr8(0, 0) = 0;
|
||||
*bm->getAddr8(1, 0) = 1;
|
||||
*bm->getAddr8(0, 1) = 2;
|
||||
*bm->getAddr8(1, 1) = 3;
|
||||
*bm->getAddr32(0, 0) = colorsPM[0];
|
||||
*bm->getAddr32(1, 0) = colorsPM[1];
|
||||
*bm->getAddr32(0, 1) = colorsPM[2];
|
||||
*bm->getAddr32(1, 1) = colorsPM[3];
|
||||
}
|
||||
|
||||
static SkScalar draw_bm(SkCanvas* canvas, const SkBitmap& bm,
|
||||
@ -67,14 +65,13 @@ static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) {
|
||||
|
||||
class FilterGM : public skiagm::GM {
|
||||
void onOnceBeforeDraw() override {
|
||||
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);
|
||||
make_bm(&fBM32);
|
||||
sk_tool_utils::copy_to(&fBM4444, kARGB_4444_SkColorType, fBM32);
|
||||
sk_tool_utils::copy_to(&fBM16, kRGB_565_SkColorType, fBM32);
|
||||
}
|
||||
|
||||
public:
|
||||
SkBitmap fBM8, fBM4444, fBM16, fBM32;
|
||||
SkBitmap fBM4444, fBM16, fBM32;
|
||||
|
||||
FilterGM() {
|
||||
this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
|
||||
@ -86,7 +83,7 @@ protected:
|
||||
}
|
||||
|
||||
SkISize onISize() override {
|
||||
return SkISize::Make(540, 330);
|
||||
return SkISize::Make(540, 250);
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
@ -94,8 +91,6 @@ protected:
|
||||
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);
|
||||
|
@ -25,10 +25,6 @@ namespace skiagm {
|
||||
static const int imageWidth = 128;
|
||||
static const int imageHeight = 128;
|
||||
|
||||
static inline int div_round_up(int a, int b) {
|
||||
return (a + b - 1) / b;
|
||||
}
|
||||
|
||||
sk_sp<SkColorSpace> fix_for_colortype(sk_sp<SkColorSpace> colorSpace, SkColorType colorType) {
|
||||
if (kRGBA_F16_SkColorType == colorType) {
|
||||
if (!colorSpace) {
|
||||
@ -41,54 +37,10 @@ sk_sp<SkColorSpace> fix_for_colortype(sk_sp<SkColorSpace> colorSpace, SkColorTyp
|
||||
return colorSpace;
|
||||
}
|
||||
|
||||
static void make_index8(SkBitmap* bitmap, SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace) {
|
||||
const SkColor colors[] = {
|
||||
0x800000FF, 0x8000FF00, 0x80FF0000, 0x80FFFF00,
|
||||
};
|
||||
|
||||
auto toPMColor = [alphaType, colorSpace](SkColor color) {
|
||||
// In the opaque/unpremul case, just convert to SkPMColor ordering.
|
||||
if (kPremul_SkAlphaType != alphaType) {
|
||||
return SkSwizzle_BGRA_to_PMColor(color);
|
||||
}
|
||||
|
||||
// Linear premultiply.
|
||||
if (colorSpace) {
|
||||
uint32_t result;
|
||||
Sk4f pmFloat = SkColor4f::FromColor(color).premul().to4f_pmorder();
|
||||
SkNx_cast<uint8_t>(sk_linear_to_srgb_needs_trunc(pmFloat)).store(&result);
|
||||
result = (result & 0x00FFFFFF) | (color & 0xFF000000);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Legacy premultiply.
|
||||
return SkPreMultiplyColor(color);
|
||||
};
|
||||
|
||||
// Note that these are not necessarily premultiplied, but they are platform byte ordering.
|
||||
SkPMColor pmColors[SK_ARRAY_COUNT(colors)];
|
||||
for (int i = 0; i < (int) SK_ARRAY_COUNT(colors); i++) {
|
||||
pmColors[i] = toPMColor(colors[i]);
|
||||
}
|
||||
|
||||
SkImageInfo info = SkImageInfo::Make(imageWidth, imageHeight, kIndex_8_SkColorType,
|
||||
alphaType, colorSpace);
|
||||
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)) +
|
||||
(y / div_round_up(imageHeight, 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void make(SkBitmap* bitmap, SkColorType colorType, SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace) {
|
||||
const char* resource;
|
||||
switch (colorType) {
|
||||
case kIndex_8_SkColorType:
|
||||
make_index8(bitmap, alphaType, colorSpace);
|
||||
return;
|
||||
case kGray_8_SkColorType:
|
||||
resource = "grayscale.jpg";
|
||||
alphaType = kOpaque_SkAlphaType;
|
||||
@ -173,14 +125,13 @@ protected:
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
const SkColorType colorTypes[] = {
|
||||
kN32_SkColorType, kRGBA_F16_SkColorType, kIndex_8_SkColorType, kGray_8_SkColorType,
|
||||
kRGB_565_SkColorType,
|
||||
kN32_SkColorType, kRGBA_F16_SkColorType, kGray_8_SkColorType, kRGB_565_SkColorType,
|
||||
};
|
||||
const SkAlphaType alphaTypes[] = {
|
||||
kUnpremul_SkAlphaType, kPremul_SkAlphaType, kOpaque_SkAlphaType,
|
||||
kUnpremul_SkAlphaType, kPremul_SkAlphaType, kOpaque_SkAlphaType,
|
||||
};
|
||||
const sk_sp<SkColorSpace> colorSpaces[] = {
|
||||
nullptr, SkColorSpace::MakeSRGB(),
|
||||
nullptr, SkColorSpace::MakeSRGB(),
|
||||
};
|
||||
|
||||
SkBitmap bitmap;
|
||||
|
@ -14,14 +14,9 @@
|
||||
namespace skiagm {
|
||||
|
||||
static SkBitmap make_bitmap() {
|
||||
const SkPMColor c[] = { SkPackARGB32(0x80, 0x80, 0, 0) };
|
||||
|
||||
SkBitmap bm;
|
||||
bm.allocPixels(SkImageInfo::Make(1, 1, kIndex_8_SkColorType,
|
||||
kPremul_SkAlphaType),
|
||||
SkColorTable::Make(c, SK_ARRAY_COUNT(c)));
|
||||
|
||||
*bm.getAddr8(0, 0) = 0;
|
||||
bm.allocN32Pixels(1, 1);
|
||||
*bm.getAddr32(0, 0) = SkPackARGB32(0x80, 0x80, 0, 0);
|
||||
return bm;
|
||||
}
|
||||
|
||||
|
@ -21,13 +21,6 @@ static void init_src(const SkBitmap& bitmap) {
|
||||
}
|
||||
}
|
||||
|
||||
static sk_sp<SkColorTable> init_ctable() {
|
||||
static const SkColor colors[] = {
|
||||
SK_ColorBLACK, SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE
|
||||
};
|
||||
return SkColorTable::Make(colors, SK_ARRAY_COUNT(colors));
|
||||
}
|
||||
|
||||
struct Pair {
|
||||
SkColorType fColorType;
|
||||
const char* fValid;
|
||||
@ -63,7 +56,6 @@ struct Coordinates {
|
||||
static const Pair gPairs[] = {
|
||||
{ kUnknown_SkColorType, "0000000" },
|
||||
{ kAlpha_8_SkColorType, "0100000" },
|
||||
{ kIndex_8_SkColorType, "0101111" },
|
||||
{ kRGB_565_SkColorType, "0101011" },
|
||||
{ kARGB_4444_SkColorType, "0101111" },
|
||||
{ kN32_SkColorType, "0101111" },
|
||||
@ -75,18 +67,13 @@ static const int H = 33;
|
||||
|
||||
static void setup_src_bitmaps(SkBitmap* srcOpaque, SkBitmap* srcPremul,
|
||||
SkColorType ct) {
|
||||
sk_sp<SkColorTable> ctable;
|
||||
if (kIndex_8_SkColorType == ct) {
|
||||
ctable = init_ctable();
|
||||
}
|
||||
|
||||
sk_sp<SkColorSpace> colorSpace = nullptr;
|
||||
if (kRGBA_F16_SkColorType == ct) {
|
||||
colorSpace = SkColorSpace::MakeSRGBLinear();
|
||||
}
|
||||
|
||||
srcOpaque->allocPixels(SkImageInfo::Make(W, H, ct, kOpaque_SkAlphaType, colorSpace), ctable);
|
||||
srcPremul->allocPixels(SkImageInfo::Make(W, H, ct, kPremul_SkAlphaType, colorSpace), ctable);
|
||||
srcOpaque->allocPixels(SkImageInfo::Make(W, H, ct, kOpaque_SkAlphaType, colorSpace));
|
||||
srcPremul->allocPixels(SkImageInfo::Make(W, H, ct, kPremul_SkAlphaType, colorSpace));
|
||||
init_src(*srcOpaque);
|
||||
init_src(*srcPremul);
|
||||
}
|
||||
@ -117,8 +104,7 @@ DEF_TEST(BitmapCopy_extractSubset, reporter) {
|
||||
if (!success) {
|
||||
// Skip checking that success matches fValid, which is redundant
|
||||
// with the code below.
|
||||
REPORTER_ASSERT(reporter, kIndex_8_SkColorType == gPairs[i].fColorType ||
|
||||
gPairs[i].fColorType != gPairs[j].fColorType);
|
||||
REPORTER_ASSERT(reporter, gPairs[i].fColorType != gPairs[j].fColorType);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -503,16 +503,6 @@ static const uint64_t f16[kNumPixels] = {
|
||||
kAlpha | kRed, kAlpha | kGreen, kAlpha | kBlue, kAlpha | kBlue | kGreen | kRed, kAlpha
|
||||
};
|
||||
|
||||
#ifdef SK_PMCOLOR_IS_RGBA
|
||||
static const SkPMColor index8colors[kNumPixels] = {
|
||||
0xFF0000FF, 0xFF00FF00, 0xFFFF0000, 0xFFFFFFFF, 0xFF000000
|
||||
};
|
||||
#else
|
||||
static const SkPMColor index8colors[kNumPixels] = {
|
||||
0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000
|
||||
};
|
||||
#endif
|
||||
static const uint8_t index8[kNumPixels] = { 0, 1, 2, 3, 4 };
|
||||
static const uint8_t alpha8[kNumPixels] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
static const uint8_t gray8[kNumPixels] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
|
||||
@ -530,12 +520,12 @@ static const void* five_reference_pixels(SkColorType colorType) {
|
||||
return rgba;
|
||||
case kBGRA_8888_SkColorType:
|
||||
return bgra;
|
||||
case kIndex_8_SkColorType:
|
||||
return index8;
|
||||
case kGray_8_SkColorType:
|
||||
return gray8;
|
||||
case kRGBA_F16_SkColorType:
|
||||
return f16;
|
||||
default:
|
||||
return nullptr; // remove me when kIndex_8 is removed from the enum
|
||||
}
|
||||
|
||||
SkASSERT(false);
|
||||
@ -548,21 +538,14 @@ static void test_conversion(skiatest::Reporter* r, const SkImageInfo& dstInfo,
|
||||
return;
|
||||
}
|
||||
|
||||
sk_sp<SkColorTable> srcColorTable = (kIndex_8_SkColorType == srcInfo.colorType())
|
||||
? sk_make_sp<SkColorTable>(index8colors, 5)
|
||||
: nullptr;
|
||||
sk_sp<SkColorTable> dstColorTable = (kIndex_8_SkColorType == dstInfo.colorType())
|
||||
? sk_make_sp<SkColorTable>(index8colors, 5)
|
||||
: nullptr;
|
||||
|
||||
const void* srcPixels = five_reference_pixels(srcInfo.colorType());
|
||||
SkPixmap srcPixmap(srcInfo, srcPixels, srcInfo.minRowBytes(), srcColorTable.get());
|
||||
SkPixmap srcPixmap(srcInfo, srcPixels, srcInfo.minRowBytes());
|
||||
sk_sp<SkImage> src = SkImage::MakeFromRaster(srcPixmap, nullptr, nullptr);
|
||||
REPORTER_ASSERT(r, src);
|
||||
|
||||
// Enough space for 5 pixels when color type is F16, more than enough space in other cases.
|
||||
uint64_t dstPixels[kNumPixels];
|
||||
SkPixmap dstPixmap(dstInfo, dstPixels, dstInfo.minRowBytes(), dstColorTable.get());
|
||||
SkPixmap dstPixmap(dstInfo, dstPixels, dstInfo.minRowBytes());
|
||||
bool success = src->readPixels(dstPixmap, 0, 0);
|
||||
REPORTER_ASSERT(r, success == SkImageInfoValidConversion(dstInfo, srcInfo));
|
||||
|
||||
|
@ -812,8 +812,6 @@ static const char* color_type_name(SkColorType colorType) {
|
||||
return SKDEBUGCANVAS_COLORTYPE_565;
|
||||
case kGray_8_SkColorType:
|
||||
return SKDEBUGCANVAS_COLORTYPE_GRAY8;
|
||||
case kIndex_8_SkColorType:
|
||||
return SKDEBUGCANVAS_COLORTYPE_INDEX8;
|
||||
case kAlpha_8_SkColorType:
|
||||
return SKDEBUGCANVAS_COLORTYPE_ALPHA8;
|
||||
default:
|
||||
@ -887,9 +885,6 @@ static SkColorType colortype_from_name(const char* name) {
|
||||
else if (!strcmp(name, SKDEBUGCANVAS_COLORTYPE_GRAY8)) {
|
||||
return kGray_8_SkColorType;
|
||||
}
|
||||
else if (!strcmp(name, SKDEBUGCANVAS_COLORTYPE_INDEX8)) {
|
||||
return kIndex_8_SkColorType;
|
||||
}
|
||||
else if (!strcmp(name, SKDEBUGCANVAS_COLORTYPE_ALPHA8)) {
|
||||
return kAlpha_8_SkColorType;
|
||||
}
|
||||
@ -934,9 +929,7 @@ static SkBitmap* load_bitmap(const Json::Value& jsonBitmap, UrlDataManager& urlD
|
||||
if (jsonBitmap.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLOR)) {
|
||||
const char* ctName = jsonBitmap[SKDEBUGCANVAS_ATTRIBUTE_COLOR].asCString();
|
||||
SkColorType ct = colortype_from_name(ctName);
|
||||
if (ct != kIndex_8_SkColorType) {
|
||||
bitmap.reset(convert_colortype(bitmap.release(), ct));
|
||||
}
|
||||
bitmap.reset(convert_colortype(bitmap.release(), ct));
|
||||
}
|
||||
return bitmap.release();
|
||||
}
|
||||
|
@ -164,7 +164,6 @@ const char* colortype_name(SkColorType ct) {
|
||||
switch (ct) {
|
||||
case kUnknown_SkColorType: return "Unknown";
|
||||
case kAlpha_8_SkColorType: return "Alpha_8";
|
||||
case kIndex_8_SkColorType: return "Index_8";
|
||||
case kARGB_4444_SkColorType: return "ARGB_4444";
|
||||
case kRGB_565_SkColorType: return "RGB_565";
|
||||
case kRGBA_8888_SkColorType: return "RGBA_8888";
|
||||
@ -566,16 +565,7 @@ bool copy_to(SkBitmap* dst, SkColorType dstColorType, const SkBitmap& src) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// allocate colortable if srcConfig == kIndex8_Config
|
||||
sk_sp<SkColorTable> ctable = nullptr;
|
||||
if (dstColorType == kIndex_8_SkColorType) {
|
||||
if (src.colorType() != kIndex_8_SkColorType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ctable = sk_ref_sp(srcPM.ctable());
|
||||
}
|
||||
if (!tmpDst.tryAllocPixels(ctable.get())) {
|
||||
if (!tmpDst.tryAllocPixels()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user