feat(vg_lite): add A8 and L8 dest buffer support (#6884)
Signed-off-by: yushuailong1 <yushuailong1@xiaomi.com> Signed-off-by: FASTSHIFT <vifextech@foxmail.com> Co-authored-by: yushuailong1 <yushuailong1@xiaomi.com> Co-authored-by: FASTSHIFT <vifextech@foxmail.com>
@ -398,6 +398,8 @@ void lv_vg_lite_matrix_dump_info(const vg_lite_matrix_t * matrix)
|
||||
bool lv_vg_lite_is_dest_cf_supported(lv_color_format_t cf)
|
||||
{
|
||||
switch(cf) {
|
||||
case LV_COLOR_FORMAT_A8:
|
||||
case LV_COLOR_FORMAT_L8:
|
||||
case LV_COLOR_FORMAT_RGB565:
|
||||
case LV_COLOR_FORMAT_ARGB8888:
|
||||
case LV_COLOR_FORMAT_XRGB8888:
|
||||
@ -419,6 +421,7 @@ bool lv_vg_lite_is_src_cf_supported(lv_color_format_t cf)
|
||||
switch(cf) {
|
||||
case LV_COLOR_FORMAT_A4:
|
||||
case LV_COLOR_FORMAT_A8:
|
||||
case LV_COLOR_FORMAT_L8:
|
||||
case LV_COLOR_FORMAT_RGB565:
|
||||
case LV_COLOR_FORMAT_ARGB8888:
|
||||
case LV_COLOR_FORMAT_XRGB8888:
|
||||
|
@ -82,6 +82,7 @@ lv_result_t lv_snapshot_take_to_draw_buf(lv_obj_t * obj, lv_color_format_t cf, l
|
||||
case LV_COLOR_FORMAT_RGB888:
|
||||
case LV_COLOR_FORMAT_XRGB8888:
|
||||
case LV_COLOR_FORMAT_ARGB8888:
|
||||
case LV_COLOR_FORMAT_A8:
|
||||
case LV_COLOR_FORMAT_L8:
|
||||
case LV_COLOR_FORMAT_I1:
|
||||
break;
|
||||
|
@ -422,6 +422,19 @@ static vg_lite_converter<vg_color32_t, uint8_t> conv_alpha4_to_bgra8888(
|
||||
}
|
||||
});
|
||||
|
||||
static vg_lite_converter<vg_color32_t, uint8_t> conv_l8_to_bgra8888(
|
||||
[](vg_color32_t * dest, const uint8_t * src, vg_lite_uint32_t px_size, vg_lite_uint32_t /* color */)
|
||||
{
|
||||
while(px_size--) {
|
||||
dest->alpha = 0xFF;
|
||||
dest->red = *src;
|
||||
dest->green = *src;
|
||||
dest->blue = *src;
|
||||
dest++;
|
||||
src++;
|
||||
}
|
||||
});
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@ -649,6 +662,24 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
static void picture_bgra8888_to_l8(uint8_t * dest, const vg_color32_t * src, vg_lite_uint32_t px_size)
|
||||
{
|
||||
while(px_size--) {
|
||||
*dest = (src->red * 19595 + src->green * 38469 + src->blue * 7472) >> 16;
|
||||
src++;
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
|
||||
static void picture_bgra8888_to_alpha8(uint8_t * dest, const vg_color32_t * src, vg_lite_uint32_t px_size)
|
||||
{
|
||||
while(px_size--) {
|
||||
*dest = src->alpha;
|
||||
src++;
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
|
||||
vg_lite_error_t vg_lite_finish(void)
|
||||
{
|
||||
vg_lite_ctx * ctx = vg_lite_ctx::get_instance();
|
||||
@ -683,6 +714,18 @@ extern "C" {
|
||||
(const vg_color32_t *)ctx->get_temp_target_buffer(),
|
||||
ctx->target_px_size);
|
||||
break;
|
||||
case VG_LITE_L8:
|
||||
picture_bgra8888_to_l8(
|
||||
(uint8_t *)ctx->target_buffer,
|
||||
(const vg_color32_t *)ctx->get_temp_target_buffer(),
|
||||
ctx->target_px_size);
|
||||
break;
|
||||
case VG_LITE_A8:
|
||||
picture_bgra8888_to_alpha8(
|
||||
(uint8_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. */
|
||||
@ -2440,6 +2483,11 @@ static Result picture_load(vg_lite_ctx * ctx, std::unique_ptr<Picture> & picture
|
||||
}
|
||||
break;
|
||||
|
||||
case VG_LITE_L8: {
|
||||
conv_l8_to_bgra8888.convert(&target, source);
|
||||
}
|
||||
break;
|
||||
|
||||
case VG_LITE_BGRX8888: {
|
||||
conv_bgrx8888_to_bgra8888.convert(&target, source);
|
||||
}
|
||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 14 KiB |
BIN
tests/ref_imgs_vg_lite/widgets/span_09.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
tests/ref_imgs_vg_lite/widgets/switch_1.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
@ -18,9 +18,6 @@ void tearDown(void)
|
||||
|
||||
void test_render_to_l8(void)
|
||||
{
|
||||
#if LV_USE_DRAW_VG_LITE
|
||||
TEST_PASS();
|
||||
#else
|
||||
lv_display_set_color_format(NULL, LV_COLOR_FORMAT_L8);
|
||||
|
||||
lv_opa_t opa_values[2] = {0xff, 0x80};
|
||||
@ -41,7 +38,6 @@ void test_render_to_l8(void)
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT(buf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|