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,
diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp
index 113a477..842e053 100644
--- a/libs/hwui/Android.bp
+++ b/libs/hwui/Android.bp
@@ -302,7 +302,6 @@
         "tests/unit/BakedOpDispatcherTests.cpp",
         "tests/unit/BakedOpRendererTests.cpp",
         "tests/unit/BakedOpStateTests.cpp",
-        "tests/unit/BitmapTests.cpp",
         "tests/unit/CacheManagerTests.cpp",
         "tests/unit/CanvasContextTests.cpp",
         "tests/unit/CanvasStateTests.cpp",
diff --git a/libs/hwui/Texture.cpp b/libs/hwui/Texture.cpp
index 4ef31d5..b7c1e29 100644
--- a/libs/hwui/Texture.cpp
+++ b/libs/hwui/Texture.cpp
@@ -217,9 +217,8 @@
             *outType = GL_UNSIGNED_SHORT_5_6_5;
         }
         break;
-    // ARGB_4444 and Index_8 are both upconverted to RGBA_8888
+    // ARGB_4444 is upconverted to RGBA_8888
     case kARGB_4444_SkColorType:
-    case kIndex_8_SkColorType:
     case kN32_SkColorType:
         *outFormat = GL_RGBA;
         *outInternalFormat = caches.rgbaInternalFormat(needSRGB);
@@ -270,7 +269,6 @@
 
 bool Texture::hasUnsupportedColorType(const SkImageInfo& info, bool hasLinearBlending) {
     return info.colorType() == kARGB_4444_SkColorType
-        || info.colorType() == kIndex_8_SkColorType
         || (info.colorType() == kRGB_565_SkColorType
                 && hasLinearBlending
                 && info.colorSpace()->isSRGB())
@@ -279,11 +277,6 @@
 }
 
 void Texture::upload(Bitmap& bitmap) {
-    if (!bitmap.readyToDraw()) {
-        ALOGE("Cannot generate texture from bitmap");
-        return;
-    }
-
     ATRACE_FORMAT("Upload %ux%u Texture", bitmap.width(), bitmap.height());
 
     // We could also enable mipmapping if both bitmap dimensions are powers
diff --git a/libs/hwui/hwui/Bitmap.cpp b/libs/hwui/hwui/Bitmap.cpp
index 6dde005..3a8914e 100644
--- a/libs/hwui/hwui/Bitmap.cpp
+++ b/libs/hwui/hwui/Bitmap.cpp
@@ -46,10 +46,10 @@
     return true;
 }
 
-typedef sk_sp<Bitmap> (*AllocPixeRef)(size_t allocSize, const SkImageInfo& info, size_t rowBytes,
-        sk_sp<SkColorTable> ctable);
+typedef sk_sp<Bitmap> (*AllocPixelRef)(size_t allocSize, const SkImageInfo& info,
+        size_t rowBytes);
 
