feat(sdl): add PARTIAL_MODE to emulate setups with display controller
This commit is contained in:
@@ -752,6 +752,7 @@
|
|||||||
#define LV_USE_SDL 0
|
#define LV_USE_SDL 0
|
||||||
#if LV_USE_SDL
|
#if LV_USE_SDL
|
||||||
#define LV_SDL_INCLUDE_PATH <SDL2/SDL.h>
|
#define LV_SDL_INCLUDE_PATH <SDL2/SDL.h>
|
||||||
|
#define LV_SDL_PARTIAL_MODE 0 /*Recommended only to emulate a setup with a display controller*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*Driver for /dev/fb*/
|
/*Driver for /dev/fb*/
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
|
/*Recommended only to emulate a setup with a display controller*/
|
||||||
|
#define LV_SDL_PARTIAL_MODE 0
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
**********************/
|
**********************/
|
||||||
@@ -85,8 +88,14 @@ lv_disp_t * lv_sdl_window_create(lv_coord_t hor_res, lv_coord_t ver_res)
|
|||||||
window_create(disp);
|
window_create(disp);
|
||||||
|
|
||||||
lv_disp_set_flush_cb(disp, flush_cb);
|
lv_disp_set_flush_cb(disp, flush_cb);
|
||||||
|
#if LV_SDL_PARTIAL_MODE
|
||||||
|
uint8_t * buf = malloc(32 * 1024);
|
||||||
|
lv_disp_set_draw_buffers(disp, buf, NULL,
|
||||||
|
32 * 1024, LV_DISP_RENDER_MODE_PARTIAL);
|
||||||
|
#else
|
||||||
lv_disp_set_draw_buffers(disp, dsc->fb, NULL,
|
lv_disp_set_draw_buffers(disp, dsc->fb, NULL,
|
||||||
lv_disp_get_hor_res(disp) * lv_disp_get_hor_res(disp) * sizeof(lv_color_t), LV_DISP_RENDER_MODE_DIRECT);
|
lv_disp_get_hor_res(disp) * lv_disp_get_hor_res(disp) * sizeof(lv_color_t), LV_DISP_RENDER_MODE_DIRECT);
|
||||||
|
#endif
|
||||||
lv_disp_add_event(disp, res_chg_event_cb, LV_EVENT_RESOLUTION_CHANGED, NULL);
|
lv_disp_add_event(disp, res_chg_event_cb, LV_EVENT_RESOLUTION_CHANGED, NULL);
|
||||||
|
|
||||||
return disp;
|
return disp;
|
||||||
@@ -131,6 +140,22 @@ static void flush_cb(lv_disp_t * disp, const lv_area_t * area, lv_color_t * colo
|
|||||||
LV_UNUSED(area);
|
LV_UNUSED(area);
|
||||||
LV_UNUSED(color_p);
|
LV_UNUSED(color_p);
|
||||||
|
|
||||||
|
#if LV_SDL_PARTIAL_MODE
|
||||||
|
int32_t y;
|
||||||
|
uint32_t w = lv_area_get_width(area);
|
||||||
|
lv_sdl_window_t * dsc = lv_disp_get_driver_data(disp);
|
||||||
|
lv_coord_t hor_res = lv_disp_get_hor_res(disp);
|
||||||
|
lv_color_t * fb_tmp = dsc->fb;
|
||||||
|
fb_tmp += area->y1 * hor_res;
|
||||||
|
fb_tmp += area->x1;
|
||||||
|
for(y = area->y1; y <= area->y2; y++) {
|
||||||
|
lv_memcpy(fb_tmp, color_p, w * sizeof(lv_color_t));
|
||||||
|
color_p += w;
|
||||||
|
fb_tmp += hor_res;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* TYPICALLY YOU DO NOT NEED THIS
|
/* TYPICALLY YOU DO NOT NEED THIS
|
||||||
* If it was the last part to refresh update the texture of the window.*/
|
* If it was the last part to refresh update the texture of the window.*/
|
||||||
if(lv_disp_flush_is_last(disp)) {
|
if(lv_disp_flush_is_last(disp)) {
|
||||||
@@ -238,8 +263,10 @@ static void texture_resize(lv_disp_t * disp)
|
|||||||
lv_sdl_window_t * dsc = lv_disp_get_driver_data(disp);
|
lv_sdl_window_t * dsc = lv_disp_get_driver_data(disp);
|
||||||
|
|
||||||
dsc->fb = (lv_color_t *)realloc(dsc->fb, sizeof(lv_color_t) * hor_res * ver_res);
|
dsc->fb = (lv_color_t *)realloc(dsc->fb, sizeof(lv_color_t) * hor_res * ver_res);
|
||||||
lv_disp_set_draw_buffers(disp, dsc->fb, NULL, hor_res * ver_res * sizeof(lv_color_t), LV_DISP_RENDER_MODE_DIRECT);
|
|
||||||
|
|
||||||
|
#if LV_SDL_PARTIAL_MODE == 0
|
||||||
|
lv_disp_set_draw_buffers(disp, dsc->fb, NULL, hor_res * ver_res * sizeof(lv_color_t), LV_DISP_RENDER_MODE_DIRECT);
|
||||||
|
#endif
|
||||||
if(dsc->texture) SDL_DestroyTexture(dsc->texture);
|
if(dsc->texture) SDL_DestroyTexture(dsc->texture);
|
||||||
|
|
||||||
#if LV_COLOR_DEPTH == 32
|
#if LV_COLOR_DEPTH == 32
|
||||||
|
|||||||
@@ -2504,6 +2504,13 @@
|
|||||||
#define LV_SDL_INCLUDE_PATH <SDL2/SDL.h>
|
#define LV_SDL_INCLUDE_PATH <SDL2/SDL.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef LV_SDL_PARTIAL_MODE
|
||||||
|
#ifdef CONFIG_LV_SDL_PARTIAL_MODE
|
||||||
|
#define LV_SDL_PARTIAL_MODE CONFIG_LV_SDL_PARTIAL_MODE
|
||||||
|
#else
|
||||||
|
#define LV_SDL_PARTIAL_MODE 0 /*Recommended only to emulate a setup with a display controller*/
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*Driver for /dev/fb*/
|
/*Driver for /dev/fb*/
|
||||||
|
|||||||
Reference in New Issue
Block a user