fix(vg_lite): fix freetype build break and imgfont draw error (#5353)
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
@@ -22,7 +22,7 @@ static const void * get_imgfont_path(const lv_font_t * font, uint32_t unicode, u
|
|||||||
else if(unicode == 0xF600) {
|
else if(unicode == 0xF600) {
|
||||||
#if LV_USE_FFMPEG
|
#if LV_USE_FFMPEG
|
||||||
return "lvgl/examples/assets/emoji/F600.png";
|
return "lvgl/examples/assets/emoji/F600.png";
|
||||||
#elif LV_USE_LODEPNG
|
#else
|
||||||
return "A:lvgl/examples/assets/emoji/F600.png";
|
return "A:lvgl/examples/assets/emoji/F600.png";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,10 @@ static void draw_letter_cb(lv_draw_unit_t * draw_unit, lv_draw_glyph_dsc_t * gly
|
|||||||
|
|
||||||
static void draw_letter_bitmap(lv_draw_vg_lite_unit_t * u, const lv_draw_glyph_dsc_t * dsc);
|
static void draw_letter_bitmap(lv_draw_vg_lite_unit_t * u, const lv_draw_glyph_dsc_t * dsc);
|
||||||
|
|
||||||
static void freetype_outline_event_cb(lv_event_t * e);
|
#if LV_USE_FREETYPE
|
||||||
static void draw_letter_outline(lv_draw_vg_lite_unit_t * u, const lv_draw_glyph_dsc_t * dsc);
|
static void freetype_outline_event_cb(lv_event_t * e);
|
||||||
|
static void draw_letter_outline(lv_draw_vg_lite_unit_t * u, const lv_draw_glyph_dsc_t * dsc);
|
||||||
|
#endif /* LV_USE_FREETYPE */
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
@@ -63,11 +65,13 @@ void lv_draw_vg_lite_label(lv_draw_unit_t * draw_unit, const lv_draw_label_dsc_t
|
|||||||
{
|
{
|
||||||
if(dsc->opa <= LV_OPA_MIN) return;
|
if(dsc->opa <= LV_OPA_MIN) return;
|
||||||
|
|
||||||
|
#if LV_USE_FREETYPE
|
||||||
static bool is_init = false;
|
static bool is_init = false;
|
||||||
if(!is_init) {
|
if(!is_init) {
|
||||||
lv_freetype_outline_add_event(freetype_outline_event_cb, LV_EVENT_ALL, draw_unit);
|
lv_freetype_outline_add_event(freetype_outline_event_cb, LV_EVENT_ALL, draw_unit);
|
||||||
is_init = true;
|
is_init = true;
|
||||||
}
|
}
|
||||||
|
#endif /* LV_USE_FREETYPE */
|
||||||
|
|
||||||
lv_draw_label_iterate_characters(draw_unit, dsc, coords, draw_letter_cb);
|
lv_draw_label_iterate_characters(draw_unit, dsc, coords, draw_letter_cb);
|
||||||
}
|
}
|
||||||
@@ -81,26 +85,46 @@ static void draw_letter_cb(lv_draw_unit_t * draw_unit, lv_draw_glyph_dsc_t * gly
|
|||||||
{
|
{
|
||||||
lv_draw_vg_lite_unit_t * u = (lv_draw_vg_lite_unit_t *)draw_unit;
|
lv_draw_vg_lite_unit_t * u = (lv_draw_vg_lite_unit_t *)draw_unit;
|
||||||
if(glyph_draw_dsc) {
|
if(glyph_draw_dsc) {
|
||||||
if(glyph_draw_dsc->format == LV_DRAW_LETTER_BITMAP_FORMAT_INVALID) {
|
|
||||||
|
switch(glyph_draw_dsc->format) {
|
||||||
|
case LV_DRAW_LETTER_BITMAP_FORMAT_A8: {
|
||||||
|
draw_letter_bitmap(u, glyph_draw_dsc);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if LV_USE_FREETYPE
|
||||||
|
case LV_DRAW_LETTER_VECTOR_FORMAT: {
|
||||||
|
if(lv_freetype_is_outline_font(glyph_draw_dsc->g->resolved_font)) {
|
||||||
|
draw_letter_outline(u, glyph_draw_dsc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif /* LV_USE_FREETYPE */
|
||||||
|
|
||||||
|
case LV_DRAW_LETTER_BITMAP_FORMAT_IMAGE: {
|
||||||
|
lv_draw_image_dsc_t img_dsc;
|
||||||
|
lv_draw_image_dsc_init(&img_dsc);
|
||||||
|
img_dsc.opa = glyph_draw_dsc->opa;
|
||||||
|
img_dsc.src = glyph_draw_dsc->glyph_data;
|
||||||
|
lv_draw_vg_lite_img(draw_unit, &img_dsc, glyph_draw_dsc->letter_coords);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
#if LV_USE_FONT_PLACEHOLDER
|
#if LV_USE_FONT_PLACEHOLDER
|
||||||
/* Draw a placeholder rectangle*/
|
case LV_DRAW_LETTER_BITMAP_FORMAT_INVALID: {
|
||||||
lv_draw_border_dsc_t border_draw_dsc;
|
/* Draw a placeholder rectangle*/
|
||||||
lv_draw_border_dsc_init(&border_draw_dsc);
|
lv_draw_border_dsc_t border_draw_dsc;
|
||||||
border_draw_dsc.opa = glyph_draw_dsc->opa;
|
lv_draw_border_dsc_init(&border_draw_dsc);
|
||||||
border_draw_dsc.color = glyph_draw_dsc->color;
|
border_draw_dsc.opa = glyph_draw_dsc->opa;
|
||||||
border_draw_dsc.width = 1;
|
border_draw_dsc.color = glyph_draw_dsc->color;
|
||||||
lv_draw_vg_lite_border(draw_unit, &border_draw_dsc, glyph_draw_dsc->bg_coords);
|
border_draw_dsc.width = 1;
|
||||||
#endif
|
lv_draw_vg_lite_border(draw_unit, &border_draw_dsc, glyph_draw_dsc->bg_coords);
|
||||||
}
|
}
|
||||||
else if(glyph_draw_dsc->format == LV_DRAW_LETTER_BITMAP_FORMAT_A8
|
break;
|
||||||
|| glyph_draw_dsc->format == LV_DRAW_LETTER_BITMAP_FORMAT_IMAGE
|
#endif /* LV_USE_FONT_PLACEHOLDER */
|
||||||
|| glyph_draw_dsc->format == LV_DRAW_LETTER_VECTOR_FORMAT) {
|
|
||||||
if(lv_freetype_is_outline_font(glyph_draw_dsc->g->resolved_font)) {
|
default:
|
||||||
draw_letter_outline(u, glyph_draw_dsc);
|
break;
|
||||||
}
|
|
||||||
else {
|
|
||||||
draw_letter_bitmap(u, glyph_draw_dsc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,6 +214,8 @@ static void draw_letter_bitmap(lv_draw_vg_lite_unit_t * u, const lv_draw_glyph_d
|
|||||||
LV_VG_LITE_CHECK_ERROR(vg_lite_finish());
|
LV_VG_LITE_CHECK_ERROR(vg_lite_finish());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LV_USE_FREETYPE
|
||||||
|
|
||||||
static void draw_letter_outline(lv_draw_vg_lite_unit_t * u, const lv_draw_glyph_dsc_t * dsc)
|
static void draw_letter_outline(lv_draw_vg_lite_unit_t * u, const lv_draw_glyph_dsc_t * dsc)
|
||||||
{
|
{
|
||||||
/* get clip area */
|
/* get clip area */
|
||||||
@@ -300,4 +326,6 @@ static void freetype_outline_event_cb(lv_event_t * e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* LV_USE_FREETYPE */
|
||||||
|
|
||||||
#endif /*LV_USE_DRAW_VG_LITE*/
|
#endif /*LV_USE_DRAW_VG_LITE*/
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ static lv_result_t decoder_open_variable(lv_image_decoder_t * decoder, lv_image_
|
|||||||
/*In case of uncompressed formats the image stored in the ROM/RAM.
|
/*In case of uncompressed formats the image stored in the ROM/RAM.
|
||||||
*So simply give its pointer*/
|
*So simply give its pointer*/
|
||||||
const uint8_t * image_data = ((lv_image_dsc_t *)dsc->src)->data;
|
const uint8_t * image_data = ((lv_image_dsc_t *)dsc->src)->data;
|
||||||
|
uint32_t image_data_size = ((lv_image_dsc_t *)dsc->src)->data_size;
|
||||||
|
|
||||||
bool has_alpha = lv_color_format_has_alpha(cf);
|
bool has_alpha = lv_color_format_has_alpha(cf);
|
||||||
bool is_indexed = LV_COLOR_FORMAT_IS_INDEXED(cf);
|
bool is_indexed = LV_COLOR_FORMAT_IS_INDEXED(cf);
|
||||||
@@ -219,7 +220,7 @@ static lv_result_t decoder_open_variable(lv_image_decoder_t * decoder, lv_image_
|
|||||||
|
|
||||||
lv_draw_buf_t * draw_buf = lv_malloc_zeroed(sizeof(lv_draw_buf_t));
|
lv_draw_buf_t * draw_buf = lv_malloc_zeroed(sizeof(lv_draw_buf_t));
|
||||||
LV_ASSERT_MALLOC(draw_buf);
|
LV_ASSERT_MALLOC(draw_buf);
|
||||||
lv_draw_buf_init(draw_buf, width, height, cf, stride, (void *)image_data, LV_VG_LITE_IMAGE_NO_CACHE);
|
lv_draw_buf_init(draw_buf, width, height, cf, stride, (void *)image_data, image_data_size);
|
||||||
dsc->decoded = draw_buf;
|
dsc->decoded = draw_buf;
|
||||||
return LV_RESULT_OK;
|
return LV_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user