1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

feat(vg_lite): add ARGB1555 ARGB4444 ARGB2222 support (#7028)

Signed-off-by: yushuailong1 <yushuailong1@xiaomi.com>
Co-authored-by: yushuailong1 <yushuailong1@xiaomi.com>
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: FASTSHIFT <vifextech@foxmail.com>
This commit is contained in:
yushuailong 2024-10-22 19:57:15 +08:00 committed by GitHub
parent 84b28ff688
commit bdfb80ef3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
110 changed files with 325 additions and 0 deletions

View File

@ -403,6 +403,9 @@ bool lv_vg_lite_is_dest_cf_supported(lv_color_format_t cf)
case LV_COLOR_FORMAT_RGB565:
case LV_COLOR_FORMAT_ARGB8888:
case LV_COLOR_FORMAT_XRGB8888:
case LV_COLOR_FORMAT_ARGB1555:
case LV_COLOR_FORMAT_ARGB4444:
case LV_COLOR_FORMAT_ARGB2222:
return true;
case LV_COLOR_FORMAT_ARGB8565:
@ -425,6 +428,9 @@ bool lv_vg_lite_is_src_cf_supported(lv_color_format_t cf)
case LV_COLOR_FORMAT_RGB565:
case LV_COLOR_FORMAT_ARGB8888:
case LV_COLOR_FORMAT_XRGB8888:
case LV_COLOR_FORMAT_ARGB1555:
case LV_COLOR_FORMAT_ARGB4444:
case LV_COLOR_FORMAT_ARGB2222:
return true;
case LV_COLOR_FORMAT_I1:
@ -476,6 +482,15 @@ vg_lite_buffer_format_t lv_vg_lite_vg_fmt(lv_color_format_t cf)
case LV_COLOR_FORMAT_I8:
return VG_LITE_INDEX_8;
case LV_COLOR_FORMAT_ARGB1555:
return VG_LITE_BGRA5551;
case LV_COLOR_FORMAT_ARGB4444:
return VG_LITE_BGRA4444;
case LV_COLOR_FORMAT_ARGB2222:
return VG_LITE_BGRA2222;
case LV_COLOR_FORMAT_RGB565:
return VG_LITE_BGR565;

View File

@ -55,12 +55,15 @@ uint8_t lv_color_format_get_bpp(lv_color_format_t cf)
case LV_COLOR_FORMAT_L8:
case LV_COLOR_FORMAT_A8:
case LV_COLOR_FORMAT_I8:
case LV_COLOR_FORMAT_ARGB2222:
return 8;
case LV_COLOR_FORMAT_RGB565A8:
case LV_COLOR_FORMAT_RGB565:
case LV_COLOR_FORMAT_YUY2:
case LV_COLOR_FORMAT_AL88:
case LV_COLOR_FORMAT_ARGB1555:
case LV_COLOR_FORMAT_ARGB4444:
return 16;
case LV_COLOR_FORMAT_ARGB8565:
@ -91,6 +94,9 @@ bool lv_color_format_has_alpha(lv_color_format_t cf)
case LV_COLOR_FORMAT_ARGB8565:
case LV_COLOR_FORMAT_ARGB8888:
case LV_COLOR_FORMAT_AL88:
case LV_COLOR_FORMAT_ARGB2222:
case LV_COLOR_FORMAT_ARGB1555:
case LV_COLOR_FORMAT_ARGB4444:
return true;
default:
return false;

View File

@ -72,10 +72,13 @@ enum {
(cf) == LV_COLOR_FORMAT_L8 ? 8 : \
(cf) == LV_COLOR_FORMAT_A8 ? 8 : \
(cf) == LV_COLOR_FORMAT_I8 ? 8 : \
(cf) == LV_COLOR_FORMAT_ARGB2222 ? 8 : \
(cf) == LV_COLOR_FORMAT_AL88 ? 16 : \
(cf) == LV_COLOR_FORMAT_RGB565 ? 16 : \
(cf) == LV_COLOR_FORMAT_RGB565A8 ? 16 : \
(cf) == LV_COLOR_FORMAT_YUY2 ? 16 : \
(cf) == LV_COLOR_FORMAT_ARGB1555 ? 16 : \
(cf) == LV_COLOR_FORMAT_ARGB4444 ? 16 : \
(cf) == LV_COLOR_FORMAT_ARGB8565 ? 24 : \
(cf) == LV_COLOR_FORMAT_RGB888 ? 24 : \
(cf) == LV_COLOR_FORMAT_ARGB8888 ? 32 : \
@ -154,6 +157,9 @@ typedef enum {
LV_COLOR_FORMAT_A1 = 0x0B,
LV_COLOR_FORMAT_A2 = 0x0C,
LV_COLOR_FORMAT_A4 = 0x0D,
LV_COLOR_FORMAT_ARGB1555 = 0x16,
LV_COLOR_FORMAT_ARGB4444 = 0x17,
LV_COLOR_FORMAT_ARGB2222 = 0X18,
/* reference to https://wiki.videolan.org/YUV/ */
/*YUV planar formats*/

View File

@ -86,6 +86,9 @@ lv_result_t lv_snapshot_take_to_draw_buf(lv_obj_t * obj, lv_color_format_t cf, l
case LV_COLOR_FORMAT_A8:
case LV_COLOR_FORMAT_L8:
case LV_COLOR_FORMAT_I1:
case LV_COLOR_FORMAT_ARGB2222:
case LV_COLOR_FORMAT_ARGB4444:
case LV_COLOR_FORMAT_ARGB1555:
break;
default:
LV_LOG_WARN("Not supported color format");

View File

@ -119,6 +119,27 @@ typedef struct {
uint8_t alpha;
} vg_color32_t;
typedef struct {
uint8_t blue : 4;
uint8_t green : 4;
uint8_t red : 4;
uint8_t alpha : 4;
} vg_color_bgra4444_t;
typedef struct {
uint8_t blue : 2;
uint8_t green : 2;
uint8_t red : 2;
uint8_t alpha : 2;
} vg_color_bgra2222_t;
typedef struct {
uint8_t blue : 5;
uint8_t green : 5;
uint8_t red : 5;
uint8_t alpha : 1;
} vg_color_bgra5551_t;
typedef struct {
vg_lite_float_t x;
vg_lite_float_t y;
@ -441,6 +462,45 @@ static vg_lite_converter<vg_color32_t, uint8_t> conv_l8_to_bgra8888(
}
});
static vg_lite_converter<vg_color32_t, vg_color_bgra5551_t> conv_bgra5551_to_bgra8888(
[](vg_color32_t * dest, const vg_color_bgra5551_t * src, vg_lite_uint32_t px_size, vg_lite_uint32_t /* color */)
{
while(px_size--) {
dest->red = src->red * 0xFF / 0x1F;
dest->green = src->green * 0xFF / 0x1F;
dest->blue = src->blue * 0xFF / 0x1F;
dest->alpha = src->alpha ? 0xFF : 0;
src++;
dest++;
}
});
static vg_lite_converter<vg_color32_t, vg_color_bgra4444_t> conv_bgra4444_to_bgra8888(
[](vg_color32_t * dest, const vg_color_bgra4444_t * src, vg_lite_uint32_t px_size, vg_lite_uint32_t /* color */)
{
while(px_size--) {
dest->red = src->red * 0xFF / 0xF;
dest->green = src->green * 0xFF / 0xF;
dest->blue = src->blue * 0xFF / 0xF;
dest->alpha = src->alpha * 0xFF / 0xF;
src++;
dest++;
}
});
static vg_lite_converter<vg_color32_t, vg_color_bgra2222_t> conv_bgra2222_to_bgra8888(
[](vg_color32_t * dest, const vg_color_bgra2222_t * src, vg_lite_uint32_t px_size, vg_lite_uint32_t /* color */)
{
while(px_size--) {
dest->red = src->red * 0xFF / 0x3;
dest->green = src->green * 0xFF / 0x3;
dest->blue = src->blue * 0xFF / 0x3;
dest->alpha = src->alpha * 0xFF / 0x3;
src++;
dest++;
}
});
/**********************
* MACROS
**********************/
@ -686,6 +746,43 @@ extern "C" {
}
}
static void picture_bgra8888_to_bgra5551(vg_color_bgra5551_t * dest, const vg_color32_t * src, vg_lite_uint32_t px_size)
{
while(px_size--) {
dest->red = src->red * 0x1F / 0xFF;
dest->green = src->green * 0x1F / 0xFF;
dest->blue = src->blue * 0x1F / 0xFF;
dest->alpha = src->alpha > (0xFF / 2) ? 1 : 0;
src++;
dest++;
}
}
static void picture_bgra8888_to_bgra4444(vg_color_bgra4444_t * dest, const vg_color32_t * src, vg_lite_uint32_t px_size)
{
while(px_size--) {
dest->red = src->red * 0xF / 0xFF;
dest->green = src->green * 0xF / 0xFF;
dest->blue = src->blue * 0xF / 0xFF;
dest->alpha = src->alpha * 0xF / 0xFF;
src++;
dest++;
}
}
static void picture_bgra8888_to_bgra2222(vg_color_bgra2222_t * dest, const vg_color32_t * src, vg_lite_uint32_t px_size)
{
while(px_size--) {
dest->red = src->red * 0x3 / 0xFF;
dest->green = src->green * 0x3 / 0xFF;
dest->blue = src->blue * 0x3 / 0xFF;
dest->alpha = src->alpha * 0x3 / 0xFF;
src++;
dest++;
}
}
vg_lite_error_t vg_lite_finish(void)
{
vg_lite_ctx * ctx = vg_lite_ctx::get_instance();
@ -732,6 +829,21 @@ extern "C" {
(const vg_color32_t *)ctx->get_temp_target_buffer(),
ctx->target_px_size);
break;
case VG_LITE_BGRA5551:
picture_bgra8888_to_bgra5551((vg_color_bgra5551_t *)ctx->target_buffer,
(const vg_color32_t *)ctx->get_temp_target_buffer(),
ctx->target_px_size);
break;
case VG_LITE_BGRA4444:
picture_bgra8888_to_bgra4444((vg_color_bgra4444_t *)ctx->target_buffer,
(const vg_color32_t *)ctx->get_temp_target_buffer(),
ctx->target_px_size);
break;
case VG_LITE_BGRA2222:
picture_bgra8888_to_bgra2222((vg_color_bgra2222_t *)ctx->target_buffer,
(const vg_color32_t *)ctx->get_temp_target_buffer(),
ctx->target_px_size);
break;
case VG_LITE_BGRA8888:
case VG_LITE_BGRX8888:
/* No conversion required. */
@ -2547,6 +2659,21 @@ static Result picture_load(vg_lite_ctx * ctx, std::unique_ptr<Picture> & picture
}
break;
case VG_LITE_BGRA5551: {
conv_bgra5551_to_bgra8888.convert(&target, source);
}
break;
case VG_LITE_BGRA4444: {
conv_bgra4444_to_bgra8888.convert(&target, source);
}
break;
case VG_LITE_BGRA2222: {
conv_bgra2222_to_bgra8888.convert(&target, source);
}
break;
#if LV_VG_LITE_THORVG_YUV_SUPPORT
case VG_LITE_NV12: {
libyuv::NV12ToARGB((const uint8_t *)source->memory, source->stride, (const uint8_t *)source->yuv.uv_memory,

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Some files were not shown because too many files have changed in this diff Show More