fix(thorvg): support rendering in draw events (#6406)

Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
Gabor Kiss-Vamosi
2024-07-19 12:04:32 +02:00
committed by GitHub
parent aa3320db53
commit e3f8d167cd
8 changed files with 77 additions and 16 deletions

View File

@@ -64,7 +64,11 @@ static const demo_entry_info_t demos_entry_info[] = {
#endif
#if LV_USE_DEMO_VECTOR_GRAPHIC && LV_USE_VECTOR_GRAPHIC
{ "vector_graphic", .entry_cb = lv_demo_vector_graphic },
{ "vector_graphic_buffered", .entry_cb = lv_demo_vector_graphic_buffered },
#endif
#if LV_USE_DEMO_VECTOR_GRAPHIC && LV_USE_VECTOR_GRAPHIC
{ "vector_graphic_not_buffered", .entry_cb = lv_demo_vector_graphic_not_buffered },
#endif
#if LV_USE_DEMO_BENCHMARK

View File

@@ -245,6 +245,13 @@ static void delete_event_cb(lv_event_t * e)
lv_draw_buf_destroy(draw_buf);
}
static void event_cb(lv_event_t * e)
{
lv_layer_t * layer = lv_event_get_layer(e);
draw_vector(layer);
}
/**********************
* STATIC VARIABLES
**********************/
@@ -257,7 +264,12 @@ static void delete_event_cb(lv_event_t * e)
* GLOBAL FUNCTIONS
**********************/
void lv_demo_vector_graphic(void)
void lv_demo_vector_graphic_not_buffered(void)
{
lv_obj_add_event_cb(lv_screen_active(), event_cb, LV_EVENT_DRAW_MAIN, NULL);
}
void lv_demo_vector_graphic_buffered(void)
{
lv_draw_buf_t * draw_buf = lv_draw_buf_create(WIDTH, HEIGHT, LV_COLOR_FORMAT_ARGB8888, LV_STRIDE_AUTO);
lv_draw_buf_clear(draw_buf, NULL);
@@ -278,7 +290,15 @@ void lv_demo_vector_graphic(void)
**********************/
#else
void lv_demo_vector_graphic(void)
void lv_demo_vector_graphic_not_buffered(void)
{
/*fallback for online examples*/
lv_obj_t * label = lv_label_create(lv_screen_active());
lv_label_set_text(label, "Vector graphics is not enabled");
lv_obj_center(label);
}
void lv_demo_vector_graphic_buffered(void)
{
/*fallback for online examples*/
lv_obj_t * label = lv_label_create(lv_screen_active());

View File

@@ -27,7 +27,18 @@ extern "C" {
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_demo_vector_graphic(void);
/**
* Draw many vector based shapes and paths to canvas.
* It requires a large amount of RAM for the buffer of the canvas
*/
void lv_demo_vector_graphic_buffered(void);
/**
* Draw many vector based shapes and paths to canvas directly to the screen.
* It's slower as the graphics needs to rendered on each rendering cycle.
*/
void lv_demo_vector_graphic_not_buffered(void);
/**********************
* MACROS