Merge "Remove references to (unused) colortables"
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index 61e138e..ad05a51 100755
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -727,7 +727,7 @@
     if (!dst->setInfo(dstInfo)) {
         return false;
     }
-    if (!dst->tryAllocPixels(alloc, nullptr)) {
+    if (!dst->tryAllocPixels(alloc)) {
         return false;
     }
 
@@ -1081,7 +1081,7 @@
 
         // Map the pixels in place and take ownership of the ashmem region.
         nativeBitmap = sk_sp<Bitmap>(GraphicsJNI::mapAshmemBitmap(env, bitmap.get(),
-                nullptr, dupFd, const_cast<void*>(blob.data()), size, !isMutable));
+                dupFd, const_cast<void*>(blob.data()), size, !isMutable));
         if (!nativeBitmap) {
             close(dupFd);
             blob.release();
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index 6ea5e9d..358c5ba 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*) {
+    virtual bool allocPixelRef(SkBitmap* bitmap) {
         // 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, nullptr);
+        return SkBitmap::HeapAllocator::allocPixelRef(bitmap);
     }
 private:
     const float mScale;
@@ -163,7 +163,7 @@
     ~RecyclingPixelAllocator() {
     }
 
-    virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable*) {
+    virtual bool allocPixelRef(SkBitmap* bitmap) {
         const SkImageInfo& info = bitmap->info();
         if (info.colorType() == kUnknown_SkColorType) {
             ALOGW("unable to reuse a bitmap as the target has an unknown bitmap configuration");
@@ -401,7 +401,7 @@
     }
     SkBitmap decodingBitmap;
     if (!decodingBitmap.setInfo(bitmapInfo) ||
-            !decodingBitmap.tryAllocPixels(decodeAllocator, nullptr)) {
+            !decodingBitmap.tryAllocPixels(decodeAllocator)) {
         // SkAndroidCodec should recommend a valid SkImageInfo, so setInfo()
         // should only only fail if the calculated value for rowBytes is too
         // large.
@@ -486,7 +486,7 @@
         // to/from unpremultiplied bitmaps.
         outputBitmap.setInfo(
                 bitmapInfo.makeWH(scaledWidth, scaledHeight).makeColorType(scaledColorType));
-        if (!outputBitmap.tryAllocPixels(outputAllocator, NULL)) {
+        if (!outputBitmap.tryAllocPixels(outputAllocator)) {
             // This should only fail on OOM.  The recyclingAllocator should have
             // enough memory since we check this before decoding using the
             // scaleCheckingAllocator.
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index ddd0821..b936432 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -433,7 +433,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 android::Bitmap* GraphicsJNI::mapAshmemBitmap(JNIEnv* env, SkBitmap* bitmap,
-        SkColorTable*, int fd, void* addr, size_t size, bool readOnly) {
+        int fd, void* addr, size_t size, bool readOnly) {
     const SkImageInfo& info = bitmap->info();
     if (info.colorType() == kUnknown_SkColorType) {
         doThrowIAE(env, "unknown bitmap configuration");
@@ -607,7 +607,7 @@
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-bool HeapAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) {
+bool HeapAllocator::allocPixelRef(SkBitmap* bitmap) {
     mStorage = android::Bitmap::allocateHeapBitmap(bitmap);
     return !!mStorage;
 }
@@ -624,7 +624,7 @@
 
 RecyclingClippingPixelAllocator::~RecyclingClippingPixelAllocator() {}
 
-bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) {
+bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap) {
     // Ensure that the caller did not pass in a NULL bitmap to the constructor or this
     // function.
     LOG_ALWAYS_FATAL_IF(!mRecycledBitmap);
@@ -683,7 +683,7 @@
     // decode is complete.
     mNeedsCopy = true;
 
-    return heapAllocator.allocPixelRef(bitmap, nullptr);
+    return heapAllocator.allocPixelRef(bitmap);
 }
 
 void RecyclingClippingPixelAllocator::copyIfNecessary() {
@@ -714,7 +714,7 @@
             "env->GetJavaVM failed");
 }
 
-bool AshmemPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) {
+bool AshmemPixelAllocator::allocPixelRef(SkBitmap* bitmap) {
     mStorage = android::Bitmap::allocateAshmemBitmap(bitmap);
     return !!mStorage;
 }
diff --git a/core/jni/android/graphics/GraphicsJNI.h b/core/jni/android/graphics/GraphicsJNI.h
index 7fbea25..7f4b384 100644
--- a/core/jni/android/graphics/GraphicsJNI.h
+++ b/core/jni/android/graphics/GraphicsJNI.h
@@ -91,7 +91,7 @@
     static jobject createBitmapRegionDecoder(JNIEnv* env, SkBitmapRegionDecoder* bitmap);
 
     static android::Bitmap* mapAshmemBitmap(JNIEnv* env, SkBitmap* bitmap,
-            SkColorTable* ctable, int fd, void* addr, size_t size, bool readOnly);
+            int fd, void* addr, size_t size, bool readOnly);
 
     /**
      * Given a bitmap we natively allocate a memory block to store the contents
@@ -99,7 +99,7 @@
      * SkPixelRef, which ensures that upon deletion the appropriate caches
      * are notified.
      */
-    static bool allocatePixels(JNIEnv* env, SkBitmap* bitmap, SkColorTable* ctable);
+    static bool allocatePixels(JNIEnv* env, SkBitmap* bitmap);
 
     /** Copy the colors in colors[] to the bitmap, convert to the correct
         format along the way.
@@ -127,7 +127,7 @@
    HeapAllocator() { };
     ~HeapAllocator() { };
 
-    virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) override;
+    virtual bool allocPixelRef(SkBitmap* bitmap) override;
 
     /**
      * Fetches the backing allocation object. Must be called!
@@ -176,7 +176,7 @@
 
     ~RecyclingClippingPixelAllocator();
 
-    virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) override;
+    virtual bool allocPixelRef(SkBitmap* bitmap) override;
 
     /**
      *  Must be called!
@@ -206,7 +206,7 @@
 public:
     explicit AshmemPixelAllocator(JNIEnv* env);
     ~AshmemPixelAllocator() { };
-    virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable);
+    virtual bool allocPixelRef(SkBitmap* bitmap);
     android::Bitmap* getStorageObjAndReset() {
         return mStorage.release();
     };
diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp
index d7345b0..0573937 100644
--- a/core/jni/android/opengl/util.cpp
+++ b/core/jni/android/opengl/util.cpp
@@ -713,28 +713,10 @@
     const int h = bitmap.height();
     const void* p = bitmap.getPixels();
     if (internalformat == GL_PALETTE8_RGBA8_OES) {
-        if (sizeof(SkPMColor) != sizeof(uint32_t)) {
-            err = -1;
-            goto error;
-        }
-        const size_t size = bitmap.getSize();
-        const size_t palette_size = 256*sizeof(SkPMColor);
-        const size_t imageSize = size + palette_size;
-        void* const data = malloc(imageSize);
-        if (data) {
-            void* const pixels = (char*)data + palette_size;
-            SkColorTable* ctable = bitmap.getColorTable();
-            memcpy(data, ctable->readColors(), ctable->count() * sizeof(SkPMColor));
-            memcpy(pixels, p, size);
-            glCompressedTexImage2D(target, level, internalformat, w, h, border, imageSize, data);
-            free(data);
-        } else {
-            err = -1;
-        }
+        err = -1;
     } else {
         glTexImage2D(target, level, internalformat, w, h, border, internalformat, type, p);
     }
-error:
     return err;
 }
 
diff --git a/libs/hwui/hwui/Bitmap.cpp b/libs/hwui/hwui/Bitmap.cpp
index 3a8914e..3361fa0 100644
--- a/libs/hwui/hwui/Bitmap.cpp
+++ b/libs/hwui/hwui/Bitmap.cpp
@@ -168,7 +168,7 @@
     // 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, nullptr);
+    this->android_only_reset(mInfo.width(), mInfo.height(), rowBytes);
 }
 
 Bitmap::Bitmap(void* address, size_t size, const SkImageInfo& info, size_t rowBytes)
@@ -201,8 +201,7 @@
 
 Bitmap::Bitmap(GraphicBuffer* buffer, const SkImageInfo& info)
         : SkPixelRef(info.width(), info.height(), nullptr,
-                     bytesPerPixel(buffer->getPixelFormat()) * buffer->getStride(),
-                     nullptr)
+                     bytesPerPixel(buffer->getPixelFormat()) * buffer->getStride())
         , mInfo(validateAlpha(info))
         , mPixelStorageType(PixelStorageType::Hardware) {
     mPixelStorage.hardware.buffer = buffer;