chore(demos): adapt new benchmark demo (#4780)

Signed-off-by: YanXiaowei <yanxiaowei@xiaomi.com>
Co-authored-by: YanXiaowei <yanxiaowei@xiaomi.com>
This commit is contained in:
bjsylvia
2023-11-10 16:43:29 +08:00
committed by GitHub
parent 2e5a551028
commit ddb1025991
+10 -56
View File
@@ -18,8 +18,6 @@
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
#define DEMO_BENCHMARK_NAME "benchmark"
#define DEMO_BENCHMARK_SCENE_NAME "benchmark_scene"
#define LV_DEMOS_COUNT (sizeof(demos_entry_info) / sizeof(demo_entry_info_t) - 1) #define LV_DEMOS_COUNT (sizeof(demos_entry_info) / sizeof(demo_entry_info_t) - 1)
/********************** /**********************
@@ -27,35 +25,15 @@
**********************/ **********************/
typedef void (*demo_method_cb)(void); typedef void (*demo_method_cb)(void);
#if LV_USE_DEMO_BENCHMARK
// typedef void (*demo_method_benchmark_cb)(lv_demo_benchmark_mode_t);
// typedef void (*demo_method_benchmark_scene_cb)(lv_demo_benchmark_mode_t, uint16_t);
#endif
typedef struct { typedef struct {
const char * name; const char * name;
union { demo_method_cb entry_cb;
demo_method_cb entry_cb;
#if LV_USE_DEMO_BENCHMARK
// demo_method_benchmark_cb entry_benchmark_cb;
// demo_method_benchmark_scene_cb entry_benchmark_scene_cb;
#endif
};
int arg_count : 8;
} demo_entry_info_t; } demo_entry_info_t;
/********************** /**********************
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
static inline bool demo_is_benchmark(const demo_entry_info_t * entry)
{
return (entry) && entry->arg_count == 1 && strcmp(entry->name, DEMO_BENCHMARK_NAME) == 0 ? true : false;
}
static inline bool demo_is_benchmark_scene(const demo_entry_info_t * entry)
{
return (entry) && entry->arg_count == 2 && strcmp(entry->name, DEMO_BENCHMARK_SCENE_NAME) == 0 ? true : false;
}
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
@@ -96,10 +74,9 @@ static const demo_entry_info_t demos_entry_info[] = {
{ "vector_graphic", .entry_cb = lv_demo_vector_graphic }, { "vector_graphic", .entry_cb = lv_demo_vector_graphic },
#endif #endif
//#if LV_USE_DEMO_BENCHMARK #if LV_USE_DEMO_BENCHMARK
// { DEMO_BENCHMARK_NAME, .entry_benchmark_cb = lv_demo_benchmark, 1 }, { "benchmark", .entry_cb = lv_demo_benchmark },
// { DEMO_BENCHMARK_SCENE_NAME, .entry_benchmark_scene_cb = lv_demo_benchmark_run_scene, 2 }, #endif
//#endif
{ "", .entry_cb = NULL } { "", .entry_cb = NULL }
}; };
@@ -125,11 +102,10 @@ bool lv_demos_create(char * info[], int size)
if(size <= 0) { /* default: first demo*/ if(size <= 0) { /* default: first demo*/
entry_info = &demos_entry_info[0]; entry_info = &demos_entry_info[0];
} }
else if(entry_info == NULL && info) {
if(entry_info == NULL && info) {
const char * name = info[0]; const char * name = info[0];
for(int i = 0; i < demos_count; i++) { for(int i = 0; i < demos_count; i++) {
if(strcmp(name, demos_entry_info[i].name) == 0 && size - 1 >= demos_entry_info[i].arg_count) { if(strcmp(name, demos_entry_info[i].name) == 0) {
entry_info = &demos_entry_info[i]; entry_info = &demos_entry_info[i];
} }
} }
@@ -140,22 +116,10 @@ bool lv_demos_create(char * info[], int size)
return false; return false;
} }
if(entry_info->arg_count == 0) { if(entry_info->entry_cb) {
if(entry_info->entry_cb) { entry_info->entry_cb();
entry_info->entry_cb(); return true;
return true;
}
} }
//#if LV_USE_DEMO_BENCHMARK
// else if(demo_is_benchmark(entry_info) && entry_info->entry_benchmark_cb) {
// entry_info->entry_benchmark_cb((lv_demo_benchmark_mode_t)atoi(info[1]));
// return true;
// }
// else if(demo_is_benchmark_scene(entry_info) && entry_info->entry_benchmark_scene_cb) {
// entry_info->entry_benchmark_scene_cb((lv_demo_benchmark_mode_t)atoi(info[1]), (uint16_t)atoi(info[2]));
// return true;
// }
//#endif
return false; return false;
} }
@@ -174,16 +138,6 @@ void lv_demos_show_help(void)
LV_LOG("\ndemo list:\n"); LV_LOG("\ndemo list:\n");
for(i = 0; i < demos_count; i++) { for(i = 0; i < demos_count; i++) {
if(demos_entry_info[i].arg_count == 0) { LV_LOG(" %s \n", demos_entry_info[i].name);
LV_LOG(" %s \n", demos_entry_info[i].name);
}
else if(demo_is_benchmark(&demos_entry_info[i])) {
LV_LOG(" %s [0, 1, 2] \t\t\t(0 for Render&Driver, 1 for Real Render, 2 for Render Only)\n",
demos_entry_info[i].name);
}
else if(demo_is_benchmark_scene(&demos_entry_info[i])) {
LV_LOG(" %s [0, 1, 2] scene_no \t(0 for Render&Driver, 1 for Real Render, 2 for Render Only)\n",
demos_entry_info[i].name);
}
} }
} }