From 114994fa8cbd1e340f4f52ef36a6fc89edee8103 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 9 Feb 2020 10:48:34 +0100 Subject: [PATCH] various draw speed improvments --- src/lv_core/lv_obj.c | 7 +- src/lv_core/lv_refr.c | 8 +- src/lv_draw/lv_draw_label.c | 5 + src/lv_draw/lv_draw_line.c | 2 +- src/lv_draw/lv_draw_rect.c | 47 ++- src/lv_objx/lv_btnm.c | 51 ++- src/lv_objx/lv_chart.c | 2 +- src/lv_objx/lv_page.c | 129 ++++--- src/lv_objx/lv_tabview.c | 7 +- src/lv_themes/lv_theme_alien.c | 2 +- tests/lv_test_assert.c | 678 ++++++++++++++++----------------- 11 files changed, 491 insertions(+), 447 deletions(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 904b3647f..7aeda3e61 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -2072,7 +2072,7 @@ lv_style_int_t lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_style case LV_STYLE_BORDER_SIDE: return LV_BORDER_SIDE_FULL; case LV_STYLE_SIZE: - return LV_DPI / 10; + return LV_DPI / 20; case LV_STYLE_SCALE_WIDTH: return LV_DPI / 8; case LV_STYLE_BG_GRAD_STOP: @@ -2874,11 +2874,10 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area if(lv_obj_get_style_clip_corner(obj, LV_OBJ_PART_MAIN)) return LV_DESIGN_RES_MASKED; + if(lv_obj_get_style_bg_opa(obj, LV_OBJ_PART_MAIN) < LV_OPA_MAX) return LV_DESIGN_RES_NOT_COVER; + if(lv_obj_get_style_bg_blend_mode(obj, LV_OBJ_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DESIGN_RES_NOT_COVER; if(lv_obj_get_style_border_blend_mode(obj, LV_OBJ_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DESIGN_RES_NOT_COVER; - - /*Can cover the area only if fully solid (no opacity)*/ - if(lv_obj_get_style_bg_opa(obj, LV_OBJ_PART_MAIN) < LV_OPA_MAX) return LV_DESIGN_RES_NOT_COVER; if(lv_obj_get_style_opa_scale(obj, LV_OBJ_PART_MAIN) < LV_OPA_MAX) return LV_DESIGN_RES_NOT_COVER; return LV_DESIGN_RES_COVER; diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index fd2c053f1..d16b2a03e 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -433,7 +433,7 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj) /*If this object is fully cover the draw area check the children too */ if(lv_area_is_in(area_p, &obj->coords, 0) && obj->hidden == 0) { - lv_design_res_t design_res = obj->design_cb(obj, area_p, LV_DESIGN_COVER_CHK); + lv_design_res_t design_res = obj->design_cb ? obj->design_cb(obj, area_p, LV_DESIGN_COVER_CHK) : LV_DESIGN_RES_NOT_COVER; if(design_res == LV_DESIGN_RES_MASKED) return NULL; lv_obj_t * i; @@ -491,7 +491,7 @@ static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p) } /*Call the post draw design function of the parents of the to object*/ - par->design_cb(par, mask_p, LV_DESIGN_DRAW_POST); + if(par->design_cb) par->design_cb(par, mask_p, LV_DESIGN_DRAW_POST); /*The new border will be there last parents, *so the 'younger' brothers of parent will be refreshed*/ @@ -529,7 +529,7 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p) if(union_ok != false) { /* Redraw the object */ - obj->design_cb(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN); + if(obj->design_cb) obj->design_cb(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN); #if MASK_AREA_DEBUG static lv_color_t debug_color = LV_COLOR_RED; @@ -576,7 +576,7 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p) } /* If all the children are redrawn make 'post draw' design */ - obj->design_cb(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST); + if(obj->design_cb) obj->design_cb(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST); } } diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 4654dff28..3249250a0 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -89,6 +89,11 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab /*No need to waste processor time if string is empty*/ if (txt[0] == '\0') return; + lv_area_t clipped_area; + bool clip_ok = lv_area_intersect(&clipped_area, coords, mask); + if(!clip_ok) return; + + if((dsc->flag & LV_TXT_FLAG_EXPAND) == 0) { /*Normally use the label's width as width*/ w = lv_area_get_width(coords); diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index 319806bee..54290775f 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -1,4 +1,4 @@ -/**lip +/** * @file lv_draw_line.c * */ diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 1404b9960..a5dc56a44 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -170,7 +170,7 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re uint16_t other_mask_cnt = lv_draw_mask_get_cnt(); bool simple_mode = true; if(other_mask_cnt) simple_mode = false; - else if(dsc->bg_grad_dir != LV_GRAD_DIR_NONE) simple_mode = false; + else if(dsc->bg_grad_dir == LV_GRAD_DIR_HOR) simple_mode = false; int16_t mask_rout_id = LV_MASK_ID_INV; @@ -264,21 +264,23 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re int32_t mask_ofs = (coords_bg.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); if(mask_ofs < 0) mask_ofs = 0; lv_blend_fill(clip, &fill_area2, - grad_color, mask_buf + mask_ofs, mask_res, opa, dsc->bg_blend_mode); + grad_color, mask_buf + mask_ofs, mask_res, opa, dsc->bg_blend_mode); } else { - if(grad_map == NULL) { + if(dsc->bg_grad_dir == LV_GRAD_DIR_HOR) { + lv_blend_map(clip, &fill_area, grad_map, mask_buf, mask_res, opa, dsc->bg_blend_mode); + } else if(dsc->bg_grad_dir == LV_GRAD_DIR_VER) { lv_blend_fill(clip, &fill_area, grad_color,mask_buf, mask_res, opa, dsc->bg_blend_mode); - } else { - lv_blend_map(clip, &fill_area, grad_map, mask_buf, mask_res, opa, dsc->bg_blend_mode); + } else if(other_mask_cnt != 0) { + lv_blend_fill(clip, &fill_area, + grad_color,mask_buf, mask_res, opa, dsc->bg_blend_mode); } - } fill_area.y1++; fill_area.y2++; } - if(simple_mode) { + if(dsc->bg_grad_dir == LV_GRAD_DIR_NONE && other_mask_cnt == 0) { lv_area_t fill_area; /*Central part*/ fill_area.x1 = coords_bg.x1 + rout; @@ -287,13 +289,21 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re fill_area.y2 = coords_bg.y1 + rout; lv_blend_fill(clip, &fill_area, - grad_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode); + dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode); fill_area.y1 = coords_bg.y2 - rout; fill_area.y2 = coords_bg.y2; lv_blend_fill(clip, &fill_area, - grad_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode); + dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode); + + fill_area.x1 = coords_bg.x1; + fill_area.x2 = coords_bg.x2; + fill_area.y1 = coords_bg.y1 + rout + 1; + fill_area.y2 = coords_bg.y2 - rout - 1; + + lv_blend_fill(clip, &fill_area, + dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode); } @@ -339,10 +349,10 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra /*Create a mask if there is a radius*/ lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w); + uint8_t other_mask_cnt = lv_draw_mask_get_cnt(); bool simple_mode = true; - if(lv_draw_mask_get_cnt()!= 0) simple_mode = false; + if(other_mask_cnt) simple_mode = false; else if(dsc->border_side != LV_BORDER_SIDE_FULL) simple_mode = false; - else if(dsc->bg_grad_dir == LV_GRAD_DIR_HOR) simple_mode = false; int16_t mask_rout_id = LV_MASK_ID_INV; @@ -361,7 +371,6 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); } - /*Get the inner radius*/ int32_t rin = rout - dsc->border_width; if(rin < 0) rin = 0; @@ -485,12 +494,18 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra fill_area.x2 = coords->x2; fill_area.y1 = disp_area->y1 + draw_area.y1; fill_area.y2 = fill_area.y1; + + if(dsc->border_side == LV_BORDER_SIDE_LEFT) fill_area.x2 = coords->x1 + rout; + else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) fill_area.x1 = coords->x2 - rout; + for(h = draw_area.y1; h <= draw_area.y2; h++) { - memset(mask_buf, LV_OPA_COVER, draw_area_w); - mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); - - lv_blend_fill( clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode); + if((dsc->border_side == LV_BORDER_SIDE_BOTTOM && fill_area.y1 >= coords->y2 - rout - 1) || + (dsc->border_side == LV_BORDER_SIDE_TOP && fill_area.y1 <= coords->y1 + rout + 1)) { + memset(mask_buf, LV_OPA_COVER, draw_area_w); + mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); + lv_blend_fill( clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode); + } fill_area.y1++; fill_area.y2++; diff --git a/src/lv_objx/lv_btnm.c b/src/lv_objx/lv_btnm.c index 9977c0645..0e42a7c00 100644 --- a/src/lv_objx/lv_btnm.c +++ b/src/lv_objx/lv_btnm.c @@ -587,8 +587,9 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar else if(mode == LV_DESIGN_DRAW_MAIN) { ancestor_design_f(btnm, clip_area, mode); - lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); + lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); + if(ext->btn_cnt == 0) return LV_DESIGN_RES_OK; lv_area_t area_btnm; lv_obj_get_coords(btnm, &area_btnm); @@ -599,6 +600,7 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar uint16_t btn_i = 0; uint16_t txt_i = 0; lv_txt_flag_t txt_flag = LV_TXT_FLAG_NONE; + if(ext->recolor) txt_flag = LV_TXT_FLAG_RECOLOR; lv_draw_rect_dsc_t draw_rect_rel_dsc; lv_draw_label_dsc_t draw_label_rel_dsc; @@ -614,7 +616,6 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar /*The state changes without re-caching the styles, disable the use of cache*/ - lv_obj_state_dsc_t state = btnm->state_dsc; lv_obj_state_dsc_t state_ori = btnm->state_dsc; btnm->state_dsc.act = LV_OBJ_STATE_NORMAL; btnm->state_dsc.prev = btnm->state_dsc.act; @@ -622,27 +623,15 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar lv_draw_label_dsc_init(&draw_label_rel_dsc); lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_PART_BTN, &draw_rect_rel_dsc); lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_rel_dsc); - - btnm->state_dsc.act = LV_OBJ_STATE_CHECKED; - btnm->state_dsc.prev = btnm->state_dsc.act; - lv_draw_rect_dsc_init(&draw_rect_chk_dsc); - lv_draw_label_dsc_init(&draw_label_chk_dsc); - lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_PART_BTN, &draw_rect_chk_dsc); - lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_chk_dsc); - - btnm->state_dsc.act = LV_OBJ_STATE_DISABLED; - btnm->state_dsc.prev = btnm->state_dsc.act; - lv_draw_rect_dsc_init(&draw_rect_ina_dsc); - lv_draw_label_dsc_init(&draw_label_ina_dsc); - lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_PART_BTN, &draw_rect_ina_dsc); - lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_ina_dsc); - + draw_label_rel_dsc.flag = txt_flag; btnm->state_dsc = state_ori; + bool chk_inited = false; + bool disabled_inited = false; + lv_style_int_t padding_top = lv_obj_get_style_pad_top(btnm, LV_BTNM_PART_BG); lv_style_int_t padding_bottom = lv_obj_get_style_pad_bottom(btnm, LV_BTNM_PART_BG); - if(ext->recolor) txt_flag = LV_TXT_FLAG_RECOLOR; for(btn_i = 0; btn_i < ext->btn_cnt; btn_i++, txt_i++) { /*Search the next valid text in the map*/ while(strcmp(ext->map_p[txt_i], "\n") == 0) { @@ -666,7 +655,32 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar lv_draw_label_dsc_t * draw_label_dsc_act; bool tgl_state = button_get_tgl_state(ext->ctrl_bits[btn_i]); + if(tgl_state) { + if(!chk_inited) { + btnm->state_dsc.act = LV_OBJ_STATE_CHECKED; + btnm->state_dsc.prev = btnm->state_dsc.act; + lv_draw_rect_dsc_init(&draw_rect_chk_dsc); + lv_draw_label_dsc_init(&draw_label_chk_dsc); + lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_PART_BTN, &draw_rect_chk_dsc); + lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_chk_dsc); + draw_label_chk_dsc.flag = txt_flag; + btnm->state_dsc = state_ori; + chk_inited = true; + } + } + if(button_is_inactive(ext->ctrl_bits[btn_i])) { + if(!disabled_inited) { + btnm->state_dsc.act = LV_OBJ_STATE_DISABLED; + btnm->state_dsc.prev = btnm->state_dsc.act; + lv_draw_rect_dsc_init(&draw_rect_ina_dsc); + lv_draw_label_dsc_init(&draw_label_ina_dsc); + lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_PART_BTN, &draw_rect_ina_dsc); + lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_ina_dsc); + draw_label_ina_dsc.flag = txt_flag; + btnm->state_dsc = state_ori; + disabled_inited = true; + } draw_rect_dsc_act = &draw_rect_ina_dsc; draw_label_dsc_act = &draw_label_ina_dsc; } @@ -687,6 +701,7 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar lv_draw_label_dsc_init(&draw_label_tmp_dsc); lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_PART_BTN, &draw_rect_tmp_dsc); lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_tmp_dsc); + draw_label_tmp_dsc.flag = txt_flag; draw_rect_dsc_act = &draw_rect_tmp_dsc; draw_label_dsc_act = &draw_label_tmp_dsc; diff --git a/src/lv_objx/lv_chart.c b/src/lv_objx/lv_chart.c index 05086f05c..690fcf408 100644 --- a/src/lv_objx/lv_chart.c +++ b/src/lv_objx/lv_chart.c @@ -806,7 +806,7 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co point_dsc.bg_opa = line_dsc.opa; point_dsc.radius = LV_RADIUS_CIRCLE; - lv_coord_t point_radius = lv_obj_get_style_radius(chart, LV_CHART_PART_SERIES); + lv_coord_t point_radius = lv_obj_get_style_size(chart, LV_CHART_PART_SERIES); /*Go through all data lines*/ LV_LL_READ_BACK(ext->series_ll, ser) diff --git a/src/lv_objx/lv_page.c b/src/lv_objx/lv_page.c index 65355597d..8f3d44395 100644 --- a/src/lv_objx/lv_page.c +++ b/src/lv_objx/lv_page.c @@ -648,76 +648,81 @@ static lv_design_res_t lv_page_design(lv_obj_t * page, const lv_area_t * clip_ar return ancestor_design(page, clip_area, mode); } else if(mode == LV_DESIGN_DRAW_POST) { ancestor_design(page, clip_area, mode); - - /*Draw the scrollbars*/ lv_page_ext_t * ext = lv_obj_get_ext_attr(page); - lv_draw_rect_dsc_t rect_dsc; - lv_draw_rect_dsc_init(&rect_dsc); - lv_obj_init_draw_rect_dsc(page, LV_PAGE_PART_SCRLBAR, &rect_dsc); - lv_area_t sb_area; - if(ext->sb.hor_draw && (ext->sb.mode & LV_SB_MODE_HIDE) == 0) { - /*Convert the relative coordinates to absolute*/ - lv_area_copy(&sb_area, &ext->sb.hor_area); - sb_area.x1 += page->coords.x1; - sb_area.y1 += page->coords.y1; - sb_area.x2 += page->coords.x1; - sb_area.y2 += page->coords.y1; - lv_draw_rect(&sb_area, clip_area, &rect_dsc); - } - if(ext->sb.ver_draw && (ext->sb.mode & LV_SB_MODE_HIDE) == 0) { - /*Convert the relative coordinates to absolute*/ - lv_area_copy(&sb_area, &ext->sb.ver_area); - sb_area.x1 += page->coords.x1; - sb_area.y1 += page->coords.y1; - sb_area.x2 += page->coords.x1; - sb_area.y2 += page->coords.y1; - lv_draw_rect(&sb_area, clip_area, &rect_dsc); - } + lv_area_t sb_hor_area; + lv_area_t sb_ver_area; + sb_hor_area.x1 += page->coords.x1; + sb_hor_area.y1 += page->coords.y1; + sb_hor_area.x2 += page->coords.x1; + sb_hor_area.y2 += page->coords.y1; + + sb_ver_area.x1 += page->coords.x1; + sb_ver_area.y1 += page->coords.y1; + sb_ver_area.x2 += page->coords.x1; + sb_ver_area.y2 += page->coords.y1; + + if((ext->sb.hor_draw || ext->sb.ver_draw) && + (lv_area_is_in(clip_area, &sb_hor_area, 0) || lv_area_is_in(clip_area, &sb_ver_area, 0))) { + /*Draw the scrollbars*/ + lv_draw_rect_dsc_t rect_dsc; + lv_draw_rect_dsc_init(&rect_dsc); + lv_obj_init_draw_rect_dsc(page, LV_PAGE_PART_SCRLBAR, &rect_dsc); + if(ext->sb.hor_draw && (ext->sb.mode & LV_SB_MODE_HIDE) == 0) { + /*Convert the relative coordinates to absolute*/ + lv_area_copy(&sb_hor_area, &ext->sb.hor_area); + lv_draw_rect(&sb_hor_area, clip_area, &rect_dsc); + } + + if(ext->sb.ver_draw && (ext->sb.mode & LV_SB_MODE_HIDE) == 0) { + /*Convert the relative coordinates to absolute*/ + lv_area_copy(&sb_ver_area, &ext->sb.ver_area); + lv_draw_rect(&sb_ver_area, clip_area, &rect_dsc); + } + } #if LV_USE_ANIMATION - { - lv_coord_t page_w = lv_obj_get_width(page); - lv_coord_t page_h = lv_obj_get_height(page); + { + lv_coord_t page_w = lv_obj_get_width(page); + lv_coord_t page_h = lv_obj_get_height(page); - lv_area_t flash_area; + lv_area_t flash_area; - if(ext->edge_flash.top_ip) { - flash_area.x1 = page->coords.x1 - page_w; - flash_area.x2 = page->coords.x2 + page_w; - flash_area.y1 = page->coords.y1 - 3 * page_w + ext->edge_flash.state; - flash_area.y2 = page->coords.y1 + ext->edge_flash.state; - } else if(ext->edge_flash.bottom_ip) { - flash_area.x1 = page->coords.x1 - page_w; - flash_area.x2 = page->coords.x2 + page_w; - flash_area.y1 = page->coords.y2 - ext->edge_flash.state; - flash_area.y2 = page->coords.y2 + 3 * page_w - ext->edge_flash.state; - } else if(ext->edge_flash.right_ip) { - flash_area.x1 = page->coords.x2 - ext->edge_flash.state; - flash_area.x2 = page->coords.x2 + 3 * page_h - ext->edge_flash.state; - flash_area.y1 = page->coords.y1 - page_h; - flash_area.y2 = page->coords.y2 + page_h; - } else if(ext->edge_flash.left_ip) { - flash_area.x1 = page->coords.x1 - 3 * page_h + ext->edge_flash.state; - flash_area.x2 = page->coords.x1 + ext->edge_flash.state; - flash_area.y1 = page->coords.y1 - page_h; - flash_area.y2 = page->coords.y2 + page_h; - } - - if(ext->edge_flash.left_ip || ext->edge_flash.right_ip || ext->edge_flash.top_ip || - ext->edge_flash.bottom_ip) { - lv_draw_rect_dsc_t edge_draw_dsc; - lv_draw_rect_dsc_init(&edge_draw_dsc); - lv_obj_init_draw_rect_dsc(page, LV_PAGE_PART_EDGE_FLASH, &edge_draw_dsc); - edge_draw_dsc.radius = LV_RADIUS_CIRCLE; - uint32_t opa = (edge_draw_dsc.bg_opa * ext->edge_flash.state) / LV_PAGE_END_FLASH_SIZE; - edge_draw_dsc.bg_opa = opa; - lv_draw_rect(&flash_area, clip_area, &edge_draw_dsc); - } - } + if(ext->edge_flash.top_ip) { + flash_area.x1 = page->coords.x1 - page_w; + flash_area.x2 = page->coords.x2 + page_w; + flash_area.y1 = page->coords.y1 - 3 * page_w + ext->edge_flash.state; + flash_area.y2 = page->coords.y1 + ext->edge_flash.state; + } else if(ext->edge_flash.bottom_ip) { + flash_area.x1 = page->coords.x1 - page_w; + flash_area.x2 = page->coords.x2 + page_w; + flash_area.y1 = page->coords.y2 - ext->edge_flash.state; + flash_area.y2 = page->coords.y2 + 3 * page_w - ext->edge_flash.state; + } else if(ext->edge_flash.right_ip) { + flash_area.x1 = page->coords.x2 - ext->edge_flash.state; + flash_area.x2 = page->coords.x2 + 3 * page_h - ext->edge_flash.state; + flash_area.y1 = page->coords.y1 - page_h; + flash_area.y2 = page->coords.y2 + page_h; + } else if(ext->edge_flash.left_ip) { + flash_area.x1 = page->coords.x1 - 3 * page_h + ext->edge_flash.state; + flash_area.x2 = page->coords.x1 + ext->edge_flash.state; + flash_area.y1 = page->coords.y1 - page_h; + flash_area.y2 = page->coords.y2 + page_h; + } + if(ext->edge_flash.left_ip || ext->edge_flash.right_ip || ext->edge_flash.top_ip || + ext->edge_flash.bottom_ip) { + lv_draw_rect_dsc_t edge_draw_dsc; + lv_draw_rect_dsc_init(&edge_draw_dsc); + lv_obj_init_draw_rect_dsc(page, LV_PAGE_PART_EDGE_FLASH, &edge_draw_dsc); + edge_draw_dsc.radius = LV_RADIUS_CIRCLE; + uint32_t opa = (edge_draw_dsc.bg_opa * ext->edge_flash.state) / LV_PAGE_END_FLASH_SIZE; + edge_draw_dsc.bg_opa = opa; + lv_draw_rect(&flash_area, clip_area, &edge_draw_dsc); + } + } #endif - } + } return LV_DESIGN_RES_OK; } diff --git a/src/lv_objx/lv_tabview.c b/src/lv_objx/lv_tabview.c index 6f2fd31c8..7f0e6dbb1 100644 --- a/src/lv_objx/lv_tabview.c +++ b/src/lv_objx/lv_tabview.c @@ -102,7 +102,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) /*The signal and design functions are not copied so set them here*/ lv_obj_set_signal_cb(tabview, lv_tabview_signal); - +// lv_obj_set_design_cb(tabview, NULL); /*Init the new tab tab*/ if(copy == NULL) { ext->tab_name_ptr = lv_mem_alloc(sizeof(char *)); @@ -129,6 +129,11 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) ext->btns = lv_btnm_create(tabview, NULL); ext->indic = lv_obj_create(ext->btns, NULL); +// lv_obj_set_design_cb(ext->content, NULL); +// lv_obj_set_design_cb(lv_page_get_scrl(ext->content), NULL); +// lv_obj_set_design_cb(ext->btns, NULL); +// lv_obj_set_design_cb(ext->indic, NULL); + if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(ext->content)); lv_obj_set_signal_cb(lv_page_get_scrl(ext->content), tabview_scrl_signal); diff --git a/src/lv_themes/lv_theme_alien.c b/src/lv_themes/lv_theme_alien.c index dcf1c4e1e..013f11909 100644 --- a/src/lv_themes/lv_theme_alien.c +++ b/src/lv_themes/lv_theme_alien.c @@ -134,7 +134,7 @@ static void basic_init(void) lv_style_set_bg_color(&scr, LV_STYLE_STATE_NORMAL, COLOR_SCREEN); lv_style_set_text_color(&scr, LV_STYLE_STATE_NORMAL, lv_color_hex(0xb8b8b9)); -#define PERF_TEST 3 +#define PERF_TEST 0 #if PERF_TEST == 0 lv_style_init(&panel); lv_style_set_radius(&panel, LV_STYLE_STATE_NORMAL, LV_DPI / 25); diff --git a/tests/lv_test_assert.c b/tests/lv_test_assert.c index 95f4e7615..f09b93954 100644 --- a/tests/lv_test_assert.c +++ b/tests/lv_test_assert.c @@ -1,339 +1,339 @@ -/** - * @file lv_test_assert.c - * - * Copyright 2002-2010 Guillaume Cottenceau. - * - * This software may be freely redistributed under the terms - * of the X11 license. - * - */ - -/********************* - * INCLUDES - *********************/ -#include -#include -#include -#include -#include - -#define PNG_DEBUG 3 -#include - -#include "lv_test_assert.h" -#include "../lvgl.h" - -/********************* - * DEFINES - *********************/ -#define REF_IMGS_PATH "lvgl/tests/lv_test_ref_imgs/" - -/********************** - * TYPEDEFS - **********************/ -typedef struct { - int width, height; - png_byte color_type; - png_byte bit_depth; - - png_structp png_ptr; - png_infop info_ptr; - int number_of_passes; - png_bytep * row_pointers; -}png_img_t; - -/********************** - * STATIC PROTOTYPES - **********************/ -void read_png_file(png_img_t * p, const char* file_name); -void write_png_file(png_img_t * p, const char* file_name); -void png_release(png_img_t * p); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - - -void lv_test_print(const char * s, ...) -{ - va_list args; - va_start(args, s); - vfprintf(stdout, s, args); - fprintf(stdout, "\n"); - va_end(args); -} - - -void lv_test_exit(const char * s, ...) -{ - va_list args; - va_start(args, s); - vfprintf(stderr, s, args); - fprintf(stderr, "\n"); - va_end(args); - - exit(1); -} - - -void lv_test_error(const char * s, ...) -{ - va_list args; - va_start(args, s); - vfprintf(stderr, s, args); - fprintf(stderr, "\n"); - va_end(args); - exit(1); -} - -void lv_test_assert_int_eq(int32_t n_ref, int32_t n_act, const char * s) -{ - if(n_ref != n_act) { - lv_test_error(" FAIL: %s. (Expected: %d, Actual: %d)", s, n_ref, n_act); - } else { - lv_test_print(" PASS: %s. (Expected: %d)", s, n_ref); - } -} - -void lv_test_assert_int_gt(int32_t n_ref, int32_t n_act, const char * s) -{ - if(n_act <= n_ref) { - lv_test_error(" FAIL: %s. (Expected: > %d, Actual: %d)", s, n_ref, n_act); - } else { - lv_test_print(" PASS: %s. (Expected: > %d, , Actual: %d)", s, n_ref, n_act); - } -} - -void lv_test_assert_int_lt(int32_t n_ref, int32_t n_act, const char * s) -{ - if(n_act >= n_ref) { - lv_test_error(" FAIL: %s. (Expected: < %d, Actual: %d)", s, n_ref, n_act); - } else { - lv_test_print(" PASS: %s. (Expected: < %d, , Actual: %d)", s, n_ref, n_act); - } -} - - -void lv_test_assert_str_eq(const char * s_ref, const char * s_act, const char * s) -{ - if(strcmp(s_ref, s_act) != 0) { - lv_test_error(" FAIL: %s. (Expected: %s, Actual: %s)", s, s_ref, s_act); - } else { - lv_test_print(" PASS: %s. (Expected: %s)", s, s_ref); - } -} - -void lv_test_assert_ptr_eq(const void * p_ref, const void * p_act, const char * s) -{ - if(p_ref != p_act) { - lv_test_error(" FAIL: %s. (Expected: 0x%lx, Actual: 0x%lx)", s, p_ref, p_act); - } else { - lv_test_print(" PASS: %s. (Expected: 0x%lx)", s, p_ref); - } -} - -void lv_test_assert_color_eq(lv_color_t c_ref, lv_color_t c_act, const char * s) -{ - if(c_ref.full != c_act.full) { - lv_test_error(" FAIL: %s. (Expected: R:%02x, G:%02x, B:%02x, Actual: R:%02x, G:%02x, B:%02x)", s, - c_ref.ch.red, c_ref.ch.green, c_ref.ch.blue, - c_act.ch.red, c_act.ch.green, c_act.ch.blue); - } else { - lv_test_print(" PASS: %s. (Expected: R:%02x, G:%02x, B:%02x)", s, - c_ref.ch.red, c_ref.ch.green, c_ref.ch.blue); - } -} - -void lv_test_assert_img_eq(const char * fn_ref, const char * s) -{ - char fn_ref_full[512]; - sprintf(fn_ref_full, "%s%s", REF_IMGS_PATH, fn_ref); - - png_img_t p; - read_png_file(&p, fn_ref_full); - uint8_t * screen_buf; - - lv_disp_t * disp = lv_disp_get_default(); - lv_refr_now(disp); - screen_buf = disp->driver.buffer->buf1; - - bool err = false; - int x, y, i_buf = 0; - for (y=0; ypng_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - - if (!p->png_ptr) - lv_test_exit("[read_png_file] png_create_read_struct failed"); - - p->info_ptr = png_create_info_struct(p->png_ptr); - if (!p->info_ptr) - lv_test_exit("[read_png_file] png_create_info_struct failed"); - - if (setjmp(png_jmpbuf(p->png_ptr))) - lv_test_exit("[read_png_file] Error during init_io"); - - png_init_io(p->png_ptr, fp); - png_set_sig_bytes(p->png_ptr, 8); - - png_read_info(p->png_ptr, p->info_ptr); - - p->width = png_get_image_width(p->png_ptr, p->info_ptr); - p->height = png_get_image_height(p->png_ptr, p->info_ptr); - p->color_type = png_get_color_type(p->png_ptr, p->info_ptr); - p->bit_depth = png_get_bit_depth(p->png_ptr, p->info_ptr); - - p->number_of_passes = png_set_interlace_handling(p->png_ptr); - png_read_update_info(p->png_ptr, p->info_ptr); - - - /* read file */ - if (setjmp(png_jmpbuf(p->png_ptr))) - lv_test_exit("[read_png_file] Error during read_image"); - - p->row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * p->height); - - int y; - for (y=0; yheight; y++) - p->row_pointers[y] = (png_byte*) malloc(png_get_rowbytes(p->png_ptr,p->info_ptr)); - - png_read_image(p->png_ptr, p->row_pointers); - - fclose(fp); -} - - -void write_png_file(png_img_t * p, const char* file_name) -{ - /* create file */ - FILE *fp = fopen(file_name, "wb"); - if (!fp) - lv_test_exit("[write_png_file] File %s could not be opened for writing", file_name); - - - /* initialize stuff */ - p->png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - - if (!p->png_ptr) - lv_test_exit("[write_png_file] png_create_write_struct failed"); - - p->info_ptr = png_create_info_struct(p->png_ptr); - if (!p->info_ptr) - lv_test_exit("[write_png_file] png_create_info_struct failed"); - - if (setjmp(png_jmpbuf(p->png_ptr))) - lv_test_exit("[write_png_file] Error during init_io"); - - png_init_io(p->png_ptr, fp); - - - /* write header */ - if (setjmp(png_jmpbuf(p->png_ptr))) - lv_test_exit("[write_png_file] Error during writing header"); - - png_set_IHDR(p->png_ptr, p->info_ptr, p->width, p->height, - p->bit_depth, p->color_type, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - png_write_info(p->png_ptr, p->info_ptr); - - - /* write bytes */ - if (setjmp(png_jmpbuf(p->png_ptr))) - lv_test_exit("[write_png_file] Error during writing bytes"); - - png_write_image(p->png_ptr, p->row_pointers); - - - /* end write */ - if (setjmp(png_jmpbuf(p->png_ptr))) - lv_test_exit("[write_png_file] Error during end of write"); - - png_write_end(p->png_ptr, NULL); - - fclose(fp); -} - -void png_release(png_img_t * p) -{ - int y; - for (y=0; yheight; y++) - free(p->row_pointers[y]); - free(p->row_pointers); -} - -void process_file(png_img_t * p) -{ - if (png_get_color_type(p->png_ptr, p->info_ptr) == PNG_COLOR_TYPE_RGB) - lv_test_exit("[process_file] input file is PNG_COLOR_TYPE_RGB but must be PNG_COLOR_TYPE_RGBA " - "(lacks the alpha channel)"); - - if (png_get_color_type(p->png_ptr, p->info_ptr) != PNG_COLOR_TYPE_RGBA) - lv_test_exit("[process_file] color_type of input file must be PNG_COLOR_TYPE_RGBA (%d) (is %d)", - PNG_COLOR_TYPE_RGBA, png_get_color_type(p->png_ptr, p->info_ptr)); - - int x, y; - for (y=0; yheight; y++) { - png_byte* row = p->row_pointers[y]; - for (x=0; xwidth; x++) { - png_byte* ptr = &(row[x*4]); - printf("Pixel at position [ %d - %d ] has RGBA values: %d - %d - %d - %d\n", - x, y, ptr[0], ptr[1], ptr[2], ptr[3]); - - /* set red value to 0 and green value to the blue one */ - ptr[0] = 0; - ptr[1] = ptr[2]; - } - } -} +///** +// * @file lv_test_assert.c +// * +// * Copyright 2002-2010 Guillaume Cottenceau. +// * +// * This software may be freely redistributed under the terms +// * of the X11 license. +// * +// */ +// +///********************* +// * INCLUDES +// *********************/ +//#include +//#include +//#include +//#include +//#include +// +//#define PNG_DEBUG 3 +//#include +// +//#include "lv_test_assert.h" +//#include "../lvgl.h" +// +///********************* +// * DEFINES +// *********************/ +//#define REF_IMGS_PATH "lvgl/tests/lv_test_ref_imgs/" +// +///********************** +// * TYPEDEFS +// **********************/ +//typedef struct { +// int width, height; +// png_byte color_type; +// png_byte bit_depth; +// +// png_structp png_ptr; +// png_infop info_ptr; +// int number_of_passes; +// png_bytep * row_pointers; +//}png_img_t; +// +///********************** +// * STATIC PROTOTYPES +// **********************/ +//void read_png_file(png_img_t * p, const char* file_name); +//void write_png_file(png_img_t * p, const char* file_name); +//void png_release(png_img_t * p); +// +///********************** +// * STATIC VARIABLES +// **********************/ +// +///********************** +// * MACROS +// **********************/ +// +///********************** +// * GLOBAL FUNCTIONS +// **********************/ +// +// +//void lv_test_print(const char * s, ...) +//{ +// va_list args; +// va_start(args, s); +// vfprintf(stdout, s, args); +// fprintf(stdout, "\n"); +// va_end(args); +//} +// +// +//void lv_test_exit(const char * s, ...) +//{ +// va_list args; +// va_start(args, s); +// vfprintf(stderr, s, args); +// fprintf(stderr, "\n"); +// va_end(args); +// +// exit(1); +//} +// +// +//void lv_test_error(const char * s, ...) +//{ +// va_list args; +// va_start(args, s); +// vfprintf(stderr, s, args); +// fprintf(stderr, "\n"); +// va_end(args); +// exit(1); +//} +// +//void lv_test_assert_int_eq(int32_t n_ref, int32_t n_act, const char * s) +//{ +// if(n_ref != n_act) { +// lv_test_error(" FAIL: %s. (Expected: %d, Actual: %d)", s, n_ref, n_act); +// } else { +// lv_test_print(" PASS: %s. (Expected: %d)", s, n_ref); +// } +//} +// +//void lv_test_assert_int_gt(int32_t n_ref, int32_t n_act, const char * s) +//{ +// if(n_act <= n_ref) { +// lv_test_error(" FAIL: %s. (Expected: > %d, Actual: %d)", s, n_ref, n_act); +// } else { +// lv_test_print(" PASS: %s. (Expected: > %d, , Actual: %d)", s, n_ref, n_act); +// } +//} +// +//void lv_test_assert_int_lt(int32_t n_ref, int32_t n_act, const char * s) +//{ +// if(n_act >= n_ref) { +// lv_test_error(" FAIL: %s. (Expected: < %d, Actual: %d)", s, n_ref, n_act); +// } else { +// lv_test_print(" PASS: %s. (Expected: < %d, , Actual: %d)", s, n_ref, n_act); +// } +//} +// +// +//void lv_test_assert_str_eq(const char * s_ref, const char * s_act, const char * s) +//{ +// if(strcmp(s_ref, s_act) != 0) { +// lv_test_error(" FAIL: %s. (Expected: %s, Actual: %s)", s, s_ref, s_act); +// } else { +// lv_test_print(" PASS: %s. (Expected: %s)", s, s_ref); +// } +//} +// +//void lv_test_assert_ptr_eq(const void * p_ref, const void * p_act, const char * s) +//{ +// if(p_ref != p_act) { +// lv_test_error(" FAIL: %s. (Expected: 0x%lx, Actual: 0x%lx)", s, p_ref, p_act); +// } else { +// lv_test_print(" PASS: %s. (Expected: 0x%lx)", s, p_ref); +// } +//} +// +//void lv_test_assert_color_eq(lv_color_t c_ref, lv_color_t c_act, const char * s) +//{ +// if(c_ref.full != c_act.full) { +// lv_test_error(" FAIL: %s. (Expected: R:%02x, G:%02x, B:%02x, Actual: R:%02x, G:%02x, B:%02x)", s, +// c_ref.ch.red, c_ref.ch.green, c_ref.ch.blue, +// c_act.ch.red, c_act.ch.green, c_act.ch.blue); +// } else { +// lv_test_print(" PASS: %s. (Expected: R:%02x, G:%02x, B:%02x)", s, +// c_ref.ch.red, c_ref.ch.green, c_ref.ch.blue); +// } +//} +// +//void lv_test_assert_img_eq(const char * fn_ref, const char * s) +//{ +// char fn_ref_full[512]; +// sprintf(fn_ref_full, "%s%s", REF_IMGS_PATH, fn_ref); +// +// png_img_t p; +// read_png_file(&p, fn_ref_full); +// uint8_t * screen_buf; +// +// lv_disp_t * disp = lv_disp_get_default(); +// lv_refr_now(disp); +// screen_buf = disp->driver.buffer->buf1; +// +// bool err = false; +// int x, y, i_buf = 0; +// for (y=0; ypng_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); +// +// if (!p->png_ptr) +// lv_test_exit("[read_png_file] png_create_read_struct failed"); +// +// p->info_ptr = png_create_info_struct(p->png_ptr); +// if (!p->info_ptr) +// lv_test_exit("[read_png_file] png_create_info_struct failed"); +// +// if (setjmp(png_jmpbuf(p->png_ptr))) +// lv_test_exit("[read_png_file] Error during init_io"); +// +// png_init_io(p->png_ptr, fp); +// png_set_sig_bytes(p->png_ptr, 8); +// +// png_read_info(p->png_ptr, p->info_ptr); +// +// p->width = png_get_image_width(p->png_ptr, p->info_ptr); +// p->height = png_get_image_height(p->png_ptr, p->info_ptr); +// p->color_type = png_get_color_type(p->png_ptr, p->info_ptr); +// p->bit_depth = png_get_bit_depth(p->png_ptr, p->info_ptr); +// +// p->number_of_passes = png_set_interlace_handling(p->png_ptr); +// png_read_update_info(p->png_ptr, p->info_ptr); +// +// +// /* read file */ +// if (setjmp(png_jmpbuf(p->png_ptr))) +// lv_test_exit("[read_png_file] Error during read_image"); +// +// p->row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * p->height); +// +// int y; +// for (y=0; yheight; y++) +// p->row_pointers[y] = (png_byte*) malloc(png_get_rowbytes(p->png_ptr,p->info_ptr)); +// +// png_read_image(p->png_ptr, p->row_pointers); +// +// fclose(fp); +//} +// +// +//void write_png_file(png_img_t * p, const char* file_name) +//{ +// /* create file */ +// FILE *fp = fopen(file_name, "wb"); +// if (!fp) +// lv_test_exit("[write_png_file] File %s could not be opened for writing", file_name); +// +// +// /* initialize stuff */ +// p->png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); +// +// if (!p->png_ptr) +// lv_test_exit("[write_png_file] png_create_write_struct failed"); +// +// p->info_ptr = png_create_info_struct(p->png_ptr); +// if (!p->info_ptr) +// lv_test_exit("[write_png_file] png_create_info_struct failed"); +// +// if (setjmp(png_jmpbuf(p->png_ptr))) +// lv_test_exit("[write_png_file] Error during init_io"); +// +// png_init_io(p->png_ptr, fp); +// +// +// /* write header */ +// if (setjmp(png_jmpbuf(p->png_ptr))) +// lv_test_exit("[write_png_file] Error during writing header"); +// +// png_set_IHDR(p->png_ptr, p->info_ptr, p->width, p->height, +// p->bit_depth, p->color_type, PNG_INTERLACE_NONE, +// PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); +// +// png_write_info(p->png_ptr, p->info_ptr); +// +// +// /* write bytes */ +// if (setjmp(png_jmpbuf(p->png_ptr))) +// lv_test_exit("[write_png_file] Error during writing bytes"); +// +// png_write_image(p->png_ptr, p->row_pointers); +// +// +// /* end write */ +// if (setjmp(png_jmpbuf(p->png_ptr))) +// lv_test_exit("[write_png_file] Error during end of write"); +// +// png_write_end(p->png_ptr, NULL); +// +// fclose(fp); +//} +// +//void png_release(png_img_t * p) +//{ +// int y; +// for (y=0; yheight; y++) +// free(p->row_pointers[y]); +// free(p->row_pointers); +//} +// +//void process_file(png_img_t * p) +//{ +// if (png_get_color_type(p->png_ptr, p->info_ptr) == PNG_COLOR_TYPE_RGB) +// lv_test_exit("[process_file] input file is PNG_COLOR_TYPE_RGB but must be PNG_COLOR_TYPE_RGBA " +// "(lacks the alpha channel)"); +// +// if (png_get_color_type(p->png_ptr, p->info_ptr) != PNG_COLOR_TYPE_RGBA) +// lv_test_exit("[process_file] color_type of input file must be PNG_COLOR_TYPE_RGBA (%d) (is %d)", +// PNG_COLOR_TYPE_RGBA, png_get_color_type(p->png_ptr, p->info_ptr)); +// +// int x, y; +// for (y=0; yheight; y++) { +// png_byte* row = p->row_pointers[y]; +// for (x=0; xwidth; x++) { +// png_byte* ptr = &(row[x*4]); +// printf("Pixel at position [ %d - %d ] has RGBA values: %d - %d - %d - %d\n", +// x, y, ptr[0], ptr[1], ptr[2], ptr[3]); +// +// /* set red value to 0 and green value to the blue one */ +// ptr[0] = 0; +// ptr[1] = ptr[2]; +// } +// } +//}