1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

optmize lv_canvas_fill_bg

This commit is contained in:
Gabor Kiss-Vamosi 2020-03-31 12:14:28 +02:00
parent 8f81a04ffb
commit 858c21d999

View File

@ -147,7 +147,6 @@ void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_
ext->dsc.header.w = w;
ext->dsc.header.h = h;
ext->dsc.data = buf;
ext->dsc.data_size = (lv_img_cf_get_px_size(cf) * w * h) / 8;
lv_img_set_src(canvas, &ext->dsc);
}
@ -652,13 +651,25 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa)
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
uint32_t x;
uint32_t y;
for(y = 0; y < dsc->header.h; y++) {
for(x = 0; x < dsc->header.w; x++) {
lv_img_buf_set_px_color(dsc, x, y, color);
lv_img_buf_set_px_alpha(dsc, x, y, opa);
}
if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
uint32_t row_byte_cnt = (dsc->header.w + 7) >> 3;
/*+8 skip the palette*/
lv_memset((uint8_t*)dsc->data + 8, color.full ? 0xff : 0x00, row_byte_cnt * dsc->header.h);
}
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
uint32_t row_byte_cnt = (dsc->header.w + 7) >> 3;
lv_memset((uint8_t*)dsc->data, opa > LV_OPA_50 ? 0xff : 0x00, row_byte_cnt * dsc->header.h);
}
else
{
uint32_t x;
uint32_t y;
for(y = 0; y < dsc->header.h; y++) {
for(x = 0; x < dsc->header.w; x++) {
lv_img_buf_set_px_color(dsc, x, y, color);
lv_img_buf_set_px_alpha(dsc, x, y, opa);
}
}
}
lv_obj_invalidate(canvas);