LVGL can't show camara buffer smoothly for high cpu usage

MCU: NXP MIMXRT1176DVMAA, with a MIPI 480x640 screen
LVGL version:8.3.2

It seems that MIPI screen doesn’t support partial refresh mode.The cpu usage is 99% even there are only some simple objects(two buttons,one label) on the screen.
Then I found the most time-consuming code is the function refr_area_part:

refr_invalid_areas
	refr_area
		refr_area_part(full_refresh == 1 branch)
refr_area_part
{
    ......
    else {
        /*Refresh the previous screen if any*/
        if(disp_refr->prev_scr) {
            if(top_prev_scr == NULL) top_prev_scr = disp_refr->prev_scr;
            refr_obj_and_children(draw_ctx, top_prev_scr); /* not executed */
        }

        if(top_act_scr == NULL) top_act_scr = disp_refr->act_scr;
        /* take up to 600ms! */
        refr_obj_and_children(draw_ctx, top_act_scr);
    }
    /*Also refresh top and sys layer unconditionally*/
    /* take up to 100ms! */
    refr_obj_and_children(draw_ctx, lv_disp_get_layer_top(disp_refr));
    refr_obj_and_children(draw_ctx, lv_disp_get_layer_sys(disp_refr));
    draw_buf_flush(disp_refr);
}

But I’ve no idea to optimize this code.Then I’ve set every relevant param(such as LV_MEM_SIZE ,LV_MEM_BUF_MAX_NUM ,LV_LAYER_SIMPLE_BUF_SIZE ,LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE…) as big as possible,but doesn’t work.

Finally,the CPU usage decrease to 50% if I set the GCC optimized flag to -O3(still too big?only 8 imagebuttons and labels).
Now I wan’t to show the camera buffer from MIPI CSI to a canvas,and the cpu usage reachs to 99% again.The display is very sluggish.

Do you have any suggestions to optimize the cpu usage further?
Thanks.

does the display you are using have GRAM in it. The fact that it doesn’t support a partial update to the display makes me think that you have to do a full refresh and it has to be done all the time because of the lack of memory on the display.

are you using double buffering with DMA memory? This would greatly improve the speed because as one buffer is being written LVGL can be filling the other.

The display you are using also has a pretty sizeable resolution. the buffer that has to get filled if using 16 bit color is 480 * 640 * 2 = 614,400 bytes. If it is using 32 bit color double that size.

The MCU you are using has 2 cores and one of the cores runs at 400mhz and the other at 1ghz. is your code running on the slower core?

The MCU also has a 2D graphics accelerator, are you using it? if not you need to set LV_USE_GPU_ARM2D in your LVGL config file.

Sorry for late reply.
I’ve enabled all you mentioned,but doesn’t work.

in the NXP SDK example,double buffer is defined as below:

static uint8_t s_frameBuffer[2][DEMO_FB_SIZE];
lv_disp_draw_buf_init(&disp_buf, s_frameBuffer[0], s_frameBuffer[1], 480*640);

But the DEMO_FB_SIZE is too big which is 480x640x2,so I have to place the variable to SDRAM.It seems external ram leads to high cpu usage.
I don’t know why the buffer should be so high.But if I decrease the buffer size, the screen doesn’t display correctly.Is it due to full-refresh mode?

if you have the display set to full refresh then the entire screen is being redrawn each time an update occurs. You display needs to support partial mode where you have the ability to only update a small area of the screen instead of the whole thing. If the display has the ability to set the page then you have the ability to do partial mode.