feat(draw): add initial SDL renderer
It caches SW rendered bitmaps in textures. The cache is also updated to support data and source separately. E.g. source is a path to an image, and if that image changes all related cache entries needs to found and invalidated. Limitations of SDL rederer: - not all draw task types are supported - image transformation is not supported - some textures (e.g. button matrix texts) are not detected as cached - images are not cached - images are supported only from path
This commit is contained in:
@@ -26,11 +26,11 @@ void lv_example_canvas_1(void)
|
||||
lv_draw_label_dsc_init(&label_dsc);
|
||||
label_dsc.color = lv_palette_main(LV_PALETTE_ORANGE);
|
||||
label_dsc.text = "Some text on text canvas";
|
||||
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
||||
/*Create a buffer for the canvas*/
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE(CANVAS_WIDTH, CANVAS_HEIGHT, 16, LV_DRAW_BUF_STRIDE_ALIGN)];
|
||||
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_NATIVE);
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_RGB565);
|
||||
lv_obj_center(canvas);
|
||||
lv_canvas_fill_bg(canvas, lv_palette_lighten(LV_PALETTE_GREY, 3), LV_OPA_COVER);
|
||||
|
||||
@@ -47,11 +47,18 @@ void lv_example_canvas_1(void)
|
||||
|
||||
/*Test the rotation. It requires another buffer where the original image is stored.
|
||||
*So copy the current image to buffer and rotate it to the canvas*/
|
||||
static uint8_t cbuf_tmp[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
||||
static uint8_t cbuf_tmp[LV_CANVAS_BUF_SIZE(CANVAS_WIDTH, CANVAS_HEIGHT, 32, LV_DRAW_BUF_STRIDE_ALIGN)];
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
lv_memcpy(cbuf_tmp, cbuf, sizeof(cbuf_tmp));
|
||||
lv_image_dsc_t img;
|
||||
img.data = (void *)cbuf_tmp;
|
||||
img.header.cf = LV_COLOR_FORMAT_NATIVE;
|
||||
img.header.cf = LV_COLOR_FORMAT_ARGB8888;
|
||||
img.header.w = CANVAS_WIDTH;
|
||||
img.header.h = CANVAS_HEIGHT;
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
void lv_example_canvas_3(void)
|
||||
{
|
||||
/*Create a buffer for the canvas*/
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE(CANVAS_WIDTH, CANVAS_HEIGHT, 32, LV_DRAW_BUF_STRIDE_ALIGN)];
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_NATIVE);
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
void lv_example_canvas_4(void)
|
||||
{
|
||||
/*Create a buffer for the canvas*/
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE(CANVAS_WIDTH, CANVAS_HEIGHT, 32, LV_DRAW_BUF_STRIDE_ALIGN)];
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_NATIVE);
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
void lv_example_canvas_5(void)
|
||||
{
|
||||
/*Create a buffer for the canvas*/
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE(CANVAS_WIDTH, CANVAS_HEIGHT, 32, LV_DRAW_BUF_STRIDE_ALIGN)];
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_NATIVE);
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
void lv_example_canvas_6(void)
|
||||
{
|
||||
/*Create a buffer for the canvas*/
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE(CANVAS_WIDTH, CANVAS_HEIGHT, 32, LV_DRAW_BUF_STRIDE_ALIGN)];
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_NATIVE);
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
void lv_example_canvas_7(void)
|
||||
{
|
||||
/*Create a buffer for the canvas*/
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE(CANVAS_WIDTH, CANVAS_HEIGHT, 32, LV_DRAW_BUF_STRIDE_ALIGN)];
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_NATIVE);
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
void lv_example_canvas_8(void)
|
||||
{
|
||||
/*Create a buffer for the canvas*/
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE(CANVAS_WIDTH, CANVAS_HEIGHT, 32, LV_DRAW_BUF_STRIDE_ALIGN)];
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_NATIVE);
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user