mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
2f3e8d4066
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
57 lines
1.6 KiB
C
57 lines
1.6 KiB
C
#include "../../lv_examples.h"
|
|
#if LV_USE_CANVAS && LV_BUILD_EXAMPLES
|
|
|
|
#if LV_USE_VECTOR_GRAPHIC
|
|
|
|
#define CANVAS_WIDTH 150
|
|
#define CANVAS_HEIGHT 150
|
|
|
|
/**
|
|
* Draw a path to the canvas
|
|
*/
|
|
void lv_example_canvas_8(void)
|
|
{
|
|
/*Create a buffer for the canvas*/
|
|
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_ARGB8888);
|
|
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
|
lv_obj_center(canvas);
|
|
|
|
lv_layer_t layer;
|
|
lv_canvas_init_layer(canvas, &layer);
|
|
|
|
lv_vector_dsc_t * dsc = lv_vector_dsc_create(&layer);
|
|
lv_vector_path_t * path = lv_vector_path_create(LV_VECTOR_PATH_QUALITY_MEDIUM);
|
|
|
|
lv_fpoint_t pts[] = {{10, 10}, {130, 130}, {10, 130}};
|
|
lv_vector_path_move_to(path, &pts[0]);
|
|
lv_vector_path_line_to(path, &pts[1]);
|
|
lv_vector_path_line_to(path, &pts[2]);
|
|
lv_vector_path_close(path);
|
|
|
|
lv_vector_dsc_set_fill_color(dsc, lv_color_make(0x00, 0x80, 0xff));
|
|
lv_vector_dsc_add_path(dsc, path);
|
|
|
|
lv_draw_vector(dsc);
|
|
lv_vector_path_delete(path);
|
|
lv_vector_dsc_delete(dsc);
|
|
|
|
lv_canvas_finish_layer(canvas, &layer);
|
|
}
|
|
#else
|
|
|
|
void lv_example_canvas_8(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);
|
|
}
|
|
|
|
#endif /*LV_USE_VECTOR_GRAPHIC*/
|
|
|
|
#endif
|