remove libui's dependency on libpixelflinger

this also remove support for unused pixelformats.

Change-Id: I2c759a6d2daa740f3786ed62095def8047ae933d
This commit is contained in:
Mathias Agopian 2012-02-21 18:56:08 -08:00
parent 725da0fb40
commit 42e2458144
3 changed files with 45 additions and 28 deletions

View File

@ -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 <stdint.h>
#include <sys/types.h>
#include <utils/Errors.h>
#include <pixelflinger/format.h>
#include <hardware/hardware.h>
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
};

View File

@ -29,7 +29,6 @@ LOCAL_SHARED_LIBRARIES := \
libcutils \
libutils \
libEGL \
libpixelflinger \
libhardware
LOCAL_MODULE:= libui

View File

@ -15,13 +15,51 @@
*/
#include <ui/PixelFormat.h>
#include <pixelflinger/format.h>
#include <hardware/hardware.h>
// ----------------------------------------------------------------------------
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
// ----------------------------------------------------------------------------