-static sk_sp<Bitmap> allocateBitmap(SkBitmap* bitmap, sk_sp<SkColorTable> ctable, AllocPixeRef alloc) {
+static sk_sp<Bitmap> allocateBitmap(SkBitmap* bitmap, AllocPixelRef alloc) {
     const SkImageInfo& info = bitmap->info();
     if (info.colorType() == kUnknown_SkColorType) {
         LOG_ALWAYS_FATAL("unknown bitmap configuration");
@@ -65,32 +65,31 @@
         return nullptr;
     }
 
-    auto wrapper = alloc(size, info, rowBytes, std::move(ctable));
+    auto wrapper = alloc(size, info, rowBytes);
     if (wrapper) {
         wrapper->getSkBitmap(bitmap);
     }
     return wrapper;
 }
 
-sk_sp<Bitmap> Bitmap::allocateAshmemBitmap(SkBitmap* bitmap, sk_sp<SkColorTable> ctable) {
-   return allocateBitmap(bitmap, std::move(ctable), &Bitmap::allocateAshmemBitmap);
+sk_sp<Bitmap> Bitmap::allocateAshmemBitmap(SkBitmap* bitmap) {
+   return allocateBitmap(bitmap, &Bitmap::allocateAshmemBitmap);
 }
 
-static sk_sp<Bitmap> allocateHeapBitmap(size_t size, const SkImageInfo& info, size_t rowBytes,
-        sk_sp<SkColorTable> ctable) {
+static sk_sp<Bitmap> allocateHeapBitmap(size_t size, const SkImageInfo& info, size_t rowBytes) {
     void* addr = calloc(size, 1);
     if (!addr) {
         return nullptr;
     }
-    return sk_sp<Bitmap>(new Bitmap(addr, size, info, rowBytes, std::move(ctable)));
+    return sk_sp<Bitmap>(new Bitmap(addr, size, info, rowBytes));
 }
 
 sk_sp<Bitmap> Bitmap::allocateHardwareBitmap(SkBitmap& bitmap) {
     return uirenderer::renderthread::RenderProxy::allocateHardwareBitmap(bitmap);
 }
 
-sk_sp<Bitmap> Bitmap::allocateHeapBitmap(SkBitmap* bitmap, sk_sp<SkColorTable> ctable) {
-   return allocateBitmap(bitmap, std::move(ctable), &android::allocateHeapBitmap);
+sk_sp<Bitmap> Bitmap::allocateHeapBitmap(SkBitmap* bitmap) {
+   return allocateBitmap(bitmap, &android::allocateHeapBitmap);
 }
 
 sk_sp<Bitmap> Bitmap::allocateHeapBitmap(const SkImageInfo& info) {
@@ -99,11 +98,11 @@
         LOG_ALWAYS_FATAL("trying to allocate too large bitmap");
         return nullptr;
     }
-    return android::allocateHeapBitmap(size, info, info.minRowBytes(), nullptr);
+    return android::allocateHeapBitmap(size, info, info.minRowBytes());
 }
 
 sk_sp<Bitmap> Bitmap::allocateAshmemBitmap(size_t size, const SkImageInfo& info,
-        size_t rowBytes, sk_sp<SkColorTable> ctable) {
+        size_t rowBytes) {
     // Create new ashmem region with read/write priv
     int fd = ashmem_create_region("bitmap", size);
     if (fd < 0) {
@@ -121,7 +120,7 @@
         close(fd);
         return nullptr;
     }
-    return sk_sp<Bitmap>(new Bitmap(addr, fd, size, info, rowBytes, std::move(ctable)));
+    return sk_sp<Bitmap>(new Bitmap(addr, fd, size, info, rowBytes));
 }
 
 void FreePixelRef(void* addr, void* context) {
@@ -132,7 +131,7 @@
 sk_sp<Bitmap> Bitmap::createFrom(const SkImageInfo& info, SkPixelRef& pixelRef) {
     pixelRef.ref();
     return sk_sp<Bitmap>(new Bitmap((void*) pixelRef.pixels(), (void*) &pixelRef, FreePixelRef,
-            info, pixelRef.rowBytes(), sk_ref_sp(pixelRef.colorTable())));
+            info, pixelRef.rowBytes()));
 }
 
 sk_sp<Bitmap> Bitmap::createFrom(sp<GraphicBuffer> graphicBuffer) {
@@ -161,11 +160,7 @@
     return info.makeAlphaType(alphaType);
 }
 
-void Bitmap::reconfigure(const SkImageInfo& newInfo, size_t rowBytes, sk_sp<SkColorTable> ctable) {
-    if (kIndex_8_SkColorType != newInfo.colorType()) {
-        ctable = nullptr;
-    }
-
+void Bitmap::reconfigure(const SkImageInfo& newInfo, size_t rowBytes) {
     mInfo = validateAlpha(newInfo);
 
     // Dirty hack is dirty
@@ -173,20 +168,11 @@
     // really hard to work with. Skia really, really wants immutable objects,
     // but with the nested-ref-count hackery going on that's just not
     // feasible without going insane trying to figure it out
-    this->android_only_reset(mInfo.width(), mInfo.height(), rowBytes, std::move(ctable));
+    this->android_only_reset(mInfo.width(), mInfo.height(), rowBytes, nullptr);
 }
 
-static sk_sp<SkColorTable> sanitize(const SkImageInfo& info, sk_sp<SkColorTable> ctable) {
-    if (info.colorType() == kIndex_8_SkColorType) {
-        SkASSERT(ctable);
-        return ctable;
-    }
-    return nullptr; // drop the ctable if we're not indexed
-}
-Bitmap::Bitmap(void* address, size_t size, const SkImageInfo& info, size_t rowBytes,
-        sk_sp<SkColorTable> ctable)
-            : SkPixelRef(info.width(), info.height(), address, rowBytes,
-                    sanitize(info, std::move(ctable)))
+Bitmap::Bitmap(void* address, size_t size, const SkImageInfo& info, size_t rowBytes)
+            : SkPixelRef(info.width(), info.height(), address, rowBytes)
             , mInfo(validateAlpha(info))
             , mPixelStorageType(PixelStorageType::Heap) {
     mPixelStorage.heap.address = address;
@@ -194,9 +180,8 @@
 }
 
 Bitmap::Bitmap(void* address, void* context, FreeFunc freeFunc,
-                const SkImageInfo& info, size_t rowBytes, sk_sp<SkColorTable> ctable)
-            : SkPixelRef(info.width(), info.height(), address, rowBytes,
-                    sanitize(info, std::move(ctable)))
+                const SkImageInfo& info, size_t rowBytes)
+            : SkPixelRef(info.width(), info.height(), address, rowBytes)
             , mInfo(validateAlpha(info))
             , mPixelStorageType(PixelStorageType::External) {
     mPixelStorage.external.address = address;
@@ -205,9 +190,8 @@
 }
 
 Bitmap::Bitmap(void* address, int fd, size_t mappedSize,
-                const SkImageInfo& info, size_t rowBytes, sk_sp<SkColorTable> ctable)
-            : SkPixelRef(info.width(), info.height(), address, rowBytes,
-                    sanitize(info, std::move(ctable)))
+                const SkImageInfo& info, size_t rowBytes)
+            : SkPixelRef(info.width(), info.height(), address, rowBytes)
             , mInfo(validateAlpha(info))
             , mPixelStorageType(PixelStorageType::Ashmem) {
     mPixelStorage.ashmem.address = address;
@@ -295,7 +279,7 @@
 }
 
 void Bitmap::reconfigure(const SkImageInfo& info) {
-    reconfigure(info, info.minRowBytes(), nullptr);
+    reconfigure(info, info.minRowBytes());
 }
 
 void Bitmap::setAlphaType(SkAlphaType alphaType) {
diff --git a/libs/hwui/hwui/Bitmap.h b/libs/hwui/hwui/Bitmap.h
index 364240670..634e764 100644
--- a/libs/hwui/hwui/Bitmap.h
+++ b/libs/hwui/hwui/Bitmap.h
@@ -17,7 +17,6 @@
 
 #include <SkBitmap.h>
 #include <SkColorSpace.h>
-#include <SkColorTable.h>
 #include <SkImage.h>
 #include <SkImageInfo.h>
 #include <SkPixelRef.h>
@@ -46,32 +45,31 @@
 
 class ANDROID_API Bitmap : public SkPixelRef {
 public:
-    static sk_sp<Bitmap> allocateHeapBitmap(SkBitmap* bitmap, sk_sp<SkColorTable> ctable);
+    static sk_sp<Bitmap> allocateHeapBitmap(SkBitmap* bitmap);
     static sk_sp<Bitmap> allocateHeapBitmap(const SkImageInfo& info);
 
     static sk_sp<Bitmap> allocateHardwareBitmap(SkBitmap& bitmap);
 
-    static sk_sp<Bitmap> allocateAshmemBitmap(SkBitmap* bitmap, sk_sp<SkColorTable> ctable);
+    static sk_sp<Bitmap> allocateAshmemBitmap(SkBitmap* bitmap);
     static sk_sp<Bitmap> allocateAshmemBitmap(size_t allocSize, const SkImageInfo& info,
-        size_t rowBytes, sk_sp<SkColorTable> ctable);
+        size_t rowBytes);
 
     static sk_sp<Bitmap> createFrom(sp<GraphicBuffer> graphicBuffer);
 
     static sk_sp<Bitmap> createFrom(const SkImageInfo&, SkPixelRef&);
 
-    Bitmap(void* address, size_t allocSize, const SkImageInfo& info, size_t rowBytes,
-            sk_sp<SkColorTable> ctable);
+    Bitmap(void* address, size_t allocSize, const SkImageInfo& info, size_t rowBytes);
     Bitmap(void* address, void* context, FreeFunc freeFunc,
-            const SkImageInfo& info, size_t rowBytes, sk_sp<SkColorTable> ctable);
+            const SkImageInfo& info, size_t rowBytes);
     Bitmap(void* address, int fd, size_t mappedSize, const SkImageInfo& info,
-            size_t rowBytes, sk_sp<SkColorTable> ctable);
+            size_t rowBytes);
     Bitmap(GraphicBuffer* buffer, const SkImageInfo& info);
 
     int rowBytesAsPixels() const {
         return rowBytes() >> SkColorTypeShiftPerPixel(mInfo.colorType());
     }
 
