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/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());
-}
-