Howto increase drawing performance on a canvas

When drawing on a canvas an with evdev input device, there are missing many events. On quick changes of coordinates, many pixels are skipped. Interpolation between two registered events is not allowed in this use-case.

What MCU/Processor/Board and compiler are you using?

Linux on PC

What LVGL version are you using?


What do you want to achieve?

Draw every pixel, that is triggered.

What have you tried so far?

Drawing rectangles has better performance than drawing pixels on the canvas. Drawing lines, (interpolating) between two registered points (lv_point_t) works fine, but I am looking for an alternative to increase real throughput, i.e. draw EVERY pixel without interpolating. With the rect_dsc it works okayish on the canvas, but many pixels are not drawn on fast motions (35% CPU usage).

Code to reproduce

    static void draw_signal(lv_event_t* e){
        lv_event_code_t code = lv_event_get_code(e);

        lv_obj_get_coords(canvas, canvas_coords);

        if(code == LV_EVENT_PRESSING) {

            lv_indev_t *indev = lv_indev_get_act();

            lv_indev_get_point(indev, p);
            p1.x = p.x-canvas_coords.x1;
            p1.y = p.y-canvas_coords.y1;
            lv_canvas_draw_rect(canvas, p1.x, p1.y, 5, 10, rect);

static lv_point_t p1, p2;
static lv_draw_rect_dsc_t rect;
static lv_area_t canvas_coords; 
static lv_obj_t* canvas = lv_canvas_create(cont);
rect.radius = 10;
rect.bg_color = lv_color_white();
rect.border_width = 0;

 lv_canvas_set_buffer(canvas, scbuf, 500, 400, LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED);
lv_obj_add_flag(canvas, LV_OBJ_FLAG_CLICKABLE);
lv_obj_add_event_cb(canvas, draw_signal, LV_EVENT_PRESSING, NULL);

Does anybody have tips ?

Hai @H_Schwarz

I am also looking for a solution to similar usecase. Were you able to solve your issue? If yes. Could you please post your solution.

Thank you in advance.