-    void reconfigure(const SkImageInfo& info, size_t rowBytes, sk_sp<SkColorTable> ctable);
+    void reconfigure(const SkImageInfo& info, size_t rowBytes);
     void reconfigure(const SkImageInfo& info);
     void setColorSpace(sk_sp<SkColorSpace> colorSpace);
     void setAlphaType(SkAlphaType alphaType);
@@ -92,10 +90,6 @@
 
     void getBounds(SkRect* bounds) const;
 
-    bool readyToDraw() const {
-        return this->colorType() != kIndex_8_SkColorType || this->colorTable();
-    }
-
     bool isHardware() const {
         return mPixelStorageType == PixelStorageType::Hardware;
     }
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
index 6d5ef1d..edfd9d4 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
@@ -270,8 +270,7 @@
     switch (info.colorType()) {
     case kRGBA_8888_SkColorType:
         isSupported = true;
-    // ARGB_4444 and Index_8 are both upconverted to RGBA_8888
-    case kIndex_8_SkColorType:
+    // ARGB_4444 is upconverted to RGBA_8888
     case kARGB_4444_SkColorType:
         pixelFormat = PIXEL_FORMAT_RGBA_8888;
         format = GL_RGBA;
diff --git a/libs/hwui/tests/common/BitmapAllocationTestUtils.h b/libs/hwui/tests/common/BitmapAllocationTestUtils.h
index 4892179..2988979 100644
--- a/libs/hwui/tests/common/BitmapAllocationTestUtils.h
+++ b/libs/hwui/tests/common/BitmapAllocationTestUtils.h
@@ -41,7 +41,7 @@
         SkBitmap skBitmap;
         SkImageInfo info = SkImageInfo::Make(width, height, colorType, kPremul_SkAlphaType);
         skBitmap.setInfo(info);
-        sk_sp<Bitmap> heapBitmap(Bitmap::allocateHeapBitmap(&skBitmap, nullptr));
+        sk_sp<Bitmap> heapBitmap(Bitmap::allocateHeapBitmap(&skBitmap));
         setup(skBitmap);
         return Bitmap::allocateHardwareBitmap(skBitmap);
     }
