Remove more references to kIndex_8
Test: Covered by existing tests. No actual change in behavior, since
kIndex_8 is not being used anyway.
Bug: 62483967
Change-Id: I317e3a814dbd102925fe412d2e19111b0af3af38
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index be8b9de..61e138e 100755
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -485,11 +485,9 @@
//////////////////// ToColor procs
-typedef void (*ToColorProc)(SkColor dst[], const void* src, int width,
- SkColorTable*);
+typedef void (*ToColorProc)(SkColor dst[], const void* src, int width);
-static void ToColor_F16_Alpha(SkColor dst[], const void* src, int width,
- SkColorTable*) {
+static void ToColor_F16_Alpha(SkColor dst[], const void* src, int width) {
SkASSERT(width > 0);
uint64_t* s = (uint64_t*)src;
do {
@@ -497,8 +495,7 @@
} while (--width != 0);
}
-static void ToColor_F16_Raw(SkColor dst[], const void* src, int width,
- SkColorTable*) {
+static void ToColor_F16_Raw(SkColor dst[], const void* src, int width) {
SkASSERT(width > 0);
uint64_t* s = (uint64_t*)src;
do {
@@ -506,8 +503,7 @@
} while (--width != 0);
}
-static void ToColor_S32_Alpha(SkColor dst[], const void* src, int width,
- SkColorTable*) {
+static void ToColor_S32_Alpha(SkColor dst[], const void* src, int width) {
SkASSERT(width > 0);
const SkPMColor* s = (const SkPMColor*)src;
do {
@@ -515,8 +511,7 @@
} while (--width != 0);
}
-static void ToColor_S32_Raw(SkColor dst[], const void* src, int width,
- SkColorTable*) {
+static void ToColor_S32_Raw(SkColor dst[], const void* src, int width) {
SkASSERT(width > 0);
const SkPMColor* s = (const SkPMColor*)src;
do {
@@ -526,8 +521,7 @@
} while (--width != 0);
}
-static void ToColor_S32_Opaque(SkColor dst[], const void* src, int width,
- SkColorTable*) {
+static void ToColor_S32_Opaque(SkColor dst[], const void* src, int width) {
SkASSERT(width > 0);
const SkPMColor* s = (const SkPMColor*)src;
do {
@@ -537,8 +531,7 @@
} while (--width != 0);
}
-static void ToColor_S4444_Alpha(SkColor dst[], const void* src, int width,
- SkColorTable*) {
+static void ToColor_S4444_Alpha(SkColor dst[], const void* src, int width) {
SkASSERT(width > 0);
const SkPMColor16* s = (const SkPMColor16*)src;
do {
@@ -546,8 +539,7 @@
} while (--width != 0);
}
-static void ToColor_S4444_Raw(SkColor dst[], const void* src, int width,
- SkColorTable*) {
+static void ToColor_S4444_Raw(SkColor dst[], const void* src, int width) {
SkASSERT(width > 0);
const SkPMColor16* s = (const SkPMColor16*)src;
do {
@@ -557,8 +549,7 @@
} while (--width != 0);
}
-static void ToColor_S4444_Opaque(SkColor dst[], const void* src, int width,
- SkColorTable*) {
+static void ToColor_S4444_Opaque(SkColor dst[], const void* src, int width) {
SkASSERT(width > 0);
const SkPMColor16* s = (const SkPMColor16*)src;
do {
@@ -568,8 +559,7 @@
} while (--width != 0);
}
-static void ToColor_S565(SkColor dst[], const void* src, int width,
- SkColorTable*) {
+static void ToColor_S565(SkColor dst[], const void* src, int width) {
SkASSERT(width > 0);
const uint16_t* s = (const uint16_t*)src;
do {
@@ -579,41 +569,7 @@
} while (--width != 0);
}
-static void ToColor_SI8_Alpha(SkColor dst[], const void* src, int width,
- SkColorTable* ctable) {
- SkASSERT(width > 0);
- const uint8_t* s = (const uint8_t*)src;
- const SkPMColor* colors = ctable->readColors();
- do {
- *dst++ = SkUnPreMultiply::PMColorToColor(colors[*s++]);
- } while (--width != 0);
-}
-
-static void ToColor_SI8_Raw(SkColor dst[], const void* src, int width,
- SkColorTable* ctable) {
- SkASSERT(width > 0);
- const uint8_t* s = (const uint8_t*)src;
- const SkPMColor* colors = ctable->readColors();
- do {
- SkPMColor c = colors[*s++];
- *dst++ = SkColorSetARGB(SkGetPackedA32(c), SkGetPackedR32(c),
- SkGetPackedG32(c), SkGetPackedB32(c));
- } while (--width != 0);
-}
-
-static void ToColor_SI8_Opaque(SkColor dst[], const void* src, int width,
- SkColorTable* ctable) {
- SkASSERT(width > 0);
- const uint8_t* s = (const uint8_t*)src;
- const SkPMColor* colors = ctable->readColors();
- do {
- SkPMColor c = colors[*s++];
- *dst++ = SkColorSetRGB(SkGetPackedR32(c), SkGetPackedG32(c),
- SkGetPackedB32(c));
- } while (--width != 0);
-}
-
-static void ToColor_SA8(SkColor dst[], const void* src, int width, SkColorTable*) {
+static void ToColor_SA8(SkColor dst[], const void* src, int width) {
SkASSERT(width > 0);
const uint8_t* s = (const uint8_t*)src;
do {
@@ -649,20 +605,6 @@
}
case kRGB_565_SkColorType:
return ToColor_S565;
- case kIndex_8_SkColorType:
- if (src.getColorTable() == NULL) {
- return NULL;
- }
- switch (src.alphaType()) {
- case kOpaque_SkAlphaType:
- return ToColor_SI8_Opaque;
- case kPremul_SkAlphaType:
- return ToColor_SI8_Alpha;
- case kUnpremul_SkAlphaType:
- return ToColor_SI8_Raw;
- default:
- return NULL;
- }
case kAlpha_8_SkColorType:
return ToColor_SA8;
case kRGBA_F16_SkColorType:
@@ -738,7 +680,7 @@
bitmap.setInfo(SkImageInfo::Make(width, height, colorType, kPremul_SkAlphaType, colorSpace));
- sk_sp<Bitmap> nativeBitmap = Bitmap::allocateHeapBitmap(&bitmap, NULL);
+ sk_sp<Bitmap> nativeBitmap = Bitmap::allocateHeapBitmap(&bitmap);
if (!nativeBitmap) {
return NULL;
}
@@ -752,8 +694,6 @@
static bool bitmapCopyTo(SkBitmap* dst, SkColorType dstCT, const SkBitmap& src,
SkBitmap::Allocator* alloc) {
- LOG_ALWAYS_FATAL_IF(kIndex_8_SkColorType == dstCT, "Error, cannot copyTo kIndex8.");
-
SkPixmap srcPM;
if (!src.peekPixels(&srcPM)) {
return false;
@@ -766,7 +706,7 @@
// allow the call to readPixels() to succeed and preserve this lenient behavior.
if (kOpaque_SkAlphaType != srcPM.alphaType()) {
srcPM = SkPixmap(srcPM.info().makeAlphaType(kOpaque_SkAlphaType), srcPM.addr(),
- srcPM.rowBytes(), srcPM.ctable());
+ srcPM.rowBytes());
dstInfo = dstInfo.makeAlphaType(kOpaque_SkAlphaType);
}
break;
@@ -800,7 +740,7 @@
for (int y = 0; y < src.height(); y++) {
const uint8_t* srcRow = srcPM.addr8(0, y);
uint32_t* dstRow = dst->getAddr32(0, y);
- ToColor_SA8(dstRow, srcRow, src.width(), nullptr);
+ ToColor_SA8(dstRow, srcRow, src.width());
}
return true;
}
@@ -1099,7 +1039,6 @@
kRGBA_F16_SkColorType != colorType &&
kRGB_565_SkColorType != colorType &&
kARGB_4444_SkColorType != colorType &&
- kIndex_8_SkColorType != colorType &&
kAlpha_8_SkColorType != colorType) {
SkDebugf("Bitmap_createFromParcel unknown colortype: %d\n", colorType);
return NULL;
@@ -1111,24 +1050,6 @@
return NULL;
}
- sk_sp<SkColorTable> ctable = NULL;
- if (colorType == kIndex_8_SkColorType) {
- int count = p->readInt32();
- if (count < 0 || count > 256) {
- // The data is corrupt, since SkColorTable enforces a value between 0 and 256,
- // inclusive.
- return NULL;
- }
- if (count > 0) {
- size_t size = count * sizeof(SkPMColor);
- const SkPMColor* src = (const SkPMColor*)p->readInplace(size);
- if (src == NULL) {
- return NULL;
- }
- ctable = SkColorTable::Make(src, count);
- }
- }
-
// Read the bitmap blob.
size_t size = bitmap->getSize();
android::Parcel::ReadableBlob blob;
@@ -1160,7 +1081,7 @@
// Map the pixels in place and take ownership of the ashmem region.
nativeBitmap = sk_sp<Bitmap>(GraphicsJNI::mapAshmemBitmap(env, bitmap.get(),
- ctable.get(), dupFd, const_cast<void*>(blob.data()), size, !isMutable));
+ nullptr, dupFd, const_cast<void*>(blob.data()), size, !isMutable));
if (!nativeBitmap) {
close(dupFd);
blob.release();
@@ -1185,7 +1106,7 @@
#endif
// Copy the pixels into a new buffer.
- nativeBitmap = Bitmap::allocateHeapBitmap(bitmap.get(), ctable);
+ nativeBitmap = Bitmap::allocateHeapBitmap(bitmap.get());
if (!nativeBitmap) {
blob.release();
doThrowRE(env, "Could not allocate java pixel ref.");
@@ -1240,19 +1161,6 @@
p->writeInt32(bitmap.rowBytes());
p->writeInt32(density);
- if (bitmap.colorType() == kIndex_8_SkColorType) {
- // The bitmap needs to be locked to access its color table.
- SkColorTable* ctable = bitmap.getColorTable();
- if (ctable != NULL) {
- int count = ctable->count();
- p->writeInt32(count);
- memcpy(p->writeInplace(count * sizeof(SkPMColor)),
- ctable->readColors(), count * sizeof(SkPMColor));
- } else {
- p->writeInt32(0); // indicate no ctable
- }
- }
-
// Transfer the underlying ashmem region if we have one and it's immutable.
android::status_t status;
int fd = bitmapWrapper->bitmap().getAshmemFd();
@@ -1394,7 +1302,7 @@
}
SkColor dst[1];
- proc(dst, src, 1, bitmap.getColorTable());
+ proc(dst, src, 1);
SkColorSpace* colorSpace = bitmap.colorSpace();
if (bitmap.colorType() != kRGBA_F16_SkColorType &&
@@ -1424,7 +1332,6 @@
return;
}
- SkColorTable* ctable = bitmap.getColorTable();
jint* dst = env->GetIntArrayElements(pixelArray, NULL);
SkColor* d = (SkColor*)dst + offset;
@@ -1432,7 +1339,7 @@
if (bitmap.colorType() == kRGBA_F16_SkColorType ||
GraphicsJNI::isColorSpaceSRGB(colorSpace)) {
while (--height >= 0) {
- proc(d, src, width, ctable);
+ proc(d, src, width);
d += stride;
src = (void*)((const char*)src + bitmap.rowBytes());
}
@@ -1441,7 +1348,7 @@
auto xform = SkColorSpaceXform::New(colorSpace, sRGB.get());
while (--height >= 0) {
- proc(d, src, width, ctable);
+ proc(d, src, width);
xform->apply(SkColorSpaceXform::kBGRA_8888_ColorFormat, d,
SkColorSpaceXform::kBGRA_8888_ColorFormat, d, width,
@@ -1551,22 +1458,6 @@
return JNI_FALSE;
}
- if (bm0.colorType() == kIndex_8_SkColorType) {
- SkColorTable* ct0 = bm0.getColorTable();
- SkColorTable* ct1 = bm1.getColorTable();
- if (NULL == ct0 || NULL == ct1) {
- return JNI_FALSE;
- }
- if (ct0->count() != ct1->count()) {
- return JNI_FALSE;
- }
-
- const size_t size = ct0->count() * sizeof(SkPMColor);
- if (memcmp(ct0->readColors(), ct1->readColors(), size) != 0) {
- return JNI_FALSE;
- }
- }
-
// now compare each scanline. We can't do the entire buffer at once,
// since we don't care about the pixel values that might extend beyond
// the width (since the scanline might be larger than the logical width)
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index 0a0e5f4..6ea5e9d 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -136,7 +136,7 @@
: mScale(scale), mSize(size) {
}
- virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) {
+ virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable*) {
// accounts for scale in final allocation, using eventual size and config
const int bytesPerPixel = SkColorTypeBytesPerPixel(bitmap->colorType());
const int requestedSize = bytesPerPixel *
@@ -147,7 +147,7 @@
mSize, requestedSize);
return false;
}
- return SkBitmap::HeapAllocator::allocPixelRef(bitmap, ctable);
+ return SkBitmap::HeapAllocator::allocPixelRef(bitmap, nullptr);
}
private:
const float mScale;
@@ -163,7 +163,7 @@
~RecyclingPixelAllocator() {
}
- virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) {
+ virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable*) {
const SkImageInfo& info = bitmap->info();
if (info.colorType() == kUnknown_SkColorType) {
ALOGW("unable to reuse a bitmap as the target has an unknown bitmap configuration");
@@ -183,7 +183,7 @@
return false;
}
- mBitmap->reconfigure(info, bitmap->rowBytes(), sk_ref_sp(ctable));
+ mBitmap->reconfigure(info, bitmap->rowBytes());
bitmap->setPixelRef(sk_ref_sp(mBitmap), 0, 0);
return true;
}
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index 5a2238f..ddd0821 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -327,8 +327,6 @@
return kARGB_4444_LegacyBitmapConfig;
case kRGB_565_SkColorType:
return kRGB_565_LegacyBitmapConfig;
- case kIndex_8_SkColorType:
- return kIndex8_LegacyBitmapConfig;
case kAlpha_8_SkColorType:
return kA8_LegacyBitmapConfig;
case kUnknown_SkColorType:
@@ -342,7 +340,7 @@
const uint8_t gConfig2ColorType[] = {
kUnknown_SkColorType,
kAlpha_8_SkColorType,
- kIndex_8_SkColorType,
+ kUnknown_SkColorType, // Previously kIndex_8_SkColorType,
kRGB_565_SkColorType,
kARGB_4444_SkColorType,
kN32_SkColorType,
@@ -435,7 +433,7 @@
///////////////////////////////////////////////////////////////////////////////
android::Bitmap* GraphicsJNI::mapAshmemBitmap(JNIEnv* env, SkBitmap* bitmap,
- SkColorTable* ctable, int fd, void* addr, size_t size, bool readOnly) {
+ SkColorTable*, int fd, void* addr, size_t size, bool readOnly) {
const SkImageInfo& info = bitmap->info();
if (info.colorType() == kUnknown_SkColorType) {
doThrowIAE(env, "unknown bitmap configuration");
@@ -456,7 +454,7 @@
// attempting to compute our own.
const size_t rowBytes = bitmap->rowBytes();
- auto wrapper = new android::Bitmap(addr, fd, size, info, rowBytes, sk_ref_sp(ctable));
+ auto wrapper = new android::Bitmap(addr, fd, size, info, rowBytes);
wrapper->getSkBitmap(bitmap);
if (readOnly) {
bitmap->pixelRef()->setImmutable();
@@ -609,8 +607,8 @@
}
///////////////////////////////////////////////////////////////////////////////
-bool HeapAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) {
- mStorage = android::Bitmap::allocateHeapBitmap(bitmap, sk_ref_sp(ctable));
+bool HeapAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) {
+ mStorage = android::Bitmap::allocateHeapBitmap(bitmap);
return !!mStorage;
}
@@ -626,7 +624,7 @@
RecyclingClippingPixelAllocator::~RecyclingClippingPixelAllocator() {}
-bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) {
+bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) {
// Ensure that the caller did not pass in a NULL bitmap to the constructor or this
// function.
LOG_ALWAYS_FATAL_IF(!mRecycledBitmap);
@@ -649,7 +647,7 @@
const size_t rowBytes = maxInfo.minRowBytes();
const size_t bytesNeeded = maxInfo.getSafeSize(rowBytes);
if (bytesNeeded <= mRecycledBytes) {
- // Here we take advantage of reconfigure() to reset the rowBytes and ctable
+ // Here we take advantage of reconfigure() to reset the rowBytes
// of mRecycledBitmap. It is very important that we pass in
// mRecycledBitmap->info() for the SkImageInfo. According to the
// specification for BitmapRegionDecoder, we are not allowed to change
@@ -658,7 +656,7 @@
// storage needs
mRecycledBitmap->reconfigure(
mRecycledBitmap->info().makeColorSpace(bitmap->refColorSpace()),
- rowBytes, sk_ref_sp(ctable));
+ rowBytes);
// Give the bitmap the same pixelRef as mRecycledBitmap.
// skbug.com/4538: We also need to make sure that the rowBytes on the pixel ref
@@ -685,7 +683,7 @@
// decode is complete.
mNeedsCopy = true;
- return heapAllocator.allocPixelRef(bitmap, ctable);
+ return heapAllocator.allocPixelRef(bitmap, nullptr);
}
void RecyclingClippingPixelAllocator::copyIfNecessary() {
@@ -716,8 +714,8 @@
"env->GetJavaVM failed");
}
-bool AshmemPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) {
- mStorage = android::Bitmap::allocateAshmemBitmap(bitmap, sk_ref_sp(ctable));
+bool AshmemPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) {
+ mStorage = android::Bitmap::allocateAshmemBitmap(bitmap);
return !!mStorage;
}
diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp
index 7c1ca81..d7345b0 100644
--- a/core/jni/android/opengl/util.cpp
+++ b/core/jni/android/opengl/util.cpp
@@ -623,9 +623,6 @@
static int checkFormat(SkColorType colorType, int format, int type)
{
switch(colorType) {
- case kIndex_8_SkColorType:
- if (format == GL_PALETTE8_RGBA8_OES)
- return 0;
case kN32_SkColorType:
case kAlpha_8_SkColorType:
if (type == GL_UNSIGNED_BYTE)
@@ -657,8 +654,6 @@
return GL_RGBA;
case kN32_SkColorType:
return GL_RGBA;
- case kIndex_8_SkColorType:
- return GL_PALETTE8_RGBA8_OES;
case kRGB_565_SkColorType:
return GL_RGB;
default:
@@ -675,8 +670,6 @@
return GL_UNSIGNED_SHORT_4_4_4_4;
case kN32_SkColorType:
return GL_UNSIGNED_BYTE;
- case kIndex_8_SkColorType:
- return -1; // No type for compressed data.
case kRGB_565_SkColorType:
return GL_UNSIGNED_SHORT_5_6_5;
default:
diff --git a/core/jni/android_graphics_Canvas.cpp b/core/jni/android_graphics_Canvas.cpp
index c0f719e..80f6abe 100644
--- a/core/jni/android_graphics_Canvas.cpp
+++ b/core/jni/android_graphics_Canvas.cpp
@@ -452,7 +452,7 @@
GraphicsJNI::defaultColorSpace());
SkBitmap bitmap;
bitmap.setInfo(info);
- sk_sp<Bitmap> androidBitmap = Bitmap::allocateHeapBitmap(&bitmap, NULL);
+ sk_sp<Bitmap> androidBitmap = Bitmap::allocateHeapBitmap(&bitmap);
if (!androidBitmap) {
return;
}
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index 97aa562..1068d6f 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -245,7 +245,7 @@
auto bitmap = new Bitmap(
(void*) screenshot->getPixels(), (void*) screenshot.get(), DeleteScreenshot,
- screenshotInfo, rowBytes, nullptr);
+ screenshotInfo, rowBytes);
screenshot.release();
bitmap->setImmutable();
return bitmap::createBitmap(env, bitmap,