From 0401c0d1d3ad9db5d3eecb3096bd569dfe5c2498 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Sun, 2 Jul 2017 15:46:49 -0400 Subject: [PATCH] hide index8 support Bug: skia: Change-Id: I4ab7f4665cc9992319d3c9a5e02a417d503c189e Reviewed-on: https://skia-review.googlesource.com/20121 Reviewed-by: Florin Malita Commit-Queue: Mike Reed --- include/core/SkBitmap.h | 9 ++++++++- src/image/SkImage_Raster.cpp | 6 ++++++ tests/ImageTest.cpp | 5 +++++ tests/ReadPixelsTest.cpp | 2 ++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index 1f4f63853d..00a68dad4f 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -120,7 +120,14 @@ public: /** Return true iff drawing this bitmap has no effect. */ - bool drawsNothing() const { return this->empty() || this->isNull(); } + bool drawsNothing() const { +#ifndef SK_SUPPORT_LEGACY_INDEX_8 + if (this->colorType() == kIndex_8_SkColorType) { + return true; + } +#endif + return this->empty() || this->isNull(); + } /** Return the number of bytes between subsequent rows of the bitmap. */ size_t rowBytes() const { return fRowBytes; } diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp index fc2e030ec8..f0338de4c8 100644 --- a/src/image/SkImage_Raster.cpp +++ b/src/image/SkImage_Raster.cpp @@ -59,9 +59,15 @@ public: } const bool needsCT = kIndex_8_SkColorType == info.colorType(); +#ifdef SK_SUPPORT_LEGACY_INDEX_8 if (needsCT != hasColorTable) { return false; } +#else + if (needsCT) { + return false; + } +#endif if (rowBytes < info.minRowBytes()) { return false; diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index 511b6f24b6..c57cafa9a3 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -296,6 +296,7 @@ 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); @@ -322,6 +323,7 @@ DEF_TEST(Image_NewRasterCopy, reporter) { 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 @@ -555,6 +557,8 @@ 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)}; @@ -565,6 +569,7 @@ DEF_TEST(ImageFromIndex8Bitmap, r) { sk_sp img(SkImage::MakeFromBitmap(bm)); REPORTER_ASSERT(r, img != nullptr); } +#endif class EmptyGenerator : public SkImageGenerator { public: diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp index 7b8dc8c6fd..ce13fcf9d4 100644 --- a/tests/ReadPixelsTest.cpp +++ b/tests/ReadPixelsTest.cpp @@ -589,7 +589,9 @@ 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, };