fix(vglite) add checks for alignment, stride and static bitmap

Signed-off-by: Cosmin-Daniel Radu <cosmin.radu_1@nxp.com>
This commit is contained in:
Cosmin-Daniel Radu
2025-05-09 13:36:58 +03:00
committed by Gabor Kiss-Vamosi
parent a1070903b0
commit 5564b5bc3c
3 changed files with 16 additions and 5 deletions
+11 -3
View File
@@ -22,6 +22,7 @@
#include "../../lv_draw_label_private.h"
#include "../../../stdlib/lv_string.h"
#include "../../../font/lv_font_fmt_txt_private.h"
/*********************
* DEFINES
@@ -52,6 +53,8 @@ static void _vglite_draw_letter(const lv_area_t * mask_area, lv_color_t color, l
* STATIC VARIABLES
**********************/
static bool _use_static_bitmap = false;
/**********************
* GLOBAL VARIABLES
**********************/
@@ -71,6 +74,12 @@ void lv_draw_vglite_label(vglite_draw_task_t * vglite_task)
if(dsc->opa <= LV_OPA_MIN) return;
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *)dsc->font->dsc;
bool is_src_buf_aligned = vglite_src_buf_aligned(fdsc->glyph_bitmap, fdsc->stride, LV_COLOR_FORMAT_A8);
bool has_static_bitmap = lv_font_has_static_bitmap(dsc->font);
_use_static_bitmap = is_src_buf_aligned & has_static_bitmap;
lv_draw_label_iterate_characters(vglite_task->t, dsc, coords, _draw_vglite_letter);
}
@@ -127,11 +136,10 @@ static void _draw_vglite_letter(lv_draw_task_t * t, lv_draw_glyph_dsc_t * glyph_
return;
lv_area_move(&blend_area, -layer->buf_area.x1, -layer->buf_area.y1);
const bool static_bitmap = lv_font_has_static_bitmap(glyph_draw_dsc->g->resolved_font);
const void * mask_buf = NULL;
const lv_draw_buf_t * draw_buf = NULL;
uint32_t mask_stride;
if(!static_bitmap) {
if(!_use_static_bitmap) {
draw_buf = lv_font_get_glyph_bitmap(glyph_draw_dsc->g, glyph_draw_dsc->_draw_buf);
if(draw_buf != NULL) {
mask_buf = draw_buf->data;
@@ -162,7 +170,7 @@ static void _draw_vglite_letter(lv_draw_task_t * t, lv_draw_glyph_dsc_t * glyph_
/* Set matrix. */
vglite_set_translation_matrix(&blend_area);
if(!static_bitmap)
if(!_use_static_bitmap)
lv_draw_buf_invalidate_cache(draw_buf, &mask_area);
_vglite_draw_letter(&mask_area, glyph_draw_dsc->color, glyph_draw_dsc->opa);
+1
View File
@@ -138,6 +138,7 @@ bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_o
dsc_out->box_w = 0;
dsc_out->adv_w = 0;
#endif
dsc_out->stride = 0;
dsc_out->resolved_font = NULL;
dsc_out->box_h = font_p->line_height;
+4 -2
View File
@@ -254,12 +254,14 @@ bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t *
dsc_out->box_w = gdsc->box_w;
dsc_out->ofs_x = gdsc->ofs_x;
dsc_out->ofs_y = gdsc->ofs_y;
if(fdsc->stride == 0) dsc_out->stride = 0;
else {
/*font_dsc stride is is e.g. 4 to align to 4 byte boundary.
*In glyph_dsc store the actual line length*/
/*e.g. font_dsc stride == 4 means align to 4 byte boundary.
*In glyph_dsc store the actual line length in bytes*/
dsc_out->stride = LV_ROUND_UP(dsc_out->box_w, fdsc->stride);
}
dsc_out->format = (uint8_t)fdsc->bpp;
dsc_out->is_placeholder = false;
dsc_out->gid.index = gid;