@@ -73,4 +73,4 @@
 
 } // namespace test
 } // namespace uirenderer
-} // namespace android
\ No newline at end of file
+} // namespace android
diff --git a/libs/hwui/tests/common/TestUtils.h b/libs/hwui/tests/common/TestUtils.h
index 98d5fb3..f293631 100644
--- a/libs/hwui/tests/common/TestUtils.h
+++ b/libs/hwui/tests/common/TestUtils.h
@@ -189,7 +189,7 @@
     static sk_sp<Bitmap> createBitmap(int width, int height, SkBitmap* outBitmap) {
         SkImageInfo info = SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType);
         outBitmap->setInfo(info);
-        return Bitmap::allocateHeapBitmap(outBitmap, nullptr);
+        return Bitmap::allocateHeapBitmap(outBitmap);
     }
 
     static sp<DeferredLayerUpdater> createTextureLayerUpdater(
diff --git a/libs/hwui/tests/unit/BitmapTests.cpp b/libs/hwui/tests/unit/BitmapTests.cpp
deleted file mode 100644
index ed689bd..0000000
--- a/libs/hwui/tests/unit/BitmapTests.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <gtest/gtest.h>
-
-#include "hwui/Bitmap.h"
-
-#include <SkBitmap.h>
-#include <SkColorTable.h>
-#include <SkImageInfo.h>
-
-#include <tests/common/TestUtils.h>
-
-using namespace android;
-using namespace android::uirenderer;
-
-TEST(Bitmap, colorTableRefCounting) {
-    const SkPMColor c[] = { SkPackARGB32(0x80, 0x80, 0, 0) };
-    sk_sp<SkColorTable> ctable = SkColorTable::Make(c, SK_ARRAY_COUNT(c));
-
-    SkBitmap* bm = new SkBitmap();
-    bm->allocPixels(SkImageInfo::Make(1, 1, kIndex_8_SkColorType, kPremul_SkAlphaType),
-            ctable);
-    sk_sp<Bitmap> bitmap = Bitmap::allocateHeapBitmap(bm, ctable);
-    EXPECT_FALSE(ctable->unique());
-    delete bm;
-    bitmap.reset();
-    EXPECT_TRUE(ctable->unique());
-}
-