From 3e3681151a231225b2b25c996bb9e85948a345a8 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Tue, 21 Feb 2012 18:56:08 -0800 Subject: [PATCH] remove libui's dependency on libpixelflinger this also remove support for unused pixelformats. Change-Id: I2c759a6d2daa740f3786ed62095def8047ae933d --- cmds/screencap/screencap.cpp | 1 - include/ui/PixelFormat.h | 12 ++------ libs/ui/Android.mk | 1 - libs/ui/PixelFormat.cpp | 60 ++++++++++++++++++++++++++---------- 4 files changed, 45 insertions(+), 29 deletions(-) diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp index bee5880ac4ccf..90dfe76f7fa33 100644 --- a/cmds/screencap/screencap.cpp +++ b/cmds/screencap/screencap.cpp @@ -49,7 +49,6 @@ static SkBitmap::Config flinger2skia(PixelFormat f) { switch (f) { case PIXEL_FORMAT_A_8: - case PIXEL_FORMAT_L_8: return SkBitmap::kA8_Config; case PIXEL_FORMAT_RGB_565: return SkBitmap::kRGB_565_Config; diff --git a/include/ui/PixelFormat.h b/include/ui/PixelFormat.h index 848c5a1149078..fc260c4f4b1de 100644 --- a/include/ui/PixelFormat.h +++ b/include/ui/PixelFormat.h @@ -21,7 +21,6 @@ // skia or SurfaceFlinger are not required to support all of these formats // (either as source or destination) -// XXX: we should consolidate these formats and skia's #ifndef UI_PIXELFORMAT_H #define UI_PIXELFORMAT_H @@ -29,7 +28,6 @@ #include #include #include -#include #include namespace android { @@ -65,10 +63,7 @@ enum { PIXEL_FORMAT_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888, // 4x8-bit BGRA PIXEL_FORMAT_RGBA_5551 = HAL_PIXEL_FORMAT_RGBA_5551, // 16-bit ARGB PIXEL_FORMAT_RGBA_4444 = HAL_PIXEL_FORMAT_RGBA_4444, // 16-bit ARGB - PIXEL_FORMAT_A_8 = GGL_PIXEL_FORMAT_A_8, // 8-bit A - PIXEL_FORMAT_L_8 = GGL_PIXEL_FORMAT_L_8, // 8-bit L (R=G=B=L) - PIXEL_FORMAT_LA_88 = GGL_PIXEL_FORMAT_LA_88, // 16-bit LA - PIXEL_FORMAT_RGB_332 = GGL_PIXEL_FORMAT_RGB_332, // 8-bit RGB + PIXEL_FORMAT_A_8 = 8, // 8-bit A // New formats can be added if they're also defined in // pixelflinger/format.h @@ -76,8 +71,7 @@ enum { typedef int32_t PixelFormat; -struct PixelFormatInfo -{ +struct PixelFormatInfo { enum { INDEX_ALPHA = 0, INDEX_RED = 1, @@ -89,8 +83,6 @@ struct PixelFormatInfo ALPHA = 1, RGB = 2, RGBA = 3, - LUMINANCE = 4, - LUMINANCE_ALPHA = 5, OTHER = 0xFF }; diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk index 579c315363a14..f0d7b02e67b5d 100644 --- a/libs/ui/Android.mk +++ b/libs/ui/Android.mk @@ -29,7 +29,6 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libutils \ libEGL \ - libpixelflinger \ libhardware LOCAL_MODULE:= libui diff --git a/libs/ui/PixelFormat.cpp b/libs/ui/PixelFormat.cpp index ee186c84de9c5..6993dac6998ab 100644 --- a/libs/ui/PixelFormat.cpp +++ b/libs/ui/PixelFormat.cpp @@ -15,13 +15,51 @@ */ #include -#include #include +// ---------------------------------------------------------------------------- namespace android { +// ---------------------------------------------------------------------------- static const int COMPONENT_YUV = 0xFF; +struct Info { + size_t size; + size_t bitsPerPixel; + struct { + uint8_t ah; + uint8_t al; + uint8_t rh; + uint8_t rl; + uint8_t gh; + uint8_t gl; + uint8_t bh; + uint8_t bl; + }; + uint8_t components; +}; + +static Info const sPixelFormatInfos[] = { + { 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }, + { 4, 32, {32,24, 8, 0, 16, 8, 24,16 }, PixelFormatInfo::RGBA }, + { 4, 24, { 0, 0, 8, 0, 16, 8, 24,16 }, PixelFormatInfo::RGB }, + { 3, 24, { 0, 0, 8, 0, 16, 8, 24,16 }, PixelFormatInfo::RGB }, + { 2, 16, { 0, 0, 16,11, 11, 5, 5, 0 }, PixelFormatInfo::RGB }, + { 4, 32, {32,24, 24,16, 16, 8, 8, 0 }, PixelFormatInfo::RGBA }, + { 2, 16, { 1, 0, 16,11, 11, 6, 6, 1 }, PixelFormatInfo::RGBA }, + { 2, 16, { 4, 0, 16,12, 12, 8, 8, 4 }, PixelFormatInfo::RGBA }, + { 1, 8, { 8, 0, 0, 0, 0, 0, 0, 0 }, PixelFormatInfo::ALPHA} +}; + +static const Info* gGetPixelFormatTable(size_t* numEntries) { + if (numEntries) { + *numEntries = sizeof(sPixelFormatInfos)/sizeof(Info); + } + return sPixelFormatInfos; +} + +// ---------------------------------------------------------------------------- + size_t PixelFormatInfo::getScanlineSize(unsigned int width) const { size_t size; @@ -77,27 +115,12 @@ status_t getPixelFormatInfo(PixelFormat format, PixelFormatInfo* info) } size_t numEntries; - const GGLFormat *i = gglGetPixelFormatTable(&numEntries) + format; + const Info *i = gGetPixelFormatTable(&numEntries) + format; bool valid = uint32_t(format) < numEntries; if (!valid) { return BAD_INDEX; } - #define COMPONENT(name) \ - case GGL_##name: info->components = PixelFormatInfo::name; break; - - switch (i->components) { - COMPONENT(ALPHA) - COMPONENT(RGB) - COMPONENT(RGBA) - COMPONENT(LUMINANCE) - COMPONENT(LUMINANCE_ALPHA) - default: - return BAD_INDEX; - } - - #undef COMPONENT - info->format = format; info->bytesPerPixel = i->size; info->bitsPerPixel = i->bitsPerPixel; @@ -109,9 +132,12 @@ status_t getPixelFormatInfo(PixelFormat format, PixelFormatInfo* info) info->l_green = i->gl; info->h_blue = i->bh; info->l_blue = i->bl; + info->components = i->components; return NO_ERROR; } +// ---------------------------------------------------------------------------- }; // namespace android +// ----------------------------------------------------------------------------