diff --git a/scripts/style_api_gen.py b/scripts/style_api_gen.py index a36aafb9e..04501be9f 100755 --- a/scripts/style_api_gen.py +++ b/scripts/style_api_gen.py @@ -1,90 +1,90 @@ props = [ -{'name': 'RADIUS', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'CLIP_CORNER', 'style_type': '_int', 'var_type': 'bool' }, -{'name': 'TRANSFORM_WIDTH', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'TRANSFORM_HEIGHT', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'TRANSFORM_ZOOM', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'TRANSFORM_ANGLE', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, -{'name': 'COLOR_FILTER_CB', 'style_type': '_func', 'var_type': 'lv_color_filter_cb_t' }, -{'name': 'COLOR_FILTER_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, -{'name': 'PAD_TOP', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'PAD_BOTTOM', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'PAD_LEFT', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'PAD_RIGHT', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'MARGIN_TOP', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'MARGIN_BOTTOM', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'MARGIN_LEFT', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'MARGIN_RIGHT', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'BG_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'BG_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'BG_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, -{'name': 'BG_GRAD_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'BG_GRAD_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'BG_GRAD_DIR', 'style_type': '_int', 'var_type': 'lv_grad_dir_t' }, -{'name': 'BG_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, -{'name': 'BG_MAIN_STOP', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'BG_GRAD_STOP', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'BORDER_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'BORDER_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'BORDER_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, -{'name': 'BORDER_WIDTH', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'BORDER_SIDE', 'style_type': '_int', 'var_type': 'lv_border_side_t' }, -{'name': 'BORDER_POST', 'style_type': '_int', 'var_type': 'bool' }, -{'name': 'BORDER_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, -{'name': 'TEXT_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'TEXT_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'TEXT_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, -{'name': 'TEXT_FONT', 'style_type': '_ptr', 'var_type': 'const lv_font_t *' }, -{'name': 'TEXT_LETTER_SPACE', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'TEXT_LINE_SPACE', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'TEXT_DECOR', 'style_type': '_int', 'var_type': 'lv_text_decor_t' }, -{'name': 'TEXT_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, -{'name': 'IMG_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, -{'name': 'IMG_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, -{'name': 'IMG_RECOLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'IMG_RECOLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'IMG_RECOLOR_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, -{'name': 'OUTLINE_WIDTH', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'OUTLINE_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'OUTLINE_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'OUTLINE_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, -{'name': 'OUTLINE_PAD', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'OUTLINE_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, -{'name': 'SHADOW_WIDTH', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'SHADOW_OFS_X', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'SHADOW_OFS_Y', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'SHADOW_SPREAD', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'SHADOW_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, -{'name': 'SHADOW_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'SHADOW_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'SHADOW_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, -{'name': 'LINE_WIDTH', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'LINE_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, -{'name': 'LINE_DASH_WIDTH', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'LINE_DASH_GAP', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'LINE_ROUNDED', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'LINE_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'LINE_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, -{'name': 'LINE_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, -{'name': 'CONTENT_SRC', 'style_type': '_ptr', 'var_type': 'const char *' }, -{'name': 'CONTENT_ALIGN', 'style_type': '_int', 'var_type': 'lv_align_t' }, -{'name': 'CONTENT_OFS_X', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'CONTENT_OFS_Y', 'style_type': '_int', 'var_type': 'lv_coord_t' }, -{'name': 'TRANSITION_TIME', 'style_type': '_int', 'var_type': 'uint16_t' }, -{'name': 'TRANSITION_DELAY', 'style_type': '_int', 'var_type': 'uint16_t' }, -{'name': 'TRANSITION_PATH', 'style_type': '_ptr', 'var_type': 'const lv_anim_path_t *' }, -{'name': 'TRANSITION_PROP_1', 'style_type': '_int', 'var_type': 'lv_style_prop_t' }, -{'name': 'TRANSITION_PROP_2', 'style_type': '_int', 'var_type': 'lv_style_prop_t' }, -{'name': 'TRANSITION_PROP_3', 'style_type': '_int', 'var_type': 'lv_style_prop_t' }, -{'name': 'TRANSITION_PROP_4', 'style_type': '_int', 'var_type': 'lv_style_prop_t' }, -{'name': 'TRANSITION_PROP_5', 'style_type': '_int', 'var_type': 'lv_style_prop_t' }, -{'name': 'TRANSITION_PROP_6', 'style_type': '_int', 'var_type': 'lv_style_prop_t' } +{'name': 'RADIUS', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'CLIP_CORNER', 'style_type': 'num', 'var_type': 'bool' }, +{'name': 'TRANSFORM_WIDTH', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'TRANSFORM_HEIGHT', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'TRANSFORM_ZOOM', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'TRANSFORM_ANGLE', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' }, +{'name': 'COLOR_FILTER_CB', 'style_type': 'func', 'var_type': 'lv_color_filter_cb_t' }, +{'name': 'COLOR_FILTER_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' }, +{'name': 'ANIM_TIME', 'style_type': 'num', 'var_type': 'uint32_t' }, +{'name': 'TRANSITION', 'style_type': 'ptr', 'var_type': 'const lv_style_transition_t *' }, +{'name': 'SIZE', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'BLEND_MODE', 'style_type': 'num', 'var_type': 'lv_blend_mode_t' }, +{'name': 'PAD_TOP', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'PAD_BOTTOM', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'PAD_LEFT', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'PAD_RIGHT', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'PAD_ROW', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'PAD_COLUMN', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'BG_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'BG_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'BG_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' }, +{'name': 'BG_GRAD_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'BG_GRAD_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'BG_GRAD_DIR', 'style_type': 'num', 'var_type': 'lv_grad_dir_t' }, +{'name': 'BG_MAIN_STOP', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'BG_GRAD_STOP', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'BG_IMG_SRC', 'style_type': 'ptr', 'var_type': 'const void *' }, +{'name': 'BG_IMG_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' }, +{'name': 'BG_IMG_RECOLOR', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'BG_IMG_RECOLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'BG_IMG_RECOLOR_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' }, +{'name': 'BG_IMG_TILED', 'style_type': 'num', 'var_type': 'bool' }, +{'name': 'BORDER_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'BORDER_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'BORDER_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' }, +{'name': 'BORDER_WIDTH', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'BORDER_SIDE', 'style_type': 'num', 'var_type': 'lv_border_side_t' }, +{'name': 'BORDER_POST', 'style_type': 'num', 'var_type': 'bool' }, +{'name': 'TEXT_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'TEXT_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'TEXT_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' }, +{'name': 'TEXT_FONT', 'style_type': 'ptr', 'var_type': 'const lv_font_t *' }, +{'name': 'TEXT_LETTER_SPACE', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'TEXT_LINE_SPACE', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'TEXT_DECOR', 'style_type': 'num', 'var_type': 'lv_text_decor_t' }, +{'name': 'TEXT_ALIGN', 'style_type': 'num', 'var_type': 'lv_text_align_t' }, +{'name': 'IMG_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' }, +{'name': 'IMG_RECOLOR', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'IMG_RECOLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'IMG_RECOLOR_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' }, +{'name': 'OUTLINE_WIDTH', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'OUTLINE_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'OUTLINE_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'OUTLINE_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' }, +{'name': 'OUTLINE_PAD', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'SHADOW_WIDTH', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'SHADOW_OFS_X', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'SHADOW_OFS_Y', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'SHADOW_SPREAD', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'SHADOW_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'SHADOW_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'SHADOW_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' }, +{'name': 'LINE_WIDTH', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'LINE_DASH_WIDTH', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'LINE_DASH_GAP', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'LINE_ROUNDED', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'LINE_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'LINE_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'LINE_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' }, +{'name': 'CONTENT_TEXT', 'style_type': 'ptr', 'var_type': 'const char *' }, +{'name': 'CONTENT_ALIGN', 'style_type': 'num', 'var_type': 'lv_align_t' }, +{'name': 'CONTENT_OFS_X', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'CONTENT_OFS_Y', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'CONTENT_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' }, +{'name': 'CONTENT_FONT', 'style_type': 'ptr', 'var_type': 'const lv_font_t *' }, +{'name': 'CONTENT_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'CONTENT_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' }, +{'name': 'CONTENT_LETTER_SPACE', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'CONTENT_LINE_SPACE', 'style_type': 'num', 'var_type': 'lv_coord_t' }, +{'name': 'CONTENT_DECOR', 'style_type': 'num', 'var_type': 'lv_text_decor_t' }, ] def obj_style_get(i): print("static inline " + props[i]['var_type'] + " lv_obj_get_style_" + props[i]['name'].lower() +"(const struct _lv_obj_t * obj, uint32_t part) {") - print(" lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_" + props[i]['name'] + "); return v." + props[i][ 'style_type'] + "; }") + print(" lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_" + props[i]['name'] + "); return (" + props[i]['var_type'] + ") v." + props[i]['style_type'] + "; }") print("") @@ -96,4 +96,8 @@ def style_set(i): for i in range(len(props)): - obj_style_get(i) + style_set(i) + + + + diff --git a/src/lv_core/lv_disp.c b/src/lv_core/lv_disp.c index a128bfb5b..51c0db34e 100644 --- a/src/lv_core/lv_disp.c +++ b/src/lv_core/lv_disp.c @@ -318,7 +318,7 @@ uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp) d = lv_disp_get_next(NULL); while(d) { uint32_t elaps = lv_tick_elaps(d->last_activity_time); - t = LV_MATH_MIN(t, elaps); + t = LV_MIN(t, elaps); d = lv_disp_get_next(d); } diff --git a/src/lv_core/lv_disp.h b/src/lv_core/lv_disp.h index e8396e9e7..5380bed2f 100644 --- a/src/lv_core/lv_disp.h +++ b/src/lv_core/lv_disp.h @@ -206,7 +206,7 @@ static inline void lv_scr_load(lv_obj_t * scr) * 1 dip is 2 px on a 320 DPI screen * https://stackoverflow.com/questions/2025282/what-is-the-difference-between-px-dip-dp-and-sp */ -#define LV_DPX(n) (n == 0 ? 0 :LV_MATH_MAX((( lv_disp_get_dpi(NULL) * (n) + 80) / 160), 1)) /*+80 for rounding*/ +#define LV_DPX(n) (n == 0 ? 0 :LV_MAX((( lv_disp_get_dpi(NULL) * (n) + 80) / 160), 1)) /*+80 for rounding*/ static inline lv_coord_t lv_dpx(lv_coord_t n) { diff --git a/src/lv_core/lv_flex.c b/src/lv_core/lv_flex.c index 7a2e77ca4..ab278056b 100644 --- a/src/lv_core/lv_flex.c +++ b/src/lv_core/lv_flex.c @@ -80,7 +80,7 @@ const lv_flex_t lv_flex_even = { void lv_flex_init(lv_flex_t * flex) { - _lv_memset_00(flex, sizeof(lv_flex_t)); + lv_memset_00(flex, sizeof(lv_flex_t)); flex->update_cb = flex_update; flex->dir = LV_FLEX_FLOW_ROW; flex->item_main_place = LV_FLEX_PLACE_START; @@ -197,6 +197,11 @@ static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t const lv_flex_t * f = cont->spec_attr->layout_dsc; bool row = f->dir == LV_FLEX_FLOW_ROW ? true : false; + bool wrap = f->wrap; + /*Can't wrap if the size if auto (i.e. the size depends on the children)*/ + if(wrap && ((row && cont->w_set == LV_SIZE_AUTO) || (!row && cont->h_set == LV_SIZE_AUTO))) { + wrap = false; + } lv_coord_t(*get_main_size)(const lv_obj_t *) = (row ? lv_obj_get_width : lv_obj_get_height); lv_coord_t(*get_cross_size)(const lv_obj_t *) = (!row ? lv_obj_get_width : lv_obj_get_height); @@ -217,10 +222,10 @@ static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t grow_item_cnt++; } else { lv_coord_t item_size = get_main_size(item) + item_gap; - if(f->wrap && t->track_main_size + item_size > max_main_size) break; + if(wrap && t->track_main_size + item_size > max_main_size) break; t->track_main_size += item_size; } - t->track_cross_size = LV_MATH_MAX(get_cross_size(item), t->track_cross_size); + t->track_cross_size = LV_MAX(get_cross_size(item), t->track_cross_size); item_id += f->rev ? -1 : +1; item = lv_obj_get_child(cont, item_id); diff --git a/src/lv_core/lv_grid.c b/src/lv_core/lv_grid.c index 349805a2e..71d54b8ca 100644 --- a/src/lv_core/lv_grid.c +++ b/src/lv_core/lv_grid.c @@ -50,7 +50,7 @@ static lv_coord_t grid_place(lv_coord_t cont_size, bool auto_size, uint8_t plac void lv_grid_init(lv_grid_t * grid) { - _lv_memset_00(grid,sizeof(lv_grid_t)); + lv_memset_00(grid,sizeof(lv_grid_t)); grid->update_cb = grid_update; grid->col_place = LV_GRID_START; grid->row_place = LV_GRID_START; @@ -105,7 +105,7 @@ static void full_refresh(lv_obj_t * cont) item_repos_hint_t hint; - _lv_memset_00(&hint, sizeof(hint)); + lv_memset_00(&hint, sizeof(hint)); /* Calculate the grids absolute x and y coordinates. * It will be used as helper during item repositioning to avoid calculating this value for every children*/ @@ -158,7 +158,7 @@ static void calc(struct _lv_obj_t * cont, _lv_grid_calc_t * calc_out) if(g->col_dsc_len == 0 || g->row_dsc_len == 0) return; if(lv_obj_get_child(cont, 0) == NULL) { - _lv_memset_00(calc_out, sizeof(_lv_grid_calc_t)); + lv_memset_00(calc_out, sizeof(_lv_grid_calc_t)); return; } @@ -186,10 +186,10 @@ static void calc(struct _lv_obj_t * cont, _lv_grid_calc_t * calc_out) */ static void calc_free(_lv_grid_calc_t * calc) { - _lv_mem_buf_release(calc->x); - _lv_mem_buf_release(calc->y); - _lv_mem_buf_release(calc->w); - _lv_mem_buf_release(calc->h); + lv_mem_buf_release(calc->x); + lv_mem_buf_release(calc->y); + lv_mem_buf_release(calc->w); + lv_mem_buf_release(calc->h); } static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c) @@ -200,8 +200,8 @@ static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c) lv_coord_t cont_w = lv_obj_get_width_fit(cont); c->col_num = grid->col_dsc_len; - c->x = _lv_mem_buf_get(sizeof(lv_coord_t) * c->col_num); - c->w = _lv_mem_buf_get(sizeof(lv_coord_t) * c->col_num); + c->x = lv_mem_buf_get(sizeof(lv_coord_t) * c->col_num); + c->w = lv_mem_buf_get(sizeof(lv_coord_t) * c->col_num); uint32_t col_fr_cnt = 0; lv_coord_t grid_w = 0; @@ -238,8 +238,8 @@ static void calc_rows(lv_obj_t * cont, _lv_grid_calc_t * c) uint32_t i; c->row_num = grid->row_dsc_len; - c->y = _lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num); - c->h = _lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num); + c->y = lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num); + c->h = lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num); uint32_t row_fr_cnt = 0; lv_coord_t grid_h = 0; diff --git a/src/lv_core/lv_group.c b/src/lv_core/lv_group.c index b3468528b..8242373f1 100644 --- a/src/lv_core/lv_group.c +++ b/src/lv_core/lv_group.c @@ -72,7 +72,7 @@ lv_group_t * lv_group_create(void) group->wrap = 1; #if LV_USE_USER_DATA - _lv_memset_00(&group->user_data, sizeof(lv_group_user_data_t)); + lv_memset_00(&group->user_data, sizeof(lv_group_user_data_t)); #endif return group; diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index 2d9c01e32..23b910f49 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -1191,8 +1191,8 @@ void indev_gesture(lv_indev_proc_t * proc) if(gesture_obj == NULL) return; - if((LV_MATH_ABS(proc->types.pointer.vect.x) < indev_act->driver.gesture_min_velocity) && - (LV_MATH_ABS(proc->types.pointer.vect.y) < indev_act->driver.gesture_min_velocity)) { + if((LV_ABS(proc->types.pointer.vect.x) < indev_act->driver.gesture_min_velocity) && + (LV_ABS(proc->types.pointer.vect.y) < indev_act->driver.gesture_min_velocity)) { proc->types.pointer.gesture_sum.x = 0; proc->types.pointer.gesture_sum.y = 0; } @@ -1201,12 +1201,12 @@ void indev_gesture(lv_indev_proc_t * proc) proc->types.pointer.gesture_sum.x += proc->types.pointer.vect.x; proc->types.pointer.gesture_sum.y += proc->types.pointer.vect.y; - if((LV_MATH_ABS(proc->types.pointer.gesture_sum.x) > indev_act->driver.gesture_limit) || - (LV_MATH_ABS(proc->types.pointer.gesture_sum.y) > indev_act->driver.gesture_limit)) { + if((LV_ABS(proc->types.pointer.gesture_sum.x) > indev_act->driver.gesture_limit) || + (LV_ABS(proc->types.pointer.gesture_sum.y) > indev_act->driver.gesture_limit)) { proc->types.pointer.gesture_sent = 1; - if(LV_MATH_ABS(proc->types.pointer.gesture_sum.x) > LV_MATH_ABS(proc->types.pointer.gesture_sum.y)) { + if(LV_ABS(proc->types.pointer.gesture_sum.x) > LV_ABS(proc->types.pointer.gesture_sum.y)) { if(proc->types.pointer.gesture_sum.x > 0) proc->types.pointer.gesture_dir = LV_GESTURE_DIR_RIGHT; else diff --git a/src/lv_core/lv_indev_scroll.c b/src/lv_core/lv_indev_scroll.c index 7be2aff40..459190eca 100644 --- a/src/lv_core/lv_indev_scroll.c +++ b/src/lv_core/lv_indev_scroll.c @@ -268,7 +268,7 @@ static lv_obj_t * find_scroll_obj(lv_indev_proc_t * proc) /*Decide if it's a horizontal or vertical scroll*/ bool hor_en = false; bool ver_en = false; - if(LV_MATH_ABS(proc->types.pointer.scroll_sum.x) > LV_MATH_ABS(proc->types.pointer.scroll_sum.y)) { + if(LV_ABS(proc->types.pointer.scroll_sum.x) > LV_ABS(proc->types.pointer.scroll_sum.y)) { hor_en = true; } else { @@ -436,7 +436,7 @@ static lv_coord_t find_snap_point_x(const lv_obj_t * obj, lv_coord_t min, lv_coo x_child += ofs; if(x_child >= min && x_child <= max) { lv_coord_t x = x_child - x_parent; - if(LV_MATH_ABS(x) < LV_MATH_ABS(dist)) dist = x; + if(LV_ABS(x) < LV_ABS(dist)) dist = x; } } } @@ -483,7 +483,7 @@ static lv_coord_t find_snap_point_y(const lv_obj_t * obj, lv_coord_t min, lv_coo y_child += ofs; if(y_child >= min && y_child <= max) { lv_coord_t y = y_child - y_parent; - if(LV_MATH_ABS(y) < LV_MATH_ABS(dist)) dist = y; + if(LV_ABS(y) < LV_ABS(dist)) dist = y; } } } diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 9e100fac0..87f08e825 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -85,7 +85,7 @@ static void lv_obj_destructor(lv_obj_t * obj); **********************/ static bool lv_initialized = false; static lv_event_temp_data_t * event_temp_data_head; -static const void * event_act_data; +static void * event_act_data; const lv_obj_class_t lv_obj = { .constructor = lv_obj_constructor, .destructor = lv_obj_destructor, @@ -117,7 +117,7 @@ void lv_init(void) LV_LOG_TRACE("lv_init started"); /*Initialize the lv_misc modules*/ - _lv_mem_init(); + lv_mem_init(); _lv_timer_core_init(); @@ -193,7 +193,7 @@ void lv_deinit(void) _lv_gc_clear_roots(); lv_disp_set_default(NULL); - _lv_mem_deinit(); + lv_mem_deinit(); lv_initialized = false; LV_LOG_INFO("lv_deinit done"); @@ -225,7 +225,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class, lv_obj_t * parent, const lv_obj_t * copy) { lv_obj_t * obj = lv_mem_alloc(class->instance_size); - _lv_memset_00(obj, class->instance_size); + lv_memset_00(obj, class->instance_size); obj->class_p = class; class->constructor(obj, parent, copy); @@ -482,13 +482,10 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent) old_parent->spec_attr->children = NULL; } - /*Add the child to the new parent*/ + /*Add the child to the new parent as the last (newest child)*/ parent->spec_attr->child_cnt++; parent->spec_attr->children = lv_mem_realloc(parent->spec_attr->children, parent->spec_attr->child_cnt * (sizeof(lv_obj_t *))); - for(i = lv_obj_get_child_cnt(parent) - 1; i > 0 ; i--) { - parent->spec_attr->children[i] = parent->spec_attr->children[i - 1]; - } - parent->spec_attr->children[0] = obj; + parent->spec_attr->children[lv_obj_get_child_cnt(parent) - 1] = obj; obj->parent = parent; @@ -584,7 +581,7 @@ void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right obj->spec_attr->ext_click_pad.y2 = bottom; #elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY if(obj->spec_attr == NULL) lv_obj_allocate_spec_attr(obj); - obj->spec_attr->ext_click_pad = LV_MATH_MAX4(left, right, top, bottom); + obj->spec_attr->ext_click_pad = LV_MAX4(left, right, top, bottom); #else LV_UNUSED(obj); LV_UNUSED(left); @@ -687,8 +684,8 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) /*If there is no difference in styles there is nothing else to do*/ if(cmp_res == _LV_STYLE_STATE_CMP_SAME) return; - trans_set_t * ts = _lv_mem_buf_get(sizeof(trans_set_t) * STYLE_TRANSITION_MAX); - _lv_memset_00(ts, sizeof(sizeof(trans_set_t) * 64)); + trans_set_t * ts = lv_mem_buf_get(sizeof(trans_set_t) * STYLE_TRANSITION_MAX); + lv_memset_00(ts, sizeof(sizeof(trans_set_t) * 64)); uint32_t tsi = 0; uint32_t i; for(i = 0; i < obj->style_list.style_cnt && tsi < STYLE_TRANSITION_MAX; i++) { @@ -698,7 +695,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) lv_style_value_t v; if(lv_style_get_prop(obj_style->style, LV_STYLE_TRANSITION, &v) == false) continue; - const lv_style_transiton_t * tr = v.ptr; + const lv_style_transition_t * tr = v.ptr; /*Add the props t the set is not added yet or added but with smaller weight*/ uint32_t j; @@ -725,7 +722,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) _lv_obj_create_style_transition(obj, ts[i].prop, ts[i].part, prev_state, new_state, ts[i].time, ts[i].delay, ts[i].path); } - _lv_mem_buf_release(ts); + lv_mem_buf_release(ts); if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_LAYOUT) _lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); else if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) _lv_obj_refresh_ext_draw_pad(obj); @@ -953,7 +950,7 @@ lv_obj_spec_attr_t * lv_obj_allocate_spec_attr(lv_obj_t * obj) LV_ASSERT_MEM(obj->spec_attr); if(obj->spec_attr == NULL) return NULL; - _lv_memset_00(obj->spec_attr, sizeof(lv_obj_spec_attr_t)); + lv_memset_00(obj->spec_attr, sizeof(lv_obj_spec_attr_t)); obj->spec_attr->scroll_dir = LV_DIR_ALL; obj->spec_attr->base_dir = LV_BIDI_DIR_INHERIT; @@ -1496,7 +1493,7 @@ static void lv_obj_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t obj->flags = copy->flags; if(copy->spec_attr) { lv_obj_allocate_spec_attr(obj); - _lv_memcpy_small(obj->spec_attr, copy->spec_attr, sizeof(lv_obj_spec_attr_t)); + lv_memcpy_small(obj->spec_attr, copy->spec_attr, sizeof(lv_obj_spec_attr_t)); obj->spec_attr->children = NULL; /*Make the child list empty*/ } #if LV_USE_GROUP @@ -1564,8 +1561,9 @@ static lv_draw_res_t lv_obj_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv if(lv_obj_get_style_bg_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) return LV_DRAW_RES_NOT_COVER; - if(lv_obj_get_style_bg_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER; - if(lv_obj_get_style_border_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER; +#if LV_USE_BLEND_MODES + if(lv_obj_get_style_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER; +#endif if(lv_obj_get_style_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) return LV_DRAW_RES_NOT_COVER; return LV_DRAW_RES_COVER; @@ -1590,30 +1588,22 @@ static lv_draw_res_t lv_obj_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv coords.y1 -= h; coords.y2 += h; - lv_obj_draw_hook_dsc_t hook_dsc; - lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area); - hook_dsc.draw_area = &coords; - hook_dsc.part = LV_PART_MAIN; - lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc); - lv_draw_rect(&coords, clip_area, &draw_dsc); if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) { - lv_draw_mask_radius_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t)); + lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t)); lv_coord_t r = lv_obj_get_style_radius(obj, LV_PART_MAIN); lv_draw_mask_radius_init(mp, &obj->coords, r, false); /*Add the mask and use `obj+8` as custom id. Don't use `obj` directly because it might be used by the user*/ lv_draw_mask_add(mp, obj + 8); } - - lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc); } else if(mode == LV_DRAW_MODE_POST_DRAW) { _lv_obj_draw_scrollbar(obj, clip_area); if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) { lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(obj + 8); - _lv_mem_buf_release(param); + lv_mem_buf_release(param); } /*If the border is drawn later disable loading other properties*/ @@ -1833,7 +1823,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { lv_coord_t * s = param; lv_coord_t d = _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_MAIN); - *s = LV_MATH_MAX(*s, d); + *s = LV_MAX(*s, d); } else if(sign == LV_SIGNAL_STYLE_CHG) { /* Padding might have changed so the layout should be recalculated*/ diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 814473eb0..a2493f3f3 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -257,23 +257,6 @@ enum { LV_PART_ITEMS, LV_PART_MARKER, LV_PART_CURSOR, //combine with marker? - - LV_PART_CUSTOM_1, - LV_PART_CUSTOM_2, - LV_PART_CUSTOM_3, - LV_PART_CUSTOM_4, - LV_PART_CUSTOM_5, - LV_PART_CUSTOM_6, - LV_PART_CUSTOM_7, - LV_PART_CUSTOM_8, - LV_PART_CUSTOM_9, - LV_PART_CUSTOM_10, - LV_PART_CUSTOM_11, - LV_PART_CUSTOM_12, - LV_PART_CUSTOM_13, - LV_PART_CUSTOM_14, - LV_PART_CUSTOM_15, - LV_PART_CUSTOM_16, }; typedef uint8_t lv_part_t; diff --git a/src/lv_core/lv_obj_draw.c b/src/lv_core/lv_obj_draw.c index 5d484d5b9..80b527c07 100644 --- a/src/lv_core/lv_obj_draw.c +++ b/src/lv_core/lv_obj_draw.c @@ -65,6 +65,10 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t } #endif +#if LV_USE_BLEND_MODES + draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part); +#endif + if(draw_dsc->bg_opa != LV_OPA_TRANSP) { draw_dsc->bg_opa = lv_obj_get_style_bg_opa(obj, part); if(draw_dsc->bg_opa > LV_OPA_MIN) { @@ -75,10 +79,6 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t draw_dsc->bg_main_color_stop = lv_obj_get_style_bg_main_stop(obj, part); draw_dsc->bg_grad_color_stop = lv_obj_get_style_bg_grad_stop(obj, part); } - -#if LV_USE_BLEND_MODES - draw_dsc->bg_blend_mode = lv_obj_get_style_bg_blend_mode(obj, part); -#endif } } @@ -90,9 +90,6 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t draw_dsc->border_side = lv_obj_get_style_border_side(obj, part); draw_dsc->border_color = lv_obj_get_style_border_color_filtered(obj, part); } -#if LV_USE_BLEND_MODES - draw_dsc->border_blend_mode = lv_obj_get_style_border_blend_mode(obj, part); -#endif } } @@ -105,44 +102,37 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t draw_dsc->outline_pad = lv_obj_get_style_outline_pad(obj, part); draw_dsc->outline_color = lv_obj_get_style_outline_color(obj, part); } -#if LV_USE_BLEND_MODES - draw_dsc->outline_blend_mode = lv_obj_get_style_outline_blend_mode(obj, part); -#endif } } #endif + if(draw_dsc->bg_img_opa != LV_OPA_TRANSP) { + draw_dsc->bg_img_src = lv_obj_get_style_bg_img_src(obj, part); + if(draw_dsc->bg_img_src) { +// draw_dsc->bg_img_opa = lv_obj_get_style_bg_img_opa(obj, part); //TODO + if(draw_dsc->bg_img_opa > LV_OPA_MIN) { + draw_dsc->bg_img_recolor = lv_obj_get_style_bg_img_recolor(obj, part); + draw_dsc->bg_img_recolor_opa = lv_obj_get_style_bg_img_recolor_opa(obj, part); + draw_dsc->bg_img_tiled = lv_obj_get_style_bg_img_tiled(obj, part); + } + } + } + #if LV_USE_PATTERN if(draw_dsc->content_opa != LV_OPA_TRANSP) { - draw_dsc->content_src = lv_obj_get_style_content_src(obj, part); - if(draw_dsc->content_src) { - draw_dsc->content_ofs_y = lv_obj_get_style_content_ofs_y(obj, part); - draw_dsc->content_ofs_x = lv_obj_get_style_content_ofs_x(obj, part); - draw_dsc->content_align = lv_obj_get_style_content_align(obj, part); + draw_dsc->content_text = lv_obj_get_style_content_text(obj, part); + if(draw_dsc->content_text) { - if(lv_img_src_get_type(draw_dsc->content_src) == LV_IMG_SRC_SYMBOL) { - draw_dsc->content_opa = lv_obj_get_style_text_opa(obj, part); - if(draw_dsc->content_opa > LV_OPA_MIN) { - draw_dsc->content_font = lv_obj_get_style_text_font(obj, part); - draw_dsc->content_color = lv_obj_get_style_text_color(obj, part); - draw_dsc->content_letter_space = lv_obj_get_style_text_letter_space(obj, part); - draw_dsc->content_line_space = lv_obj_get_style_text_line_space(obj, part); -#if LV_USE_BLEND_MODES - draw_dsc->content_blend_mode = lv_obj_get_style_text_blend_mode(obj, part); -#endif - } - } - else { - draw_dsc->content_opa = lv_obj_get_style_img_opa(obj, part); - if(draw_dsc->content_opa > LV_OPA_MIN) { - draw_dsc->content_color = lv_obj_get_style_img_recolor(obj, part); - draw_dsc->content_recolor_opa = lv_obj_get_style_img_recolor_opa(obj, part); - -#if LV_USE_BLEND_MODES - draw_dsc->content_blend_mode = lv_obj_get_style_img_blend_mode(obj, part); -#endif - } + draw_dsc->content_opa = lv_obj_get_style_content_opa(obj, part); + if(draw_dsc->content_opa > LV_OPA_MIN) { + draw_dsc->content_ofs_y = lv_obj_get_style_content_ofs_y(obj, part); + draw_dsc->content_ofs_x = lv_obj_get_style_content_ofs_x(obj, part); + draw_dsc->content_align = lv_obj_get_style_content_align(obj, part); + draw_dsc->content_font = lv_obj_get_style_content_font(obj, part); + draw_dsc->content_color = lv_obj_get_style_content_color_filtered(obj, part); + draw_dsc->content_letter_space = lv_obj_get_style_content_letter_space(obj, part); + draw_dsc->content_line_space = lv_obj_get_style_content_line_space(obj, part); } } } @@ -160,9 +150,6 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t draw_dsc->shadow_ofs_y = lv_obj_get_style_shadow_ofs_y(obj, part); draw_dsc->shadow_spread = lv_obj_get_style_shadow_spread(obj, part); draw_dsc->shadow_color = lv_obj_get_style_shadow_color(obj, part); -#if LV_USE_BLEND_MODES - draw_dsc->shadow_blend_mode = lv_obj_get_style_shadow_blend_mode(obj, part); -#endif } } } @@ -210,7 +197,7 @@ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_ draw_dsc->line_space = lv_obj_get_style_text_line_space(obj, part); draw_dsc->decor = lv_obj_get_style_text_decor(obj, part); #if LV_USE_BLEND_MODES - draw_dsc->blend_mode = lv_obj_get_style_text_blend_mode(obj, part); + draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part); #endif draw_dsc->font = lv_obj_get_style_text_font(obj, part); @@ -245,29 +232,29 @@ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_ */ void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t * draw_dsc) { -// draw_dsc->opa = lv_obj_get_style_image_opa(obj, part); -// if(draw_dsc->opa <= LV_OPA_MIN) return; -// -//#if LV_USE_OPA_SCALE -// lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, part); -// if(opa_scale < LV_OPA_MAX) { -// draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8; -// } -// if(draw_dsc->opa <= LV_OPA_MIN) return; -//#endif -// -// draw_dsc->angle = 0; -// draw_dsc->zoom = LV_IMG_ZOOM_NONE; -// draw_dsc->pivot.x = lv_area_get_width(&obj->coords) / 2; -// draw_dsc->pivot.y = lv_area_get_height(&obj->coords) / 2; -// -// draw_dsc->recolor_opa = lv_obj_get_style_image_recolor_opa(obj, part); -// if(draw_dsc->recolor_opa > 0) { -// draw_dsc->recolor = lv_obj_get_style_image_recolor(obj, part); -// } -//#if LV_USE_BLEND_MODES -// draw_dsc->blend_mode = lv_obj_get_style_image_blend_mode(obj, part); -//#endif + draw_dsc->opa = lv_obj_get_style_img_opa(obj, part); + if(draw_dsc->opa <= LV_OPA_MIN) return; + +#if LV_USE_OPA_SCALE + lv_opa_t opa_scale = lv_obj_get_style_opa(obj, part); + if(opa_scale < LV_OPA_MAX) { + draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8; + } + if(draw_dsc->opa <= LV_OPA_MIN) return; +#endif + + draw_dsc->angle = 0; + draw_dsc->zoom = LV_IMG_ZOOM_NONE; + draw_dsc->pivot.x = lv_area_get_width(&obj->coords) / 2; + draw_dsc->pivot.y = lv_area_get_height(&obj->coords) / 2; + + draw_dsc->recolor_opa = lv_obj_get_style_img_recolor_opa(obj, part); + if(draw_dsc->recolor_opa > 0) { + draw_dsc->recolor = lv_obj_get_style_img_recolor(obj, part); + } +#if LV_USE_BLEND_MODES + draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part); +#endif } @@ -306,10 +293,45 @@ void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t draw_dsc->round_end = draw_dsc->round_start; #if LV_USE_BLEND_MODES - draw_dsc->blend_mode = lv_obj_get_style_line_blend_mode(obj, part); + draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part); #endif } +/** + * Initialize a line draw descriptor from an object's styles in its current state + * @param obj pointer to an object + * @param type type of style. E.g. `LV_LINE_PART_MAIN` + * @param draw_dsc the descriptor the initialize. + * If the `opa` filed is set to or the property is equal to `LV_OPA_TRANSP` the rest won't be initialized. + * Should be initialized with `lv_draw_line_dsc_init(draw_dsc)`. + */ +void lv_obj_init_draw_arc_dsc(lv_obj_t * obj, uint8_t part, lv_draw_arc_dsc_t * draw_dsc) +{ + draw_dsc->width = lv_obj_get_style_line_width(obj, part); + if(draw_dsc->width == 0) return; + + draw_dsc->opa = lv_obj_get_style_line_opa(obj, part); + if(draw_dsc->opa <= LV_OPA_MIN) return; + +#if LV_USE_OPA_SCALE + lv_opa_t opa = lv_obj_get_style_opa(obj, part); + if(opa < LV_OPA_MAX) { + draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa) >> 8; + } + if(draw_dsc->opa <= LV_OPA_MIN) return; +#endif + + draw_dsc->color = lv_obj_get_style_line_color(obj, part); + draw_dsc->bg_img_src = lv_obj_get_style_bg_img_src(obj, part); + + draw_dsc->rounded = lv_obj_get_style_line_rounded(obj, part); + +#if LV_USE_BLEND_MODES + draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part); +#endif + + +} /** * Get the required extra size (around the object's part) to draw shadow, outline, value etc. * @param obj pointer to an object @@ -328,8 +350,8 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part) sh_width += lv_obj_get_style_shadow_spread(obj, part); lv_coord_t sh_ofs_x = lv_obj_get_style_shadow_ofs_x(obj, part); lv_coord_t sh_ofs_y = lv_obj_get_style_shadow_ofs_y(obj, part); - sh_width += LV_MATH_MAX(LV_MATH_ABS(sh_ofs_x), LV_MATH_ABS(sh_ofs_y)); - s = LV_MATH_MAX(s, sh_width); + sh_width += LV_MAX(LV_ABS(sh_ofs_x), LV_ABS(sh_ofs_y)); + s = LV_MAX(s, sh_width); } } @@ -338,12 +360,12 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part) lv_opa_t outline_opa = lv_obj_get_style_outline_opa(obj, part); if(outline_opa > LV_OPA_MIN) { lv_coord_t outline_pad = lv_obj_get_style_outline_pad(obj, part); - s = LV_MATH_MAX(s, outline_pad + outline_width); + s = LV_MAX(s, outline_pad + outline_width); } } - const void * content_src = lv_obj_get_style_content_src(obj, part); - if(content_src) { + const void * content_text = lv_obj_get_style_content_text(obj, part); + if(content_text) { lv_opa_t content_opa; lv_point_t content_size; content_opa = lv_obj_get_style_text_opa(obj, part); @@ -351,7 +373,7 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part) lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, part); lv_coord_t line_space = lv_obj_get_style_text_letter_space(obj, part); const lv_font_t * font = lv_obj_get_style_text_font(obj, part); - _lv_txt_get_size(&content_size, content_src, font, letter_space, line_space, LV_COORD_MAX, LV_TEXT_FLAG_NONE); + _lv_txt_get_size(&content_size, content_text, font, letter_space, line_space, LV_COORD_MAX, LV_TEXT_FLAG_NONE); lv_area_t content_area; content_area.x1 = 0; @@ -370,16 +392,16 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part) content_area.x2 += p_align.x + xofs; content_area.y2 += p_align.y + yofs; - s = LV_MATH_MAX(s, obj->coords.x1 - content_area.x1); - s = LV_MATH_MAX(s, obj->coords.y1 - content_area.y1); - s = LV_MATH_MAX(s, content_area.x2 - obj->coords.x2); - s = LV_MATH_MAX(s, content_area.y2 - obj->coords.y2); + s = LV_MAX(s, obj->coords.x1 - content_area.x1); + s = LV_MAX(s, obj->coords.y1 - content_area.y1); + s = LV_MAX(s, content_area.x2 - obj->coords.x2); + s = LV_MAX(s, content_area.y2 - obj->coords.y2); } } lv_coord_t w = lv_obj_get_style_transform_width(obj, part); lv_coord_t h = lv_obj_get_style_transform_height(obj, part); - lv_coord_t wh = LV_MATH_MAX(w, h); + lv_coord_t wh = LV_MAX(w, h); if(wh > 0) s += wh; return s; @@ -387,7 +409,7 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part) void lv_obj_draw_hook_dsc_init(lv_obj_draw_hook_dsc_t * hook_dsc, const lv_area_t * clip_area) { - _lv_memset_00(hook_dsc, sizeof(lv_obj_draw_hook_dsc_t)); + lv_memset_00(hook_dsc, sizeof(lv_obj_draw_hook_dsc_t)); hook_dsc->clip_area = clip_area; } @@ -488,7 +510,7 @@ void _lv_obj_draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area) if(ver_draw && _lv_area_is_on(&area, clip_area)) { lv_coord_t content_h = obj_h + st + sb; lv_coord_t sb_h = ((obj_h - end_space * 2 - hor_req_space) * obj_h) / content_h; - sb_h = LV_MATH_MAX(sb_h, SCROLLBAR_MIN_SIZE); + sb_h = LV_MAX(sb_h, SCROLLBAR_MIN_SIZE); rem = (obj_h - end_space * 2 - hor_req_space) - sb_h; /*Remaining size from the scrollbar track that is not the scrollbar itself*/ lv_coord_t scroll_h = content_h - obj_h; /*The size of the content which can be really scrolled*/ if(scroll_h <= 0) { @@ -524,7 +546,7 @@ void _lv_obj_draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area) if(hor_draw && _lv_area_is_on(&area, clip_area)) { lv_coord_t content_w = obj_w + sl + sr; lv_coord_t sb_w = ((obj_w - end_space * 2 - ver_reg_space) * obj_w) / content_w; - sb_w = LV_MATH_MAX(sb_w, SCROLLBAR_MIN_SIZE); + sb_w = LV_MAX(sb_w, SCROLLBAR_MIN_SIZE); rem = (obj_w - end_space * 2 - ver_reg_space) - sb_w; /*Remaining size from the scrollbar track that is not the scrollbar itself*/ lv_coord_t scroll_w = content_w - obj_w; /*The size of the content which can be really scrolled*/ if(scroll_w <= 0) { diff --git a/src/lv_core/lv_obj_draw.h b/src/lv_core/lv_obj_draw.h index b6de0d59f..d7ec13f50 100644 --- a/src/lv_core/lv_obj_draw.h +++ b/src/lv_core/lv_obj_draw.h @@ -40,7 +40,11 @@ typedef struct lv_draw_label_dsc_t * label_dsc; lv_draw_line_dsc_t * line_dsc; lv_draw_img_dsc_t * img_dsc; + lv_draw_arc_dsc_t * arc_dsc; const lv_area_t * draw_area; + const lv_point_t * p1; + const lv_point_t * p2; + const lv_coord_t * radius; const lv_area_t * clip_area; uint32_t id; uint8_t part; @@ -105,6 +109,7 @@ void lv_obj_init_draw_img_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_img_ */ void lv_obj_init_draw_line_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t * draw_dsc); +void lv_obj_init_draw_arc_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_arc_dsc_t * draw_dsc); bool lv_obj_draw_has_custom(const struct _lv_obj_t * obj, uint8_t part); diff --git a/src/lv_core/lv_obj_scroll.c b/src/lv_core/lv_obj_scroll.c index da79679f9..31dd23467 100644 --- a/src/lv_core/lv_obj_scroll.c +++ b/src/lv_core/lv_obj_scroll.c @@ -130,7 +130,7 @@ lv_coord_t lv_obj_get_scroll_bottom(lv_obj_t * obj) uint32_t i; for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { lv_obj_t * child = lv_obj_get_child(obj, i); - child_res = LV_MATH_MAX(child_res, child->coords.y2); + child_res = LV_MAX(child_res, child->coords.y2); } lv_coord_t pad_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN); @@ -141,7 +141,7 @@ lv_coord_t lv_obj_get_scroll_bottom(lv_obj_t * obj) lv_coord_t self_h = _lv_obj_get_self_height(obj); self_h = self_h - (lv_obj_get_height(obj) - pad_top - pad_bottom); self_h -= lv_obj_get_scroll_y(obj); - return LV_MATH_MAX(child_res, self_h); + return LV_MAX(child_res, self_h); } lv_coord_t lv_obj_get_scroll_left(lv_obj_t * obj) @@ -165,7 +165,7 @@ lv_coord_t lv_obj_get_scroll_left(lv_obj_t * obj) lv_coord_t x1 = LV_COORD_MAX; for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { lv_obj_t * child = lv_obj_get_child(obj, i); - x1 = LV_MATH_MIN(x1, child->coords.x1); + x1 = LV_MIN(x1, child->coords.x1); } @@ -178,7 +178,7 @@ lv_coord_t lv_obj_get_scroll_left(lv_obj_t * obj) self_w = self_w - (lv_obj_get_width(obj) - pad_right - pad_left); self_w -= lv_obj_get_scroll_x(obj); - return LV_MATH_MAX(child_res, self_w); + return LV_MAX(child_res, self_w); } lv_coord_t lv_obj_get_scroll_right(lv_obj_t * obj) @@ -197,7 +197,7 @@ lv_coord_t lv_obj_get_scroll_right(lv_obj_t * obj) uint32_t i; for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { lv_obj_t * child = lv_obj_get_child(obj, i); - child_res = LV_MATH_MAX(child_res, child->coords.x2); + child_res = LV_MAX(child_res, child->coords.x2); } lv_coord_t pad_right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN); @@ -209,7 +209,7 @@ lv_coord_t lv_obj_get_scroll_right(lv_obj_t * obj) self_w = _lv_obj_get_self_width(obj); self_w = self_w - (lv_obj_get_width(obj) - pad_right - pad_left); self_w -= lv_obj_get_scroll_x(obj); - return LV_MATH_MAX(child_res, self_w); + return LV_MAX(child_res, self_w); } void lv_obj_get_scroll_end(struct _lv_obj_t * obj, lv_point_t * end) @@ -336,13 +336,13 @@ void lv_obj_scroll_to_view(lv_obj_t * obj, lv_anim_enable_t anim_en) lv_coord_t y_scroll = 0; if((top_diff > 0 || bottom_diff > 0)) { - if(LV_MATH_ABS(top_diff) < LV_MATH_ABS(bottom_diff)) y_scroll = top_diff; + if(LV_ABS(top_diff) < LV_ABS(bottom_diff)) y_scroll = top_diff; else y_scroll = -bottom_diff; } lv_coord_t x_scroll = 0; if((left_diff > 0 || right_diff > 0)) { - if(LV_MATH_ABS(left_diff) < LV_MATH_ABS(right_diff)) x_scroll = left_diff; + if(LV_ABS(left_diff) < LV_ABS(right_diff)) x_scroll = left_diff; else x_scroll = -right_diff; } diff --git a/src/lv_core/lv_obj_style.c b/src/lv_core/lv_obj_style.c index 1b5956a3c..c97715bc4 100644 --- a/src/lv_core/lv_obj_style.c +++ b/src/lv_core/lv_obj_style.c @@ -104,7 +104,7 @@ void lv_obj_add_style_no_refresh(struct _lv_obj_t * obj, uint32_t part, uint32_t obj->style_list.styles[j] = obj->style_list.styles[j - 1]; } - _lv_memset_00(&obj->style_list.styles[i], sizeof(lv_obj_style_t)); + lv_memset_00(&obj->style_list.styles[i], sizeof(lv_obj_style_t)); obj->style_list.styles[i].style = style; obj->style_list.styles[i].part = part; obj->style_list.styles[i].state = state; @@ -460,7 +460,7 @@ lv_obj_style_t * _get_trans_style(lv_obj_t * obj, uint32_t part) obj->style_list.styles[i] = obj->style_list.styles[i - 1]; } - _lv_memset_00(&obj->style_list.styles[0], sizeof(lv_obj_style_t)); + lv_memset_00(&obj->style_list.styles[0], sizeof(lv_obj_style_t)); obj->style_list.styles[0].style = lv_mem_alloc(sizeof(lv_style_t)); lv_style_init(obj->style_list.styles[0].style); obj->style_list.styles[0].is_trans = 1; @@ -491,7 +491,7 @@ lv_style_t * lv_obj_get_local_style(lv_obj_t * obj, uint32_t part, uint32_t stat obj->style_list.styles[i] = obj->style_list.styles[i - 1]; } - _lv_memset_00(&obj->style_list.styles[i], sizeof(lv_obj_style_t)); + lv_memset_00(&obj->style_list.styles[i], sizeof(lv_obj_style_t)); obj->style_list.styles[i].style = lv_mem_alloc(sizeof(lv_style_t)); lv_style_init(obj->style_list.styles[i].style); obj->style_list.styles[i].is_local = 1; @@ -546,8 +546,8 @@ void _lv_obj_create_style_transition(lv_obj_t * obj, lv_style_prop_t prop, uint8 if(v1.num == LV_RADIUS_CIRCLE || v2.num == LV_RADIUS_CIRCLE) { lv_coord_t whalf = lv_obj_get_width(obj) / 2; lv_coord_t hhalf = lv_obj_get_width(obj) / 2; - if(v1.num == LV_RADIUS_CIRCLE) v1.num = LV_MATH_MIN(whalf + 1, hhalf + 1); - if(v2.num == LV_RADIUS_CIRCLE) v2.num = LV_MATH_MIN(whalf + 1, hhalf + 1); + if(v1.num == LV_RADIUS_CIRCLE) v1.num = LV_MIN(whalf + 1, hhalf + 1); + if(v2.num == LV_RADIUS_CIRCLE) v2.num = LV_MIN(whalf + 1, hhalf + 1); } } @@ -632,10 +632,14 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta else if(lv_style_get_prop(style, LV_STYLE_SHADOW_OFS_Y, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; else if(lv_style_get_prop(style, LV_STYLE_SHADOW_SPREAD, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; else if(lv_style_get_prop(style, LV_STYLE_LINE_WIDTH, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; - else if(lv_style_get_prop(style, LV_STYLE_CONTENT_SRC, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; + else if(lv_style_get_prop(style, LV_STYLE_CONTENT_TEXT, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; else if(lv_style_get_prop(style, LV_STYLE_CONTENT_OFS_X, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; else if(lv_style_get_prop(style, LV_STYLE_CONTENT_OFS_Y, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; else if(lv_style_get_prop(style, LV_STYLE_CONTENT_ALIGN, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; + else if(lv_style_get_prop(style, LV_STYLE_CONTENT_FONT, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; + else if(lv_style_get_prop(style, LV_STYLE_CONTENT_LINE_SPACE, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; + else if(lv_style_get_prop(style, LV_STYLE_CONTENT_LETTER_SPACE, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; + else if(lv_style_get_prop(style, LV_STYLE_CONTENT_OPA, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; else { if(res != _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) res = _LV_STYLE_STATE_CMP_DIFF_REDRAW; } @@ -719,16 +723,9 @@ static void update_cache(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop) list->cache_transform_zero = 0; } } - if(prop == LV_STYLE_PROP_ALL || prop == LV_STYLE_BG_BLEND_MODE || prop == LV_STYLE_TEXT_BLEND_MODE || prop == LV_STYLE_BORDER_BLEND_MODE) { - lv_style_value_t va[5]; - if(get_prop_core(obj, part, LV_STYLE_BG_BLEND_MODE, &va[0]) == false) va[0].num = 0; - if(get_prop_core(obj, part, LV_STYLE_BORDER_BLEND_MODE, &va[1]) == false) va[1].num = 0; - if(get_prop_core(obj, part, LV_STYLE_SHADOW_BLEND_MODE, &va[1]) == false) va[2].num = 0; - if(get_prop_core(obj, part, LV_STYLE_OUTLINE_BLEND_MODE, &va[1]) == false) va[3].num = 0; - if(get_prop_core(obj, part, LV_STYLE_TEXT_BLEND_MODE, &va[2]) == false) va[4].num = 0; - - if(va[0].num || va[1].num || va[2].num || va[3].num || va[4].num) list->cache_blend_mode_zero = 1; - else list->cache_blend_mode_zero = 0; + if(prop == LV_STYLE_PROP_ALL || prop == LV_STYLE_BLEND_MODE) { + if(get_prop_core(obj, part, LV_STYLE_BLEND_MODE, &v) == false) v.num = LV_BLEND_MODE_NORMAL; + list->cache_blend_mode_zero = v.num == LV_BLEND_MODE_NORMAL ? 1 : 0; } if(prop == LV_STYLE_PROP_ALL || prop == LV_STYLE_BG_GRAD_DIR) { @@ -751,8 +748,8 @@ static void update_cache(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop) if(v.num == 0) list->cache_img_recolor_opa_zero = 1; else list->cache_img_recolor_opa_zero = 0; } - if(prop == LV_STYLE_PROP_ALL || prop == LV_STYLE_CONTENT_SRC) { - if(get_prop_core(obj, part, LV_STYLE_CONTENT_SRC, &v) == false) v.ptr = NULL; + if(prop == LV_STYLE_PROP_ALL || prop == LV_STYLE_CONTENT_TEXT) { + if(get_prop_core(obj, part, LV_STYLE_CONTENT_TEXT, &v) == false) v.ptr = NULL; if(v.ptr == NULL) list->cache_content_src_zero = 1; else list->cache_content_src_zero = 0; } @@ -806,19 +803,11 @@ static cache_t read_cache(const lv_obj_t * obj, lv_part_t part, lv_style_prop_t switch(prop) { - case LV_STYLE_BG_BLEND_MODE: - case LV_STYLE_BORDER_BLEND_MODE: - case LV_STYLE_SHADOW_BLEND_MODE: - case LV_STYLE_OUTLINE_BLEND_MODE: + case LV_STYLE_BLEND_MODE: if(list->cache_blend_mode_zero ) return CACHE_ZERO; else return CACHE_NEED_CHECK; break; - case LV_STYLE_TEXT_BLEND_MODE: - if(list->cache_blend_mode_zero ) return CACHE_UNSET; - else return CACHE_NEED_CHECK; - break; - case LV_STYLE_OPA: if(list->cache_opa_set) return CACHE_NEED_CHECK; else return CACHE_UNSET; @@ -871,7 +860,7 @@ static cache_t read_cache(const lv_obj_t * obj, lv_part_t part, lv_style_prop_t if(list->cache_shadow_width_zero ) return CACHE_ZERO; else return CACHE_NEED_CHECK; break; - case LV_STYLE_CONTENT_SRC: + case LV_STYLE_CONTENT_TEXT: if(list->cache_content_src_zero ) return CACHE_ZERO; else return CACHE_NEED_CHECK; break; @@ -1004,12 +993,7 @@ static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v) case LV_STYLE_BORDER_SIDE: case LV_STYLE_BORDER_POST: - case LV_STYLE_BG_BLEND_MODE: - case LV_STYLE_BORDER_BLEND_MODE: - case LV_STYLE_OUTLINE_BLEND_MODE: - case LV_STYLE_SHADOW_BLEND_MODE: - case LV_STYLE_TEXT_BLEND_MODE: - case LV_STYLE_LINE_BLEND_MODE: + case LV_STYLE_BLEND_MODE: if(v < 255) value_final.num = tr->start_value.num; else value_final.num = tr->end_value.num; break; diff --git a/src/lv_core/lv_obj_style.h b/src/lv_core/lv_obj_style.h index de7693b94..edca2a978 100644 --- a/src/lv_core/lv_obj_style.h +++ b/src/lv_core/lv_obj_style.h @@ -195,228 +195,245 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(struct _lv_obj_t * obj, lv_sta /********************* * OBJ STYLE GET *********************/ - static inline lv_coord_t lv_obj_get_style_radius(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_RADIUS); return v.num; } + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_RADIUS); return (lv_coord_t) v.num; } static inline bool lv_obj_get_style_clip_corner(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CLIP_CORNER); return v.num; } + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CLIP_CORNER); return (bool) v.num; } static inline lv_coord_t lv_obj_get_style_transform_width(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_WIDTH); return v.num; } + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_WIDTH); return (lv_coord_t) v.num; } static inline lv_coord_t lv_obj_get_style_transform_height(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_HEIGHT); return v.num; } + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_HEIGHT); return (lv_coord_t) v.num; } static inline lv_coord_t lv_obj_get_style_transform_zoom(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ZOOM); return v.num; } + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ZOOM); return (lv_coord_t) v.num; } static inline lv_coord_t lv_obj_get_style_transform_angle(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ANGLE); return v.num; } + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ANGLE); return (lv_coord_t) v.num; } static inline lv_opa_t lv_obj_get_style_opa(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OPA); return v.num; } - -static inline lv_opa_t lv_obj_get_style_anim_time(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ANIM_TIME); return v.num; } + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OPA); return (lv_opa_t) v.num; } static inline lv_color_filter_cb_t lv_obj_get_style_color_filter_cb(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_CB); return (lv_color_filter_cb_t)v.func; } + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_CB); return (lv_color_filter_cb_t) v.func; } static inline lv_opa_t lv_obj_get_style_color_filter_opa(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_OPA); return v.num; } + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_OPA); return (lv_opa_t) v.num; } -static inline lv_coord_t lv_obj_get_style_pad_top(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_TOP); return v.num; } +static inline uint32_t lv_obj_get_style_anim_time(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ANIM_TIME); return (uint32_t) v.num; } -static inline lv_coord_t lv_obj_get_style_pad_bottom(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_BOTTOM); return v.num; } - -static inline lv_coord_t lv_obj_get_style_pad_left(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_LEFT); return v.num; } - -static inline lv_coord_t lv_obj_get_style_pad_right(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_RIGHT); return v.num; } - -static inline lv_coord_t lv_obj_get_style_pad_row(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_ROW); return v.num; } - -static inline lv_coord_t lv_obj_get_style_pad_column(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_COLUMN); return v.num; } - -static inline lv_color_t lv_obj_get_style_bg_color(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR); return v.color; } - -static inline lv_color_t lv_obj_get_style_bg_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR_FILTERED); return v.color; } - -static inline lv_opa_t lv_obj_get_style_bg_opa(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_OPA); return v.num; } - -static inline lv_color_t lv_obj_get_style_bg_grad_color(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_COLOR); return v.color; } - -static inline lv_color_t lv_obj_get_style_bg_grad_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_COLOR_FILTERED); return v.color; } - -static inline lv_grad_dir_t lv_obj_get_style_bg_grad_dir(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_DIR); return v.num; } - -static inline lv_blend_mode_t lv_obj_get_style_bg_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_BLEND_MODE); return v.num; } - -static inline lv_coord_t lv_obj_get_style_bg_main_stop(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_MAIN_STOP); return v.num; } - -static inline lv_coord_t lv_obj_get_style_bg_grad_stop(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_STOP); return v.num; } - -static inline lv_color_t lv_obj_get_style_border_color(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_COLOR); return v.color; } - -static inline lv_color_t lv_obj_get_style_border_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_COLOR_FILTERED); return v.color; } - -static inline lv_opa_t lv_obj_get_style_border_opa(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_OPA); return v.num; } - -static inline lv_coord_t lv_obj_get_style_border_width(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_WIDTH); return v.num; } - -static inline lv_border_side_t lv_obj_get_style_border_side(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_SIDE); return v.num; } - -static inline bool lv_obj_get_style_border_post(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_POST); return v.num; } - -static inline lv_blend_mode_t lv_obj_get_style_border_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_BLEND_MODE); return v.num; } - -static inline lv_color_t lv_obj_get_style_text_color(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_COLOR); return v.color; } - -static inline lv_color_t lv_obj_get_style_text_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_COLOR_FILTERED); return v.color; } - -static inline lv_opa_t lv_obj_get_style_text_opa(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_OPA); return v.num; } - -static inline const lv_font_t * lv_obj_get_style_text_font(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_FONT); return v.ptr; } - -static inline lv_coord_t lv_obj_get_style_text_letter_space(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_LETTER_SPACE); return v.num; } - -static inline lv_coord_t lv_obj_get_style_text_line_space(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_LINE_SPACE); return v.num; } - -static inline lv_coord_t lv_obj_get_style_text_align(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_ALIGN); return v.num; } - -static inline lv_text_decor_t lv_obj_get_style_text_decor(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_DECOR); return v.num; } - -static inline lv_blend_mode_t lv_obj_get_style_text_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_BLEND_MODE); return v.num; } - -static inline lv_opa_t lv_obj_get_style_img_opa(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_OPA); return v.num; } - -static inline lv_blend_mode_t lv_obj_get_style_img_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_BLEND_MODE); return v.num; } - -static inline lv_color_t lv_obj_get_style_img_recolor(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR); return v.color; } - -static inline lv_color_t lv_obj_get_style_img_recolor_filtered(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR_FILTERED); return v.color; } - -static inline lv_opa_t lv_obj_get_style_img_recolor_opa(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR_OPA); return v.num; } - -static inline lv_coord_t lv_obj_get_style_outline_width(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_WIDTH); return v.num; } - -static inline lv_color_t lv_obj_get_style_outline_color(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_COLOR); return v.color; } - -static inline lv_color_t lv_obj_get_style_outline_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_COLOR_FILTERED); return v.color; } - -static inline lv_opa_t lv_obj_get_style_outline_opa(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_OPA); return v.num; } - -static inline lv_coord_t lv_obj_get_style_outline_pad(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_PAD); return v.num; } - -static inline lv_blend_mode_t lv_obj_get_style_outline_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_BLEND_MODE); return v.num; } - -static inline lv_coord_t lv_obj_get_style_shadow_width(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_WIDTH); return v.num; } - -static inline lv_coord_t lv_obj_get_style_shadow_ofs_x(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OFS_X); return v.num; } - -static inline lv_coord_t lv_obj_get_style_shadow_ofs_y(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OFS_Y); return v.num; } - -static inline lv_coord_t lv_obj_get_style_shadow_spread(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_SPREAD); return v.num; } - -static inline lv_blend_mode_t lv_obj_get_style_shadow_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_BLEND_MODE); return v.num; } - -static inline lv_color_t lv_obj_get_style_shadow_color(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_COLOR); return v.color; } - -static inline lv_color_t lv_obj_get_style_shadow_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_COLOR_FILTERED); return v.color; } - -static inline lv_opa_t lv_obj_get_style_shadow_opa(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OPA); return v.num; } - -static inline lv_coord_t lv_obj_get_style_line_width(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_WIDTH); return v.num; } - -static inline lv_blend_mode_t lv_obj_get_style_line_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_BLEND_MODE); return v.num; } - -static inline lv_coord_t lv_obj_get_style_line_dash_width(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_DASH_WIDTH); return v.num; } - -static inline lv_coord_t lv_obj_get_style_line_dash_gap(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_DASH_GAP); return v.num; } - -static inline lv_coord_t lv_obj_get_style_line_rounded(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_ROUNDED); return v.num; } - -static inline lv_color_t lv_obj_get_style_line_color(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_COLOR); return v.color; } - -static inline lv_color_t lv_obj_get_style_line_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_COLOR_FILTERED); return v.color; } - -static inline lv_opa_t lv_obj_get_style_line_opa(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_OPA); return v.num; } - -static inline const char * lv_obj_get_style_content_src(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_SRC); return v.ptr; } - -static inline lv_align_t lv_obj_get_style_content_align(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_ALIGN); return v.num; } - -static inline lv_coord_t lv_obj_get_style_content_ofs_x(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OFS_X); return v.num; } - -static inline lv_coord_t lv_obj_get_style_content_ofs_y(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OFS_Y); return v.num; } - -static inline const lv_style_transiton_t * lv_obj_get_style_transition(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION); return v.ptr; } +static inline const lv_style_transition_t * lv_obj_get_style_transition(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION); return (const lv_style_transition_t *) v.ptr; } static inline lv_coord_t lv_obj_get_style_size(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SIZE); return v.num; } + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SIZE); return (lv_coord_t) v.num; } + +static inline lv_blend_mode_t lv_obj_get_style_blend_mode(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BLEND_MODE); return (lv_blend_mode_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_pad_top(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_TOP); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_pad_bottom(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_BOTTOM); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_pad_left(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_LEFT); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_pad_right(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_RIGHT); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_pad_row(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_ROW); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_pad_column(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_COLUMN); return (lv_coord_t) v.num; } + +static inline lv_color_t lv_obj_get_style_bg_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR); return (lv_color_t) v.color; } + +static inline lv_color_t lv_obj_get_style_bg_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR_FILTERED); return (lv_color_t) v.color; } + +static inline lv_opa_t lv_obj_get_style_bg_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_OPA); return (lv_opa_t) v.num; } + +static inline lv_color_t lv_obj_get_style_bg_grad_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_COLOR); return (lv_color_t) v.color; } + +static inline lv_color_t lv_obj_get_style_bg_grad_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_COLOR_FILTERED); return (lv_color_t) v.color; } + +static inline lv_grad_dir_t lv_obj_get_style_bg_grad_dir(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_DIR); return (lv_grad_dir_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_bg_main_stop(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_MAIN_STOP); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_bg_grad_stop(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_STOP); return (lv_coord_t) v.num; } + +static inline const void * lv_obj_get_style_bg_img_src(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMG_SRC); return (const void *) v.ptr; } + +static inline lv_color_t lv_obj_get_style_bg_img_recolor(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMG_RECOLOR); return (lv_color_t) v.color; } + +static inline lv_color_t lv_obj_get_style_bg_img_recolor_filtered(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMG_RECOLOR_FILTERED); return (lv_color_t) v.color; } + +static inline lv_opa_t lv_obj_get_style_bg_img_recolor_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMG_RECOLOR_OPA); return (lv_opa_t) v.num; } + +static inline bool lv_obj_get_style_bg_img_tiled(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMG_TILED); return (bool) v.num; } + +static inline lv_color_t lv_obj_get_style_border_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_COLOR); return (lv_color_t) v.color; } + +static inline lv_color_t lv_obj_get_style_border_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_COLOR_FILTERED); return (lv_color_t) v.color; } + +static inline lv_opa_t lv_obj_get_style_border_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_OPA); return (lv_opa_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_border_width(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_WIDTH); return (lv_coord_t) v.num; } + +static inline lv_border_side_t lv_obj_get_style_border_side(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_SIDE); return (lv_border_side_t) v.num; } + +static inline bool lv_obj_get_style_border_post(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_POST); return (bool) v.num; } + +static inline lv_color_t lv_obj_get_style_text_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_COLOR); return (lv_color_t) v.color; } + +static inline lv_color_t lv_obj_get_style_text_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_COLOR_FILTERED); return (lv_color_t) v.color; } + +static inline lv_opa_t lv_obj_get_style_text_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_OPA); return (lv_opa_t) v.num; } + +static inline const lv_font_t * lv_obj_get_style_text_font(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_FONT); return (const lv_font_t *) v.ptr; } + +static inline lv_coord_t lv_obj_get_style_text_letter_space(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_LETTER_SPACE); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_text_line_space(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_LINE_SPACE); return (lv_coord_t) v.num; } + +static inline lv_text_decor_t lv_obj_get_style_text_decor(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_DECOR); return (lv_text_decor_t) v.num; } + +static inline lv_text_align_t lv_obj_get_style_text_align(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_ALIGN); return (lv_text_align_t) v.num; } + +static inline lv_opa_t lv_obj_get_style_img_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_OPA); return (lv_opa_t) v.num; } + +static inline lv_color_t lv_obj_get_style_img_recolor(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR); return (lv_color_t) v.color; } + +static inline lv_color_t lv_obj_get_style_img_recolor_filtered(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR_FILTERED); return (lv_color_t) v.color; } + +static inline lv_opa_t lv_obj_get_style_img_recolor_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR_OPA); return (lv_opa_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_outline_width(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_WIDTH); return (lv_coord_t) v.num; } + +static inline lv_color_t lv_obj_get_style_outline_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_COLOR); return (lv_color_t) v.color; } + +static inline lv_color_t lv_obj_get_style_outline_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_COLOR_FILTERED); return (lv_color_t) v.color; } + +static inline lv_opa_t lv_obj_get_style_outline_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_OPA); return (lv_opa_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_outline_pad(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_PAD); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_shadow_width(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_WIDTH); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_shadow_ofs_x(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OFS_X); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_shadow_ofs_y(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OFS_Y); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_shadow_spread(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_SPREAD); return (lv_coord_t) v.num; } + +static inline lv_color_t lv_obj_get_style_shadow_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_COLOR); return (lv_color_t) v.color; } + +static inline lv_color_t lv_obj_get_style_shadow_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_COLOR_FILTERED); return (lv_color_t) v.color; } + +static inline lv_opa_t lv_obj_get_style_shadow_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OPA); return (lv_opa_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_line_width(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_WIDTH); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_line_dash_width(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_DASH_WIDTH); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_line_dash_gap(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_DASH_GAP); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_line_rounded(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_ROUNDED); return (lv_coord_t) v.num; } + +static inline lv_color_t lv_obj_get_style_line_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_COLOR); return (lv_color_t) v.color; } + +static inline lv_color_t lv_obj_get_style_line_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_COLOR_FILTERED); return (lv_color_t) v.color; } + +static inline lv_opa_t lv_obj_get_style_line_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_OPA); return (lv_opa_t) v.num; } + +static inline const char * lv_obj_get_style_content_text(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_TEXT); return (const char *) v.ptr; } + +static inline lv_align_t lv_obj_get_style_content_align(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_ALIGN); return (lv_align_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_content_ofs_x(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OFS_X); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_content_ofs_y(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OFS_Y); return (lv_coord_t) v.num; } + +static inline lv_opa_t lv_obj_get_style_content_opa(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OPA); return (lv_opa_t) v.num; } + +static inline const lv_font_t * lv_obj_get_style_content_font(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_FONT); return (const lv_font_t *) v.ptr; } + +static inline lv_color_t lv_obj_get_style_content_color(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_COLOR); return (lv_color_t) v.color; } + +static inline lv_color_t lv_obj_get_style_content_color_filtered(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_COLOR_FILTERED); return (lv_color_t) v.color; } + +static inline lv_coord_t lv_obj_get_style_content_letter_space(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_LETTER_SPACE); return (lv_coord_t) v.num; } + +static inline lv_coord_t lv_obj_get_style_content_line_space(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_LINE_SPACE); return (lv_coord_t) v.num; } + +static inline lv_text_decor_t lv_obj_get_style_content_decor(const struct _lv_obj_t * obj, uint32_t part) { + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_DECOR); return (lv_text_decor_t) v.num; } /********************** * MACROS diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index 7d5fcb0f4..ea7a3dbb7 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -225,7 +225,7 @@ void _lv_disp_refr_task(lv_timer_t * tmr) #if LV_USE_GPU_STM32_DMA2D LV_UNUSED(copy_buf); #else - copy_buf = _lv_mem_buf_get(disp_refr->driver.hor_res * sizeof(lv_color_t)); + copy_buf = lv_mem_buf_get(disp_refr->driver.hor_res * sizeof(lv_color_t)); #endif uint8_t * buf_act = (uint8_t *)vdb->buf_act; @@ -250,21 +250,21 @@ void _lv_disp_refr_task(lv_timer_t * tmr) for(y = disp_refr->inv_areas[a].y1; y <= disp_refr->inv_areas[a].y2; y++) { /* The frame buffer is probably in an external RAM where sequential access is much faster. * So first copy a line into a buffer and write it back the ext. RAM */ - _lv_memcpy(copy_buf, buf_ina + start_offs, line_length); - _lv_memcpy(buf_act + start_offs, copy_buf, line_length); + lv_memcpy(copy_buf, buf_ina + start_offs, line_length); + lv_memcpy(buf_act + start_offs, copy_buf, line_length); start_offs += hres * sizeof(lv_color_t); } #endif } } - if(copy_buf) _lv_mem_buf_release(copy_buf); + if(copy_buf) lv_mem_buf_release(copy_buf); } } /*End of true double buffer handling*/ /*Clean up*/ - _lv_memset_00(disp_refr->inv_areas, sizeof(disp_refr->inv_areas)); - _lv_memset_00(disp_refr->inv_area_joined, sizeof(disp_refr->inv_area_joined)); + lv_memset_00(disp_refr->inv_areas, sizeof(disp_refr->inv_areas)); + lv_memset_00(disp_refr->inv_area_joined, sizeof(disp_refr->inv_area_joined)); disp_refr->inv_p = 0; elaps = lv_tick_elaps(start); @@ -274,7 +274,7 @@ void _lv_disp_refr_task(lv_timer_t * tmr) } } - _lv_mem_buf_free_all(); + lv_mem_buf_free_all(); _lv_font_clean_up_fmt_txt(); #if LV_USE_PERF_MONITOR && LV_USE_LABEL diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index 691c5a139..20f674566 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -21,9 +21,6 @@ /********************** * STATIC PROTOTYPES **********************/ -static void set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value); -static bool get_prop(const lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value); -static bool remove_prop(lv_style_t * style, lv_style_prop_t prop); /********************** * GLOBAL VARIABLES @@ -51,7 +48,7 @@ void _lv_style_system_init(void) */ void lv_style_init(lv_style_t * style) { - _lv_memset_00(style, sizeof(lv_style_t)); + lv_memset_00(style, sizeof(lv_style_t)); #if LV_USE_ASSERT_STYLE style->sentinel = LV_DEBUG_STYLE_SENTINEL_VALUE; #endif @@ -75,7 +72,50 @@ uint16_t lv_style_register_prop(bool inherit) */ bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop) { - return remove_prop(style, prop); + if(style == NULL) return false; + LV_ASSERT_STYLE(style); + + if(!style->allocated) { + if(style->prop1 == prop) { + style->prop1 = _LV_STYLE_PROP_INV; + return true; + } + return false; + + } + + uint8_t * tmp = style->props_and_values + style->prop_cnt * sizeof(lv_style_value_t); + uint16_t * props = (uint16_t *) tmp; + uint32_t i; + for(i = 0; i < style->prop_cnt; i++) { + if(props[i] == prop) { + lv_style_value_t * values = (lv_style_value_t *)style->props_and_values; + style->prop_cnt--; + size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t)); + uint8_t * new_values_and_props = lv_mem_alloc(size); + + uint8_t * tmp = new_values_and_props + style->prop_cnt * sizeof(lv_style_value_t); + uint16_t * new_props = (uint16_t *) tmp; + lv_style_value_t * new_values = (lv_style_value_t *)new_values_and_props; + + uint32_t j; + for(j = 0; j < style->prop_cnt + 1; j++) { /* +1: because prop_cnt already reduced but all the old props. needs to be checked. */ + if(props[j] != prop) { + *new_values = values[j]; + *new_props = props[j]; + + new_values++; + new_props++; + } + } + + lv_mem_free(style->props_and_values); + style->props_and_values = new_values_and_props; + return true; + } + } + + return false; } /** @@ -91,17 +131,87 @@ void lv_style_reset(lv_style_t * style) void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value) { - set_prop(style, prop, value); + if(style->allocated) { + uint8_t * tmp = style->props_and_values + style->prop_cnt * sizeof(lv_style_value_t); + uint16_t * props = (uint16_t *) tmp; + int32_t i; + for(i = 0; i < style->prop_cnt; i++) { + if(props[i] == prop) { + lv_style_value_t * values = (lv_style_value_t *)style->props_and_values; + values[i] = value; + return; + } + } + + style->prop_cnt++; + size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t)); + style->props_and_values = lv_mem_realloc(style->props_and_values, size); + tmp = style->props_and_values + (style->prop_cnt - 1) * sizeof(lv_style_value_t); + props = (uint16_t *) tmp; + /*Shift all props to make place for the value before them*/ + for(i = style->prop_cnt - 2; i >= 0; i--) { + props[i + sizeof(lv_style_value_t) /sizeof(uint16_t)] = props[i]; + } + + /*Go to the new position wit the props*/ + tmp = style->props_and_values + (style->prop_cnt) * sizeof(lv_style_value_t); + props = (uint16_t *) tmp; + lv_style_value_t * values = (lv_style_value_t *)style->props_and_values; + + /*Set the new property and value*/ + props[style->prop_cnt - 1] = prop; + values[style->prop_cnt - 1] = value; + } else if(style->prop_cnt == 1) { + if(style->prop1 == prop) { + style->value1 = value; + return; + } + style->prop_cnt++; + size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t)); + uint8_t * props_and_values = lv_mem_alloc(size); + uint8_t * tmp = props_and_values + (style->prop_cnt) * sizeof(lv_style_value_t); + uint16_t * props = (uint16_t *) tmp; + lv_style_value_t * values = (lv_style_value_t *)props_and_values; + props[0] = style->prop1; + props[1] = prop; + values[0] = style->value1; + values[1] = value; + + style->props_and_values = props_and_values; + + style->allocated = 1; + } else if (style->prop_cnt == 0) { + style->prop_cnt++; + style->prop1 = prop; + style->value1 = value; + } } bool lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value) { - return get_prop(style, prop, value); + if(style->allocated) { + uint8_t * tmp = style->props_and_values + style->prop_cnt * sizeof(lv_style_value_t); + uint16_t * props = (uint16_t *) tmp; + uint32_t i; + for(i = 0; i < style->prop_cnt; i++) { + if(props[i] == prop) { + lv_style_value_t * values = (lv_style_value_t *)style->props_and_values; + *value = values[i]; + return true; + } + } + } else { + if(style->prop1 == prop) { + *value = style->value1; + return true; + } + } + return false; } -void lv_style_transition_init(lv_style_transiton_t * tr, const lv_style_prop_t * props, const lv_anim_path_t * path, uint32_t time, uint32_t delay) +void lv_style_transition_init(lv_style_transition_t * tr, const lv_style_prop_t * props, const lv_anim_path_t * path, uint32_t time, uint32_t delay) { - _lv_memset_00(tr, sizeof(lv_style_transiton_t)); + lv_memset_00(tr, sizeof(lv_style_transition_t)); tr->props = props; tr->path = path; tr->time = time; @@ -187,134 +297,3 @@ bool lv_style_is_empty(const lv_style_t * style) /********************** * STATIC FUNCTIONS **********************/ - -static void set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value) -{ - if(style->allocated) { - uint8_t * tmp = style->props_and_values + style->prop_cnt * sizeof(lv_style_value_t); - uint16_t * props = (uint16_t *) tmp; - int32_t i; - for(i = 0; i < style->prop_cnt; i++) { - if(props[i] == prop) { - lv_style_value_t * values = (lv_style_value_t *)style->props_and_values; - values[i] = value; - return; - } - } - - style->prop_cnt++; - size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t)); - style->props_and_values = lv_mem_realloc(style->props_and_values, size); - tmp = style->props_and_values + (style->prop_cnt - 1) * sizeof(lv_style_value_t); - props = (uint16_t *) tmp; - /*Shift all props to make place for the value before them*/ - for(i = style->prop_cnt - 2; i >= 0; i--) { - props[i + sizeof(lv_style_value_t) /sizeof(uint16_t)] = props[i]; - } - - /*Go to the new position wit the props*/ - tmp = style->props_and_values + (style->prop_cnt) * sizeof(lv_style_value_t); - props = (uint16_t *) tmp; - lv_style_value_t * values = (lv_style_value_t *)style->props_and_values; - - /*Set the new propery and value*/ - props[style->prop_cnt - 1] = prop; - values[style->prop_cnt - 1] = value; - } else if(style->prop_cnt == 1) { - if(style->prop1 == prop) { - style->value1 = value; - return; - } - style->prop_cnt++; - size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t)); - uint8_t * props_and_values = lv_mem_alloc(size); - uint8_t * tmp = props_and_values + (style->prop_cnt) * sizeof(lv_style_value_t); - uint16_t * props = (uint16_t *) tmp; - lv_style_value_t * values = (lv_style_value_t *)props_and_values; - props[0] = style->prop1; - props[1] = prop; - values[0] = style->value1; - values[1] = value; - - style->props_and_values = props_and_values; - - style->allocated = 1; - } else if (style->prop_cnt == 0) { - style->prop_cnt++; - style->prop1 = prop; - style->value1 = value; - } -} - - -static bool get_prop(const lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value) -{ - if(style->allocated) { - uint8_t * tmp = style->props_and_values + style->prop_cnt * sizeof(lv_style_value_t); - uint16_t * props = (uint16_t *) tmp; - uint32_t i; - for(i = 0; i < style->prop_cnt; i++) { - if(props[i] == prop) { - lv_style_value_t * values = (lv_style_value_t *)style->props_and_values; - *value = values[i]; - return true; - } - } - } else { - if(style->prop1 == prop) { - *value = style->value1; - return true; - } - } - return false; -} - -static bool remove_prop(lv_style_t * style, lv_style_prop_t prop) -{ - if(style == NULL) return false; - LV_ASSERT_STYLE(style); - - if(!style->allocated) { - if(style->prop1 == prop) { - style->prop1 = _LV_STYLE_PROP_INV; - return true; - } - return false; - - } - - - - uint8_t * tmp = style->props_and_values + style->prop_cnt * sizeof(lv_style_value_t); - uint16_t * props = (uint16_t *) tmp; - uint32_t i; - for(i = 0; i < style->prop_cnt; i++) { - if(props[i] == prop) { - lv_style_value_t * values = (lv_style_value_t *)style->props_and_values; - style->prop_cnt--; - size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t)); - uint8_t * new_values_and_props = lv_mem_alloc(size); - - uint8_t * tmp = new_values_and_props + style->prop_cnt * sizeof(lv_style_value_t); - uint16_t * new_props = (uint16_t *) tmp; - lv_style_value_t * new_values = (lv_style_value_t *)new_values_and_props; - - uint32_t j; - for(j = 0; j < style->prop_cnt + 1; j++) { /* +1: because prop_cnt already reduced but all the old props. needs to be checked. */ - if(props[j] != prop) { - *new_values = values[j]; - *new_props = props[j]; - - new_values++; - new_props++; - } - } - - lv_mem_free(style->props_and_values); - style->props_and_values = new_values_and_props; - return true; - } - } - - return false; -} diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index 79bb1acbe..867aca995 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -63,6 +63,7 @@ typedef enum { LV_STYLE_ANIM_TIME = 10, LV_STYLE_TRANSITION = 11, LV_STYLE_SIZE = 12, + LV_STYLE_BLEND_MODE = 13, LV_STYLE_PAD_TOP = 20 | LV_STYLE_PROP_LAYOUT_REFR, LV_STYLE_PAD_BOTTOM = 21 | LV_STYLE_PROP_LAYOUT_REFR, @@ -77,63 +78,70 @@ typedef enum { LV_STYLE_BG_GRAD_COLOR = 32, LV_STYLE_BG_GRAD_COLOR_FILTERED = 32 | LV_STYLE_PROP_FILTER, LV_STYLE_BG_GRAD_DIR = 33, - LV_STYLE_BG_BLEND_MODE = 34, LV_STYLE_BG_MAIN_STOP = 35, LV_STYLE_BG_GRAD_STOP = 36, - LV_STYLE_BORDER_COLOR = 40, - LV_STYLE_BORDER_COLOR_FILTERED = 40 | LV_STYLE_PROP_FILTER, - LV_STYLE_BORDER_OPA = 41, - LV_STYLE_BORDER_WIDTH = 42, - LV_STYLE_BORDER_SIDE = 43, - LV_STYLE_BORDER_POST = 44, - LV_STYLE_BORDER_BLEND_MODE = 45, + LV_STYLE_BG_IMG_SRC = 40, + LV_STYLE_BG_IMG_OPA = 41, + LV_STYLE_BG_IMG_RECOLOR = 42, + LV_STYLE_BG_IMG_RECOLOR_FILTERED = 43 | LV_STYLE_PROP_FILTER, + LV_STYLE_BG_IMG_RECOLOR_OPA = 44, + LV_STYLE_BG_IMG_TILED = 45, - LV_STYLE_TEXT_COLOR = 50 | LV_STYLE_PROP_INHERIT, - LV_STYLE_TEXT_COLOR_FILTERED = 50 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_FILTER, - LV_STYLE_TEXT_OPA = 51 | LV_STYLE_PROP_INHERIT, - LV_STYLE_TEXT_FONT = 52 | LV_STYLE_PROP_INHERIT, - LV_STYLE_TEXT_LETTER_SPACE = 53 | LV_STYLE_PROP_INHERIT, - LV_STYLE_TEXT_LINE_SPACE = 54 | LV_STYLE_PROP_INHERIT, - LV_STYLE_TEXT_DECOR = 55 | LV_STYLE_PROP_INHERIT, - LV_STYLE_TEXT_ALIGN = 56 | LV_STYLE_PROP_INHERIT, - LV_STYLE_TEXT_BLEND_MODE = 57 | LV_STYLE_PROP_INHERIT, + LV_STYLE_BORDER_COLOR = 50, + LV_STYLE_BORDER_COLOR_FILTERED = 50 | LV_STYLE_PROP_FILTER, + LV_STYLE_BORDER_OPA = 51, + LV_STYLE_BORDER_WIDTH = 52, + LV_STYLE_BORDER_SIDE = 53, + LV_STYLE_BORDER_POST = 54, - LV_STYLE_IMG_OPA = 60, - LV_STYLE_IMG_BLEND_MODE = 61, - LV_STYLE_IMG_RECOLOR = 62, - LV_STYLE_IMG_RECOLOR_FILTERED = 62 | LV_STYLE_PROP_FILTER, - LV_STYLE_IMG_RECOLOR_OPA = 63, + LV_STYLE_TEXT_COLOR = 60 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_COLOR_FILTERED = 60 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_FILTER, + LV_STYLE_TEXT_OPA = 61 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_FONT = 62 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_LETTER_SPACE = 63 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_LINE_SPACE = 64 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_DECOR = 65 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_ALIGN = 66 | LV_STYLE_PROP_INHERIT, - LV_STYLE_OUTLINE_WIDTH = 71 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_OUTLINE_COLOR = 72, - LV_STYLE_OUTLINE_COLOR_FILTERED = 72 | LV_STYLE_PROP_FILTER, - LV_STYLE_OUTLINE_OPA = 73 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_OUTLINE_PAD = 74 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_OUTLINE_BLEND_MODE = 75, + LV_STYLE_IMG_OPA = 70, + LV_STYLE_IMG_RECOLOR = 71, + LV_STYLE_IMG_RECOLOR_FILTERED = 71 | LV_STYLE_PROP_FILTER, + LV_STYLE_IMG_RECOLOR_OPA = 73, - LV_STYLE_SHADOW_WIDTH = 80 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_SHADOW_OFS_X = 81 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_SHADOW_OFS_Y = 82 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_SHADOW_SPREAD = 83 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_SHADOW_BLEND_MODE = 84, - LV_STYLE_SHADOW_COLOR = 85, - LV_STYLE_SHADOW_COLOR_FILTERED = 85 | LV_STYLE_PROP_FILTER, - LV_STYLE_SHADOW_OPA = 86 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_OUTLINE_WIDTH = 80 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_OUTLINE_COLOR = 81, + LV_STYLE_OUTLINE_COLOR_FILTERED = 81 | LV_STYLE_PROP_FILTER, + LV_STYLE_OUTLINE_OPA = 82 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_OUTLINE_PAD = 83 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_LINE_WIDTH = 90 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_LINE_BLEND_MODE = 91, - LV_STYLE_LINE_DASH_WIDTH = 92, - LV_STYLE_LINE_DASH_GAP = 93, - LV_STYLE_LINE_ROUNDED = 94, - LV_STYLE_LINE_COLOR = 95, - LV_STYLE_LINE_COLOR_FILTERED = 95 | LV_STYLE_PROP_FILTER, - LV_STYLE_LINE_OPA = 96, + LV_STYLE_SHADOW_WIDTH = 90 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_SHADOW_OFS_X = 91 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_SHADOW_OFS_Y = 92 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_SHADOW_SPREAD = 93 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_SHADOW_COLOR = 94, + LV_STYLE_SHADOW_COLOR_FILTERED = 94 | LV_STYLE_PROP_FILTER, + LV_STYLE_SHADOW_OPA = 95 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_CONTENT_SRC = 100 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_CONTENT_ALIGN = 101 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_CONTENT_OFS_X = 102 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_CONTENT_OFS_Y = 103 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_LINE_WIDTH = 100 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_LINE_DASH_WIDTH = 101, + LV_STYLE_LINE_DASH_GAP = 102, + LV_STYLE_LINE_ROUNDED = 103, + LV_STYLE_LINE_COLOR = 104, + LV_STYLE_LINE_COLOR_FILTERED = 104 | LV_STYLE_PROP_FILTER, + LV_STYLE_LINE_OPA = 105, + + LV_STYLE_CONTENT_TEXT = 110 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_CONTENT_ALIGN = 111 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_CONTENT_OFS_X = 112 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_CONTENT_OFS_Y = 113 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_CONTENT_FONT = 114 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT, + LV_STYLE_CONTENT_COLOR = 115 | LV_STYLE_PROP_INHERIT, + LV_STYLE_CONTENT_COLOR_FILTERED = 115 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_FILTER, + LV_STYLE_CONTENT_OPA = 116 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT, + LV_STYLE_CONTENT_LETTER_SPACE = 117 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT, + LV_STYLE_CONTENT_LINE_SPACE = 118 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT, + LV_STYLE_CONTENT_DECOR = 119 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT, _LV_STYLE_LAST_BUILT_IN_PROP = 128, @@ -147,7 +155,7 @@ typedef struct _lv_style_transiton_t{ const lv_anim_path_t * path; uint32_t time; uint32_t delay; -}lv_style_transiton_t; +}lv_style_transition_t; #if LV_USE_ASSERT_STYLE # define _LV_STYLE_SENTINEL uint32_t sentinel; @@ -196,7 +204,7 @@ void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_ bool lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value); -void lv_style_transition_init(lv_style_transiton_t * tr, const lv_style_prop_t * props, const lv_anim_path_t * path, uint32_t time, uint32_t delay); +void lv_style_transition_init(lv_style_transition_t * tr, const lv_style_prop_t * props, const lv_anim_path_t * path, uint32_t time, uint32_t delay); uint32_t lv_style_find_index_num(lv_style_value_t v); uint32_t lv_style_find_index_color(lv_style_value_t v); @@ -213,9 +221,6 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop); static inline void lv_style_set_radius(lv_style_t * style, lv_coord_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_RADIUS, v); } -static inline void lv_style_set_anim_time(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_ANIM_TIME, v); } - static inline void lv_style_set_clip_corner(lv_style_t * style, bool value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CLIP_CORNER, v); } @@ -240,6 +245,18 @@ static inline void lv_style_set_color_filter_cb(lv_style_t * style, lv_color_fil static inline void lv_style_set_color_filter_opa(lv_style_t * style, lv_opa_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_COLOR_FILTER_OPA, v); } +static inline void lv_style_set_anim_time(lv_style_t * style, uint32_t value) { + lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_ANIM_TIME, v); } + +static inline void lv_style_set_transition(lv_style_t * style, const lv_style_transition_t * value) { + lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_TRANSITION, v); } + +static inline void lv_style_set_size(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SIZE, v); } + +static inline void lv_style_set_blend_mode(lv_style_t * style, lv_blend_mode_t value) { + lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BLEND_MODE, v); } + static inline void lv_style_set_pad_top(lv_style_t * style, lv_coord_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_PAD_TOP, v); } @@ -276,15 +293,27 @@ static inline void lv_style_set_bg_grad_color_filtered(lv_style_t * style, lv_co static inline void lv_style_set_bg_grad_dir(lv_style_t * style, lv_grad_dir_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_DIR, v); } -static inline void lv_style_set_bg_blend_mode(lv_style_t * style, lv_blend_mode_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_BLEND_MODE, v); } - static inline void lv_style_set_bg_main_stop(lv_style_t * style, lv_coord_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_MAIN_STOP, v); } static inline void lv_style_set_bg_grad_stop(lv_style_t * style, lv_coord_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_STOP, v); } +static inline void lv_style_set_bg_img_src(lv_style_t * style, const void * value) { + lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_SRC, v); } + +static inline void lv_style_set_bg_img_recolor(lv_style_t * style, lv_color_t value) { + lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_RECOLOR, v); } + +static inline void lv_style_set_bg_img_recolor_filtered(lv_style_t * style, lv_color_t value) { + lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_RECOLOR_FILTERED, v); } + +static inline void lv_style_set_bg_img_recolor_opa(lv_style_t * style, lv_opa_t value) { + lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_RECOLOR_OPA, v); } + +static inline void lv_style_set_bg_img_tiled(lv_style_t * style, bool value) { + lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_TILED, v); } + static inline void lv_style_set_border_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BORDER_COLOR, v); } @@ -303,9 +332,6 @@ static inline void lv_style_set_border_side(lv_style_t * style, lv_border_side_t static inline void lv_style_set_border_post(lv_style_t * style, bool value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BORDER_POST, v); } -static inline void lv_style_set_border_blend_mode(lv_style_t * style, lv_blend_mode_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BORDER_BLEND_MODE, v); } - static inline void lv_style_set_text_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_TEXT_COLOR, v); } @@ -327,15 +353,12 @@ static inline void lv_style_set_text_line_space(lv_style_t * style, lv_coord_t v static inline void lv_style_set_text_decor(lv_style_t * style, lv_text_decor_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TEXT_DECOR, v); } -static inline void lv_style_set_text_blend_mode(lv_style_t * style, lv_blend_mode_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TEXT_BLEND_MODE, v); } +static inline void lv_style_set_text_align(lv_style_t * style, lv_text_align_t value) { + lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TEXT_ALIGN, v); } static inline void lv_style_set_img_opa(lv_style_t * style, lv_opa_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_IMG_OPA, v); } -static inline void lv_style_set_img_blend_mode(lv_style_t * style, lv_blend_mode_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_IMG_BLEND_MODE, v); } - static inline void lv_style_set_img_recolor(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_IMG_RECOLOR, v); } @@ -351,15 +374,15 @@ static inline void lv_style_set_outline_width(lv_style_t * style, lv_coord_t val static inline void lv_style_set_outline_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_COLOR, v); } +static inline void lv_style_set_outline_color_filtered(lv_style_t * style, lv_color_t value) { + lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_COLOR_FILTERED, v); } + static inline void lv_style_set_outline_opa(lv_style_t * style, lv_opa_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_OPA, v); } static inline void lv_style_set_outline_pad(lv_style_t * style, lv_coord_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_PAD, v); } -static inline void lv_style_set_outline_blend_mode(lv_style_t * style, lv_blend_mode_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_BLEND_MODE, v); } - static inline void lv_style_set_shadow_width(lv_style_t * style, lv_coord_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_WIDTH, v); } @@ -372,9 +395,6 @@ static inline void lv_style_set_shadow_ofs_y(lv_style_t * style, lv_coord_t valu static inline void lv_style_set_shadow_spread(lv_style_t * style, lv_coord_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_SPREAD, v); } -static inline void lv_style_set_shadow_blend_mode(lv_style_t * style, lv_blend_mode_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_BLEND_MODE, v); } - static inline void lv_style_set_shadow_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_COLOR, v); } @@ -387,9 +407,6 @@ static inline void lv_style_set_shadow_opa(lv_style_t * style, lv_opa_t value) { static inline void lv_style_set_line_width(lv_style_t * style, lv_coord_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_WIDTH, v); } -static inline void lv_style_set_line_blend_mode(lv_style_t * style, lv_blend_mode_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_BLEND_MODE, v); } - static inline void lv_style_set_line_dash_width(lv_style_t * style, lv_coord_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_DASH_WIDTH, v); } @@ -408,8 +425,8 @@ static inline void lv_style_set_line_color_filtered(lv_style_t * style, lv_color static inline void lv_style_set_line_opa(lv_style_t * style, lv_opa_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_OPA, v); } -static inline void lv_style_set_content_src(lv_style_t * style, const char * value) { - lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_SRC, v); } +static inline void lv_style_set_content_text(lv_style_t * style, const char * value) { + lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_TEXT, v); } static inline void lv_style_set_content_align(lv_style_t * style, lv_align_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_ALIGN, v); } @@ -420,11 +437,27 @@ static inline void lv_style_set_content_ofs_x(lv_style_t * style, lv_coord_t val static inline void lv_style_set_content_ofs_y(lv_style_t * style, lv_coord_t value) { lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_OFS_Y, v); } -static inline void lv_style_set_transition(lv_style_t * style, const lv_style_transiton_t * value) { - lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_TRANSITION, v); } +static inline void lv_style_set_content_opa(lv_style_t * style, lv_opa_t value) { + lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_OPA, v); } + +static inline void lv_style_set_content_font(lv_style_t * style, const lv_font_t * value) { + lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_FONT, v); } + +static inline void lv_style_set_content_color(lv_style_t * style, lv_color_t value) { + lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_COLOR, v); } + +static inline void lv_style_set_content_color_filtered(lv_style_t * style, lv_color_t value) { + lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_COLOR_FILTERED, v); } + +static inline void lv_style_set_content_letter_space(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_LETTER_SPACE, v); } + +static inline void lv_style_set_content_line_space(lv_style_t * style, lv_coord_t value) { + lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_LINE_SPACE, v); } + +static inline void lv_style_set_content_decor(lv_style_t * style, lv_text_decor_t value) { + lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_DECOR, v); } -static inline void lv_style_set_size(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SIZE, v); } static inline void lv_style_set_pad_ver(lv_style_t * style, lv_coord_t value) { diff --git a/src/lv_draw/lv_draw_arc.c b/src/lv_draw/lv_draw_arc.c index d8affe48a..5626038e8 100644 --- a/src/lv_draw/lv_draw_arc.c +++ b/src/lv_draw/lv_draw_arc.c @@ -57,6 +57,14 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t thickness * GLOBAL FUNCTIONS **********************/ +LV_ATTRIBUTE_FAST_MEM void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc) +{ + lv_memset_00(dsc, sizeof(lv_draw_arc_dsc_t)); + dsc->width = 1; + dsc->opa = LV_OPA_COVER; + dsc->color = LV_COLOR_BLACK; +} + /** * Draw an arc. (Can draw pie too with great thickness.) * @param center_x the x coordinate of the center of the arc @@ -69,7 +77,7 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t thickness * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, - const lv_area_t * clip_area, const lv_draw_line_dsc_t * dsc) + const lv_area_t * clip_area, const lv_draw_arc_dsc_t * dsc) { if(dsc->opa <= LV_OPA_MIN) return; if(dsc->width == 0) return; @@ -80,22 +88,27 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin lv_draw_rect_dsc_t cir_dsc; lv_draw_rect_dsc_init(&cir_dsc); - cir_dsc.radius = LV_RADIUS_CIRCLE; - cir_dsc.bg_opa = LV_OPA_TRANSP; - cir_dsc.border_opa = dsc->opa; - cir_dsc.border_color = dsc->color; - cir_dsc.border_width = width; - cir_dsc.border_blend_mode = dsc->blend_mode; + cir_dsc.bg_opa = dsc->opa; + cir_dsc.bg_color = dsc->color; + cir_dsc.blend_mode = dsc->blend_mode; + cir_dsc.bg_img_src = dsc->bg_img_src; - lv_area_t area; - area.x1 = center_x - radius; - area.y1 = center_y - radius; - area.x2 = center_x + radius - 1; /*-1 because the center already belongs to the left/bottom part*/ - area.y2 = center_y + radius - 1; + lv_area_t area_out; + area_out.x1 = center_x - radius; + area_out.y1 = center_y - radius; + area_out.x2 = center_x + radius - 1; /*-1 because the center already belongs to the left/bottom part*/ + area_out.y2 = center_y + radius - 1; + + lv_area_t area_in; + lv_area_copy(&area_in, &area_out); + area_in.x1 += dsc->width; + area_in.y1 += dsc->width; + area_in.x2 -= dsc->width; + area_in.y2 -= dsc->width; /*Draw a full ring*/ if(start_angle + 360 == end_angle || start_angle == end_angle + 360) { - lv_draw_rect(&area, clip_area, &cir_dsc); + lv_draw_rect(&area_out, clip_area, &cir_dsc); return; } @@ -104,9 +117,17 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin lv_draw_mask_angle_param_t mask_angle_param; lv_draw_mask_angle_init(&mask_angle_param, center_x, center_y, start_angle, end_angle); - int16_t mask_angle_id = lv_draw_mask_add(&mask_angle_param, NULL); + /*Create inner the mask*/ + lv_draw_mask_radius_param_t mask_in_param; + lv_draw_mask_radius_init(&mask_in_param, &area_in, LV_RADIUS_CIRCLE, true); + int16_t mask_in_id = lv_draw_mask_add(&mask_in_param, NULL); + + lv_draw_mask_radius_param_t mask_out_param; + lv_draw_mask_radius_init(&mask_out_param, &area_out, LV_RADIUS_CIRCLE, false); + int16_t mask_out_id = lv_draw_mask_add(&mask_out_param, NULL); + int32_t angle_gap; if(end_angle > start_angle) { angle_gap = 360 - (end_angle - start_angle); @@ -126,7 +147,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin q_dsc.end_quarter = (end_angle / 90) & 0x3; q_dsc.width = width; q_dsc.draw_dsc = &cir_dsc; - q_dsc.draw_area = &area; + q_dsc.draw_area = &area_out; q_dsc.clip_area = clip_area; draw_quarter_0(&q_dsc); @@ -135,35 +156,42 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin draw_quarter_3(&q_dsc); } else { - lv_draw_rect(&area, clip_area, &cir_dsc); + lv_draw_rect(&area_out, clip_area, &cir_dsc); } lv_draw_mask_remove_id(mask_angle_id); + lv_draw_mask_remove_id(mask_out_id); + lv_draw_mask_remove_id(mask_in_id); - if(dsc->round_start || dsc->round_end) { - cir_dsc.bg_color = dsc->color; - cir_dsc.bg_opa = dsc->opa; - cir_dsc.bg_blend_mode = dsc->blend_mode; - cir_dsc.border_width = 0; + if(dsc->rounded) { + + lv_draw_mask_radius_param_t mask_end_param; lv_area_t round_area; - if(dsc->round_start) { - get_rounded_area(start_angle, radius, width, &round_area); - round_area.x1 += center_x; - round_area.x2 += center_x; - round_area.y1 += center_y; - round_area.y2 += center_y; + get_rounded_area(start_angle, radius, width, &round_area); + round_area.x1 += center_x; + round_area.x2 += center_x; + round_area.y1 += center_y; + round_area.y2 += center_y; + lv_area_t clip_area2; + if(_lv_area_intersect(&clip_area2, clip_area, &round_area)) { + lv_draw_mask_radius_init(&mask_end_param, &round_area, LV_RADIUS_CIRCLE, false); + int16_t mask_end_id = lv_draw_mask_add(&mask_end_param, NULL); - lv_draw_rect(&round_area, clip_area, &cir_dsc); + lv_draw_rect(&area_out, &clip_area2, &cir_dsc); + lv_draw_mask_remove_id(mask_end_id); } - if(dsc->round_end) { - get_rounded_area(end_angle, radius, width, &round_area); - round_area.x1 += center_x; - round_area.x2 += center_x; - round_area.y1 += center_y; - round_area.y2 += center_y; + get_rounded_area(end_angle, radius, width, &round_area); + round_area.x1 += center_x; + round_area.x2 += center_x; + round_area.y1 += center_y; + round_area.y2 += center_y; + if(_lv_area_intersect(&clip_area2, clip_area, &round_area)) { + lv_draw_mask_radius_init(&mask_end_param, &round_area, LV_RADIUS_CIRCLE, false); + int16_t mask_end_id = lv_draw_mask_add(&mask_end_param, NULL); - lv_draw_rect(&round_area, clip_area, &cir_dsc); + lv_draw_rect(&area_out, &clip_area2, &cir_dsc); + lv_draw_mask_remove_id(mask_end_id); } } } @@ -178,11 +206,11 @@ static void draw_quarter_0(quarter_draw_dsc_t * q) if(q->start_quarter == 0 && q->end_quarter == 0 && q->start_angle < q->end_angle) { /*Small arc here*/ - quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); - quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); + quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); - quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->end_angle) * q->radius) >> LV_TRIGO_SHIFT); - quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->end_angle) * q->radius) >> LV_TRIGO_SHIFT); + quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); @@ -193,8 +221,8 @@ static void draw_quarter_0(quarter_draw_dsc_t * q) quarter_area.x1 = q->center_x; quarter_area.y2 = q->center_y + q->radius; - quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); - quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); + quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); @@ -203,8 +231,8 @@ static void draw_quarter_0(quarter_draw_dsc_t * q) quarter_area.x2 = q->center_x + q->radius; quarter_area.y1 = q->center_y; - quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->end_angle) * q->radius) >> LV_TRIGO_SHIFT); - quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->end_angle) * q->radius) >> LV_TRIGO_SHIFT); + quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); @@ -231,11 +259,11 @@ static void draw_quarter_1(quarter_draw_dsc_t * q) if(q->start_quarter == 1 && q->end_quarter == 1 && q->start_angle < q->end_angle) { /*Small arc here*/ - quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT); - quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT); + quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); - quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); - quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); + quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); @@ -246,8 +274,8 @@ static void draw_quarter_1(quarter_draw_dsc_t * q) quarter_area.x1 = q->center_x - q->radius; quarter_area.y1 = q->center_y; - quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT); - quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT); + quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); @@ -256,8 +284,8 @@ static void draw_quarter_1(quarter_draw_dsc_t * q) quarter_area.x2 = q->center_x - 1; quarter_area.y2 = q->center_y + q->radius; - quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); - quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); + quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); @@ -284,11 +312,11 @@ static void draw_quarter_2(quarter_draw_dsc_t * q) if(q->start_quarter == 2 && q->end_quarter == 2 && q->start_angle < q->end_angle) { /*Small arc here*/ - quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); - quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); + quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); - quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->end_angle) * q->radius) >> LV_TRIGO_SHIFT); - quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->end_angle) * q->radius) >> LV_TRIGO_SHIFT); + quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); @@ -299,8 +327,8 @@ static void draw_quarter_2(quarter_draw_dsc_t * q) quarter_area.x2 = q->center_x - 1; quarter_area.y1 = q->center_y - q->radius; - quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); - quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); + quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); @@ -309,8 +337,8 @@ static void draw_quarter_2(quarter_draw_dsc_t * q) quarter_area.x1 = q->center_x - q->radius; quarter_area.y2 = q->center_y - 1; - quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); - quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->end_angle) * (q->radius)) >> LV_TRIGO_SHIFT); + quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius)) >> LV_TRIGO_SHIFT); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); @@ -338,11 +366,11 @@ static void draw_quarter_3(quarter_draw_dsc_t * q) if(q->start_quarter == 3 && q->end_quarter == 3 && q->start_angle < q->end_angle) { /*Small arc here*/ - quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); - quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT); + quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT); - quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); - quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); + quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); @@ -353,8 +381,8 @@ static void draw_quarter_3(quarter_draw_dsc_t * q) quarter_area.x2 = q->center_x + q->radius; quarter_area.y2 = q->center_y - 1; - quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); - quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT); + quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); @@ -363,8 +391,8 @@ static void draw_quarter_3(quarter_draw_dsc_t * q) quarter_area.x1 = q->center_x; quarter_area.y1 = q->center_y - q->radius; - quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); - quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); + quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); + quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); @@ -397,8 +425,8 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t thickness int32_t cir_x; int32_t cir_y; - cir_x = ((radius - thick_half) * _lv_trigo_sin(90 - angle)) >> (LV_TRIGO_SHIFT - ps); - cir_y = ((radius - thick_half) * _lv_trigo_sin(angle)) >> (LV_TRIGO_SHIFT - ps); + cir_x = ((radius - thick_half) * lv_trigo_sin(90 - angle)) >> (LV_TRIGO_SHIFT - ps); + cir_y = ((radius - thick_half) * lv_trigo_sin(angle)) >> (LV_TRIGO_SHIFT - ps); /* Actually the center of the pixel need to be calculated so apply 1/2 px offset*/ if(cir_x > 0) { diff --git a/src/lv_draw/lv_draw_arc.h b/src/lv_draw/lv_draw_arc.h index a4b182410..8055447f7 100644 --- a/src/lv_draw/lv_draw_arc.h +++ b/src/lv_draw/lv_draw_arc.h @@ -22,11 +22,22 @@ extern "C" { /********************** * TYPEDEFS **********************/ +typedef struct { + lv_color_t color; + lv_coord_t width; + const void * bg_img_src; + lv_opa_t opa; + lv_blend_mode_t blend_mode : 2; + uint8_t rounded : 1; +} lv_draw_arc_dsc_t; + /********************** * GLOBAL PROTOTYPES **********************/ +LV_ATTRIBUTE_FAST_MEM void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc); + /** * Draw an arc. (Can draw pie too with great thickness.) * @param center_x the x coordinate of the center of the arc @@ -39,7 +50,7 @@ extern "C" { * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, - const lv_area_t * clip_area, const lv_draw_line_dsc_t * dsc); + const lv_area_t * clip_area, const lv_draw_arc_dsc_t * dsc); /********************** * MACROS diff --git a/src/lv_draw/lv_draw_blend.c b/src/lv_draw/lv_draw_blend.c index d5187815c..023ec137d 100644 --- a/src/lv_draw/lv_draw_blend.c +++ b/src/lv_draw/lv_draw_blend.c @@ -801,7 +801,7 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col /*Software rendering*/ for(y = 0; y < draw_area_h; y++) { - _lv_memcpy(disp_buf_first, map_buf_first, draw_area_w * sizeof(lv_color_t)); + lv_memcpy(disp_buf_first, map_buf_first, draw_area_w * sizeof(lv_color_t)); disp_buf_first += disp_w; map_buf_first += map_w; } @@ -1041,41 +1041,41 @@ static inline lv_color_t color_blend_true_color_additive(lv_color_t fg, lv_color uint32_t tmp; #if LV_COLOR_DEPTH == 1 tmp = bg.full + fg.full; - fg.full = LV_MATH_MIN(tmp, 1); + fg.full = LV_MIN(tmp, 1); #else tmp = bg.ch.red + fg.ch.red; #if LV_COLOR_DEPTH == 8 - fg.ch.red = LV_MATH_MIN(tmp, 7); + fg.ch.red = LV_MIN(tmp, 7); #elif LV_COLOR_DEPTH == 16 - fg.ch.red = LV_MATH_MIN(tmp, 31); + fg.ch.red = LV_MIN(tmp, 31); #elif LV_COLOR_DEPTH == 32 - fg.ch.red = LV_MATH_MIN(tmp, 255); + fg.ch.red = LV_MIN(tmp, 255); #endif #if LV_COLOR_DEPTH == 8 - fg.ch.green = LV_MATH_MIN(tmp, 7); + fg.ch.green = LV_MIN(tmp, 7); #elif LV_COLOR_DEPTH == 16 #if LV_COLOR_16_SWAP == 0 tmp = bg.ch.green + fg.ch.green; - fg.ch.green = LV_MATH_MIN(tmp, 63); + fg.ch.green = LV_MIN(tmp, 63); #else tmp = (bg.ch.green_h << 3) + bg.ch.green_l + (fg.ch.green_h << 3) + fg.ch.green_l; - tmp = LV_MATH_MIN(tmp, 63); + tmp = LV_MIN(tmp, 63); fg.ch.green_h = tmp >> 3; fg.ch.green_l = tmp & 0x7; #endif #elif LV_COLOR_DEPTH == 32 - fg.ch.green = LV_MATH_MIN(tmp, 255); + fg.ch.green = LV_MIN(tmp, 255); #endif tmp = bg.ch.blue + fg.ch.blue; #if LV_COLOR_DEPTH == 8 - fg.ch.blue = LV_MATH_MIN(tmp, 4); + fg.ch.blue = LV_MIN(tmp, 4); #elif LV_COLOR_DEPTH == 16 - fg.ch.blue = LV_MATH_MIN(tmp, 31); + fg.ch.blue = LV_MIN(tmp, 31); #elif LV_COLOR_DEPTH == 32 - fg.ch.blue = LV_MATH_MIN(tmp, 255); + fg.ch.blue = LV_MIN(tmp, 255); #endif #endif @@ -1091,20 +1091,20 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co int32_t tmp; tmp = bg.ch.red - fg.ch.red; - fg.ch.red = LV_MATH_MAX(tmp, 0); + fg.ch.red = LV_MAX(tmp, 0); #if LV_COLOR_16_SWAP == 0 tmp = bg.ch.green - fg.ch.green; - fg.ch.green = LV_MATH_MAX(tmp, 0); + fg.ch.green = LV_MAX(tmp, 0); #else tmp = (bg.ch.green_h << 3) + bg.ch.green_l + (fg.ch.green_h << 3) + fg.ch.green_l; - tmp = LV_MATH_MAX(tmp, 0); + tmp = LV_MAX(tmp, 0); fg.ch.green_h = tmp >> 3; fg.ch.green_l = tmp & 0x7; #endif tmp = bg.ch.blue - fg.ch.blue; - fg.ch.blue = LV_MATH_MAX(tmp, 0); + fg.ch.blue = LV_MAX(tmp, 0); if(opa == LV_OPA_COVER) return fg; diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index 15e0809e3..7f6c813e0 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -56,7 +56,7 @@ static void draw_cleanup(lv_img_cache_entry_t * cache); void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc) { - _lv_memset_00(dsc, sizeof(lv_draw_img_dsc_t)); + lv_memset_00(dsc, sizeof(lv_draw_img_dsc_t)); dsc->recolor = LV_COLOR_BLACK; dsc->opa = LV_OPA_COVER; dsc->zoom = LV_IMG_ZOOM_NONE; @@ -289,7 +289,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, int32_t width = lv_area_get_width(&mask_com); - uint8_t * buf = _lv_mem_buf_get(lv_area_get_width(&mask_com) * + uint8_t * buf = lv_mem_buf_get(lv_area_get_width(&mask_com) * LV_IMG_PX_SIZE_ALPHA_BYTE); /*+1 because of the possible alpha byte*/ lv_area_t line; @@ -308,7 +308,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, if(read_res != LV_RES_OK) { lv_img_decoder_close(&cdsc->dec_dsc); LV_LOG_WARN("Image draw can't read the line"); - _lv_mem_buf_release(buf); + lv_mem_buf_release(buf); draw_cleanup(cdsc); return LV_RES_INV; } @@ -319,7 +319,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, line.y2++; y++; } - _lv_mem_buf_release(buf); + lv_mem_buf_release(buf); } draw_cleanup(cdsc); @@ -426,8 +426,8 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const #endif uint32_t hor_res = (uint32_t) lv_disp_get_hor_res(disp); uint32_t mask_buf_size = lv_area_get_size(&draw_area) > (uint32_t) hor_res ? hor_res : lv_area_get_size(&draw_area); - lv_color_t * map2 = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t)); - lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size); + lv_color_t * map2 = lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t)); + lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size); int32_t x; int32_t y; @@ -469,20 +469,20 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const _lv_blend_map(clip_area, &blend_area, map2, mask_buf, LV_DRAW_MASK_RES_CHANGED, draw_dsc->opa, draw_dsc->blend_mode); } - _lv_mem_buf_release(mask_buf); - _lv_mem_buf_release(map2); + lv_mem_buf_release(mask_buf); + lv_mem_buf_release(map2); } /*Most complicated case: transform or other mask or chroma keyed*/ else { /*Build the image and a mask line-by-line*/ uint32_t hor_res = (uint32_t) lv_disp_get_hor_res(disp); uint32_t mask_buf_size = lv_area_get_size(&draw_area) > hor_res ? hor_res : lv_area_get_size(&draw_area); - lv_color_t * map2 = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t)); - lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size); + lv_color_t * map2 = lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t)); + lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size); #if LV_USE_IMG_TRANSFORM lv_img_transform_dsc_t trans_dsc; - _lv_memset_00(&trans_dsc, sizeof(lv_img_transform_dsc_t)); + lv_memset_00(&trans_dsc, sizeof(lv_img_transform_dsc_t)); if(transform) { lv_img_cf_t cf = LV_IMG_CF_TRUE_COLOR; if(alpha_byte) cf = LV_IMG_CF_TRUE_COLOR_ALPHA; @@ -515,7 +515,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const /*Prepare the `mask_buf`if there are other masks*/ if(other_mask_cnt) { - _lv_memset_ff(mask_buf, mask_buf_size); + lv_memset_ff(mask_buf, mask_buf_size); } int32_t x; @@ -600,7 +600,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const mask_res_sub = lv_draw_mask_apply(mask_buf + px_i_start, draw_area.x1 + vdb->area.x1, y + draw_area.y1 + vdb->area.y1, lv_area_get_width(&draw_area)); if(mask_res_sub == LV_DRAW_MASK_RES_TRANSP) { - _lv_memset_00(mask_buf + px_i_start, lv_area_get_width(&draw_area)); + lv_memset_00(mask_buf + px_i_start, lv_area_get_width(&draw_area)); mask_res = LV_DRAW_MASK_RES_CHANGED; } else if(mask_res_sub == LV_DRAW_MASK_RES_CHANGED) { @@ -625,7 +625,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const /*Prepare the `mask_buf`if there are other masks*/ if(other_mask_cnt) { - _lv_memset_ff(mask_buf, mask_buf_size); + lv_memset_ff(mask_buf, mask_buf_size); } } } @@ -636,8 +636,8 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const _lv_blend_map(clip_area, &blend_area, map2, mask_buf, mask_res, draw_dsc->opa, draw_dsc->blend_mode); } - _lv_mem_buf_release(mask_buf); - _lv_mem_buf_release(map2); + lv_mem_buf_release(mask_buf); + lv_mem_buf_release(map2); } } } diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 6942c9a67..512e6a5ad 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -92,7 +92,7 @@ const uint8_t _lv_bpp8_opa_table[256] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1 LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc) { - _lv_memset_00(dsc, sizeof(lv_draw_label_dsc_t)); + lv_memset_00(dsc, sizeof(lv_draw_label_dsc_t)); dsc->opa = LV_OPA_COVER; dsc->color = LV_COLOR_BLACK; dsc->font = LV_THEME_DEFAULT_FONT_NORMAL; @@ -162,7 +162,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area /*Check the hint to use the cached info*/ if(hint && y_ofs == 0 && coords->y1 < 0) { /*If the label changed too much recalculate the hint.*/ - if(LV_MATH_ABS(hint->coord_y - coords->y1) > LV_LABEL_HINT_UPDATE_TH - 2 * line_height) { + if(LV_ABS(hint->coord_y - coords->y1) > LV_LABEL_HINT_UPDATE_TH - 2 * line_height) { hint->line_start = -1; } last_line_start = hint->line_start; @@ -245,7 +245,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area cmd_state = CMD_STATE_WAIT; i = 0; #if LV_USE_BIDI - char * bidi_txt = _lv_mem_buf_get(line_end - line_start + 1); + char * bidi_txt = lv_mem_buf_get(line_end - line_start + 1); _lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, dsc->bidi_dir, NULL, 0); #else const char * bidi_txt = txt + line_start; @@ -289,7 +289,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area /*Get the parameter*/ if(i - par_start == LABEL_RECOLOR_PAR_LENGTH + 1) { char buf[LABEL_RECOLOR_PAR_LENGTH + 1]; - _lv_memcpy_small(buf, &bidi_txt[par_start], LABEL_RECOLOR_PAR_LENGTH); + lv_memcpy_small(buf, &bidi_txt[par_start], LABEL_RECOLOR_PAR_LENGTH); buf[LABEL_RECOLOR_PAR_LENGTH] = '\0'; int r, g, b; r = (hex_char_to_num(buf[0]) << 4) + hex_char_to_num(buf[1]); @@ -352,7 +352,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area } #if LV_USE_BIDI - _lv_mem_buf_release(bidi_txt); + lv_mem_buf_release(bidi_txt); bidi_txt = NULL; #endif /*Go to next line*/ @@ -525,7 +525,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_ lv_coord_t hor_res = lv_disp_get_hor_res(_lv_refr_get_disp_refreshing()); uint32_t mask_buf_size = box_w * box_h > hor_res ? hor_res : box_w * box_h; - lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size); + lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size); int32_t mask_p = 0; lv_area_t fill_area; @@ -574,7 +574,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_ lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, fill_area.x1, fill_area.y2, lv_area_get_width(&fill_area)); if(mask_res == LV_DRAW_MASK_RES_TRANSP) { - _lv_memset_00(mask_buf + mask_p_start, lv_area_get_width(&fill_area)); + lv_memset_00(mask_buf + mask_p_start, lv_area_get_width(&fill_area)); } } @@ -605,7 +605,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_ mask_p = 0; } - _lv_mem_buf_release(mask_buf); + lv_mem_buf_release(mask_buf); } static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area, @@ -663,10 +663,10 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_ col_bit = bit_ofs & 0x7; /* "& 0x7" equals to "% 8" just faster */ int32_t mask_buf_size = box_w * box_h > LV_HOR_RES_MAX ? LV_HOR_RES_MAX : g->box_w * g->box_h; - lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size); + lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size); int32_t mask_p = 0; - lv_color_t * color_buf = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t)); + lv_color_t * color_buf = lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t)); lv_disp_t * disp = _lv_refr_get_disp_refreshing(); lv_disp_buf_t * vdb = lv_disp_get_buf(disp); @@ -779,7 +779,7 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_ lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, map_area.x1, map_area.y2, lv_area_get_width(&map_area)); if(mask_res == LV_DRAW_MASK_RES_TRANSP) { - _lv_memset_00(mask_buf + mask_p_start, lv_area_get_width(&map_area)); + lv_memset_00(mask_buf + mask_p_start, lv_area_get_width(&map_area)); } } @@ -809,8 +809,8 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_ _lv_blend_map(clip_area, &map_area, color_buf, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa, blend_mode); } - _lv_mem_buf_release(mask_buf); - _lv_mem_buf_release(color_buf); + lv_mem_buf_release(mask_buf); + lv_mem_buf_release(color_buf); #else LV_LOG_WARN("Can't draw sub-pixel rendered letter because LV_USE_FONT_SUBPX == 0 in lv_conf.h"); #endif diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index 37bd8a0f7..59a2a5012 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -48,7 +48,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc) { - _lv_memset_00(dsc, sizeof(lv_draw_line_dsc_t)); + lv_memset_00(dsc, sizeof(lv_draw_line_dsc_t)); dsc->width = 1; dsc->opa = LV_OPA_COVER; dsc->color = LV_COLOR_BLACK; @@ -70,10 +70,10 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_poin if(point1->x == point2->x && point1->y == point2->y) return; lv_area_t clip_line; - clip_line.x1 = LV_MATH_MIN(point1->x, point2->x) - dsc->width / 2; - clip_line.x2 = LV_MATH_MAX(point1->x, point2->x) + dsc->width / 2; - clip_line.y1 = LV_MATH_MIN(point1->y, point2->y) - dsc->width / 2; - clip_line.y2 = LV_MATH_MAX(point1->y, point2->y) + dsc->width / 2; + clip_line.x1 = LV_MIN(point1->x, point2->x) - dsc->width / 2; + clip_line.x2 = LV_MAX(point1->x, point2->x) + dsc->width / 2; + clip_line.y1 = LV_MIN(point1->y, point2->y) - dsc->width / 2; + clip_line.y2 = LV_MAX(point1->y, point2->y) + dsc->width / 2; bool is_common; is_common = _lv_area_intersect(&clip_line, &clip_line, clip); @@ -139,8 +139,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const else if(dashed) simple_mode = false; lv_area_t draw_area; - draw_area.x1 = LV_MATH_MIN(point1->x, point2->x); - draw_area.x2 = LV_MATH_MAX(point1->x, point2->x) - 1; + draw_area.x1 = LV_MIN(point1->x, point2->x); + draw_area.x2 = LV_MAX(point1->x, point2->x) - 1; draw_area.y1 = point1->y - w_half1; draw_area.y2 = point1->y + w_half0; @@ -178,10 +178,10 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const dash_start = (vdb->area.x1 + draw_area.x1) % (dsc->dash_gap + dsc->dash_width); } - lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); + lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w); int32_t h; for(h = draw_area.y1; h <= draw_area.y2; h++) { - _lv_memset_ff(mask_buf, draw_area_w); + lv_memset_ff(mask_buf, draw_area_w); lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); if(dashed) { @@ -213,7 +213,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const fill_area.y1++; fill_area.y2++; } - _lv_mem_buf_release(mask_buf); + lv_mem_buf_release(mask_buf); } } @@ -242,8 +242,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const lv_area_t draw_area; draw_area.x1 = point1->x - w_half1; draw_area.x2 = point1->x + w_half0; - draw_area.y1 = LV_MATH_MIN(point1->y, point2->y); - draw_area.y2 = LV_MATH_MAX(point1->y, point2->y) - 1; + draw_area.y1 = LV_MIN(point1->y, point2->y); + draw_area.y2 = LV_MAX(point1->y, point2->y) - 1; /*If there is no mask then simply draw a rectangle*/ if(simple_mode) { @@ -274,7 +274,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const fill_area.y1 = draw_area.y1 + disp_area->y1; fill_area.y2 = fill_area.y1; - lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); + lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w); lv_coord_t dash_start = 0; if(dashed) { @@ -285,7 +285,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const int32_t h; for(h = draw_area.y1; h <= draw_area.y2; h++) { - _lv_memset_ff(mask_buf, draw_area_w); + lv_memset_ff(mask_buf, draw_area_w); lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); if(dashed) { @@ -308,7 +308,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const fill_area.y1++; fill_area.y2++; } - _lv_mem_buf_release(mask_buf); + lv_mem_buf_release(mask_buf); } } @@ -335,7 +335,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons int32_t xdiff = p2.x - p1.x; int32_t ydiff = p2.y - p1.y; - bool flat = LV_MATH_ABS(xdiff) > LV_MATH_ABS(ydiff) ? true : false; + bool flat = LV_ABS(xdiff) > LV_ABS(ydiff) ? true : false; static const uint8_t wcorr[] = { 128, 128, 128, 129, 129, 130, 130, 131, @@ -347,18 +347,18 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons int32_t w = dsc->width; int32_t wcorr_i = 0; - if(flat) wcorr_i = (LV_MATH_ABS(ydiff) << 5) / LV_MATH_ABS(xdiff); - else wcorr_i = (LV_MATH_ABS(xdiff) << 5) / LV_MATH_ABS(ydiff); + if(flat) wcorr_i = (LV_ABS(ydiff) << 5) / LV_ABS(xdiff); + else wcorr_i = (LV_ABS(xdiff) << 5) / LV_ABS(ydiff); w = (w * wcorr[wcorr_i] + 63) >> 7; /*+ 63 for rounding*/ int32_t w_half0 = w >> 1; int32_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/ lv_area_t draw_area; - draw_area.x1 = LV_MATH_MIN(p1.x, p2.x) - w; - draw_area.x2 = LV_MATH_MAX(p1.x, p2.x) + w; - draw_area.y1 = LV_MATH_MIN(p1.y, p2.y) - w; - draw_area.y2 = LV_MATH_MAX(p1.y, p2.y) + w; + draw_area.x1 = LV_MIN(p1.x, p2.x) - w; + draw_area.x2 = LV_MAX(p1.x, p2.x) + w; + draw_area.y1 = LV_MIN(p1.y, p2.y) - w; + draw_area.y2 = LV_MAX(p1.y, p2.y) + w; /* Get the union of `coords` and `clip`*/ /* `clip` is already truncated to the `vdb` size @@ -425,8 +425,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons /*Draw the background line by line*/ int32_t h; uint32_t hor_res = (uint32_t)lv_disp_get_hor_res(disp); - size_t mask_buf_size = LV_MATH_MIN(lv_area_get_size(&draw_area), hor_res); - lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size); + size_t mask_buf_size = LV_MIN(lv_area_get_size(&draw_area), hor_res); + lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size); lv_area_t fill_area; fill_area.x1 = draw_area.x1 + disp_area->x1; @@ -438,13 +438,13 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons uint32_t mask_p = 0; - _lv_memset_ff(mask_buf, mask_buf_size); + lv_memset_ff(mask_buf, mask_buf_size); /*Fill the first row with 'color'*/ for(h = draw_area.y1 + disp_area->y1; h <= draw_area.y2 + disp_area->y1; h++) { lv_draw_mask_res_t mask_res = lv_draw_mask_apply(&mask_buf[mask_p], x, h, draw_area_w); if(mask_res == LV_DRAW_MASK_RES_TRANSP) { - _lv_memset_00(&mask_buf[mask_p], draw_area_w); + lv_memset_00(&mask_buf[mask_p], draw_area_w); } mask_p += draw_area_w; @@ -459,7 +459,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons fill_area.y1 = fill_area.y2 + 1; fill_area.y2 = fill_area.y1; mask_p = 0; - _lv_memset_ff(mask_buf, mask_buf_size); + lv_memset_ff(mask_buf, mask_buf_size); } } @@ -472,7 +472,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons } - _lv_mem_buf_release(mask_buf); + lv_mem_buf_release(mask_buf); lv_draw_mask_remove_id(mask_left_id); lv_draw_mask_remove_id(mask_right_id); diff --git a/src/lv_draw/lv_draw_mask.c b/src/lv_draw/lv_draw_mask.c index f7b8bc1ff..7cd673d92 100644 --- a/src/lv_draw/lv_draw_mask.c +++ b/src/lv_draw/lv_draw_mask.c @@ -189,7 +189,7 @@ LV_ATTRIBUTE_FAST_MEM uint8_t lv_draw_mask_get_cnt(void) void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t p1y, lv_coord_t p2x, lv_coord_t p2y, lv_draw_mask_line_side_t side) { - _lv_memset_00(param, sizeof(lv_draw_mask_line_param_t)); + lv_memset_00(param, sizeof(lv_draw_mask_line_param_t)); if(p1y > p2y) { lv_coord_t t; @@ -210,7 +210,7 @@ void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t param->origo.x = p1x; param->origo.y = p1y; - param->flat = (LV_MATH_ABS(p2x - p1x) > LV_MATH_ABS(p2y - p1y)) ? 1 : 0; + param->flat = (LV_ABS(p2x - p1x) > LV_ABS(p2y - p1y)) ? 1 : 0; param->yx_steep = 0; param->xy_steep = 0; param->dsc.cb = (lv_draw_mask_xcb_t)lv_draw_mask_line; @@ -288,8 +288,8 @@ void lv_draw_mask_line_angle_init(lv_draw_mask_line_param_t * param, lv_coord_t int32_t p2x; int32_t p2y; - p2x = (_lv_trigo_sin(angle + 90) >> 5) + p1x; - p2y = (_lv_trigo_sin(angle) >> 5) + py; + p2x = (lv_trigo_sin(angle + 90) >> 5) + p1x; + p2y = (lv_trigo_sin(angle) >> 5) + py; lv_draw_mask_line_points_init(param, p1x, py, p2x, p2y, side); } @@ -324,7 +324,7 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert param->delta_deg = 360 - start_angle + end_angle; } else { - param->delta_deg = LV_MATH_ABS(end_angle - start_angle); + param->delta_deg = LV_ABS(end_angle - start_angle); } param->cfg.start_angle = start_angle; @@ -372,7 +372,7 @@ void lv_draw_mask_radius_init(lv_draw_mask_radius_param_t * param, const lv_area { lv_coord_t w = lv_area_get_width(rect); lv_coord_t h = lv_area_get_height(rect); - int32_t short_side = LV_MATH_MIN(w, h); + int32_t short_side = LV_MIN(w, h); if(radius > short_side >> 1) radius = short_side >> 1; lv_area_copy(¶m->cfg.rect, rect); @@ -460,7 +460,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mas else { int32_t k = - abs_x; if(k < 0) return LV_DRAW_MASK_RES_TRANSP; - if(k >= 0 && k < len) _lv_memset_00(&mask_buf[k], len - k); + if(k >= 0 && k < len) lv_memset_00(&mask_buf[k], len - k); return LV_DRAW_MASK_RES_CHANGED; } } @@ -470,7 +470,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mas int32_t k = - abs_x; if(k < 0) k = 0; if(k >= len) return LV_DRAW_MASK_RES_TRANSP; - else if(k >= 0 && k < len) _lv_memset_00(&mask_buf[0], k); + else if(k >= 0 && k < len) lv_memset_00(&mask_buf[0], k); return LV_DRAW_MASK_RES_CHANGED; } } @@ -589,7 +589,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_b return LV_DRAW_MASK_RES_TRANSP; } if(k >= 0) { - _lv_memset_00(&mask_buf[0], k); + lv_memset_00(&mask_buf[0], k); } } else { @@ -598,7 +598,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_b return LV_DRAW_MASK_RES_TRANSP; } if(k <= len) { - _lv_memset_00(&mask_buf[k], len - k); + lv_memset_00(&mask_buf[k], len - k); } } @@ -668,13 +668,13 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_ if(k >= len) { return LV_DRAW_MASK_RES_TRANSP; } - if(k >= 0) _lv_memset_00(&mask_buf[0], k); + if(k >= 0) lv_memset_00(&mask_buf[0], k); } else { if(k > len) k = len; if(k == 0) return LV_DRAW_MASK_RES_TRANSP; - else if(k > 0) _lv_memset_00(&mask_buf[k], len - k); + else if(k > 0) lv_memset_00(&mask_buf[k], len - k); } } @@ -703,12 +703,12 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_ k = xsi - abs_x - 1; if(k > len) k = len; - else if(k > 0) _lv_memset_00(&mask_buf[0], k); + else if(k > 0) lv_memset_00(&mask_buf[0], k); } else { if(k > len) return LV_DRAW_MASK_RES_FULL_COVER; - if(k >= 0) _lv_memset_00(&mask_buf[k], len - k); + if(k >= 0) lv_memset_00(&mask_buf[k], len - k); } } @@ -733,13 +733,13 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_ if(p->inv) { k = xsi - abs_x; if(k > len) return LV_DRAW_MASK_RES_TRANSP; - if(k >= 0) _lv_memset_00(&mask_buf[0], k); + if(k >= 0) lv_memset_00(&mask_buf[0], k); } else { if(k > len) k = len; if(k == 0) return LV_DRAW_MASK_RES_TRANSP; - else if(k > 0) _lv_memset_00(&mask_buf[k], len - k); + else if(k > 0) lv_memset_00(&mask_buf[k], len - k); } } } @@ -789,7 +789,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * ma if(tmp > 0) { res1 = lv_draw_mask_line(&mask_buf[0], abs_x, abs_y, tmp, &p->start_line); if(res1 == LV_DRAW_MASK_RES_TRANSP) { - _lv_memset_00(&mask_buf[0], tmp); + lv_memset_00(&mask_buf[0], tmp); } } @@ -797,7 +797,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * ma if(tmp < 0) tmp = 0; res2 = lv_draw_mask_line(&mask_buf[tmp], abs_x + tmp, abs_y, len - tmp, &p->end_line); if(res2 == LV_DRAW_MASK_RES_TRANSP) { - _lv_memset_00(&mask_buf[tmp], len - tmp); + lv_memset_00(&mask_buf[tmp], len - tmp); } if(res1 == res2) return res1; else return LV_DRAW_MASK_RES_CHANGED; @@ -831,7 +831,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * ma if(tmp > 0) { res1 = lv_draw_mask_line(&mask_buf[0], abs_x, abs_y, tmp, (lv_draw_mask_line_param_t *)&p->end_line); if(res1 == LV_DRAW_MASK_RES_TRANSP) { - _lv_memset_00(&mask_buf[0], tmp); + lv_memset_00(&mask_buf[0], tmp); } } @@ -839,7 +839,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * ma if(tmp < 0) tmp = 0; res2 = lv_draw_mask_line(&mask_buf[tmp], abs_x + tmp, abs_y, len - tmp, (lv_draw_mask_line_param_t *)&p->start_line); if(res2 == LV_DRAW_MASK_RES_TRANSP) { - _lv_memset_00(&mask_buf[tmp], len - tmp); + lv_memset_00(&mask_buf[tmp], len - tmp); } if(res1 == res2) return res1; else return LV_DRAW_MASK_RES_CHANGED; @@ -915,13 +915,13 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m int32_t last = rect.x1 - abs_x; if(last > len) return LV_DRAW_MASK_RES_TRANSP; if(last >= 0) { - _lv_memset_00(&mask_buf[0], last); + lv_memset_00(&mask_buf[0], last); } int32_t first = rect.x2 - abs_x + 1; if(first <= 0) return LV_DRAW_MASK_RES_TRANSP; else if(first < len) { - _lv_memset_00(&mask_buf[first], len - first); + lv_memset_00(&mask_buf[first], len - first); } if(last == 0 && first == len) return LV_DRAW_MASK_RES_FULL_COVER; else return LV_DRAW_MASK_RES_CHANGED; @@ -933,7 +933,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m int32_t last = rect.x2 - abs_x - first + 1; if(first + last > len) last = len - first; if(last >= 0) { - _lv_memset_00(&mask_buf[first], last); + lv_memset_00(&mask_buf[first], last); } } } @@ -971,9 +971,9 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m x0.i = p->y_prev_x.i; } else { - _lv_sqrt(r2 - (y * y), &x0, sqrt_mask); + lv_sqrt(r2 - (y * y), &x0, sqrt_mask); } - _lv_sqrt(r2 - ((y - 1) * (y - 1)), &x1, sqrt_mask); + lv_sqrt(r2 - ((y - 1) * (y - 1)), &x1, sqrt_mask); p->y_prev = y - 1; p->y_prev_x.f = x1.f; p->y_prev_x.i = x1.i; @@ -989,10 +989,10 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m x1.i = p->y_prev_x.i; } else { - _lv_sqrt(r2 - ((y - 1) * (y - 1)), &x1, sqrt_mask); + lv_sqrt(r2 - ((y - 1) * (y - 1)), &x1, sqrt_mask); } - _lv_sqrt(r2 - (y * y), &x0, sqrt_mask); + lv_sqrt(r2 - (y * y), &x0, sqrt_mask); p->y_prev = y; p->y_prev_x.f = x0.f; p->y_prev_x.i = x0.i; @@ -1031,13 +1031,13 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m return LV_DRAW_MASK_RES_TRANSP; } if(kl >= 0) { - _lv_memset_00(&mask_buf[0], kl); + lv_memset_00(&mask_buf[0], kl); } if(kr < 0) { return LV_DRAW_MASK_RES_TRANSP; } if(kr <= len) { - _lv_memset_00(&mask_buf[kr], len - kr); + lv_memset_00(&mask_buf[kr], len - kr); } } else { @@ -1048,7 +1048,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m int32_t len_tmp = kr - first; if(len_tmp + first > len) len_tmp = len - first; if(first < len && len_tmp >= 0) { - _lv_memset_00(&mask_buf[first], len_tmp); + lv_memset_00(&mask_buf[first], len_tmp); } } } @@ -1065,7 +1065,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m int32_t len_tmp = kr - first; if(len_tmp + first > len) len_tmp = len - first; if(first < len && len_tmp >= 0) { - _lv_memset_00(&mask_buf[first], len_tmp); + lv_memset_00(&mask_buf[first], len_tmp); } } @@ -1074,7 +1074,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m lv_sqrt_res_t y_prev; lv_sqrt_res_t y_next; - _lv_sqrt(r2 - (x0.i * x0.i), &y_prev, sqrt_mask); + lv_sqrt(r2 - (x0.i * x0.i), &y_prev, sqrt_mask); if(y_prev.f == 0) { y_prev.i--; @@ -1083,7 +1083,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m /*The first y intersection is special as it might be in the previous line*/ if(y_prev.i >= y) { - _lv_sqrt(r2 - (i * i), &y_next, sqrt_mask); + lv_sqrt(r2 - (i * i), &y_next, sqrt_mask); m = 255 - (((255 - x0.f) * (255 - y_next.f)) >> 9); if(outer) m = 255 - m; @@ -1126,12 +1126,12 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m if(kl > len) { return LV_DRAW_MASK_RES_TRANSP; } - if(kl >= 0) _lv_memset_00(&mask_buf[0], kl); + if(kl >= 0) lv_memset_00(&mask_buf[0], kl); if(kr < 0) { return LV_DRAW_MASK_RES_TRANSP; } - if(kr < len) _lv_memset_00(&mask_buf[kr], len - kr); + if(kr < len) lv_memset_00(&mask_buf[kr], len - kr); } } } @@ -1227,7 +1227,7 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_opa_t mask_mix(lv_opa_t mask_act, lv_opa_ if(mask_new >= LV_OPA_MAX) return mask_act; if(mask_new <= LV_OPA_MIN) return 0; - return LV_MATH_UDIV255(mask_act * mask_new);// >> 8); + return LV_UDIV255(mask_act * mask_new);// >> 8); } /** diff --git a/src/lv_draw/lv_draw_mask.h b/src/lv_draw/lv_draw_mask.h index dc40ce0f4..6d2256ced 100644 --- a/src/lv_draw/lv_draw_mask.h +++ b/src/lv_draw/lv_draw_mask.h @@ -16,6 +16,7 @@ extern "C" { #include #include "../lv_misc/lv_area.h" #include "../lv_misc/lv_color.h" +#include "../lv_misc/lv_math.h" /********************* * DEFINES diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 5e64a5a5a..22d456116 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -30,6 +30,8 @@ **********************/ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc); +LV_ATTRIBUTE_FAST_MEM static void draw_bg_img(const lv_area_t * coords, const lv_area_t * clip, + const lv_draw_rect_dsc_t * dsc); LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc); @@ -71,7 +73,7 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(const lv_draw_rect_dsc_t LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc) { - _lv_memset_00(dsc, sizeof(lv_draw_rect_dsc_t)); + lv_memset_00(dsc, sizeof(lv_draw_rect_dsc_t)); dsc->bg_color = LV_COLOR_WHITE; dsc->bg_grad_color = LV_COLOR_BLACK; dsc->border_color = LV_COLOR_BLACK; @@ -79,6 +81,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc) dsc->shadow_color = LV_COLOR_BLACK; dsc->bg_grad_color_stop = 0xFF; dsc->bg_opa = LV_OPA_COVER; + dsc->bg_img_opa = LV_OPA_COVER; dsc->outline_opa = LV_OPA_COVER; dsc->border_opa = LV_OPA_COVER; dsc->content_font = LV_THEME_DEFAULT_FONT_NORMAL; @@ -86,7 +89,6 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc) dsc->content_align = LV_ALIGN_CENTER; dsc->shadow_opa = LV_OPA_COVER; dsc->border_side = LV_BORDER_SIDE_FULL; - } /** @@ -103,6 +105,7 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_dra #endif draw_bg(coords, clip, dsc); + draw_bg_img(coords, clip, dsc); draw_border(coords, clip, dsc); @@ -117,41 +120,6 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_dra LV_ASSERT_MEM_INTEGRITY(); } -/** - * Draw a pixel - * @param point the coordinates of the point to draw - * @param mask the pixel will be drawn only in this mask - * @param style pointer to a style - * @param opa_scale scale down the opacity by the factor - */ -void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style) -{ - LV_UNUSED(point); - LV_UNUSED(clip_area); - LV_UNUSED(style); - // lv_opa_t opa = style->body.opa; - // if(opa_scale != LV_OPA_COVER) opa = (opa * opa_scale) >> 8; - // - // if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; - // - // lv_area_t fill_area; - // fill_area.x1 = point->x; - // fill_area.y1 = point->y; - // fill_area.x2 = point->x; - // fill_area.y2 = point->y; - // - // uint8_t mask_cnt = lv_draw_mask_get_cnt(); - // - // if(mask_cnt == 0) { - // lv_blend_fill(clip_area, &fill_area, style->body.main_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, style->body.blend_mode); - // } else { - // uint8_t mask_buf; - // lv_draw_mask_res_t mask_res; - // mask_res = lv_draw_mask_apply(&mask_buf, point->x, point->y, 1); - // lv_blend_fill(clip_area, &fill_area, style->body.main_color, &mask_buf, mask_res, opa, style->body.blend_mode); - // } -} - /********************** * STATIC FUNCTIONS **********************/ @@ -198,7 +166,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are int32_t draw_area_w = lv_area_get_width(&draw_area); /*Create a mask if there is a radius*/ - lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); + lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w); lv_grad_dir_t grad_dir = dsc->bg_grad_dir; if(dsc->bg_color.full == dsc->bg_grad_color.full) grad_dir = LV_GRAD_DIR_NONE; @@ -215,14 +183,14 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are /*Get the real radius*/ int32_t rout = dsc->radius; - int32_t short_side = LV_MATH_MIN(coords_w, coords_h); + int32_t short_side = LV_MIN(coords_w, coords_h); if(rout > short_side >> 1) rout = short_side >> 1; /*Most simple case: just a plain rectangle*/ if(simple_mode && rout == 0 && (grad_dir == LV_GRAD_DIR_NONE)) { _lv_blend_fill(clip, &coords_bg, dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, - dsc->bg_blend_mode); + dsc->blend_mode); } /*More complex case: there is a radius, gradient or other mask.*/ else { @@ -241,7 +209,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are lv_color_t * grad_map = NULL; /*In case of horizontal gradient pre-compute a line with a gradient*/ if(grad_dir == LV_GRAD_DIR_HOR) { - grad_map = _lv_mem_buf_get(coords_w * sizeof(lv_color_t)); + grad_map = lv_mem_buf_get(coords_w * sizeof(lv_color_t)); int32_t i; for(i = 0; i < coords_w; i++) { @@ -269,13 +237,13 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are y < coords_bg.y2 - rout - 1) { mask_res = LV_DRAW_MASK_RES_FULL_COVER; if(simple_mode == false) { - _lv_memset(mask_buf, opa, draw_area_w); + lv_memset(mask_buf, opa, draw_area_w); mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); } } /*In corner areas apply the mask anyway*/ else { - _lv_memset(mask_buf, opa, draw_area_w); + lv_memset(mask_buf, opa, draw_area_w); mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); } @@ -303,14 +271,14 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are fill_area2.y2 = fill_area.y2; _lv_blend_fill(clip, &fill_area2, - grad_color, mask_buf, mask_res, opa2, dsc->bg_blend_mode); + grad_color, mask_buf, mask_res, opa2, dsc->blend_mode); /*Center part*/ if(grad_dir == LV_GRAD_DIR_VER) { fill_area2.x1 = coords_bg.x1 + rout; fill_area2.x2 = coords_bg.x2 - rout; _lv_blend_fill(clip, &fill_area2, - grad_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode); + grad_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->blend_mode); } /*Right part*/ @@ -320,21 +288,21 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are 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, opa2, dsc->bg_blend_mode); + grad_color, mask_buf + mask_ofs, mask_res, opa2, dsc->blend_mode); } else { if(grad_dir == LV_GRAD_DIR_HOR) { - _lv_blend_map(clip, &fill_area, grad_map, mask_buf, mask_res, opa2, dsc->bg_blend_mode); + _lv_blend_map(clip, &fill_area, grad_map, mask_buf, mask_res, opa2, dsc->blend_mode); } else if(grad_dir == LV_GRAD_DIR_VER) { _lv_blend_fill(clip, &fill_area, - grad_color, mask_buf, mask_res, opa2, dsc->bg_blend_mode); + grad_color, mask_buf, mask_res, opa2, dsc->blend_mode); } else if(other_mask_cnt != 0 || !split) { _lv_blend_fill(clip, &fill_area, - grad_color, mask_buf, mask_res, opa2, dsc->bg_blend_mode); + grad_color, mask_buf, mask_res, opa2, dsc->blend_mode); } } fill_area.y1++; @@ -349,7 +317,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are fill_area.y2 = coords_bg.y1 + rout; _lv_blend_fill(clip, &fill_area, - dsc->bg_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->blend_mode); fill_area.y1 = coords_bg.y2 - rout; if(fill_area.y1 <= fill_area.y2) fill_area.y1 = fill_area.y2 + 1; /*Avoid overdrawing the last line*/ @@ -357,7 +325,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are _lv_blend_fill(clip, &fill_area, - dsc->bg_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->blend_mode); fill_area.x1 = coords_bg.x1; fill_area.x2 = coords_bg.x2; @@ -365,19 +333,64 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are 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); + dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->blend_mode); } - if(grad_map) _lv_mem_buf_release(grad_map); + if(grad_map) lv_mem_buf_release(grad_map); } lv_draw_mask_remove_id(mask_rout_id); - _lv_mem_buf_release(mask_buf); + lv_mem_buf_release(mask_buf); } +LV_ATTRIBUTE_FAST_MEM static void draw_bg_img(const lv_area_t * coords, const lv_area_t * clip, + const lv_draw_rect_dsc_t * dsc) +{ + if(dsc->bg_img_src == NULL) return; + if(dsc->bg_img_opa <= LV_OPA_MIN) return; + + lv_img_header_t header; + lv_res_t res = lv_img_decoder_get_info(dsc->bg_img_src, &header); + if(res != LV_RES_OK) { + LV_LOG_WARN("Coudn't read the background image"); + return; + } + + lv_draw_img_dsc_t img_dsc; + lv_draw_img_dsc_init(&img_dsc); + img_dsc.blend_mode = dsc->blend_mode; + img_dsc.recolor = dsc->bg_img_recolor; + img_dsc.recolor_opa = dsc->bg_img_recolor_opa; + img_dsc.opa = dsc->bg_img_opa; + + /*Center align*/ + if(dsc->bg_img_tiled == false) { + lv_area_t area; + area.x1 = coords->x1 + lv_area_get_width(coords) / 2 - header.w / 2; + area.y1 = coords->y1 + lv_area_get_height(coords) / 2 - header.h / 2; + area.x2 = area.x1 + header.w - 1; + area.y2 = area.y1 + header.h - 1; + + lv_draw_img(&area, clip, dsc->bg_img_src, &img_dsc); + } else { + lv_area_t area; + area.y1 = coords->y1; + area.y2 = area.y1 + header.h - 1; + + for(; area.y1 <= coords->y2; area.y1 += header.h, area.y2 += header.h) { + + area.x1 = coords->x1; + area.x2 = area.x1 + header.w - 1; + for(; area.x1 <= coords->x2; area.x1 += header.w, area.x2 += header.w) { + lv_draw_img(&area, clip, dsc->bg_img_src, &img_dsc); + } + } + } +} + LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc) { @@ -391,7 +404,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv /*Get the real radius*/ int32_t rout = dsc->radius; - int32_t short_side = LV_MATH_MIN(coords_w, coords_h); + int32_t short_side = LV_MIN(coords_w, coords_h); if(rout > short_side >> 1) rout = short_side >> 1; /*Get the inner area*/ @@ -404,7 +417,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv if(dsc->border_side == LV_BORDER_SIDE_FULL) { draw_full_border(&area_inner, coords, clip, dsc->radius, false, dsc->border_color, dsc->border_opa, - dsc->border_blend_mode); + dsc->blend_mode); } else { lv_opa_t opa = dsc->border_opa; @@ -432,7 +445,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv int32_t draw_area_w = lv_area_get_width(&draw_area); /*Create a mask if there is a radius*/ - lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); + lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w); /*Create mask for the outer area*/ int16_t mask_rout_id = LV_MASK_ID_INV; @@ -449,14 +462,14 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv lv_draw_mask_radius_init(&mask_rin_param, &area_inner, rout - dsc->border_width, true); int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL); - int32_t corner_size = LV_MATH_MAX(rout, dsc->border_width - 1); + int32_t corner_size = LV_MAX(rout, dsc->border_width - 1); int32_t h; lv_draw_mask_res_t mask_res; lv_area_t fill_area; lv_color_t color = dsc->border_color; - lv_blend_mode_t blend_mode = dsc->border_blend_mode; + lv_blend_mode_t blend_mode = dsc->blend_mode; fill_area.x1 = coords->x1; fill_area.x2 = coords->x2; @@ -485,7 +498,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv if(normal || (top_only && fill_area.y1 <= coords->y1 + corner_size) || (bottom_only && fill_area.y1 >= coords->y2 - corner_size)) { - _lv_memset_ff(mask_buf, draw_area_w); + lv_memset_ff(mask_buf, 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 + buf_ofs, mask_res, opa, blend_mode); } @@ -495,7 +508,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv } lv_draw_mask_remove_id(mask_rin_id); lv_draw_mask_remove_id(mask_rout_id); - _lv_mem_buf_release(mask_buf); + lv_mem_buf_release(mask_buf); } } @@ -574,11 +587,11 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv /*Get the real radius*/ int32_t r_bg = dsc->radius; - int32_t short_side = LV_MATH_MIN(lv_area_get_width(&bg_coords), lv_area_get_height(&bg_coords)); + int32_t short_side = LV_MIN(lv_area_get_width(&bg_coords), lv_area_get_height(&bg_coords)); if(r_bg > short_side >> 1) r_bg = short_side >> 1; int32_t r_sh = dsc->radius; - short_side = LV_MATH_MIN(lv_area_get_width(&sh_rect_area), lv_area_get_height(&sh_rect_area)); + short_side = LV_MIN(lv_area_get_width(&sh_rect_area), lv_area_get_height(&sh_rect_area)); if(r_sh > short_side >> 1) r_sh = short_side >> 1; @@ -589,23 +602,23 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv #if LV_SHADOW_CACHE_SIZE if(sh_cache_size == corner_size && sh_cache_r == r_sh) { /*Use the cache if available*/ - sh_buf = _lv_mem_buf_get(corner_size * corner_size); - _lv_memcpy(sh_buf, sh_cache, corner_size * corner_size); + sh_buf = lv_mem_buf_get(corner_size * corner_size); + lv_memcpy(sh_buf, sh_cache, corner_size * corner_size); } else { /*A larger buffer is required for calculation */ - sh_buf = _lv_mem_buf_get(corner_size * corner_size * sizeof(uint16_t)); + sh_buf = lv_mem_buf_get(corner_size * corner_size * sizeof(uint16_t)); shadow_draw_corner_buf(&sh_rect_area, (uint16_t *)sh_buf, dsc->shadow_width, r_sh); /*Cache the corner if it fits into the cache size*/ if(corner_size * corner_size < sizeof(sh_cache)) { - _lv_memcpy(sh_cache, sh_buf, corner_size * corner_size); + lv_memcpy(sh_cache, sh_buf, corner_size * corner_size); sh_cache_size = corner_size; sh_cache_r = r_sh; } } #else - sh_buf = _lv_mem_buf_get(corner_size * corner_size * sizeof(uint16_t)); + sh_buf = lv_mem_buf_get(corner_size * corner_size * sizeof(uint16_t)); shadow_draw_corner_buf(&sh_rect_area, (uint16_t *)sh_buf, dsc->shadow_width, r_sh); #endif @@ -619,7 +632,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv /*Create a mask*/ lv_draw_mask_res_t mask_res; - lv_opa_t * mask_buf = _lv_mem_buf_get(lv_area_get_width(&sh_area)); + lv_opa_t * mask_buf = lv_mem_buf_get(lv_area_get_width(&sh_area)); lv_draw_mask_radius_param_t mask_rout_param; lv_draw_mask_radius_init(&mask_rout_param, &bg_coords, r_bg, true); @@ -654,12 +667,12 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv fa.y2 = fa.y1; for(y = 0; y < h; y++) { - _lv_memcpy(mask_buf, sh_buf_tmp, w); + lv_memcpy(mask_buf, sh_buf_tmp, w); mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w); if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED; _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, - mask_res, opa, dsc->shadow_blend_mode); + mask_res, opa, dsc->blend_mode); fa.y1++; fa.y2++; sh_buf_tmp += corner_size; @@ -691,12 +704,12 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv fa.y1 = fa.y2; /*Fill from bottom to top*/ for(y = 0; y < h; y++) { - _lv_memcpy(mask_buf, sh_buf_tmp, w); + lv_memcpy(mask_buf, sh_buf_tmp, w); mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w); if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED; _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, - mask_res, opa, dsc->shadow_blend_mode); + mask_res, opa, dsc->blend_mode); fa.y1--; fa.y2--; sh_buf_tmp += corner_size; @@ -712,7 +725,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv has_com = _lv_area_intersect(&ca, &a, clip); if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) { - if(simple_mode) ca.x1 = LV_MATH_MAX(ca.x1, coords->x2); + if(simple_mode) ca.x1 = LV_MAX(ca.x1, coords->x2); /*Draw horizontal lines*/ lv_coord_t w = lv_area_get_width(&ca); if(w > 0) { @@ -727,7 +740,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv fa.y2 = fa.y1; mask_res = LV_DRAW_MASK_RES_FULL_COVER; for(y = 0; y < h; y++) { - _lv_memcpy(mask_buf, sh_buf_tmp, w); + lv_memcpy(mask_buf, sh_buf_tmp, w); if(simple_mode) { mask_res = LV_DRAW_MASK_RES_CHANGED; @@ -738,7 +751,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv } _lv_blend_fill(clip, &fa, - dsc->shadow_color, mask_buf, mask_res, dsc->shadow_opa, dsc->shadow_blend_mode); + dsc->shadow_color, mask_buf, mask_res, dsc->shadow_opa, dsc->blend_mode); fa.y1++; fa.y2++; } @@ -780,12 +793,12 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv fa.y2 = fa.y1; for(y = 0; y < h; y++) { - _lv_memcpy(mask_buf, sh_buf_tmp, w); + lv_memcpy(mask_buf, sh_buf_tmp, w); mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w); if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED; _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, - mask_res, opa, dsc->shadow_blend_mode); + mask_res, opa, dsc->blend_mode); fa.y1++; fa.y2++; sh_buf_tmp += corner_size; @@ -816,12 +829,12 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv fa.y1 = fa.y2; /*Fill from bottom to top*/ for(y = 0; y < h; y++) { - _lv_memcpy(mask_buf, sh_buf_tmp, w); + lv_memcpy(mask_buf, sh_buf_tmp, w); mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w); if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED; _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, - mask_res, opa, dsc->shadow_blend_mode); + mask_res, opa, dsc->blend_mode); fa.y1--; fa.y2--; sh_buf_tmp += corner_size; @@ -837,7 +850,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv has_com = _lv_area_intersect(&ca, &a, clip); if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) { - if(simple_mode) ca.x2 = LV_MATH_MIN(coords->x1, ca.x2); + if(simple_mode) ca.x2 = LV_MIN(coords->x1, ca.x2); /*Draw vertical lines*/ lv_coord_t w = lv_area_get_width(&ca); if(w > 0) { @@ -850,7 +863,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv lv_area_copy(&fa, &ca); fa.y2 = fa.y1; for(y = 0; y < h; y++) { - _lv_memcpy(mask_buf, sh_buf_tmp, w); + lv_memcpy(mask_buf, sh_buf_tmp, w); if(simple_mode) { mask_res = LV_DRAW_MASK_RES_CHANGED; } @@ -860,7 +873,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv } _lv_blend_fill(clip, &fa, - dsc->shadow_color, mask_buf, mask_res, dsc->shadow_opa, dsc->shadow_blend_mode); + dsc->shadow_color, mask_buf, mask_res, dsc->shadow_opa, dsc->blend_mode); fa.y1++; fa.y2++; } @@ -875,7 +888,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv has_com = _lv_area_intersect(&ca, &a, clip); if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) { - if(simple_mode) ca.y2 = LV_MATH_MIN(ca.y2, coords->y1); + if(simple_mode) ca.y2 = LV_MIN(ca.y2, coords->y1); /*Draw horizontal lines*/ lv_coord_t w = lv_area_get_width(&ca); lv_coord_t h = lv_area_get_height(&ca); @@ -890,7 +903,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv lv_opa_t opa_tmp = sh_buf_tmp[0]; if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8; - _lv_memset(mask_buf, opa_tmp, w); + lv_memset(mask_buf, opa_tmp, w); if(simple_mode) { mask_res = LV_DRAW_MASK_RES_CHANGED; @@ -901,7 +914,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv } _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, - mask_res, LV_OPA_COVER, dsc->shadow_blend_mode); + mask_res, LV_OPA_COVER, dsc->blend_mode); fa.y1++; fa.y2++; sh_buf_tmp += corner_size; @@ -917,7 +930,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv has_com = _lv_area_intersect(&ca, &a, clip); if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) { - if(simple_mode) ca.y1 = LV_MATH_MAX(ca.y1, coords->y2); + if(simple_mode) ca.y1 = LV_MAX(ca.y1, coords->y2); /*Draw horizontal lines*/ lv_coord_t w = lv_area_get_width(&ca); lv_coord_t h = lv_area_get_height(&ca); @@ -931,7 +944,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv lv_opa_t opa_tmp = sh_buf_tmp[0]; if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8; - _lv_memset(mask_buf, opa_tmp, w); + lv_memset(mask_buf, opa_tmp, w); if(simple_mode) { mask_res = LV_DRAW_MASK_RES_CHANGED; } @@ -941,7 +954,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv } _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, - mask_res, LV_OPA_COVER, dsc->shadow_blend_mode); + mask_res, LV_OPA_COVER, dsc->blend_mode); fa.y1--; fa.y2--; sh_buf_tmp += corner_size; @@ -964,20 +977,20 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv lv_area_copy(&fa, &ca); fa.y2 = fa.y1; for(y = 0; y < h; y++) { - _lv_memset(mask_buf, dsc->shadow_opa, w); + lv_memset(mask_buf, dsc->shadow_opa, w); mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w); if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED; _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, - mask_res, LV_OPA_COVER, dsc->shadow_blend_mode); + mask_res, LV_OPA_COVER, dsc->blend_mode); fa.y1++; fa.y2++; } } lv_draw_mask_remove_id(mask_rout_id); - _lv_mem_buf_release(mask_buf); - _lv_mem_buf_release(sh_buf); + lv_mem_buf_release(mask_buf); + lv_mem_buf_release(sh_buf); } /** @@ -1011,13 +1024,13 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coord #endif int32_t y; - lv_opa_t * mask_line = _lv_mem_buf_get(size); + lv_opa_t * mask_line = lv_mem_buf_get(size); uint16_t * sh_ups_tmp_buf = (uint16_t *)sh_buf; for(y = 0; y < size; y++) { - _lv_memset_ff(mask_line, size); + lv_memset_ff(mask_line, size); lv_draw_mask_res_t mask_res = mask_param.dsc.cb(mask_line, 0, y, size, &mask_param); if(mask_res == LV_DRAW_MASK_RES_TRANSP) { - _lv_memset_00(sh_ups_tmp_buf, size * sizeof(sh_ups_tmp_buf[0])); + lv_memset_00(sh_ups_tmp_buf, size * sizeof(sh_ups_tmp_buf[0])); } else { int32_t i; @@ -1030,7 +1043,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coord sh_ups_tmp_buf += size; } - _lv_mem_buf_release(mask_line); + lv_mem_buf_release(mask_line); if(sw == 1) { int32_t i; @@ -1078,7 +1091,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t if((sw & 1) == 0) s_left--; /*Horizontal blur*/ - uint16_t * sh_ups_blur_buf = _lv_mem_buf_get(size * sizeof(uint16_t)); + uint16_t * sh_ups_blur_buf = lv_mem_buf_get(size * sizeof(uint16_t)); int32_t x; int32_t y; @@ -1101,7 +1114,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t else left_val = sh_ups_tmp_buf[x - s_left - 1]; v += left_val; } - _lv_memcpy(sh_ups_tmp_buf, sh_ups_blur_buf, size * sizeof(uint16_t)); + lv_memcpy(sh_ups_tmp_buf, sh_ups_blur_buf, size * sizeof(uint16_t)); sh_ups_tmp_buf += size; } @@ -1139,7 +1152,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t } } - _lv_mem_buf_release(sh_ups_blur_buf); + lv_mem_buf_release(sh_ups_blur_buf); } #endif @@ -1171,65 +1184,36 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, const area_outer.y2 += dsc->outline_width; draw_full_border(&area_inner, &area_outer, clip, dsc->radius, true, dsc->outline_color, dsc->outline_opa, - dsc->outline_blend_mode); + dsc->blend_mode); } #endif #if LV_USE_PATTERN static void draw_content(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc) { - if(dsc->content_src == NULL) return; + if(dsc->content_text == NULL) return; if(dsc->content_opa == LV_OPA_MIN) return; - lv_img_src_t src_type = lv_img_src_get_type(dsc->content_src); - - lv_draw_img_dsc_t img_dsc; lv_draw_label_dsc_t label_dsc; - int32_t img_w; - int32_t img_h; - if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_VARIABLE) { - lv_img_header_t header; - lv_res_t res = lv_img_decoder_get_info(dsc->content_src, &header); - if(res != LV_RES_OK) { - LV_LOG_WARN("draw_img: can't get image info"); - return; - } + lv_draw_label_dsc_init(&label_dsc); + label_dsc.color = dsc->content_color; + label_dsc.font = dsc->content_font; + label_dsc.opa = dsc->content_opa; + lv_point_t s; + _lv_txt_get_size(&s, dsc->content_text, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, + LV_TEXT_FLAG_NONE); - img_w = header.w; - img_h = header.h; - - lv_draw_img_dsc_init(&img_dsc); - img_dsc.opa = dsc->content_opa; - img_dsc.recolor = dsc->content_color; - img_dsc.recolor_opa = dsc->content_recolor_opa; - } - else if(src_type == LV_IMG_SRC_SYMBOL) { - lv_draw_label_dsc_init(&label_dsc); - label_dsc.color = dsc->content_color; - label_dsc.font = dsc->content_font; - label_dsc.opa = dsc->content_opa; - lv_point_t s; - _lv_txt_get_size(&s, dsc->content_src, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, - LV_TEXT_FLAG_NONE); - img_w = s.x; - img_h = s.y; - - } - else { - LV_LOG_WARN("image source type is unknown"); - return; - } /*Can't draw zero sized images*/ - if(img_w == 0 || img_h == 0) return; + if(s.x == 0 || s.y == 0) return; lv_area_t coords_tmp; coords_tmp.x1 = 0; coords_tmp.y1 = 0; - coords_tmp.x2 = img_w - 1; - coords_tmp.y2 = img_h - 1; + coords_tmp.x2 = s.x - 1; + coords_tmp.y2 = s.y - 1; lv_point_t p_align; _lv_area_align(coords, &coords_tmp, dsc->content_align, &p_align); @@ -1239,11 +1223,10 @@ static void draw_content(const lv_area_t * coords, const lv_area_t * clip, const coords_tmp.x2 += p_align.x + dsc->content_ofs_x; coords_tmp.y2 += p_align.y + dsc->content_ofs_y; - if(src_type == LV_IMG_SRC_SYMBOL) lv_draw_label(&coords_tmp, clip, &label_dsc, dsc->content_src, NULL); - else lv_draw_img(&coords_tmp, clip, dsc->content_src, &img_dsc); + lv_draw_label(&coords_tmp, clip, &label_dsc, dsc->content_text, NULL); #if LV_USE_ARABIC_PERSIAN_CHARS - _lv_mem_buf_release(str); + lv_mem_buf_release(str); #endif } #endif @@ -1267,7 +1250,7 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are int32_t rout; if(radius_is_in) { rin = radius; - int32_t short_side = LV_MATH_MIN(inner_w, inner_h); + int32_t short_side = LV_MIN(inner_w, inner_h); if(rin > short_side >> 1) rin = short_side >> 1; /*Get the outer area*/ @@ -1275,7 +1258,7 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are } else { rout = radius; - int32_t short_side = LV_MATH_MIN(coords_out_w, coords_out_h); + int32_t short_side = LV_MIN(coords_out_w, coords_out_h); if(rout > short_side >> 1) rout = short_side >> 1; /*Get the outer area*/ @@ -1314,9 +1297,9 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are lv_draw_mask_radius_init(&mask_rout_param, area_outer, rout, false); int16_t mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); - lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); + lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w); - int32_t corner_size = LV_MATH_MAX(rout, border_width - 1); + int32_t corner_size = LV_MAX(rout, border_width - 1); int32_t h; lv_draw_mask_res_t mask_res; @@ -1332,7 +1315,7 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are fill_area.y1 = disp_area->y1 + draw_area.y1; fill_area.y2 = fill_area.y1; for(h = draw_area.y1; h <= upper_corner_end; h++) { - _lv_memset_ff(mask_buf, draw_area_w); + lv_memset_ff(mask_buf, 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_area_t fill_area2; @@ -1369,7 +1352,7 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are fill_area.y1 = disp_area->y1 + lower_corner_end; fill_area.y2 = fill_area.y1; for(h = lower_corner_end; h <= draw_area.y2; h++) { - _lv_memset_ff(mask_buf, draw_area_w); + lv_memset_ff(mask_buf, 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_area_t fill_area2; @@ -1421,7 +1404,7 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are fill_area.y2 = fill_area.y1; for(h = draw_area.y1; h <= draw_area.y2; h++) { - _lv_memset_ff(mask_buf, draw_area_w); + lv_memset_ff(mask_buf, 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); @@ -1432,6 +1415,6 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are } lv_draw_mask_remove_id(mask_rin_id); lv_draw_mask_remove_id(mask_rout_id); - _lv_mem_buf_release(mask_buf); + lv_mem_buf_release(mask_buf); } diff --git a/src/lv_draw/lv_draw_rect.h b/src/lv_draw/lv_draw_rect.h index 584db86ee..b5481859d 100644 --- a/src/lv_draw/lv_draw_rect.h +++ b/src/lv_draw/lv_draw_rect.h @@ -51,30 +51,35 @@ typedef uint8_t lv_grad_dir_t; typedef struct { lv_coord_t radius; + lv_blend_mode_t blend_mode; /*Background*/ lv_color_t bg_color; lv_color_t bg_grad_color; - lv_grad_dir_t bg_grad_dir; uint8_t bg_main_color_stop; uint8_t bg_grad_color_stop; lv_opa_t bg_opa; - lv_blend_mode_t bg_blend_mode; + lv_grad_dir_t bg_grad_dir :3; + + /*Background img*/ + const void * bg_img_src; + lv_color_t bg_img_recolor; + lv_opa_t bg_img_opa; + lv_opa_t bg_img_recolor_opa; + uint8_t bg_img_tiled; /*Border*/ lv_color_t border_color; lv_coord_t border_width; - lv_border_side_t border_side; lv_opa_t border_opa; - lv_blend_mode_t border_blend_mode; uint8_t border_post : 1; /*There is a border it will be drawn later. */ + lv_border_side_t border_side :5; /*Outline*/ lv_color_t outline_color; lv_coord_t outline_width; lv_coord_t outline_pad; lv_opa_t outline_opa; - lv_blend_mode_t outline_blend_mode; /*Shadow*/ lv_color_t shadow_color; @@ -83,21 +88,18 @@ typedef struct { lv_coord_t shadow_ofs_y; lv_coord_t shadow_spread; lv_opa_t shadow_opa; - lv_blend_mode_t shadow_blend_mode; /*Content*/ - const void * content_src; - const void * content_img; - lv_align_t content_align; - lv_coord_t content_ofs_x; - lv_coord_t content_ofs_y; - lv_opa_t content_opa; + const void * content_text; const lv_font_t * content_font; - lv_opa_t content_recolor_opa; - lv_blend_mode_t content_blend_mode; - lv_color_t content_color; lv_coord_t content_letter_space; lv_coord_t content_line_space; + lv_coord_t content_ofs_x; + lv_coord_t content_ofs_y; + lv_color_t content_color; + lv_opa_t content_opa; + lv_align_t content_align : 5; + } lv_draw_rect_dsc_t; /********************** diff --git a/src/lv_draw/lv_draw_triangle.c b/src/lv_draw/lv_draw_triangle.c index e5775a7e2..84b792abd 100644 --- a/src/lv_draw/lv_draw_triangle.c +++ b/src/lv_draw/lv_draw_triangle.c @@ -59,7 +59,7 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are if(points == NULL) return; /*Join adjacent points if they are on the same coordinate*/ - lv_point_t * p = _lv_mem_buf_get(point_cnt * sizeof(lv_point_t)); + lv_point_t * p = lv_mem_buf_get(point_cnt * sizeof(lv_point_t)); if(p == NULL) return; uint16_t i; uint16_t pcnt = 0; @@ -78,24 +78,24 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are point_cnt = pcnt; if(point_cnt < 3) { - _lv_mem_buf_release(p); + lv_mem_buf_release(p); return; } lv_area_t poly_coords = {.x1 = LV_COORD_MAX, .y1 = LV_COORD_MAX, .x2 = LV_COORD_MIN, .y2 = LV_COORD_MIN}; for(i = 0; i < point_cnt; i++) { - poly_coords.x1 = LV_MATH_MIN(poly_coords.x1, p[i].x); - poly_coords.y1 = LV_MATH_MIN(poly_coords.y1, p[i].y); - poly_coords.x2 = LV_MATH_MAX(poly_coords.x2, p[i].x); - poly_coords.y2 = LV_MATH_MAX(poly_coords.y2, p[i].y); + poly_coords.x1 = LV_MIN(poly_coords.x1, p[i].x); + poly_coords.y1 = LV_MIN(poly_coords.y1, p[i].y); + poly_coords.x2 = LV_MAX(poly_coords.x2, p[i].x); + poly_coords.y2 = LV_MAX(poly_coords.y2, p[i].y); } bool is_common; lv_area_t poly_mask; is_common = _lv_area_intersect(&poly_mask, &poly_coords, clip_area); if(!is_common) { - _lv_mem_buf_release(p); + lv_mem_buf_release(p); return; } /*Find the lowest point*/ @@ -109,7 +109,7 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are } } - lv_draw_mask_line_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_line_param_t) * point_cnt); + lv_draw_mask_line_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_line_param_t) * point_cnt); lv_draw_mask_line_param_t * mp_next = mp; int32_t i_prev_left = y_min_i; @@ -192,8 +192,8 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are lv_draw_mask_remove_custom(mp); - _lv_mem_buf_release(mp); - _lv_mem_buf_release(p); + lv_mem_buf_release(mp); + lv_mem_buf_release(p); } diff --git a/src/lv_draw/lv_img_buf.c b/src/lv_draw/lv_img_buf.c index f18a6fd6c..97699631d 100644 --- a/src/lv_draw/lv_img_buf.c +++ b/src/lv_draw/lv_img_buf.c @@ -58,7 +58,7 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) { uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3; uint32_t px = dsc->header.w * y * px_size + x * px_size; - _lv_memcpy_small(&p_color, &buf_u8[px], sizeof(lv_color_t)); + lv_memcpy_small(&p_color, &buf_u8[px], sizeof(lv_color_t)); #if LV_COLOR_SIZE == 32 p_color.ch.alpha = 0xFF; /*Only the color should be get so use a default alpha value*/ #endif @@ -245,12 +245,12 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_ if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) { uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3; uint32_t px = dsc->header.w * y * px_size + x * px_size; - _lv_memcpy_small(&buf_u8[px], &c, px_size); + lv_memcpy_small(&buf_u8[px], &c, px_size); } else if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) { uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3; uint32_t px = dsc->header.w * y * px_size + x * px_size; - _lv_memcpy_small(&buf_u8[px], &c, px_size - 1); /*-1 to not overwrite the alpha value*/ + lv_memcpy_small(&buf_u8[px], &c, px_size - 1); /*-1 to not overwrite the alpha value*/ } else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) { buf_u8 += sizeof(lv_color32_t) * 2; /*Skip the palette*/ @@ -318,7 +318,7 @@ void lv_img_buf_set_palette(lv_img_dsc_t * dsc, uint8_t id, lv_color_t c) lv_color32_t c32; c32.full = lv_color_to32(c); uint8_t * buf = (uint8_t *)dsc->data; - _lv_memcpy_small(&buf[id * sizeof(c32)], &c32, sizeof(c32)); + lv_memcpy_small(&buf[id * sizeof(c32)], &c32, sizeof(c32)); } /** @@ -335,7 +335,7 @@ lv_img_dsc_t * lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf) if(dsc == NULL) return NULL; - _lv_memset_00(dsc, sizeof(lv_img_dsc_t)); + lv_memset_00(dsc, sizeof(lv_img_dsc_t)); /* Get image data size */ dsc->data_size = lv_img_buf_get_img_size(w, h, cf); @@ -350,7 +350,7 @@ lv_img_dsc_t * lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf) lv_mem_free(dsc); return NULL; } - _lv_memset_00((uint8_t *)dsc->data, dsc->data_size); + lv_memset_00((uint8_t *)dsc->data, dsc->data_size); /* Fill in header */ dsc->header.always_zero = 0; @@ -426,11 +426,11 @@ void _lv_img_buf_transform_init(lv_img_transform_dsc_t * dsc) int32_t angle_high = angle_low + 1; int32_t angle_rem = dsc->cfg.angle - (angle_low * 10); - int32_t s1 = _lv_trigo_sin(-angle_low); - int32_t s2 = _lv_trigo_sin(-angle_high); + int32_t s1 = lv_trigo_sin(-angle_low); + int32_t s2 = lv_trigo_sin(-angle_high); - int32_t c1 = _lv_trigo_sin(-angle_low + 90); - int32_t c2 = _lv_trigo_sin(-angle_high + 90); + int32_t c1 = lv_trigo_sin(-angle_low + 90); + int32_t c2 = lv_trigo_sin(-angle_high + 90); dsc->tmp.sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10; dsc->tmp.cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10; @@ -503,11 +503,11 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t int32_t angle_high = angle_low + 1; int32_t angle_rem = angle - (angle_low * 10); - int32_t s1 = _lv_trigo_sin(angle_low); - int32_t s2 = _lv_trigo_sin(angle_high); + int32_t s1 = lv_trigo_sin(angle_low); + int32_t s2 = lv_trigo_sin(angle_high); - int32_t c1 = _lv_trigo_sin(angle_low + 90); - int32_t c2 = _lv_trigo_sin(angle_high + 90); + int32_t c1 = lv_trigo_sin(angle_low + 90); + int32_t c2 = lv_trigo_sin(angle_high + 90); int32_t sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10; int32_t cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10; @@ -544,10 +544,10 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t rb.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x; rb.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y; - res->x1 = LV_MATH_MIN4(lb.x, lt.x, rb.x, rt.x); - res->x2 = LV_MATH_MAX4(lb.x, lt.x, rb.x, rt.x); - res->y1 = LV_MATH_MIN4(lb.y, lt.y, rb.y, rt.y); - res->y2 = LV_MATH_MAX4(lb.y, lt.y, rb.y, rt.y); + res->x1 = LV_MIN4(lb.x, lt.x, rb.x, rt.x); + res->x2 = LV_MAX4(lb.x, lt.x, rb.x, rt.x); + res->y1 = LV_MIN4(lb.y, lt.y, rb.y, rt.y); + res->y2 = LV_MAX4(lb.y, lt.y, rb.y, rt.y); #else LV_UNUSED(angle); LV_UNUSED(zoom); @@ -560,6 +560,95 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t } #if LV_USE_IMG_TRANSFORM +/** + * Get which color and opa would come to a pixel if it were rotated + * @param dsc a descriptor initialized by `lv_img_buf_rotate_init` + * @param x the coordinate which color and opa should be get + * @param y the coordinate which color and opa should be get + * @return true: there is valid pixel on these x/y coordinates; false: the rotated pixel was out of the image + * @note the result is written back to `dsc->res_color` and `dsc->res_opa` + */ +bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t y) +{ + const uint8_t * src_u8 = (const uint8_t *)dsc->cfg.src; + + /*Get the target point relative coordinates to the pivot*/ + int32_t xt = x - dsc->cfg.pivot_x; + int32_t yt = y - dsc->cfg.pivot_y; + + int32_t xs; + int32_t ys; + if(dsc->cfg.zoom == LV_IMG_ZOOM_NONE) { + /*Get the source pixel from the upscaled image*/ + xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_x_256; + ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_y_256; + } + else if(dsc->cfg.angle == 0) { + xt = (int32_t)((int32_t)xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; + yt = (int32_t)((int32_t)yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; + xs = xt + dsc->tmp.pivot_x_256; + ys = yt + dsc->tmp.pivot_y_256; + } + else { + xt = (int32_t)((int32_t)xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; + yt = (int32_t)((int32_t)yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; + xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_x_256; + ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_y_256; + } + + /*Get the integer part of the source pixel*/ + int32_t xs_int = xs >> 8; + int32_t ys_int = ys >> 8; + + if(xs_int >= dsc->cfg.src_w) return false; + else if(xs_int < 0) return false; + + if(ys_int >= dsc->cfg.src_h) return false; + else if(ys_int < 0) return false; + + uint8_t px_size; + uint32_t pxi; + if(dsc->tmp.native_color) { + if(dsc->tmp.has_alpha == 0) { + px_size = LV_COLOR_SIZE >> 3; + + pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size; + lv_memcpy_small(&dsc->res.color, &src_u8[pxi], px_size); + } + else { + px_size = LV_IMG_PX_SIZE_ALPHA_BYTE; + pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size; + lv_memcpy_small(&dsc->res.color, &src_u8[pxi], px_size - 1); + dsc->res.opa = src_u8[pxi + px_size - 1]; + } + } + else { + pxi = 0; /*unused*/ + px_size = 0; /*unused*/ + dsc->res.color = lv_img_buf_get_px_color(&dsc->tmp.img_dsc, xs_int, ys_int, dsc->cfg.color); + dsc->res.opa = lv_img_buf_get_px_alpha(&dsc->tmp.img_dsc, xs_int, ys_int); + } + + if(dsc->tmp.chroma_keyed) { + lv_color_t ct = LV_COLOR_TRANSP; + if(dsc->res.color.full == ct.full) return false; + } + + if(dsc->cfg.antialias == false) return true; + + dsc->tmp.xs = xs; + dsc->tmp.ys = ys; + dsc->tmp.xs_int = xs_int; + dsc->tmp.ys_int = ys_int; + dsc->tmp.pxi = pxi; + dsc->tmp.px_size = px_size; + + bool ret; + ret = _lv_img_buf_transform_anti_alias(dsc); + + return ret; +} + /** * Continue transformation by taking the neighbors into account * @param dsc pointer to the transformation descriptor @@ -620,9 +709,9 @@ bool _lv_img_buf_transform_anti_alias(lv_img_transform_dsc_t * dsc) lv_opa_t a11 = 0; if(dsc->tmp.native_color) { - _lv_memcpy_small(&c01, &src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn], sizeof(lv_color_t)); - _lv_memcpy_small(&c10, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn], sizeof(lv_color_t)); - _lv_memcpy_small(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn], + lv_memcpy_small(&c01, &src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn], sizeof(lv_color_t)); + lv_memcpy_small(&c10, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn], sizeof(lv_color_t)); + lv_memcpy_small(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn], sizeof(lv_color_t)); if(dsc->tmp.has_alpha) { a10 = src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn + dsc->tmp.px_size - 1]; diff --git a/src/lv_draw/lv_img_buf.h b/src/lv_draw/lv_img_buf.h index 5b43456ac..ad8d5b26a 100644 --- a/src/lv_draw/lv_img_buf.h +++ b/src/lv_draw/lv_img_buf.h @@ -292,86 +292,8 @@ bool _lv_img_buf_transform_anti_alias(lv_img_transform_dsc_t * dsc); * @return true: there is valid pixel on these x/y coordinates; false: the rotated pixel was out of the image * @note the result is written back to `dsc->res_color` and `dsc->res_opa` */ -static inline bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t y) -{ - const uint8_t * src_u8 = (const uint8_t *)dsc->cfg.src; +bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t y); - /*Get the target point relative coordinates to the pivot*/ - int32_t xt = x - dsc->cfg.pivot_x; - int32_t yt = y - dsc->cfg.pivot_y; - - int32_t xs; - int32_t ys; - if(dsc->cfg.zoom == LV_IMG_ZOOM_NONE) { - /*Get the source pixel from the upscaled image*/ - xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_x_256; - ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_y_256; - } - else if(dsc->cfg.angle == 0) { - xt = (int32_t)((int32_t)xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; - yt = (int32_t)((int32_t)yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; - xs = xt + dsc->tmp.pivot_x_256; - ys = yt + dsc->tmp.pivot_y_256; - } - else { - xt = (int32_t)((int32_t)xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; - yt = (int32_t)((int32_t)yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE; - xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_x_256; - ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_y_256; - } - - /*Get the integer part of the source pixel*/ - int32_t xs_int = xs >> 8; - int32_t ys_int = ys >> 8; - - if(xs_int >= dsc->cfg.src_w) return false; - else if(xs_int < 0) return false; - - if(ys_int >= dsc->cfg.src_h) return false; - else if(ys_int < 0) return false; - - uint8_t px_size; - uint32_t pxi; - if(dsc->tmp.native_color) { - if(dsc->tmp.has_alpha == 0) { - px_size = LV_COLOR_SIZE >> 3; - - pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size; - _lv_memcpy_small(&dsc->res.color, &src_u8[pxi], px_size); - } - else { - px_size = LV_IMG_PX_SIZE_ALPHA_BYTE; - pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size; - _lv_memcpy_small(&dsc->res.color, &src_u8[pxi], px_size - 1); - dsc->res.opa = src_u8[pxi + px_size - 1]; - } - } - else { - pxi = 0; /*unused*/ - px_size = 0; /*unused*/ - dsc->res.color = lv_img_buf_get_px_color(&dsc->tmp.img_dsc, xs_int, ys_int, dsc->cfg.color); - dsc->res.opa = lv_img_buf_get_px_alpha(&dsc->tmp.img_dsc, xs_int, ys_int); - } - - if(dsc->tmp.chroma_keyed) { - lv_color_t ct = LV_COLOR_TRANSP; - if(dsc->res.color.full == ct.full) return false; - } - - if(dsc->cfg.antialias == false) return true; - - dsc->tmp.xs = xs; - dsc->tmp.ys = ys; - dsc->tmp.xs_int = xs_int; - dsc->tmp.ys_int = ys_int; - dsc->tmp.pxi = pxi; - dsc->tmp.px_size = px_size; - - bool ret; - ret = _lv_img_buf_transform_anti_alias(dsc); - - return ret; -} #endif /** * Get the area of a rectangle if its rotated and scaled diff --git a/src/lv_draw/lv_img_cache.c b/src/lv_draw/lv_img_cache.c index 2488865c3..650fc3eeb 100644 --- a/src/lv_draw/lv_img_cache.c +++ b/src/lv_draw/lv_img_cache.c @@ -137,8 +137,8 @@ lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color) if(open_res == LV_RES_INV) { LV_LOG_WARN("Image draw cannot open the image resource"); lv_img_decoder_close(&cached_src->dec_dsc); - _lv_memset_00(&cached_src->dec_dsc, sizeof(lv_img_decoder_dsc_t)); - _lv_memset_00(cached_src, sizeof(lv_img_cache_entry_t)); + lv_memset_00(&cached_src->dec_dsc, sizeof(lv_img_decoder_dsc_t)); + lv_memset_00(cached_src, sizeof(lv_img_cache_entry_t)); cached_src->life = INT32_MIN; /*Make the empty entry very "weak" to force its use */ return NULL; } @@ -185,8 +185,8 @@ void lv_img_cache_set_size(uint16_t new_entry_cnt) /*Clean the cache*/ uint16_t i; for(i = 0; i < entry_cnt; i++) { - _lv_memset_00(&LV_GC_ROOT(_lv_img_cache_array)[i].dec_dsc, sizeof(lv_img_decoder_dsc_t)); - _lv_memset_00(&LV_GC_ROOT(_lv_img_cache_array)[i], sizeof(lv_img_cache_entry_t)); + lv_memset_00(&LV_GC_ROOT(_lv_img_cache_array)[i].dec_dsc, sizeof(lv_img_decoder_dsc_t)); + lv_memset_00(&LV_GC_ROOT(_lv_img_cache_array)[i], sizeof(lv_img_cache_entry_t)); } #endif } @@ -208,8 +208,8 @@ void lv_img_cache_invalidate_src(const void * src) lv_img_decoder_close(&cache[i].dec_dsc); } - _lv_memset_00(&cache[i].dec_dsc, sizeof(lv_img_decoder_dsc_t)); - _lv_memset_00(&cache[i], sizeof(lv_img_cache_entry_t)); + lv_memset_00(&cache[i].dec_dsc, sizeof(lv_img_decoder_dsc_t)); + lv_memset_00(&cache[i], sizeof(lv_img_cache_entry_t)); } } #endif diff --git a/src/lv_draw/lv_img_decoder.c b/src/lv_draw/lv_img_decoder.c index c082cb3a2..ff57ebbd8 100644 --- a/src/lv_draw/lv_img_decoder.c +++ b/src/lv_draw/lv_img_decoder.c @@ -200,7 +200,7 @@ lv_img_decoder_t * lv_img_decoder_create(void) LV_ASSERT_MEM(decoder); if(decoder == NULL) return NULL; - _lv_memset_00(decoder, sizeof(lv_img_decoder_t)); + lv_memset_00(decoder, sizeof(lv_img_decoder_t)); return decoder; } @@ -338,7 +338,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder LV_LOG_ERROR("img_decoder_built_in_open: out of memory"); return LV_RES_INV; } - _lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t)); + lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t)); } lv_img_decoder_built_in_data_t * user_data = dsc->user_data; @@ -387,7 +387,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder lv_img_decoder_built_in_close(decoder, dsc); return LV_RES_INV; } - _lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t)); + lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t)); } lv_img_decoder_built_in_data_t * user_data = dsc->user_data; @@ -631,7 +631,7 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l #if LV_USE_FILESYSTEM lv_img_decoder_built_in_data_t * user_data = dsc->user_data; - uint8_t * fs_buf = _lv_mem_buf_get(w); + uint8_t * fs_buf = lv_mem_buf_get(w); #endif const uint8_t * data_tmp = NULL; @@ -665,7 +665,7 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l } } #if LV_USE_FILESYSTEM - _lv_mem_buf_release(fs_buf); + lv_mem_buf_release(fs_buf); #endif return LV_RES_OK; @@ -719,7 +719,7 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc, lv_img_decoder_built_in_data_t * user_data = dsc->user_data; #if LV_USE_FILESYSTEM - uint8_t * fs_buf = _lv_mem_buf_get(w); + uint8_t * fs_buf = lv_mem_buf_get(w); #endif const uint8_t * data_tmp = NULL; if(dsc->src_type == LV_IMG_SRC_VARIABLE) { @@ -763,7 +763,7 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc, } } #if LV_USE_FILESYSTEM - _lv_mem_buf_release(fs_buf); + lv_mem_buf_release(fs_buf); #endif return LV_RES_OK; #else diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index 011f55e86..666082620 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -117,7 +117,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic break; } - if(_lv_mem_get_size(LV_GC_ROOT(_lv_font_decompr_buf)) < buf_size) { + if(lv_mem_get_size(LV_GC_ROOT(_lv_font_decompr_buf)) < buf_size) { LV_GC_ROOT(_lv_font_decompr_buf) = lv_mem_realloc(LV_GC_ROOT(_lv_font_decompr_buf), buf_size); LV_ASSERT_MEM(LV_GC_ROOT(_lv_font_decompr_buf)); if(LV_GC_ROOT(_lv_font_decompr_buf) == NULL) return NULL; @@ -359,12 +359,12 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord rle_init(in, bpp); - uint8_t * line_buf1 = _lv_mem_buf_get(w); + uint8_t * line_buf1 = lv_mem_buf_get(w); uint8_t * line_buf2 = NULL; if(prefilter) { - line_buf2 = _lv_mem_buf_get(w); + line_buf2 = lv_mem_buf_get(w); } decompress_line(line_buf1, w); @@ -397,8 +397,8 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord } } - _lv_mem_buf_release(line_buf1); - _lv_mem_buf_release(line_buf2); + lv_mem_buf_release(line_buf1); + lv_mem_buf_release(line_buf2); } /** diff --git a/src/lv_gpu/lv_gpu_nxp_pxp.c b/src/lv_gpu/lv_gpu_nxp_pxp.c index ccb720297..8024a14c9 100644 --- a/src/lv_gpu/lv_gpu_nxp_pxp.c +++ b/src/lv_gpu/lv_gpu_nxp_pxp.c @@ -443,7 +443,7 @@ static void lv_gpu_nxp_pxp_blit_recolor(lv_color_t * dest, lv_coord_t dest_width /* Recolor with transparency */ /* Step 1: Recolor with full opacity to temporary buffer */ - lv_color_t * tmpBuf = (lv_color_t *) _lv_mem_buf_get(copy_width * copy_height * sizeof(lv_color_t)); + lv_color_t * tmpBuf = (lv_color_t *) lv_mem_buf_get(copy_width * copy_height * sizeof(lv_color_t)); lv_gpu_nxp_pxp_blit_recolor(tmpBuf, copy_width, src, src_width, copy_width, copy_height, LV_OPA_COVER, recolor, recolorOpa); @@ -453,7 +453,7 @@ static void lv_gpu_nxp_pxp_blit_recolor(lv_color_t * dest, lv_coord_t dest_width lv_gpu_nxp_pxp_enable_recolor(recolor, recolorOpa); /* restore state */ /* Step 3: Clean-up memory */ - _lv_mem_buf_release(tmpBuf); + lv_mem_buf_release(tmpBuf); } } } diff --git a/src/lv_hal/lv_hal_disp.c b/src/lv_hal/lv_hal_disp.c index 0ce054ffd..91537d56a 100644 --- a/src/lv_hal/lv_hal_disp.c +++ b/src/lv_hal/lv_hal_disp.c @@ -56,7 +56,7 @@ static lv_disp_t * disp_def; */ void lv_disp_drv_init(lv_disp_drv_t * driver) { - _lv_memset_00(driver, sizeof(lv_disp_drv_t)); + lv_memset_00(driver, sizeof(lv_disp_drv_t)); driver->flush_cb = NULL; driver->hor_res = LV_HOR_RES_MAX; @@ -103,7 +103,7 @@ void lv_disp_drv_init(lv_disp_drv_t * driver) */ void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32_t size_in_px_cnt) { - _lv_memset_00(disp_buf, sizeof(lv_disp_buf_t)); + lv_memset_00(disp_buf, sizeof(lv_disp_buf_t)); disp_buf->buf1 = buf1; disp_buf->buf2 = buf2; @@ -125,8 +125,8 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) return NULL; } - _lv_memset_00(disp, sizeof(lv_disp_t)); - _lv_memcpy(&disp->driver, driver, sizeof(lv_disp_drv_t)); + lv_memset_00(disp, sizeof(lv_disp_t)); + lv_memcpy(&disp->driver, driver, sizeof(lv_disp_drv_t)); disp->last_activity_time = 0; @@ -327,7 +327,7 @@ LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t * disp_drv) /*If the screen is transparent initialize it when the flushing is ready*/ #if LV_COLOR_SCREEN_TRANSP if(disp_drv->screen_transp) { - _lv_memset_00(disp_drv->buffer->buf_act, disp_drv->buffer->size * sizeof(lv_color32_t)); + lv_memset_00(disp_drv->buffer->buf_act, disp_drv->buffer->size * sizeof(lv_color32_t)); } #endif diff --git a/src/lv_hal/lv_hal_indev.c b/src/lv_hal/lv_hal_indev.c index 915416ec4..44683ea47 100644 --- a/src/lv_hal/lv_hal_indev.c +++ b/src/lv_hal/lv_hal_indev.c @@ -51,7 +51,7 @@ */ void lv_indev_drv_init(lv_indev_drv_t * driver) { - _lv_memset_00(driver, sizeof(lv_indev_drv_t)); + lv_memset_00(driver, sizeof(lv_indev_drv_t)); driver->type = LV_INDEV_TYPE_NONE; driver->scroll_limit = LV_INDEV_DEF_DRAG_LIMIT; @@ -84,8 +84,8 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver) return NULL; } - _lv_memset_00(indev, sizeof(lv_indev_t)); - _lv_memcpy(&indev->driver, driver, sizeof(lv_indev_drv_t)); + lv_memset_00(indev, sizeof(lv_indev_t)); + lv_memcpy(&indev->driver, driver, sizeof(lv_indev_drv_t)); indev->proc.reset_query = 1; indev->cursor = NULL; @@ -131,7 +131,7 @@ bool _lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data) { bool cont = false; - _lv_memset_00(data, sizeof(lv_indev_data_t)); + lv_memset_00(data, sizeof(lv_indev_data_t)); /* For touchpad sometimes users don't the last pressed coordinate on release. * So be sure a coordinates are initialized to the last point */ diff --git a/src/lv_misc/lv_anim.c b/src/lv_misc/lv_anim.c index e296fd7fa..6b52b4c66 100644 --- a/src/lv_misc/lv_anim.c +++ b/src/lv_misc/lv_anim.c @@ -76,11 +76,11 @@ void _lv_anim_core_init(void) */ void lv_anim_init(lv_anim_t * a) { - _lv_memset_00(a, sizeof(lv_anim_t)); + lv_memset_00(a, sizeof(lv_anim_t)); a->time = 500; a->start = 0; a->end = 100; - _lv_memcpy_small(&a->path, &lv_anim_path_def, sizeof(lv_anim_path_cb_t)); + lv_memcpy_small(&a->path, &lv_anim_path_def, sizeof(lv_anim_path_cb_t)); a->repeat_cnt = 1; a->early_apply = 1; } @@ -106,7 +106,7 @@ void lv_anim_start(lv_anim_t * a) /*Initialize the animation descriptor*/ a->time_orig = a->time; - _lv_memcpy(new_anim, a, sizeof(lv_anim_t)); + lv_memcpy(new_anim, a, sizeof(lv_anim_t)); /*Set the start value*/ if(new_anim->early_apply) { @@ -120,6 +120,27 @@ void lv_anim_start(lv_anim_t * a) LV_LOG_TRACE("animation created") } +/** + * Initialize an animation path + * @param path pointer to path + */ +void lv_anim_path_init(lv_anim_path_t * path) +{ + lv_memset_00(path, sizeof(lv_anim_path_t)); +} + + +/** + * Set the path (curve) of the animation. + * @param a pointer to an initialized `lv_anim_t` variable + * @param path_cb a function the get the current value of the animation. + * The built in functions starts with `lv_anim_path_...` + */ +void lv_anim_set_path(lv_anim_t * a, const lv_anim_path_t * path) +{ + lv_memcpy_small(&a->path, path, sizeof(lv_anim_path_t)); +} + /** * Delete an animation of a variable with a given animator function * @param var pointer to variable @@ -192,7 +213,7 @@ uint16_t lv_anim_count_running(void) */ uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end) { - int32_t d = LV_MATH_ABS((int32_t)start - end); + int32_t d = LV_ABS((int32_t)start - end); uint32_t time = (int32_t)((int32_t)(d * 1000) / speed); if(time > UINT16_MAX) time = UINT16_MAX; @@ -259,7 +280,7 @@ lv_anim_value_t lv_anim_path_ease_in(const lv_anim_path_t * path, const lv_anim_ else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; - int32_t step = _lv_bezier3(t, 0, 0, 580, 1024); + int32_t step = lv_bezier3(t, 0, 0, 580, 1024); int32_t new_value; new_value = (int32_t)step * (a->end - a->start); @@ -286,7 +307,7 @@ lv_anim_value_t lv_anim_path_ease_out(const lv_anim_path_t * path, const lv_anim else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; - int32_t step = _lv_bezier3(t, 0, 420, 1000, 1024); + int32_t step = lv_bezier3(t, 0, 420, 1000, 1024); int32_t new_value; new_value = (int32_t)step * (a->end - a->start); @@ -313,7 +334,7 @@ lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_path_t * path, const lv_a else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; - int32_t step = _lv_bezier3(t, 0, 64, 1024 - 64, 1024); + int32_t step = lv_bezier3(t, 0, 64, 1024 - 64, 1024); int32_t new_value; new_value = (int32_t)step * (a->end - a->start); @@ -340,7 +361,7 @@ lv_anim_value_t lv_anim_path_overshoot(const lv_anim_path_t * path, const lv_ani else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; - int32_t step = _lv_bezier3(t, 0, 1000, 1300, 1024); + int32_t step = lv_bezier3(t, 0, 1000, 1300, 1024); int32_t new_value; new_value = (int32_t)step * (a->end - a->start); @@ -405,7 +426,7 @@ lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t if(t > 1024) t = 1024; if(t < 0) t = 0; - int32_t step = _lv_bezier3(t, 1024, 800, 500, 0); + int32_t step = lv_bezier3(t, 1024, 800, 500, 0); int32_t new_value; new_value = (int32_t)step * diff; @@ -520,7 +541,7 @@ static bool anim_ready_handler(lv_anim_t * a) /*Create copy from the animation and delete the animation from the list. * This way the `ready_cb` will see the animations like it's animation is ready deleted*/ lv_anim_t a_tmp; - _lv_memcpy(&a_tmp, a, sizeof(lv_anim_t)); + lv_memcpy(&a_tmp, a, sizeof(lv_anim_t)); _lv_ll_remove(&LV_GC_ROOT(_lv_anim_ll), a); lv_mem_free(a); /*Flag that the list has changed */ diff --git a/src/lv_misc/lv_anim.h b/src/lv_misc/lv_anim.h index e48dae50f..357da37e4 100644 --- a/src/lv_misc/lv_anim.h +++ b/src/lv_misc/lv_anim.h @@ -18,7 +18,6 @@ extern "C" { #include #include #include -#include "lv_mem.h" /********************* * DEFINES @@ -197,10 +196,7 @@ static inline void lv_anim_set_custom_exec_cb(lv_anim_t * a, lv_anim_custom_exec * @param path_cb a function the get the current value of the animation. * The built in functions starts with `lv_anim_path_...` */ -static inline void lv_anim_set_path(lv_anim_t * a, const lv_anim_path_t * path) -{ - _lv_memcpy_small(&a->path, path, sizeof(lv_anim_path_t)); -} +void lv_anim_set_path(lv_anim_t * a, const lv_anim_path_t * path); /** @@ -273,10 +269,7 @@ void lv_anim_start(lv_anim_t * a); * Initialize an animation path * @param path pointer to path */ -static inline void lv_anim_path_init(lv_anim_path_t * path) -{ - _lv_memset_00(path, sizeof(lv_anim_path_t)); -} +void lv_anim_path_init(lv_anim_path_t * path); /** * Set a callback for a path diff --git a/src/lv_misc/lv_area.c b/src/lv_misc/lv_area.c index 8f0045583..d6de64500 100644 --- a/src/lv_misc/lv_area.c +++ b/src/lv_misc/lv_area.c @@ -113,10 +113,10 @@ uint32_t lv_area_get_size(const lv_area_t * area_p) bool _lv_area_intersect(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area_t * a2_p) { /* Get the smaller area from 'a1_p' and 'a2_p' */ - res_p->x1 = LV_MATH_MAX(a1_p->x1, a2_p->x1); - res_p->y1 = LV_MATH_MAX(a1_p->y1, a2_p->y1); - res_p->x2 = LV_MATH_MIN(a1_p->x2, a2_p->x2); - res_p->y2 = LV_MATH_MIN(a1_p->y2, a2_p->y2); + res_p->x1 = LV_MAX(a1_p->x1, a2_p->x1); + res_p->y1 = LV_MAX(a1_p->y1, a2_p->y1); + res_p->x2 = LV_MIN(a1_p->x2, a2_p->x2); + res_p->y2 = LV_MIN(a1_p->y2, a2_p->y2); /*If x1 or y1 greater then x2 or y2 then the areas union is empty*/ bool union_ok = true; @@ -134,10 +134,10 @@ bool _lv_area_intersect(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area */ void _lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t * a2_p) { - a_res_p->x1 = LV_MATH_MIN(a1_p->x1, a2_p->x1); - a_res_p->y1 = LV_MATH_MIN(a1_p->y1, a2_p->y1); - a_res_p->x2 = LV_MATH_MAX(a1_p->x2, a2_p->x2); - a_res_p->y2 = LV_MATH_MAX(a1_p->y2, a2_p->y2); + a_res_p->x1 = LV_MIN(a1_p->x1, a2_p->x1); + a_res_p->y1 = LV_MIN(a1_p->y1, a2_p->y1); + a_res_p->x2 = LV_MAX(a1_p->x2, a2_p->x2); + a_res_p->y2 = LV_MAX(a1_p->y2, a2_p->y2); } /** @@ -163,7 +163,7 @@ bool _lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p, lv_coor } lv_coord_t w = lv_area_get_width(a_p) / 2; lv_coord_t h = lv_area_get_height(a_p) / 2; - lv_coord_t max_radius = LV_MATH_MIN(w, h); + lv_coord_t max_radius = LV_MIN(w, h); if(radius > max_radius) radius = max_radius; diff --git a/src/lv_misc/lv_area.h b/src/lv_misc/lv_area.h index 487cebec5..a4c1bc322 100644 --- a/src/lv_misc/lv_area.h +++ b/src/lv_misc/lv_area.h @@ -17,7 +17,6 @@ extern "C" { #include #include #include -#include "lv_mem.h" /********************* * DEFINES @@ -113,7 +112,10 @@ void lv_area_set(lv_area_t * area_p, lv_coord_t x1, lv_coord_t y1, lv_coord_t x2 */ inline static void lv_area_copy(lv_area_t * dest, const lv_area_t * src) { - _lv_memcpy_small(dest, src, sizeof(lv_area_t)); + dest->x1 = src->x1; + dest->y1 = src->y1; + dest->x2 = src->x2; + dest->y2 = src->y2; } /** diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index e3cf51463..27c2f2f12 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -138,12 +138,12 @@ uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_ uint32_t visual_pos, bool * is_rtl) { uint32_t pos_conv_len = get_txt_len(str_in, len); - char * buf = _lv_mem_buf_get(len + 1); + char * buf = lv_mem_buf_get(len + 1); if(buf == NULL) return (uint16_t) -1; - uint16_t * pos_conv_buf = _lv_mem_buf_get(pos_conv_len * sizeof(uint16_t)); + uint16_t * pos_conv_buf = lv_mem_buf_get(pos_conv_len * sizeof(uint16_t)); if(pos_conv_buf == NULL) { - _lv_mem_buf_release(buf); + lv_mem_buf_release(buf); return (uint16_t) -1; } @@ -153,9 +153,9 @@ uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_ if(is_rtl) *is_rtl = IS_RTL_POS(pos_conv_buf[visual_pos]); - if(bidi_txt == NULL) _lv_mem_buf_release(buf); + if(bidi_txt == NULL) lv_mem_buf_release(buf); uint16_t res = GET_POS(pos_conv_buf[visual_pos]); - _lv_mem_buf_release(pos_conv_buf); + lv_mem_buf_release(pos_conv_buf); return res; } @@ -175,12 +175,12 @@ uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t uint32_t logical_pos, bool * is_rtl) { uint32_t pos_conv_len = get_txt_len(str_in, len); - char * buf = _lv_mem_buf_get(len + 1); + char * buf = lv_mem_buf_get(len + 1); if(buf == NULL) return (uint16_t) -1; - uint16_t * pos_conv_buf = _lv_mem_buf_get(pos_conv_len * sizeof(uint16_t)); + uint16_t * pos_conv_buf = lv_mem_buf_get(pos_conv_len * sizeof(uint16_t)); if(pos_conv_buf == NULL) { - _lv_mem_buf_release(buf); + lv_mem_buf_release(buf); return (uint16_t) -1; } @@ -192,14 +192,14 @@ uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t if(GET_POS(pos_conv_buf[i]) == logical_pos) { if(is_rtl) *is_rtl = IS_RTL_POS(pos_conv_buf[i]); - _lv_mem_buf_release(pos_conv_buf); + lv_mem_buf_release(pos_conv_buf); - if(bidi_txt == NULL) _lv_mem_buf_release(buf); + if(bidi_txt == NULL) lv_mem_buf_release(buf); return i; } } - _lv_mem_buf_release(pos_conv_buf); - if(bidi_txt == NULL) _lv_mem_buf_release(buf); + lv_mem_buf_release(pos_conv_buf); + if(bidi_txt == NULL) lv_mem_buf_release(buf); return (uint16_t) -1; } @@ -258,7 +258,7 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le if(rd) { if(base_dir == LV_BIDI_DIR_LTR) { if(str_out) { - _lv_memcpy(&str_out[wr], str_in, rd); + lv_memcpy(&str_out[wr], str_in, rd); wr += rd; } if(pos_conv_out) { @@ -281,7 +281,7 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le if(base_dir == LV_BIDI_DIR_LTR) { if(run_dir == LV_BIDI_DIR_LTR) { - if(str_out) _lv_memcpy(&str_out[wr], &str_in[rd], run_len); + if(str_out) lv_memcpy(&str_out[wr], &str_in[rd], run_len); if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); } else rtl_reverse(str_out ? &str_out[wr] : NULL, &str_in[rd], run_len, pos_conv_out ? &pos_conv_out[pos_conv_wr] : NULL, @@ -293,7 +293,7 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le wr -= run_len; pos_conv_wr -= pos_conv_run_len; if(run_dir == LV_BIDI_DIR_LTR) { - if(str_out) _lv_memcpy(&str_out[wr], &str_in[rd], run_len); + if(str_out) lv_memcpy(&str_out[wr], &str_in[rd], run_len); if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); } else rtl_reverse(str_out ? &str_out[wr] : NULL, &str_in[rd], run_len, pos_conv_out ? &pos_conv_out[pos_conv_wr] : NULL, @@ -536,7 +536,7 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t * pos_conv_first_weak = 0; } - if(dest) _lv_memcpy(&dest[wr], &src[first_weak], last_weak - first_weak + 1); + if(dest) lv_memcpy(&dest[wr], &src[first_weak], last_weak - first_weak + 1); if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_last_weak - pos_conv_first_weak + 1, pos_conv_rd_base + pos_conv_first_weak); wr += last_weak - first_weak + 1; @@ -556,7 +556,7 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t * } /*Just store the letter*/ else { - if(dest) _lv_memcpy(&dest[wr], &src[i], letter_size); + if(dest) lv_memcpy(&dest[wr], &src[i], letter_size); if(pos_conv_out) pos_conv_out[pos_conv_wr] = SET_RTL_POS(pos_conv_rd_base + pos_conv_i, true); wr += letter_size; pos_conv_wr++; diff --git a/src/lv_misc/lv_class.c b/src/lv_misc/lv_class.c index 9e4de3824..c086afdb4 100644 --- a/src/lv_misc/lv_class.c +++ b/src/lv_misc/lv_class.c @@ -38,10 +38,10 @@ //{ // lv_base_class_t * c = class_p; // const lv_base_class_t * bc = base_p; -// _lv_memset_00(c, class_size); +// lv_memset_00(c, class_size); // // /*By default use the same methods as the base*/ -// if(bc) _lv_memcpy(c, base_p, bc->_class_size); +// if(bc) lv_memcpy(c, base_p, bc->_class_size); // // c->base_p = base_p; /*Save the base to allow accessing its methods later*/ // c->init = NULL; @@ -55,7 +55,7 @@ //{ // lv_base_class_t * base_class_p = class_p; // lv_base_t * instance = lv_mem_alloc(base_class_p->_instance_size); -// _lv_memset_00(instance, base_class_p->_instance_size); +// lv_memset_00(instance, base_class_p->_instance_size); // instance->class_p = class_p; // return instance; //} @@ -84,6 +84,6 @@ //{ // lv_base_t * base_inst = inst; // void * class_p = base_inst->class_p; -// _lv_memset_00(inst, base_inst->class_p->_instance_size); +// lv_memset_00(inst, base_inst->class_p->_instance_size); // base_inst->class_p = class_p; /*Restore class dsc pointer*/ //} diff --git a/src/lv_misc/lv_color.c b/src/lv_misc/lv_color.c index 77e982a7b..ee8b5c6f2 100644 --- a/src/lv_misc/lv_color.c +++ b/src/lv_misc/lv_color.c @@ -234,7 +234,7 @@ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8) hsv.v = (100 * rgbMax) >> 10; int32_t delta = rgbMax - rgbMin; - if(LV_MATH_ABS(delta) < 3) { + if(LV_ABS(delta) < 3) { hsv.h = 0; hsv.s = 0; return hsv; diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index b16d49039..3a4f8cf04 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -14,7 +14,6 @@ extern "C" { * INCLUDES *********************/ #include "../lv_conf_internal.h" -#include "lv_math.h" /*Error checking*/ #if LV_COLOR_DEPTH == 24 @@ -208,6 +207,9 @@ enum { # define LV_COLOR_GET_A(c) LV_COLOR_GET_A32(c) #endif + +#define LV_UDIV255(x) ((uint32_t)((uint32_t) (x) * 0x8081) >> 0x17) + /********************** * TYPEDEFS **********************/ @@ -467,11 +469,11 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t lv_color_mix(lv_color_t c1, lv_co lv_color_t ret; #if LV_COLOR_DEPTH != 1 /*LV_COLOR_DEPTH == 8, 16 or 32*/ - LV_COLOR_SET_R(ret, LV_MATH_UDIV255((uint16_t) LV_COLOR_GET_R(c1) * mix + LV_COLOR_GET_R(c2) * + LV_COLOR_SET_R(ret, LV_UDIV255((uint16_t) LV_COLOR_GET_R(c1) * mix + LV_COLOR_GET_R(c2) * (255 - mix) + LV_COLOR_MIX_ROUND_OFS)); - LV_COLOR_SET_G(ret, LV_MATH_UDIV255((uint16_t) LV_COLOR_GET_G(c1) * mix + LV_COLOR_GET_G(c2) * + LV_COLOR_SET_G(ret, LV_UDIV255((uint16_t) LV_COLOR_GET_G(c1) * mix + LV_COLOR_GET_G(c2) * (255 - mix) + LV_COLOR_MIX_ROUND_OFS)); - LV_COLOR_SET_B(ret, LV_MATH_UDIV255((uint16_t) LV_COLOR_GET_B(c1) * mix + LV_COLOR_GET_B(c2) * + LV_COLOR_SET_B(ret, LV_UDIV255((uint16_t) LV_COLOR_GET_B(c1) * mix + LV_COLOR_GET_B(c2) * (255 - mix) + LV_COLOR_MIX_ROUND_OFS)); LV_COLOR_SET_A(ret, 0xFF); #else @@ -513,9 +515,9 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t lv_color_mix_premult(uint16_t * p lv_color_t ret; #if LV_COLOR_DEPTH != 1 /*LV_COLOR_DEPTH == 8, 16 or 32*/ - LV_COLOR_SET_R(ret, LV_MATH_UDIV255((uint16_t) premult_c1[0] + LV_COLOR_GET_R(c2) * mix + LV_COLOR_MIX_ROUND_OFS)); - LV_COLOR_SET_G(ret, LV_MATH_UDIV255((uint16_t) premult_c1[1] + LV_COLOR_GET_G(c2) * mix + LV_COLOR_MIX_ROUND_OFS)); - LV_COLOR_SET_B(ret, LV_MATH_UDIV255((uint16_t) premult_c1[2] + LV_COLOR_GET_B(c2) * mix + LV_COLOR_MIX_ROUND_OFS)); + LV_COLOR_SET_R(ret, LV_UDIV255((uint16_t) premult_c1[0] + LV_COLOR_GET_R(c2) * mix + LV_COLOR_MIX_ROUND_OFS)); + LV_COLOR_SET_G(ret, LV_UDIV255((uint16_t) premult_c1[1] + LV_COLOR_GET_G(c2) * mix + LV_COLOR_MIX_ROUND_OFS)); + LV_COLOR_SET_B(ret, LV_UDIV255((uint16_t) premult_c1[2] + LV_COLOR_GET_B(c2) * mix + LV_COLOR_MIX_ROUND_OFS)); LV_COLOR_SET_A(ret, 0xFF); #else /*LV_COLOR_DEPTH == 1*/ diff --git a/src/lv_misc/lv_debug.c b/src/lv_misc/lv_debug.c index 80229bb94..2571f47ff 100644 --- a/src/lv_misc/lv_debug.c +++ b/src/lv_misc/lv_debug.c @@ -99,7 +99,7 @@ void lv_debug_log_error(const char * msg, uint64_t value) char * bufp = buf; /*Add the function name*/ - _lv_memcpy(bufp, msg, msg_len); + lv_memcpy(bufp, msg, msg_len); bufp += msg_len; /*Add value in hey*/ diff --git a/src/lv_misc/lv_fs.c b/src/lv_misc/lv_fs.c index 3b5843378..2615f28c5 100644 --- a/src/lv_misc/lv_fs.c +++ b/src/lv_misc/lv_fs.c @@ -473,7 +473,7 @@ lv_fs_res_t lv_fs_free_space(char letter, uint32_t * total_p, uint32_t * free_p) */ void lv_fs_drv_init(lv_fs_drv_t * drv) { - _lv_memset_00(drv, sizeof(lv_fs_drv_t)); + lv_memset_00(drv, sizeof(lv_fs_drv_t)); } /** @@ -489,7 +489,7 @@ void lv_fs_drv_register(lv_fs_drv_t * drv_p) LV_ASSERT_MEM(new_drv); if(new_drv == NULL) return; - _lv_memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t)); + lv_memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t)); } /** diff --git a/src/lv_misc/lv_fs.h b/src/lv_misc/lv_fs.h index bbf797c78..850dea382 100644 --- a/src/lv_misc/lv_fs.h +++ b/src/lv_misc/lv_fs.h @@ -19,7 +19,6 @@ extern "C" { #include #include -#include "lv_mem.h" /********************* * DEFINES diff --git a/src/lv_misc/lv_gc.c b/src/lv_misc/lv_gc.c index a9b355861..41b32b08d 100644 --- a/src/lv_misc/lv_gc.c +++ b/src/lv_misc/lv_gc.c @@ -44,7 +44,7 @@ void _lv_gc_clear_roots(void) { -#define LV_CLEAR_ROOT(root_type, root_name) _lv_memset_00(&LV_GC_ROOT(root_name), sizeof(LV_GC_ROOT(root_name))); +#define LV_CLEAR_ROOT(root_type, root_name) lv_memset_00(&LV_GC_ROOT(root_name), sizeof(LV_GC_ROOT(root_name))); LV_ITERATE_ROOTS(LV_CLEAR_ROOT) } diff --git a/src/lv_misc/lv_gc.h b/src/lv_misc/lv_gc.h index 73861e37c..3c956ac9d 100644 --- a/src/lv_misc/lv_gc.h +++ b/src/lv_misc/lv_gc.h @@ -37,7 +37,7 @@ extern "C" { f(lv_ll_t, _lv_obj_style_trans_ll) \ f(lv_img_cache_entry_t*, _lv_img_cache_array) \ f(lv_timer_t*, _lv_timer_act) \ - f(lv_mem_buf_arr_t , _lv_mem_buf) \ + f(lv_mem_buf_arr_t , lv_mem_buf) \ f(_lv_draw_mask_saved_arr_t , _lv_draw_mask_list) \ f(void * , _lv_theme_material_styles) \ f(void * , _lv_theme_mono_styles) \ diff --git a/src/lv_misc/lv_ll.h b/src/lv_misc/lv_ll.h index 812f840a6..8346ab92e 100644 --- a/src/lv_misc/lv_ll.h +++ b/src/lv_misc/lv_ll.h @@ -13,7 +13,6 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "lv_mem.h" #include #include #include diff --git a/src/lv_misc/lv_math.c b/src/lv_misc/lv_math.c index b0ecfaad7..17421c858 100644 --- a/src/lv_misc/lv_math.c +++ b/src/lv_misc/lv_math.c @@ -50,7 +50,7 @@ static const int16_t sin0_90_table[] = { * @param angle * @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 */ -LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_sin(int16_t angle) +LV_ATTRIBUTE_FAST_MEM int16_t lv_trigo_sin(int16_t angle) { int16_t ret = 0; angle = angle % 360; @@ -85,7 +85,7 @@ LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_sin(int16_t angle) * @param u3 end values in range of [0..LV_BEZIER_VAL_MAX] * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] */ -int32_t _lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3) +int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3) { uint32_t t_rem = 1024 - t; uint32_t t_rem2 = (t_rem * t_rem) >> 10; @@ -111,7 +111,7 @@ int32_t _lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3) * If root < 256: mask = 0x800 * Else: mask = 0x8000 */ -LV_ATTRIBUTE_FAST_MEM void _lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask) +LV_ATTRIBUTE_FAST_MEM void lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask) { x = x << 8; /*To get 4 bit precision. (sqrt(256) = 16 = 4 bit)*/ @@ -134,7 +134,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask * @param y * @return the angle in degree calculated from the given parameters in range of [0..360] */ -uint16_t _lv_atan2(int x, int y) +uint16_t lv_atan2(int x, int y) { // Fast XY vector to integer degree algorithm - Jan 2011 www.RomanBlack.com // Converts any XY values including 0 to a degree value that should be @@ -150,8 +150,6 @@ uint16_t _lv_atan2(int x, int y) unsigned char tempdegree; unsigned char comp; unsigned int degree; // this will hold the result - //signed int x; // these hold the XY vector at the start - //signed int y; // (and they will be destroyed) unsigned int ux; unsigned int uy; @@ -218,7 +216,7 @@ uint16_t _lv_atan2(int x, int y) * @param power * @return base raised to the power exponent */ -int64_t _lv_pow(int64_t base, int8_t exp) +int64_t lv_pow(int64_t base, int8_t exp) { int64_t result = 1; while(exp) { @@ -240,13 +238,13 @@ int64_t _lv_pow(int64_t base, int8_t exp) * @param max_out max output range * @return the mapped number */ -int16_t _lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out) +int16_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out) { if(x <= min_in) return min_out; if(x >= max_in) return max_out; /* The equation should be: - * ((x - min_in) / delta in) * delta_out + min_out + * ((x - min_in) * (delta_out / delta_min)) + min_out * To avoid rounding error reorder the operations: * (((x - min_in) * delta_out) / delta in) + min_out */ diff --git a/src/lv_misc/lv_math.h b/src/lv_misc/lv_math.h index 5dbf721ce..9a98680c6 100644 --- a/src/lv_misc/lv_math.h +++ b/src/lv_misc/lv_math.h @@ -3,8 +3,8 @@ * */ -#ifndef LV_MATH_H -#define LV_MATH_H +#ifndef LV_H +#define LV_H #ifdef __cplusplus extern "C" { @@ -45,12 +45,12 @@ typedef struct { * @param angle * @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 */ -LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_sin(int16_t angle); +LV_ATTRIBUTE_FAST_MEM int16_t lv_trigo_sin(int16_t angle); -static inline LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_cos(int16_t angle) +static inline LV_ATTRIBUTE_FAST_MEM int16_t lv_trigo_cos(int16_t angle) { - return _lv_trigo_sin(angle + 90); + return lv_trigo_sin(angle + 90); } //! @endcond @@ -64,7 +64,7 @@ static inline LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_cos(int16_t angle) * @param u3 end values in range of [0..LV_BEZIER_VAL_MAX] * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] */ -int32_t _lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3); +int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3); /** * Calculate the atan2 of a vector. @@ -72,7 +72,7 @@ int32_t _lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3); * @param y * @return the angle in degree calculated from the given parameters in range of [0..360] */ -uint16_t _lv_atan2(int x, int y); +uint16_t lv_atan2(int x, int y); //! @cond Doxygen_Suppress @@ -87,7 +87,7 @@ uint16_t _lv_atan2(int x, int y); * If root < 256: mask = 0x800 * Else: mask = 0x8000 */ -LV_ATTRIBUTE_FAST_MEM void _lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask); +LV_ATTRIBUTE_FAST_MEM void lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask); //! @endcond @@ -97,7 +97,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask * @param power * @return base raised to the power exponent */ -int64_t _lv_pow(int64_t base, int8_t exp); +int64_t lv_pow(int64_t base, int8_t exp); /** * Get the mapped of a number given an input and output range @@ -108,25 +108,23 @@ int64_t _lv_pow(int64_t base, int8_t exp); * @param max_out max output range * @return the mapped number */ -int16_t _lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min, int32_t max); +int16_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min, int32_t max); /********************** * MACROS **********************/ -#define LV_MATH_MIN(a, b) ((a) < (b) ? (a) : (b)) -#define LV_MATH_MIN3(a, b, c) (LV_MATH_MIN(LV_MATH_MIN(a,b), c)) -#define LV_MATH_MIN4(a, b, c, d) (LV_MATH_MIN(LV_MATH_MIN(a,b), LV_MATH_MIN(c,d))) +#define LV_MIN(a, b) ((a) < (b) ? (a) : (b)) +#define LV_MIN3(a, b, c) (LV_MIN(LV_MIN(a,b), c)) +#define LV_MIN4(a, b, c, d) (LV_MIN(LV_MIN(a,b), LV_MIN(c,d))) -#define LV_MATH_MAX(a, b) ((a) > (b) ? (a) : (b)) -#define LV_MATH_MAX3(a, b, c) (LV_MATH_MAX(LV_MATH_MAX(a,b), c)) -#define LV_MATH_MAX4(a, b, c, d) (LV_MATH_MAX(LV_MATH_MAX(a,b), LV_MATH_MAX(c,d))) +#define LV_MAX(a, b) ((a) > (b) ? (a) : (b)) +#define LV_MAX3(a, b, c) (LV_MAX(LV_MAX(a,b), c)) +#define LV_MAX4(a, b, c, d) (LV_MAX(LV_MAX(a,b), LV_MAX(c,d))) -#define LV_CLAMP(min, val, max) (LV_MATH_MAX(min, (LV_MATH_MIN(val, max)))) +#define LV_CLAMP(min, val, max) (LV_MAX(min, (LV_MIN(val, max)))) -#define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x))) - -#define LV_MATH_UDIV255(x) ((uint32_t)((uint32_t) (x) * 0x8081) >> 0x17) +#define LV_ABS(x) ((x) > 0 ? (x) : (-(x))) #define LV_IS_SIGNED(t) (((t)(-1)) < ((t) 0)) #define LV_UMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0xFULL << ((sizeof(t) * 8ULL) - 4ULL))) diff --git a/src/lv_misc/lv_mem.c b/src/lv_misc/lv_mem.c index 05fe12793..95286e07b 100644 --- a/src/lv_misc/lv_mem.c +++ b/src/lv_misc/lv_mem.c @@ -115,7 +115,7 @@ static lv_mem_buf_t mem_buf_small[] = {{.p = mem_buf1_32, .size = MEM_BUF_SMALL_ /** * Initialize the dyn_mem module (work memory and other variables) */ -void _lv_mem_init(void) +void lv_mem_init(void) { #if LV_MEM_CUSTOM == 0 @@ -139,10 +139,10 @@ void _lv_mem_init(void) * Clean up the memory buffer which frees all the allocated memories. * @note It work only if `LV_MEM_CUSTOM == 0` */ -void _lv_mem_deinit(void) +void lv_mem_deinit(void) { #if LV_MEM_CUSTOM == 0 - _lv_memset_00(work_mem, (LV_MEM_SIZE / sizeof(MEM_UNIT)) * sizeof(MEM_UNIT)); + lv_memset_00(work_mem, (LV_MEM_SIZE / sizeof(MEM_UNIT)) * sizeof(MEM_UNIT)); lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem; full->header.s.used = 0; /*The total mem size id reduced by the first header and the close patterns */ @@ -195,7 +195,7 @@ void * lv_mem_alloc(size_t size) #endif /* LV_MEM_CUSTOM */ #if LV_MEM_ADD_JUNK - if(alloc != NULL) _lv_memset(alloc, 0xaa, size); + if(alloc != NULL) lv_memset(alloc, 0xaa, size); #endif if(alloc == NULL) { @@ -233,7 +233,7 @@ void lv_mem_free(const void * data) /*e points to the header*/ lv_mem_ent_t * e = (lv_mem_ent_t *)((uint8_t *)data - sizeof(lv_mem_header_t)); # if LV_MEM_ADD_JUNK - _lv_memset((void *)data, 0xbb, _lv_mem_get_size(data)); + lv_memset((void *)data, 0xbb, lv_mem_get_size(data)); # endif #endif @@ -285,7 +285,7 @@ void * lv_mem_realloc(void * data_p, size_t new_size) } } - uint32_t old_size = _lv_mem_get_size(data_p); + uint32_t old_size = lv_mem_get_size(data_p); if(old_size == new_size) return data_p; /*Also avoid reallocating the same memory*/ #if LV_MEM_CUSTOM == 0 @@ -307,7 +307,7 @@ void * lv_mem_realloc(void * data_p, size_t new_size) if(data_p != NULL) { /*Copy the old data to the new. Use the smaller size*/ if(old_size != 0) { - _lv_memcpy(new_p, data_p, LV_MATH_MIN(new_size, old_size)); + lv_memcpy(new_p, data_p, LV_MIN(new_size, old_size)); lv_mem_free(data_p); } } @@ -394,7 +394,7 @@ lv_res_t lv_mem_test(void) void lv_mem_monitor(lv_mem_monitor_t * mon_p) { /*Init the data*/ - _lv_memset(mon_p, 0, sizeof(lv_mem_monitor_t)); + lv_memset(mon_p, 0, sizeof(lv_mem_monitor_t)); #if LV_MEM_CUSTOM == 0 lv_mem_ent_t * e; e = NULL; @@ -436,7 +436,7 @@ void lv_mem_monitor(lv_mem_monitor_t * mon_p) #if LV_ENABLE_GC == 0 -uint32_t _lv_mem_get_size(const void * data) +uint32_t lv_mem_get_size(const void * data) { if(data == NULL) return 0; if(data == &zero_mem) return 0; @@ -448,7 +448,7 @@ uint32_t _lv_mem_get_size(const void * data) #else /* LV_ENABLE_GC */ -uint32_t _lv_mem_get_size(const void * data) +uint32_t lv_mem_get_size(const void * data) { return LV_MEM_CUSTOM_GET_SIZE(data); } @@ -459,7 +459,7 @@ uint32_t _lv_mem_get_size(const void * data) * Get a temporal buffer with the given size. * @param size the required size */ -void * _lv_mem_buf_get(uint32_t size) +void * lv_mem_buf_get(uint32_t size) { if(size == 0) return NULL; @@ -477,38 +477,38 @@ void * _lv_mem_buf_get(uint32_t size) /*Try to find a free buffer with suitable size */ int8_t i_guess = -1; for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) { - if(LV_GC_ROOT(_lv_mem_buf[i]).used == 0 && LV_GC_ROOT(_lv_mem_buf[i]).size >= size) { - if(LV_GC_ROOT(_lv_mem_buf[i]).size == size) { - LV_GC_ROOT(_lv_mem_buf[i]).used = 1; - return LV_GC_ROOT(_lv_mem_buf[i]).p; + if(LV_GC_ROOT(lv_mem_buf[i]).used == 0 && LV_GC_ROOT(lv_mem_buf[i]).size >= size) { + if(LV_GC_ROOT(lv_mem_buf[i]).size == size) { + LV_GC_ROOT(lv_mem_buf[i]).used = 1; + return LV_GC_ROOT(lv_mem_buf[i]).p; } else if(i_guess < 0) { i_guess = i; } /*If size of `i` is closer to `size` prefer it*/ - else if(LV_GC_ROOT(_lv_mem_buf[i]).size < LV_GC_ROOT(_lv_mem_buf[i_guess]).size) { + else if(LV_GC_ROOT(lv_mem_buf[i]).size < LV_GC_ROOT(lv_mem_buf[i_guess]).size) { i_guess = i; } } } if(i_guess >= 0) { - LV_GC_ROOT(_lv_mem_buf[i_guess]).used = 1; - return LV_GC_ROOT(_lv_mem_buf[i_guess]).p; + LV_GC_ROOT(lv_mem_buf[i_guess]).used = 1; + return LV_GC_ROOT(lv_mem_buf[i_guess]).p; } /*Reallocate a free buffer*/ for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) { - if(LV_GC_ROOT(_lv_mem_buf[i]).used == 0) { - LV_GC_ROOT(_lv_mem_buf[i]).used = 1; - LV_GC_ROOT(_lv_mem_buf[i]).size = size; + if(LV_GC_ROOT(lv_mem_buf[i]).used == 0) { + LV_GC_ROOT(lv_mem_buf[i]).used = 1; + LV_GC_ROOT(lv_mem_buf[i]).size = size; /*if this fails you probably need to increase your LV_MEM_SIZE/heap size*/ - LV_GC_ROOT(_lv_mem_buf[i]).p = lv_mem_realloc(LV_GC_ROOT(_lv_mem_buf[i]).p, size); - if(LV_GC_ROOT(_lv_mem_buf[i]).p == NULL) { + LV_GC_ROOT(lv_mem_buf[i]).p = lv_mem_realloc(LV_GC_ROOT(lv_mem_buf[i]).p, size); + if(LV_GC_ROOT(lv_mem_buf[i]).p == NULL) { LV_DEBUG_ASSERT(false, "Out of memory, can't allocate a new buffer (increase your LV_MEM_SIZE/heap size", 0x00); } - return LV_GC_ROOT(_lv_mem_buf[i]).p; + return LV_GC_ROOT(lv_mem_buf[i]).p; } } @@ -520,7 +520,7 @@ void * _lv_mem_buf_get(uint32_t size) * Release a memory buffer * @param p buffer to release */ -void _lv_mem_buf_release(void * p) +void lv_mem_buf_release(void * p) { uint8_t i; @@ -533,8 +533,8 @@ void _lv_mem_buf_release(void * p) } for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) { - if(LV_GC_ROOT(_lv_mem_buf[i]).p == p) { - LV_GC_ROOT(_lv_mem_buf[i]).used = 0; + if(LV_GC_ROOT(lv_mem_buf[i]).p == p) { + LV_GC_ROOT(lv_mem_buf[i]).used = 0; return; } } @@ -545,7 +545,7 @@ void _lv_mem_buf_release(void * p) /** * Free all memory buffers */ -void _lv_mem_buf_free_all(void) +void lv_mem_buf_free_all(void) { uint8_t i; for(i = 0; i < sizeof(mem_buf_small) / sizeof(mem_buf_small[0]); i++) { @@ -553,11 +553,11 @@ void _lv_mem_buf_free_all(void) } for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) { - if(LV_GC_ROOT(_lv_mem_buf[i]).p) { - lv_mem_free(LV_GC_ROOT(_lv_mem_buf[i]).p); - LV_GC_ROOT(_lv_mem_buf[i]).p = NULL; - LV_GC_ROOT(_lv_mem_buf[i]).used = 0; - LV_GC_ROOT(_lv_mem_buf[i]).size = 0; + if(LV_GC_ROOT(lv_mem_buf[i]).p) { + lv_mem_free(LV_GC_ROOT(lv_mem_buf[i]).p); + LV_GC_ROOT(lv_mem_buf[i]).p = NULL; + LV_GC_ROOT(lv_mem_buf[i]).used = 0; + LV_GC_ROOT(lv_mem_buf[i]).size = 0; } } } @@ -569,7 +569,7 @@ void _lv_mem_buf_free_all(void) * @param src pointer to the source buffer * @param len number of byte to copy */ -LV_ATTRIBUTE_FAST_MEM void * _lv_memcpy(void * dst, const void * src, size_t len) +LV_ATTRIBUTE_FAST_MEM void * lv_memcpy(void * dst, const void * src, size_t len) { uint8_t * d8 = dst; const uint8_t * s8 = src; @@ -633,7 +633,7 @@ LV_ATTRIBUTE_FAST_MEM void * _lv_memcpy(void * dst, const void * src, size_t len * @param v value to set [0..255] * @param len number of byte to set */ -LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len) +LV_ATTRIBUTE_FAST_MEM void lv_memset(void * dst, uint8_t v, size_t len) { uint8_t * d8 = (uint8_t *) dst; @@ -686,7 +686,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len) * @param dst pointer to the destination buffer * @param len number of byte to set */ -LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len) +LV_ATTRIBUTE_FAST_MEM void lv_memset_00(void * dst, size_t len) { uint8_t * d8 = (uint8_t *) dst; uintptr_t d_align = (lv_uintptr_t) d8 & ALIGN_MASK; @@ -735,7 +735,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len) * @param dst pointer to the destination buffer * @param len number of byte to set */ -LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len) +LV_ATTRIBUTE_FAST_MEM void lv_memset_ff(void * dst, size_t len) { uint8_t * d8 = (uint8_t *) dst; uintptr_t d_align = (lv_uintptr_t) d8 & ALIGN_MASK; diff --git a/src/lv_misc/lv_mem.h b/src/lv_misc/lv_mem.h index f3ca9c6f2..6154c921b 100644 --- a/src/lv_misc/lv_mem.h +++ b/src/lv_misc/lv_mem.h @@ -57,7 +57,7 @@ typedef struct { } lv_mem_buf_t; typedef lv_mem_buf_t lv_mem_buf_arr_t[LV_MEM_BUF_MAX_NUM]; -extern lv_mem_buf_arr_t _lv_mem_buf; +extern lv_mem_buf_arr_t lv_mem_buf; /********************** * GLOBAL PROTOTYPES @@ -66,13 +66,13 @@ extern lv_mem_buf_arr_t _lv_mem_buf; /** * Initialize the dyn_mem module (work memory and other variables) */ -void _lv_mem_init(void); +void lv_mem_init(void); /** * Clean up the memory buffer which frees all the allocated memories. * @note It work only if `LV_MEM_CUSTOM == 0` */ -void _lv_mem_deinit(void); +void lv_mem_deinit(void); /** * Allocate a memory dynamically @@ -119,24 +119,24 @@ void lv_mem_monitor(lv_mem_monitor_t * mon_p); * @param data pointer to an allocated memory * @return the size of data memory in bytes */ -uint32_t _lv_mem_get_size(const void * data); +uint32_t lv_mem_get_size(const void * data); /** * Get a temporal buffer with the given size. * @param size the required size */ -void * _lv_mem_buf_get(uint32_t size); +void * lv_mem_buf_get(uint32_t size); /** * Release a memory buffer * @param p buffer to release */ -void _lv_mem_buf_release(void * p); +void lv_mem_buf_release(void * p); /** * Free all memory buffers */ -void _lv_mem_buf_free_all(void); +void lv_mem_buf_free_all(void); //! @cond Doxygen_Suppress @@ -149,7 +149,7 @@ void _lv_mem_buf_free_all(void); * @param src pointer to the source buffer * @param len number of byte to copy */ -static inline void * _lv_memcpy(void * dst, const void * src, size_t len) +static inline void * lv_memcpy(void * dst, const void * src, size_t len) { return memcpy(dst, src, len); } @@ -160,7 +160,7 @@ static inline void * _lv_memcpy(void * dst, const void * src, size_t len) * @param src pointer to the source buffer * @param len number of byte to copy */ -static inline void * _lv_memcpy_small(void * dst, const void * src, size_t len) +static inline void * lv_memcpy_small(void * dst, const void * src, size_t len) { return memcpy(dst, src, len); } @@ -171,7 +171,7 @@ static inline void * _lv_memcpy_small(void * dst, const void * src, size_t len) * @param v value to set [0..255] * @param len number of byte to set */ -static inline void _lv_memset(void * dst, uint8_t v, size_t len) +static inline void lv_memset(void * dst, uint8_t v, size_t len) { memset(dst, v, len); } @@ -181,7 +181,7 @@ static inline void _lv_memset(void * dst, uint8_t v, size_t len) * @param dst pointer to the destination buffer * @param len number of byte to set */ -static inline void _lv_memset_00(void * dst, size_t len) +static inline void lv_memset_00(void * dst, size_t len) { memset(dst, 0x00, len); } @@ -191,7 +191,7 @@ static inline void _lv_memset_00(void * dst, size_t len) * @param dst pointer to the destination buffer * @param len number of byte to set */ -static inline void _lv_memset_ff(void * dst, size_t len) +static inline void lv_memset_ff(void * dst, size_t len) { memset(dst, 0xFF, len); } @@ -203,7 +203,7 @@ static inline void _lv_memset_ff(void * dst, size_t len) * @param src pointer to the source buffer * @param len number of byte to copy */ -LV_ATTRIBUTE_FAST_MEM void * _lv_memcpy(void * dst, const void * src, size_t len); +LV_ATTRIBUTE_FAST_MEM void * lv_memcpy(void * dst, const void * src, size_t len); /** * Same as `memcpy` but optimized to copy only a few bytes. @@ -211,7 +211,7 @@ LV_ATTRIBUTE_FAST_MEM void * _lv_memcpy(void * dst, const void * src, size_t len * @param src pointer to the source buffer * @param len number of byte to copy */ -LV_ATTRIBUTE_FAST_MEM static inline void * _lv_memcpy_small(void * dst, const void * src, size_t len) +LV_ATTRIBUTE_FAST_MEM static inline void * lv_memcpy_small(void * dst, const void * src, size_t len) { uint8_t * d8 = (uint8_t *)dst; const uint8_t * s8 = (const uint8_t *)src; @@ -232,21 +232,21 @@ LV_ATTRIBUTE_FAST_MEM static inline void * _lv_memcpy_small(void * dst, const vo * @param v value to set [0..255] * @param len number of byte to set */ -LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len); +LV_ATTRIBUTE_FAST_MEM void lv_memset(void * dst, uint8_t v, size_t len); /** * Same as `memset(dst, 0x00, len)` but optimized for 4 byte operation. * @param dst pointer to the destination buffer * @param len number of byte to set */ -LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len); +LV_ATTRIBUTE_FAST_MEM void lv_memset_00(void * dst, size_t len); /** * Same as `memset(dst, 0xFF, len)` but optimized for 4 byte operation. * @param dst pointer to the destination buffer * @param len number of byte to set */ -LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len); +LV_ATTRIBUTE_FAST_MEM void lv_memset_ff(void * dst, size_t len); //! @endcond diff --git a/src/lv_misc/lv_txt.c b/src/lv_misc/lv_txt.c index bd7e0aedb..222951698 100644 --- a/src/lv_misc/lv_txt.c +++ b/src/lv_misc/lv_txt.c @@ -11,6 +11,7 @@ #include "lv_txt_ap.h" #include "lv_math.h" #include "lv_log.h" +#include "lv_mem.h" #include "lv_debug.h" /********************* @@ -125,7 +126,7 @@ void _lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t lv_coord_t act_line_length = _lv_txt_get_width(&text[line_start], new_line_start - line_start, font, letter_space, flag); - size_res->x = LV_MATH_MAX(act_line_length, size_res->x); + size_res->x = LV_MAX(act_line_length, size_res->x); line_start = new_line_start; } @@ -451,7 +452,7 @@ void _lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt) } /* Copy the text into the new space*/ - _lv_memcpy_small(txt_buf + pos, ins_txt, ins_len); + lv_memcpy_small(txt_buf + pos, ins_txt, ins_len); } /** @@ -492,7 +493,7 @@ char * _lv_txt_set_text_vfmt(const char * fmt, va_list ap) char * text = 0; #if LV_USE_ARABIC_PERSIAN_CHARS /*Put together the text according to the format string*/ - char * raw_txt = _lv_mem_buf_get(len + 1); + char * raw_txt = lv_mem_buf_get(len + 1); LV_ASSERT_MEM(raw_txt); if(raw_txt == NULL) { return NULL; @@ -509,7 +510,7 @@ char * _lv_txt_set_text_vfmt(const char * fmt, va_list ap) } _lv_txt_ap_proc(raw_txt, text); - _lv_mem_buf_release(raw_txt); + lv_mem_buf_release(raw_txt); #else text = lv_mem_alloc(len + 1); LV_ASSERT_MEM(text); @@ -592,7 +593,7 @@ static uint32_t lv_txt_utf8_conv_wc(uint32_t c) if((c & 0x80) != 0) { uint32_t swapped; uint8_t c8[4]; - _lv_memcpy_small(c8, &c, 4); + lv_memcpy_small(c8, &c, 4); swapped = (c8[0] << 24) + (c8[1] << 16) + (c8[2] << 8) + (c8[3]); uint8_t i; for(i = 0; i < 4; i++) { diff --git a/src/lv_misc/lv_utils.c b/src/lv_misc/lv_utils.c index ea2a17b07..61ae7bb62 100644 --- a/src/lv_misc/lv_utils.c +++ b/src/lv_misc/lv_utils.c @@ -54,7 +54,7 @@ char * _lv_utils_num_to_str(int32_t num, char * buf) int8_t i = 0; if(num < 0) { buf[digitCount++] = '-'; - num = LV_MATH_ABS(num); + num = LV_ABS(num); ++i; } while(num) { diff --git a/src/lv_themes/lv_theme.c b/src/lv_themes/lv_theme.c index e02d01b93..8871efaf9 100644 --- a/src/lv_themes/lv_theme.c +++ b/src/lv_themes/lv_theme.c @@ -76,7 +76,7 @@ void lv_theme_apply(lv_obj_t * obj) */ void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy) { - _lv_memset_00(theme, sizeof(lv_theme_t)); + lv_memset_00(theme, sizeof(lv_theme_t)); if(copy) { theme->font_small = copy->font_small; diff --git a/src/lv_themes/lv_theme_default.c b/src/lv_themes/lv_theme_default.c index ea70e7d1f..7f29ccf77 100644 --- a/src/lv_themes/lv_theme_default.c +++ b/src/lv_themes/lv_theme_default.c @@ -125,7 +125,7 @@ typedef struct { #endif #if LV_USE_DROPDOWN - lv_style_t ddlist_page, ddlist_sel; + lv_style_t ddlist_flip; #endif //#if LV_USE_ROLLER @@ -175,14 +175,16 @@ static void basic_init(void) LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR, LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT, + LV_STYLE_TRANSFORM_ZOOM, + LV_STYLE_TRANSFORM_ANGLE, LV_STYLE_COLOR_FILTER_OPA, LV_STYLE_COLOR_FILTER_CB, 0 }; - static lv_style_transiton_t trans_delayed; + static lv_style_transition_t trans_delayed; lv_style_transition_init(&trans_delayed, trans_props, &lv_anim_path_def, TRANSITION_TIME, 70); - static lv_style_transiton_t trans_normal; + static lv_style_transition_t trans_normal; lv_style_transition_init(&trans_normal, trans_props, &lv_anim_path_def, TRANSITION_TIME, 0); style_init_reset(&styles->transition_delayed); @@ -299,7 +301,7 @@ static void basic_init(void) style_init_reset(&styles->grow); lv_style_set_transform_width(&styles->grow, LV_DPX(3)); - lv_style_set_transform_height(&styles->grow, LV_DPX(3)); + lv_style_set_transform_angle(&styles->grow, LV_DPX(3)); style_init_reset(&styles->knob); lv_style_set_bg_color(&styles->knob, IS_LIGHT ? theme.color_primary : LV_COLOR_WHITE); @@ -322,6 +324,13 @@ static void basic_init(void) style_init_reset(&styles->arc_indic_primary); lv_style_set_line_color(&styles->arc_indic_primary, theme.color_primary); + LV_IMG_DECLARE(asd); + lv_style_set_bg_img_src(&styles->arc_indic_primary, &asd); +#endif + +#if LV_USE_DROPDOWN + style_init_reset(&styles->ddlist_flip); + lv_style_set_transform_angle(&styles->ddlist_flip, 1800); #endif #if LV_USE_CHECKBOX @@ -334,7 +343,7 @@ static void basic_init(void) lv_style_set_radius(&styles->cb_marker, RADIUS_DEFAULT / 2); style_init_reset(&styles->cb_marker_checked); - lv_style_set_content_src(&styles->cb_marker_checked, LV_SYMBOL_OK); + lv_style_set_content_text(&styles->cb_marker_checked, LV_SYMBOL_OK); lv_style_set_text_color(&styles->cb_marker_checked, LV_COLOR_WHITE); lv_style_set_text_font(&styles->cb_marker_checked, theme.font_small); #endif @@ -613,6 +622,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) #if LV_USE_DROPDOWN else if(lv_obj_check_type(obj, &lv_dropdown)) { lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card); + lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_CHECKED, &styles->ddlist_flip); + lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->transition_normal); } else if(lv_obj_check_type(obj, &lv_dropdown_list)) { lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card); diff --git a/src/lv_themes/lv_theme_mono.c b/src/lv_themes/lv_theme_mono.c index 235bdea58..49b63ec20 100644 --- a/src/lv_themes/lv_theme_mono.c +++ b/src/lv_themes/lv_theme_mono.c @@ -101,8 +101,8 @@ static bool inited; #define COLOR_INV(c) ((c).ch.red == 0 ? LV_COLOR_WHITE : LV_COLOR_BLACK) #define BG_COLOR theme.color_primary.ch.red == 0 ? LV_COLOR_WHITE : LV_COLOR_BLACK #define FG_COLOR COLOR_INV(BG_COLOR) -#define RADIUS (LV_MATH_MAX(LV_DPI / 30, 2)) -#define BORDER_WIDTH (LV_MATH_MAX(LV_DPI / 60, 1)) +#define RADIUS (LV_MAX(LV_DPI / 30, 2)) +#define BORDER_WIDTH (LV_MAX(LV_DPI / 60, 1)) /********************** * STATIC FUNCTIONS @@ -127,8 +127,8 @@ static void basic_init(void) lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED, BORDER_WIDTH * 2); lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED | LV_STATE_EDITED, BORDER_WIDTH * 3); lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR); - lv_style_set_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1)); - lv_style_set_scale_end_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1)); + lv_style_set_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 100, 1)); + lv_style_set_scale_end_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 100, 1)); lv_style_set_line_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_scale_grad_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_scale_end_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR); @@ -211,11 +211,11 @@ static void arc_init(void) { #if LV_USE_ARC != 0 style_init_reset(&styles->arc_bg); - lv_style_set_line_width(&styles->arc_bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1)); + lv_style_set_line_width(&styles->arc_bg, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 100, 1)); lv_style_set_line_color(&styles->arc_bg, LV_STATE_DEFAULT, FG_COLOR); style_init_reset(&styles->arc_indic); - lv_style_set_line_width(&styles->arc_indic, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 10, 3)); + lv_style_set_line_width(&styles->arc_indic, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 10, 3)); lv_style_set_line_color(&styles->arc_indic, LV_STATE_DEFAULT, FG_COLOR); #endif } @@ -248,7 +248,7 @@ static void chart_init(void) style_init_reset(&styles->chart_series); lv_style_set_size(&styles->chart_series, LV_STATE_DEFAULT, 0); lv_style_set_bg_opa(&styles->chart_series, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_style_set_line_width(&styles->chart_series, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 50, 1)); + lv_style_set_line_width(&styles->chart_series, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 50, 1)); #endif } @@ -264,19 +264,19 @@ static void gauge_init(void) { #if LV_USE_GAUGE != 0 style_init_reset(&styles->gauge_needle); - lv_style_set_line_width(&styles->gauge_needle, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 30, 2)); + lv_style_set_line_width(&styles->gauge_needle, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 30, 2)); lv_style_set_line_color(&styles->gauge_needle, LV_STATE_DEFAULT, FG_COLOR); - lv_style_set_size(&styles->gauge_needle, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 10, 4)); + lv_style_set_size(&styles->gauge_needle, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 10, 4)); lv_style_set_bg_opa(&styles->gauge_needle, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&styles->gauge_needle, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_radius(&styles->gauge_needle, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); style_init_reset(&styles->gauge_major); - lv_style_set_line_width(&styles->gauge_major, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 25, 2)); + lv_style_set_line_width(&styles->gauge_major, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 25, 2)); lv_style_set_line_color(&styles->gauge_major, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_scale_end_color(&styles->gauge_major, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_scale_grad_color(&styles->gauge_major, LV_STATE_DEFAULT, FG_COLOR); - lv_style_set_scale_end_line_width(&styles->gauge_major, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 25, 2)); + lv_style_set_scale_end_line_width(&styles->gauge_major, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 25, 2)); #endif } @@ -300,8 +300,8 @@ static void linemeter_init(void) { #if LV_USE_LINEMETER != 0 style_init_reset(&styles->linemeter); - lv_style_set_line_width(&styles->linemeter, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 25, 2)); - lv_style_set_scale_end_line_width(&styles->linemeter, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 70, 1)); + lv_style_set_line_width(&styles->linemeter, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 25, 2)); + lv_style_set_scale_end_line_width(&styles->linemeter, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 70, 1)); #endif } @@ -331,7 +331,7 @@ static void textarea_init(void) #if LV_USE_TEXTAREA style_init_reset(&styles->ta_cursor); lv_style_set_bg_opa(&styles->ta_cursor, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_style_set_border_width(&styles->ta_cursor, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1)); + lv_style_set_border_width(&styles->ta_cursor, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 100, 1)); lv_style_set_border_side(&styles->ta_cursor, LV_STATE_DEFAULT, LV_BORDER_SIDE_LEFT); lv_style_set_border_color(&styles->ta_cursor, LV_STATE_DEFAULT, FG_COLOR); diff --git a/src/lv_widgets/lv_arc.c b/src/lv_widgets/lv_arc.c index 4f7f8c97d..19f607863 100644 --- a/src/lv_widgets/lv_arc.c +++ b/src/lv_widgets/lv_arc.c @@ -94,17 +94,17 @@ void lv_arc_set_start_angle(lv_obj_t * obj, uint16_t start) if(start > 360) start -= 360; /*Too large move, the whole arc need to be invalidated anyway*/ - if(LV_MATH_ABS(start -arc->indic_angle_start) >= 180) { + if(LV_ABS(start -arc->indic_angle_start) >= 180) { lv_obj_invalidate(obj); } /*Only a smaller incremental move*/ else if(arc->indic_angle_start >arc->indic_angle_end && start >arc->indic_angle_end) { - inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_start, start), LV_MATH_MAX(arc->indic_angle_start, start), + inv_arc_area(obj, LV_MIN(arc->indic_angle_start, start), LV_MAX(arc->indic_angle_start, start), LV_PART_INDICATOR); } /*Only a smaller incremental move*/ else if(arc->indic_angle_start indic_angle_end && start indic_angle_end) { - inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_start, start), LV_MATH_MAX(arc->indic_angle_start, start), + inv_arc_area(obj, LV_MIN(arc->indic_angle_start, start), LV_MAX(arc->indic_angle_start, start), LV_PART_INDICATOR); } /*Crossing the start angle makes the whole arc change*/ @@ -128,16 +128,16 @@ void lv_arc_set_end_angle(lv_obj_t * obj, uint16_t end) if(end > (arc->indic_angle_start + 360)) end =arc->indic_angle_start + 360; /*Too large move, the whole arc need to be invalidated anyway*/ - if(LV_MATH_ABS(end -arc->indic_angle_end) >= 180) { + if(LV_ABS(end -arc->indic_angle_end) >= 180) { lv_obj_invalidate(obj); } /*Only a smaller incremental move*/ else if(arc->indic_angle_end >arc->indic_angle_start && end >arc->indic_angle_start) { - inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_end, end), LV_MATH_MAX(arc->indic_angle_end, end), LV_PART_INDICATOR); + inv_arc_area(obj, LV_MIN(arc->indic_angle_end, end), LV_MAX(arc->indic_angle_end, end), LV_PART_INDICATOR); } /*Only a smaller incremental move*/ else if(arc->indic_angle_end indic_angle_start && end indic_angle_start) { - inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_end, end), LV_MATH_MAX(arc->indic_angle_end, end), LV_PART_INDICATOR); + inv_arc_area(obj, LV_MIN(arc->indic_angle_end, end), LV_MAX(arc->indic_angle_end, end), LV_PART_INDICATOR); } /*Crossing the end angle makes the whole arc change*/ else { @@ -183,16 +183,16 @@ void lv_arc_set_bg_start_angle(lv_obj_t * obj, uint16_t start) if(start > 360) start -= 360; /*Too large move, the whole arc need to be invalidated anyway*/ - if(LV_MATH_ABS(start -arc->bg_angle_start) >= 180) { + if(LV_ABS(start -arc->bg_angle_start) >= 180) { lv_obj_invalidate(obj); } /*Only a smaller incremental move*/ else if(arc->bg_angle_start >arc->bg_angle_end && start >arc->bg_angle_end) { - inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_start, start), LV_MATH_MAX(arc->bg_angle_start, start), LV_PART_MAIN); + inv_arc_area(obj, LV_MIN(arc->bg_angle_start, start), LV_MAX(arc->bg_angle_start, start), LV_PART_MAIN); } /*Only a smaller incremental move*/ else if(arc->bg_angle_start bg_angle_end && start bg_angle_end) { - inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_start, start), LV_MATH_MAX(arc->bg_angle_start, start), LV_PART_MAIN); + inv_arc_area(obj, LV_MIN(arc->bg_angle_start, start), LV_MAX(arc->bg_angle_start, start), LV_PART_MAIN); } /*Crossing the start angle makes the whole arc change*/ else { @@ -218,16 +218,16 @@ void lv_arc_set_bg_end_angle(lv_obj_t * obj, uint16_t end) if(end > (arc->bg_angle_start + 360)) end =arc->bg_angle_start + 360; /*Too large move, the whole arc need to be invalidated anyway*/ - if(LV_MATH_ABS(end -arc->bg_angle_end) >= 180) { + if(LV_ABS(end -arc->bg_angle_end) >= 180) { lv_obj_invalidate(obj); } /*Only a smaller incremental move*/ else if(arc->bg_angle_end >arc->bg_angle_start && end >arc->bg_angle_start) { - inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_end, end), LV_MATH_MAX(arc->bg_angle_end, end), LV_PART_MAIN); + inv_arc_area(obj, LV_MIN(arc->bg_angle_end, end), LV_MAX(arc->bg_angle_end, end), LV_PART_MAIN); } /*Only a smaller incremental move*/ else if(arc->bg_angle_end bg_angle_start && end bg_angle_start) { - inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_end, end), LV_MATH_MAX(arc->bg_angle_end, end), LV_PART_MAIN); + inv_arc_area(obj, LV_MIN(arc->bg_angle_end, end), LV_MAX(arc->bg_angle_end, end), LV_PART_MAIN); } /*Crossing the end angle makes the whole arc change*/ else { @@ -506,29 +506,19 @@ static lv_draw_res_t lv_arc_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv lv_arc_t * arc = (lv_arc_t *)obj; - lv_obj_draw_hook_dsc_t hook_dsc; - lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area); - - lv_point_t center; lv_coord_t arc_r; get_center(obj, ¢er, &arc_r); /*Draw the background arc*/ - lv_draw_line_dsc_t arc_dsc; + lv_draw_arc_dsc_t arc_dsc; if(arc_r > 0) { - lv_draw_line_dsc_init(&arc_dsc); - lv_obj_init_draw_line_dsc(obj, LV_PART_MAIN, &arc_dsc); - - hook_dsc.part = LV_PART_MAIN; - hook_dsc.line_dsc = &arc_dsc; - lv_event_send(obj,LV_EVENT_DRAW_PART_BEGIN, &hook_dsc); + lv_draw_arc_dsc_init(&arc_dsc); + lv_obj_init_draw_arc_dsc(obj, LV_PART_MAIN, &arc_dsc); lv_draw_arc(center.x, center.y, arc_r,arc->bg_angle_start +arc->angle_ofs, arc->bg_angle_end + arc->angle_ofs, clip_area, &arc_dsc); - - lv_event_send(obj,LV_EVENT_DRAW_PART_END, &hook_dsc); } @@ -537,21 +527,15 @@ static lv_draw_res_t lv_arc_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv lv_coord_t right_indic = lv_obj_get_style_pad_right(obj, LV_PART_INDICATOR); lv_coord_t top_indic = lv_obj_get_style_pad_top(obj, LV_PART_INDICATOR); lv_coord_t bottom_indic = lv_obj_get_style_pad_bottom(obj, LV_PART_INDICATOR); - lv_coord_t indic_r = arc_r - LV_MATH_MAX4(left_indic, right_indic, top_indic, bottom_indic); + lv_coord_t indic_r = arc_r - LV_MAX4(left_indic, right_indic, top_indic, bottom_indic); if(indic_r > 0) { - lv_draw_line_dsc_init(&arc_dsc); - lv_obj_init_draw_line_dsc(obj, LV_PART_INDICATOR, &arc_dsc); - - hook_dsc.part = LV_PART_INDICATOR; - hook_dsc.line_dsc = &arc_dsc; - lv_event_send(obj,LV_EVENT_DRAW_PART_BEGIN, &hook_dsc); + lv_draw_arc_dsc_init(&arc_dsc); + lv_obj_init_draw_arc_dsc(obj, LV_PART_INDICATOR, &arc_dsc); lv_draw_arc(center.x, center.y, indic_r,arc->indic_angle_start +arc->angle_ofs, arc->indic_angle_end +arc->angle_ofs, clip_area, &arc_dsc); - - lv_event_send(obj,LV_EVENT_DRAW_PART_END, &hook_dsc); } if(arc->adjustable) { @@ -562,13 +546,7 @@ static lv_draw_res_t lv_arc_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv lv_draw_rect_dsc_init(&knob_rect_dsc); lv_obj_init_draw_rect_dsc(obj, LV_PART_KNOB, &knob_rect_dsc); - hook_dsc.part = LV_PART_KNOB; - hook_dsc.rect_dsc = &knob_rect_dsc; - lv_event_send(obj,LV_EVENT_DRAW_PART_BEGIN, &hook_dsc); - lv_draw_rect(&knob_area, clip_area, &knob_rect_dsc); - - lv_event_send(obj,LV_EVENT_DRAW_PART_END, &hook_dsc); } } @@ -642,7 +620,7 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param) } - angle = _lv_atan2(p.y, p.x); + angle = lv_atan2(p.y, p.x); angle -=arc->angle_ofs; angle -=arc->bg_angle_start; /*Make the angle relative to the start angle*/ if(angle < 0) angle += 360; @@ -655,7 +633,7 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param) /* Do not allow big jumps. * It's mainly to avoid jumping to the opposite end if the "dead" range between min. an max. is crossed. * Check which and was closer on the last valid press (arc->min_close) and prefer that end */ - if(LV_MATH_ABS(delta_angle) > 180) { + if(LV_ABS(delta_angle) > 180) { if(arc->min_close) angle = 0; else angle = deg_range; } @@ -687,7 +665,7 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param) /*Set the new value*/ int16_t old_value =arc->value; - int16_t new_value = _lv_map(angle,arc->bg_angle_start, bg_end,arc->min_value,arc->max_value); + int16_t new_value = lv_map(angle,arc->bg_angle_start, bg_end,arc->min_value,arc->max_value); if(new_value != lv_arc_get_value(obj)) { arc->last_tick = lv_tick_get(); /*Cache timestamp for the next iteration*/ lv_arc_set_value(obj, new_value); /*set_value caches the last_angle for the next iteration*/ @@ -765,7 +743,7 @@ static void inv_arc_area(lv_obj_t * obj, uint16_t start_angle, uint16_t end_angl lv_coord_t right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN); lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN); lv_coord_t bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN); - lv_coord_t rout = (LV_MATH_MIN(lv_obj_get_width(obj) - left - right, lv_obj_get_height(obj) - top - bottom)) / 2; + lv_coord_t rout = (LV_MIN(lv_obj_get_width(obj) - left - right, lv_obj_get_height(obj) - top - bottom)) / 2; lv_coord_t x = obj->coords.x1 + rout + left; lv_coord_t y = obj->coords.y1 + rout + top; lv_coord_t w = lv_obj_get_style_line_width(obj, part); @@ -783,9 +761,9 @@ static void inv_arc_area(lv_obj_t * obj, uint16_t start_angle, uint16_t end_angl lv_coord_t knob_top = lv_obj_get_style_pad_top(obj, LV_PART_KNOB); lv_coord_t knob_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_KNOB); - knob_extra_size += LV_MATH_MAX4(knob_left, knob_right, knob_top, knob_bottom); + knob_extra_size += LV_MAX4(knob_left, knob_right, knob_top, knob_bottom); - extra_area = LV_MATH_MAX(extra_area, w / 2 + 2 + knob_extra_size); + extra_area = LV_MAX(extra_area, w / 2 + 2 + knob_extra_size); } @@ -793,74 +771,74 @@ static void inv_arc_area(lv_obj_t * obj, uint16_t start_angle, uint16_t end_angl if(start_quarter == end_quarter && start_angle <= end_angle) { if(start_quarter == 0) { - inv_area.y1 = y + ((_lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) - extra_area; - inv_area.x2 = x + ((_lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.y1 = y + ((lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.x2 = x + ((lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area; - inv_area.y2 = y + ((_lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area; - inv_area.x1 = x + ((_lv_trigo_sin(end_angle + 90) * rin) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.y2 = y + ((lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.x1 = x + ((lv_trigo_sin(end_angle + 90) * rin) >> LV_TRIGO_SHIFT) - extra_area; lv_obj_invalidate_area(obj, &inv_area); } else if(start_quarter == 1) { - inv_area.y2 = y + ((_lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area; - inv_area.x2 = x + ((_lv_trigo_sin(start_angle + 90) * rin) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.y2 = y + ((lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.x2 = x + ((lv_trigo_sin(start_angle + 90) * rin) >> LV_TRIGO_SHIFT) + extra_area; - inv_area.y1 = y + ((_lv_trigo_sin(end_angle) * rin) >> LV_TRIGO_SHIFT) - extra_area; - inv_area.x1 = x + ((_lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.y1 = y + ((lv_trigo_sin(end_angle) * rin) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.x1 = x + ((lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area; lv_obj_invalidate_area(obj, &inv_area); } else if(start_quarter == 2) { - inv_area.x1 = x + ((_lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area; - inv_area.y2 = y + ((_lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.x1 = x + ((lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.y2 = y + ((lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area; - inv_area.y1 = y + ((_lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area; - inv_area.x2 = x + ((_lv_trigo_sin(end_angle + 90) * rin) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.y1 = y + ((lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.x2 = x + ((lv_trigo_sin(end_angle + 90) * rin) >> LV_TRIGO_SHIFT) + extra_area; lv_obj_invalidate_area(obj, &inv_area); } else if(start_quarter == 3) { /*Small arc here*/ - inv_area.x1 = x + ((_lv_trigo_sin(start_angle + 90) * rin) >> LV_TRIGO_SHIFT) - extra_area; - inv_area.y1 = y + ((_lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.x1 = x + ((lv_trigo_sin(start_angle + 90) * rin) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.y1 = y + ((lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area; - inv_area.x2 = x + ((_lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area; - inv_area.y2 = y + ((_lv_trigo_sin(end_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.x2 = x + ((lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.y2 = y + ((lv_trigo_sin(end_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area; lv_obj_invalidate_area(obj, &inv_area); } } else if(start_quarter == 0 && end_quarter == 1) { - inv_area.x1 = x + ((_lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area; - inv_area.y1 = y + ((LV_MATH_MIN(_lv_trigo_sin(end_angle), - _lv_trigo_sin(start_angle)) * rin) >> LV_TRIGO_SHIFT) - extra_area; - inv_area.x2 = x + ((_lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.x1 = x + ((lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.y1 = y + ((LV_MIN(lv_trigo_sin(end_angle), + lv_trigo_sin(start_angle)) * rin) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.x2 = x + ((lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area; inv_area.y2 = y + rout + extra_area; lv_obj_invalidate_area(obj, &inv_area); } else if(start_quarter == 1 && end_quarter == 2) { inv_area.x1 = x - rout - extra_area; - inv_area.y1 = y + ((_lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area; - inv_area.x2 = x + ((LV_MATH_MAX(_lv_trigo_sin(start_angle + 90), - _lv_trigo_sin(end_angle + 90)) * rin) >> LV_TRIGO_SHIFT) + extra_area; - inv_area.y2 = y + ((_lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.y1 = y + ((lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.x2 = x + ((LV_MAX(lv_trigo_sin(start_angle + 90), + lv_trigo_sin(end_angle + 90)) * rin) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.y2 = y + ((lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area; lv_obj_invalidate_area(obj, &inv_area); } else if(start_quarter == 2 && end_quarter == 3) { - inv_area.x1 = x + ((_lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.x1 = x + ((lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area; inv_area.y1 = y - rout - extra_area; - inv_area.x2 = x + ((_lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area; - inv_area.y2 = y + (LV_MATH_MAX(_lv_trigo_sin(end_angle) * rin, - _lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.x2 = x + ((lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.y2 = y + (LV_MAX(lv_trigo_sin(end_angle) * rin, + lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area; lv_obj_invalidate_area(obj, &inv_area); } else if(start_quarter == 3 && end_quarter == 0) { - inv_area.x1 = x + ((LV_MATH_MIN(_lv_trigo_sin(end_angle + 90), - _lv_trigo_sin(start_angle + 90)) * rin) >> LV_TRIGO_SHIFT) - extra_area; - inv_area.y1 = y + ((_lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.x1 = x + ((LV_MIN(lv_trigo_sin(end_angle + 90), + lv_trigo_sin(start_angle + 90)) * rin) >> LV_TRIGO_SHIFT) - extra_area; + inv_area.y1 = y + ((lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area; inv_area.x2 = x + rout + extra_area; - inv_area.y2 = y + ((_lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area; + inv_area.y2 = y + ((lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area; lv_obj_invalidate_area(obj, &inv_area); } @@ -876,7 +854,7 @@ static void get_center(lv_obj_t * obj, lv_point_t * center, lv_coord_t * arc_r) lv_coord_t top_bg = lv_obj_get_style_pad_top(obj, LV_PART_MAIN); lv_coord_t bottom_bg = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN); - lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(obj) - left_bg - right_bg, + lv_coord_t r = (LV_MIN(lv_obj_get_width(obj) - left_bg - right_bg, lv_obj_get_height(obj) - top_bg - bottom_bg)) / 2; *arc_r = r; @@ -909,8 +887,8 @@ static void get_knob_area(lv_obj_t * obj, const lv_point_t * center, lv_coord_t if(arc->value < range_midpoint) angle +=arc->indic_angle_start; else angle +=arc->indic_angle_end; } - lv_coord_t knob_x = (r * _lv_trigo_sin(angle + 90)) >> LV_TRIGO_SHIFT; - lv_coord_t knob_y = (r * _lv_trigo_sin(angle)) >> LV_TRIGO_SHIFT; + lv_coord_t knob_x = (r * lv_trigo_sin(angle + 90)) >> LV_TRIGO_SHIFT; + lv_coord_t knob_y = (r * lv_trigo_sin(angle)) >> LV_TRIGO_SHIFT; lv_coord_t left_knob = lv_obj_get_style_pad_left(obj, LV_PART_KNOB); lv_coord_t right_knob = lv_obj_get_style_pad_right(obj, LV_PART_KNOB); @@ -942,22 +920,22 @@ static void value_update(lv_obj_t * obj) range_midpoint = (int32_t)(arc->min_value +arc->max_value) / 2; if(arc->value < range_midpoint) { - angle = _lv_map(arc->value,arc->min_value, range_midpoint,arc->bg_angle_start, bg_midpoint); + angle = lv_map(arc->value,arc->min_value, range_midpoint,arc->bg_angle_start, bg_midpoint); lv_arc_set_start_angle(obj, angle); lv_arc_set_end_angle(obj, bg_midpoint); } else { - angle = _lv_map(arc->value, range_midpoint,arc->max_value, bg_midpoint, bg_end); + angle = lv_map(arc->value, range_midpoint,arc->max_value, bg_midpoint, bg_end); lv_arc_set_start_angle(obj, bg_midpoint); lv_arc_set_end_angle(obj, angle); } break; case LV_ARC_TYPE_REVERSE: - angle = _lv_map(arc->value,arc->min_value,arc->max_value,arc->bg_angle_start, bg_end); + angle = lv_map(arc->value,arc->min_value,arc->max_value,arc->bg_angle_start, bg_end); lv_arc_set_start_angle(obj, angle); break; default: /** LV_ARC_TYPE_NORMAL*/ - angle = _lv_map(arc->value,arc->min_value,arc->max_value,arc->bg_angle_start, bg_end); + angle = lv_map(arc->value,arc->min_value,arc->max_value,arc->bg_angle_start, bg_end); lv_arc_set_end_angle(obj, angle); lv_arc_set_start_angle(obj,arc->bg_angle_start); } diff --git a/src/lv_widgets/lv_bar.c b/src/lv_widgets/lv_bar.c index 4a26e0dd4..9a2f7a3cc 100644 --- a/src/lv_widgets/lv_bar.c +++ b/src/lv_widgets/lv_bar.c @@ -474,7 +474,7 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area) if(!sym && indic_length_calc(&bar->indic_area) <= 1) return; uint16_t bg_radius = lv_obj_get_style_radius(obj, LV_PART_MAIN); - lv_coord_t short_side = LV_MATH_MIN(barw, barh); + lv_coord_t short_side = LV_MIN(barw, barh); if(bg_radius > short_side >> 1) bg_radius = short_side >> 1; lv_draw_rect_dsc_t draw_indic_dsc; @@ -484,14 +484,6 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area) lv_area_t indic_area; lv_area_copy(&indic_area, &bar->indic_area); - /*Handle custom drawer*/ - lv_obj_draw_hook_dsc_t hook_dsc; - lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area); - hook_dsc.draw_area = &indic_area; - hook_dsc.part = LV_PART_INDICATOR; - lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc); - - /* Draw only the shadow if the indicator is long enough. * The radius of the bg and the indicator can make a strange shape where * it'd be very difficult to draw shadow. */ @@ -560,9 +552,6 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area) draw_indic_dsc.content_opa = content_opa; draw_indic_dsc.border_opa = LV_OPA_TRANSP; lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc); - - lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc); - } /** @@ -587,7 +576,7 @@ static lv_res_t lv_bar_signal(lv_obj_t * obj, lv_signal_t sign, void * param) /*Bg size is handled by lv_obj*/ lv_coord_t * s = param; - *s = LV_MATH_MAX(*s, indic_size); + *s = LV_MAX(*s, indic_size); } return res; diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index f8b13118c..80880d43b 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -200,7 +200,7 @@ void lv_btnmatrix_set_ctrl_map(lv_obj_t * obj, const lv_btnmatrix_ctrl_t ctrl_ma LV_ASSERT_OBJ(obj, LV_OBJX_NAME); lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; - _lv_memcpy(btnm->ctrl_bits, ctrl_map, sizeof(lv_btnmatrix_ctrl_t) * btnm->btn_cnt); + lv_memcpy(btnm->ctrl_bits, ctrl_map, sizeof(lv_btnmatrix_ctrl_t) * btnm->btn_cnt); lv_btnmatrix_set_map(obj, btnm->map_p); } @@ -591,7 +591,7 @@ static lv_draw_res_t lv_btnmatrix_draw(lv_obj_t * obj, const lv_area_t * clip_ar #if LV_USE_ARABIC_PERSIAN_CHARS const size_t txt_ap_size = 256 ; - char * txt_ap = _lv_mem_buf_get(txt_ap_size); + char * txt_ap = lv_mem_buf_get(txt_ap_size); #endif lv_obj_draw_hook_dsc_t hook_dsc; @@ -636,8 +636,8 @@ static lv_draw_res_t lv_btnmatrix_draw(lv_obj_t * obj, const lv_area_t * clip_ar /*Set up the draw descriptors*/ if(btn_state == LV_STATE_DEFAULT) { - _lv_memcpy(&draw_rect_dsc_act, &draw_rect_def_default, sizeof(lv_draw_rect_dsc_t)); - _lv_memcpy(&draw_label_dsc_act, &draw_label_def_default, sizeof(lv_draw_label_dsc_t)); + lv_memcpy(&draw_rect_dsc_act, &draw_rect_def_default, sizeof(lv_draw_rect_dsc_t)); + lv_memcpy(&draw_label_dsc_act, &draw_label_def_default, sizeof(lv_draw_label_dsc_t)); } /*In other cases get the styles directly without caching them*/ else { @@ -698,7 +698,7 @@ static lv_draw_res_t lv_btnmatrix_draw(lv_obj_t * obj, const lv_area_t * clip_ar obj->style_list.skip_trans = 0; #if LV_USE_ARABIC_PERSIAN_CHARS - _lv_mem_buf_release(txt_ap); + lv_mem_buf_release(txt_ap); #endif } else if(mode == LV_DRAW_MODE_POST_DRAW) { @@ -921,7 +921,7 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * obj, lv_signal_t sign, void * par lv_obj_invalidate(obj); } else if(c == LV_KEY_DOWN) { - lv_coord_t col_gap = LV_MATH_MAX(lv_obj_get_style_margin_left(obj, LV_BTNMATRIX_PART_BTN), lv_obj_get_style_margin_right(obj, LV_BTNMATRIX_PART_BTN)); + lv_coord_t col_gap = LV_MAX(lv_obj_get_style_margin_left(obj, LV_BTNMATRIX_PART_BTN), lv_obj_get_style_margin_right(obj, LV_BTNMATRIX_PART_BTN)); /*Find the area below the the current*/ if(btnm->btn_id_focused == LV_BTNMATRIX_BTN_NONE) { @@ -948,7 +948,7 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * obj, lv_signal_t sign, void * par lv_obj_invalidate(obj); } else if(c == LV_KEY_UP) { - lv_coord_t col_gap = LV_MATH_MAX(lv_obj_get_style_margin_left(obj, LV_BTNMATRIX_PART_BTN), lv_obj_get_style_margin_right(obj, LV_BTNMATRIX_PART_BTN)); + lv_coord_t col_gap = LV_MAX(lv_obj_get_style_margin_left(obj, LV_BTNMATRIX_PART_BTN), lv_obj_get_style_margin_right(obj, LV_BTNMATRIX_PART_BTN)); /*Find the area below the the current*/ if(btnm->btn_id_focused == LV_BTNMATRIX_BTN_NONE) { btnm->btn_id_focused = 0; @@ -1021,7 +1021,7 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * obj, const char ** LV_ASSERT_MEM(btnm->ctrl_bits); if(btnm->button_areas == NULL || btnm->ctrl_bits == NULL) btn_cnt = 0; - _lv_memset_00(btnm->ctrl_bits, sizeof(lv_btnmatrix_ctrl_t) * btn_cnt); + lv_memset_00(btnm->ctrl_bits, sizeof(lv_btnmatrix_ctrl_t) * btn_cnt); btnm->btn_cnt = btn_cnt; } @@ -1094,25 +1094,25 @@ static uint16_t get_button_from_point(lv_obj_t * obj, lv_point_t * p) prow = (prow / 2) + 1 + (prow & 1); pcol = (pcol / 2) + 1 + (pcol & 1); - prow = LV_MATH_MIN(prow, BTN_EXTRA_CLICK_AREA_MAX); - pcol = LV_MATH_MIN(pcol, BTN_EXTRA_CLICK_AREA_MAX); - pright = LV_MATH_MIN(pright, BTN_EXTRA_CLICK_AREA_MAX); - ptop = LV_MATH_MIN(ptop, BTN_EXTRA_CLICK_AREA_MAX); - pbottom = LV_MATH_MIN(pbottom, BTN_EXTRA_CLICK_AREA_MAX); + prow = LV_MIN(prow, BTN_EXTRA_CLICK_AREA_MAX); + pcol = LV_MIN(pcol, BTN_EXTRA_CLICK_AREA_MAX); + pright = LV_MIN(pright, BTN_EXTRA_CLICK_AREA_MAX); + ptop = LV_MIN(ptop, BTN_EXTRA_CLICK_AREA_MAX); + pbottom = LV_MIN(pbottom, BTN_EXTRA_CLICK_AREA_MAX); for(i = 0; i < btnm->btn_cnt; i++) { lv_area_copy(&btn_area, &btnm->button_areas[i]); - if(btn_area.x1 <= pleft) btn_area.x1 += obj_cords.x1 - LV_MATH_MIN(pleft, BTN_EXTRA_CLICK_AREA_MAX); + if(btn_area.x1 <= pleft) btn_area.x1 += obj_cords.x1 - LV_MIN(pleft, BTN_EXTRA_CLICK_AREA_MAX); else btn_area.x1 += obj_cords.x1 - pcol; - if(btn_area.y1 <= ptop) btn_area.y1 += obj_cords.y1 - LV_MATH_MIN(ptop, BTN_EXTRA_CLICK_AREA_MAX); + if(btn_area.y1 <= ptop) btn_area.y1 += obj_cords.y1 - LV_MIN(ptop, BTN_EXTRA_CLICK_AREA_MAX); else btn_area.y1 += obj_cords.y1 - prow; - if(btn_area.x2 >= w - pright - 2) btn_area.x2 += obj_cords.x1 + LV_MATH_MIN(pright, + if(btn_area.x2 >= w - pright - 2) btn_area.x2 += obj_cords.x1 + LV_MIN(pright, BTN_EXTRA_CLICK_AREA_MAX); /*-2 for rounding error*/ else btn_area.x2 += obj_cords.x1 + pcol; - if(btn_area.y2 >= h - pbottom - 2) btn_area.y2 += obj_cords.y1 + LV_MATH_MIN(pbottom, + if(btn_area.y2 >= h - pbottom - 2) btn_area.y2 += obj_cords.y1 + LV_MIN(pbottom, BTN_EXTRA_CLICK_AREA_MAX); /*-2 for rounding error*/ else btn_area.y2 += obj_cords.y1 + prow; diff --git a/src/lv_widgets/lv_canvas.c b/src/lv_widgets/lv_canvas.c index 3177351cf..081ee88dd 100644 --- a/src/lv_widgets/lv_canvas.c +++ b/src/lv_widgets/lv_canvas.c @@ -219,7 +219,7 @@ void lv_canvas_copy_buf(lv_obj_t * obj, const void * to_copy, lv_coord_t x, lv_c uint8_t * to_copy8 = (uint8_t *)to_copy; lv_coord_t i; for(i = 0; i < h; i++) { - _lv_memcpy((void *)&canvas->dsc.data[px], to_copy8, w * px_size); + lv_memcpy((void *)&canvas->dsc.data[px], to_copy8, w * px_size); px += canvas->dsc.header.w * px_size; to_copy8 += w * px_size; } @@ -383,7 +383,7 @@ void lv_canvas_blur_hor(lv_obj_t * obj, const lv_area_t * area, uint16_t r) bool has_alpha = lv_img_cf_has_alpha(canvas->dsc.header.cf); lv_coord_t line_w = lv_img_buf_get_img_size(canvas->dsc.header.w, 1, canvas->dsc.header.cf); - uint8_t * line_buf = _lv_mem_buf_get(line_w); + uint8_t * line_buf = lv_mem_buf_get(line_w); lv_img_dsc_t line_img; line_img.data = line_buf; @@ -404,7 +404,7 @@ void lv_canvas_blur_hor(lv_obj_t * obj, const lv_area_t * area, uint16_t r) lv_color_t c; lv_opa_t opa = LV_OPA_TRANSP; - _lv_memcpy(line_buf, &canvas->dsc.data[y * line_w], line_w); + lv_memcpy(line_buf, &canvas->dsc.data[y * line_w], line_w); for(x = a.x1 - r_back; x <= a.x1 + r_front; x++) { @@ -476,7 +476,7 @@ void lv_canvas_blur_hor(lv_obj_t * obj, const lv_area_t * area, uint16_t r) } lv_obj_invalidate(obj); - _lv_mem_buf_release(line_buf); + lv_mem_buf_release(line_buf); } @@ -518,7 +518,7 @@ void lv_canvas_blur_ver(lv_obj_t * obj, const lv_area_t * area, uint16_t r) bool has_alpha = lv_img_cf_has_alpha(canvas->dsc.header.cf); lv_coord_t col_w = lv_img_buf_get_img_size(1, canvas->dsc.header.h, canvas->dsc.header.cf); - uint8_t * col_buf = _lv_mem_buf_get(col_w); + uint8_t * col_buf = lv_mem_buf_get(col_w); lv_img_dsc_t line_img; line_img.data = col_buf; @@ -616,7 +616,7 @@ void lv_canvas_blur_ver(lv_obj_t * obj, const lv_area_t * area, uint16_t r) lv_obj_invalidate(obj); - _lv_mem_buf_release(col_buf); + lv_mem_buf_release(col_buf); } /** @@ -634,11 +634,11 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t 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); + 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); + lv_memset((uint8_t *)dsc->data, opa > LV_OPA_50 ? 0xff : 0x00, row_byte_cnt * dsc->header.h); } else { uint32_t x; @@ -690,7 +690,7 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord coords.y2 = y + h - 1; lv_disp_t disp; - _lv_memset_00(&disp, sizeof(lv_disp_t)); + lv_memset_00(&disp, sizeof(lv_disp_t)); lv_disp_buf_t disp_buf; lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); @@ -760,7 +760,7 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord coords.y2 = dsc->header.h - 1; lv_disp_t disp; - _lv_memset_00(&disp, sizeof(lv_disp_t)); + lv_memset_00(&disp, sizeof(lv_disp_t)); lv_disp_buf_t disp_buf; lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); @@ -824,7 +824,7 @@ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const voi coords.y2 = y + header.h - 1; lv_disp_t disp; - _lv_memset_00(&disp, sizeof(lv_disp_t)); + lv_memset_00(&disp, sizeof(lv_disp_t)); lv_disp_buf_t disp_buf; lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); @@ -875,7 +875,7 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t mask.y2 = dsc->header.h - 1; lv_disp_t disp; - _lv_memset_00(&disp, sizeof(lv_disp_t)); + lv_memset_00(&disp, sizeof(lv_disp_t)); lv_disp_buf_t disp_buf; lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); @@ -939,7 +939,7 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32 mask.y2 = dsc->header.h - 1; lv_disp_t disp; - _lv_memset_00(&disp, sizeof(lv_disp_t)); + lv_memset_00(&disp, sizeof(lv_disp_t)); lv_disp_buf_t disp_buf; lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); @@ -1003,7 +1003,7 @@ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_ mask.y2 = dsc->header.h - 1; lv_disp_t disp; - _lv_memset_00(&disp, sizeof(lv_disp_t)); + lv_memset_00(&disp, sizeof(lv_disp_t)); lv_disp_buf_t disp_buf; lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); @@ -1044,6 +1044,8 @@ static void lv_canvas_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ob { LV_LOG_TRACE("canvas create started"); + lv_obj_construct_base(obj, parent, copy); + lv_canvas_t * canvas = (lv_canvas_t *) obj; /*Initialize the allocated 'ext' */ diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index e63c64f1c..1b90dd73b 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -47,8 +47,8 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area); static void draw_series_column(lv_obj_t * obj, const lv_area_t * clip_area); static void draw_cursors(lv_obj_t * obj, const lv_area_t * clip_area); static void draw_axes(lv_obj_t * obj, const lv_area_t * mask); -static void invalidate_lines(lv_obj_t * obj, uint16_t i); -static void invalidate_columns(lv_obj_t * obj, uint16_t i); +static uint32_t get_index_from_x(lv_obj_t * obj, lv_coord_t x); +static void invalidate_point(lv_obj_t * obj, uint16_t i); /********************** * STATIC VARIABLES @@ -392,8 +392,7 @@ void lv_chart_set_next(lv_obj_t * obj, lv_chart_series_t * ser, lv_coord_t y) else if(chart->update_mode == LV_CHART_UPDATE_MODE_CIRCULAR) { ser->points[ser->start_point] = y; - if(chart->type & LV_CHART_TYPE_LINE) invalidate_lines(obj, ser->start_point); - if(chart->type & LV_CHART_TYPE_COLUMN) invalidate_columns(obj, ser->start_point); + invalidate_point(obj, ser->start_point); ser->start_point = (ser->start_point + 1) % chart->point_cnt; /*update the x for next incoming y*/ } @@ -625,25 +624,6 @@ lv_point_t lv_chart_get_cursor_point(lv_obj_t * obj, lv_chart_cursor_t * cursor) return cursor->point; } -/** - * Get the nearest index to an X coordinate - * @param chart pointer to a chart object - * @param coord the coordination of the point relative to the series area. - * @return the found index - */ -uint16_t lv_chart_get_nearest_index_from_coord(lv_obj_t * obj, lv_coord_t x) -{ - lv_coord_t w = lv_obj_get_width(obj); - lv_chart_t * chart = (lv_chart_t *)obj; - - if(x < 0) return 0; - if(x > w) return chart->point_cnt - 1; - if(chart->type == LV_CHART_TYPE_LINE) return (x * (chart->point_cnt - 1) + w / 2) / w; - if(chart->type == LV_CHART_TYPE_COLUMN) return (x * chart->point_cnt) / w; - - return 0; -} - /** * Get the x coordinate of the an index with respect * to the origin of series area of the chart. @@ -777,8 +757,8 @@ static void lv_chart_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj chart->hdiv_cnt = chart_copy->hdiv_cnt; chart->vdiv_cnt = chart_copy->vdiv_cnt; chart->point_cnt = chart_copy->point_cnt; - _lv_memcpy_small(chart->ymin, chart_copy->ymin, sizeof(chart->ymin)); - _lv_memcpy_small(chart->ymax, chart_copy->ymax, sizeof(chart->ymax)); + lv_memcpy_small(chart->ymin, chart_copy->ymin, sizeof(chart->ymin)); + lv_memcpy_small(chart->ymax, chart_copy->ymax, sizeof(chart->ymax)); } LV_LOG_INFO("chart created"); } @@ -832,7 +812,8 @@ static lv_draw_res_t lv_chart_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_t * chart = (lv_chart_t *)obj; if(chart->type & LV_CHART_TYPE_LINE) draw_series_line(obj, clip_area); - if(chart->type & LV_CHART_TYPE_COLUMN) draw_series_column(obj, clip_area); + else if(chart->type & LV_CHART_TYPE_COLUMN) draw_series_column(obj, clip_area); + draw_cursors(obj, clip_area); } else if(mode == LV_DRAW_MODE_POST_DRAW) { @@ -861,7 +842,22 @@ static lv_res_t lv_chart_signal(lv_obj_t * obj, lv_signal_t sign, void * param) p->y = (lv_obj_get_height(obj) * chart->y_zoom) >> 8; } else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { lv_coord_t * s = param; - *s = LV_MATH_MAX(*s, chart->ext_size); + *s = LV_MAX(*s, chart->ext_size); + } else if(sign == LV_SIGNAL_PRESSING) { + lv_indev_t * indev = lv_indev_get_act(); + lv_point_t p; + lv_indev_get_point(indev, &p); + + p.x -= obj->coords.x1; + uint32_t id = get_index_from_x(obj, p.x); + if(id != chart->pressed_point_id) { + invalidate_point(obj, id); + invalidate_point(obj, chart->pressed_point_id); + chart->pressed_point_id = id; + } + } else if(sign == LV_SIGNAL_PRESSING) { + invalidate_point(obj, chart->pressed_point_id); + chart->pressed_point_id = -1; } return res; @@ -939,45 +935,33 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area) bool mask_ret = _lv_area_intersect(&series_mask, &obj->coords, clip_area); if(mask_ret == false) return; - lv_draw_line_dsc_t line_dsc; - lv_draw_line_dsc_init(&line_dsc); - lv_obj_init_draw_line_dsc(obj, LV_PART_ITEMS, &line_dsc); + lv_state_t state_ori = obj->state; + obj->state = LV_STATE_DEFAULT; + lv_draw_line_dsc_t line_dsc_default; + lv_draw_line_dsc_init(&line_dsc_default); + lv_obj_init_draw_line_dsc(obj, LV_PART_ITEMS, &line_dsc_default); - lv_draw_mask_fade_param_t mask_fade_p; - int16_t mask_fade_id = LV_MASK_ID_INV; - lv_draw_rect_dsc_t area_dsc; - bool has_area = lv_obj_get_style_bg_opa(obj, LV_PART_ITEMS) > LV_OPA_MIN ? true : false; - bool has_fade = false; - if(has_area) { - lv_draw_rect_dsc_init(&area_dsc); - lv_obj_init_draw_rect_dsc(obj, LV_PART_ITEMS, &area_dsc); - area_dsc.border_width = 0; + lv_draw_rect_dsc_t point_dsc_default; + lv_draw_rect_dsc_init(&point_dsc_default); + point_dsc_default.radius = LV_RADIUS_CIRCLE; - has_fade = area_dsc.bg_grad_dir == LV_GRAD_DIR_VER ? true : false; - if(has_fade) { - lv_draw_mask_fade_init(&mask_fade_p, &obj->coords, area_dsc.bg_main_color_stop, obj->coords.y1, - area_dsc.bg_grad_color_stop, obj->coords.y2); - } - } + lv_coord_t point_size = lv_obj_get_style_size(obj, LV_PART_ITEMS); - lv_draw_rect_dsc_t point_dsc; - lv_draw_rect_dsc_init(&point_dsc); - point_dsc.bg_opa = line_dsc.opa; - point_dsc.radius = LV_RADIUS_CIRCLE; + obj->state = LV_STATE_PRESSED; + lv_coord_t point_size_pr = lv_obj_get_style_size(obj, LV_PART_ITEMS); + obj->state = state_ori; - lv_coord_t point_radius = 5;//lv_obj_get_style_size(obj, LV_PART_ITEMS); + lv_coord_t point_size_act; /*Do not bother with line ending is the point will over it*/ - if(point_radius > line_dsc.width / 2) line_dsc.raw_end = 1; + if(point_size > line_dsc_default.width / 2) line_dsc_default.raw_end = 1; /*Go through all data lines*/ _LV_LL_READ_BACK(&chart->series_ll, ser) { if (ser->hidden) continue; - line_dsc.color = ser->color; - point_dsc.bg_color = ser->color; - area_dsc.bg_color = ser->color; - area_dsc.bg_grad_color = ser->color; + line_dsc_default.color = ser->color; + point_dsc_default.bg_color = ser->color; lv_coord_t start_point = chart->update_mode == LV_CHART_UPDATE_MODE_SHIFT ? ser->start_point : 0; @@ -990,11 +974,19 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area) y_tmp = y_tmp / (chart->ymax[ser->y_axis] - chart->ymin[ser->y_axis]); p2.y = h - y_tmp + y_ofs; + lv_obj_draw_hook_dsc_t hook_dsc; + lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area); + hook_dsc.part = LV_PART_ITEMS; + hook_dsc.line_dsc = &line_dsc_default; + hook_dsc.rect_dsc = &point_dsc_default; + for(i = 0; i < chart->point_cnt; i++) { p1.x = p2.x; p1.y = p2.y; - if(p1.x > obj->coords.x2 + point_radius) break; + point_size_act = p_act == chart->pressed_point_id ? point_size_pr : point_size; + + if(p1.x > clip_area->x2 + point_size_act) break; p2.x = ((w * i) / (chart->point_cnt - 1)) + x_ofs; p_act = (start_point + i) % chart->point_cnt; @@ -1003,67 +995,53 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area) y_tmp = y_tmp / (chart->ymax[ser->y_axis] - chart->ymin[ser->y_axis]); p2.y = h - y_tmp + y_ofs; - if(p2.x < obj->coords.x1 - point_radius) continue; + if(p2.x < clip_area->x1 - point_size_act) continue; + + hook_dsc.id = p_act; + hook_dsc.p1 = &p1; + hook_dsc.p2 = &p2; + + lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc); /*Don't draw the first point. A second point is also required to draw the line*/ if(i != 0 && ser->points[p_prev] != LV_CHART_POINT_DEF && ser->points[p_act] != LV_CHART_POINT_DEF) { - lv_draw_line(&p1, &p2, &series_mask, &line_dsc); - - lv_coord_t y_top = LV_MATH_MIN(p1.y, p2.y); - if(has_area && y_top <= clip_area->y2) { - int16_t mask_line_id; - lv_draw_mask_line_param_t mask_line_p; - lv_draw_mask_line_points_init(&mask_line_p, p1.x, p1.y, p2.x, p2.y, LV_DRAW_MASK_LINE_SIDE_BOTTOM); - mask_line_id = lv_draw_mask_add(&mask_line_p, NULL); - - lv_area_t a; - a.x1 = p1.x; - a.x2 = p2.x - 1; - a.y1 = y_top; - a.y2 = obj->coords.y2; - - if(has_fade) mask_fade_id = lv_draw_mask_add(&mask_fade_p, NULL); - - lv_draw_rect(&a, &series_mask, &area_dsc); - - lv_draw_mask_remove_id(mask_line_id); - lv_draw_mask_remove_id(mask_fade_id); - } + lv_draw_line(&p1, &p2, &series_mask, &line_dsc_default); } - if(point_radius) { + if(point_size_act) { lv_area_t point_area; point_area.x1 = p1.x; - point_area.x2 = point_area.x1 + point_radius; - point_area.x1 -= point_radius; + point_area.x2 = point_area.x1 + point_size_act; + point_area.x1 -= point_size_act; point_area.y1 = p1.y; - point_area.y2 = point_area.y1 + point_radius; - point_area.y1 -= point_radius; + point_area.y2 = point_area.y1 + point_size_act; + point_area.y1 -= point_size_act; if(ser->points[p_act] != LV_CHART_POINT_DEF) { - lv_draw_rect(&point_area, &series_mask, &point_dsc); + lv_draw_rect(&point_area, &series_mask, &point_dsc_default); } } + lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc); p_prev = p_act; } /*Draw the last point*/ - if(point_radius) { + if(point_size) { lv_area_t point_area; point_area.x1 = p2.x; - point_area.x2 = point_area.x1 + point_radius; - point_area.x1 -= point_radius; + point_area.x2 = point_area.x1 + point_size; + point_area.x1 -= point_size; point_area.y1 = p2.y; - point_area.y2 = point_area.y1 + point_radius; - point_area.y1 -= point_radius; + point_area.y2 = point_area.y1 + point_size; + point_area.y1 -= point_size; if(ser->points[p_act] != LV_CHART_POINT_DEF) { - lv_draw_rect(&point_area, &series_mask, &point_dsc); + lv_draw_rect(&point_area, &series_mask, &point_dsc_default); } } } @@ -1164,7 +1142,7 @@ static void draw_cursors(lv_obj_t * obj, const lv_area_t * clip_area) point_dsc.bg_opa = line_dsc.opa; point_dsc.radius = LV_RADIUS_CIRCLE; - lv_coord_t point_radius = 5;//lv_obj_get_style_size(chart, LV_PART_CURSOR); + lv_coord_t point_radius = lv_obj_get_style_size(chart, LV_PART_CURSOR); /*Do not bother with line ending is the point will over it*/ if(point_radius > line_dsc.width / 2) line_dsc.raw_end = 1; @@ -1403,64 +1381,76 @@ static void draw_axes(lv_obj_t * obj, const lv_area_t * mask) draw_y_ticks(obj, mask, LV_CHART_AXIS_SECONDARY_Y); draw_x_ticks(obj, mask); } +/** + * Get the nearest index to an X coordinate + * @param chart pointer to a chart object + * @param coord the coordination of the point relative to the series area. + * @return the found index + */ +static uint32_t get_index_from_x(lv_obj_t * obj, lv_coord_t x) +{ + lv_coord_t w = lv_obj_get_width(obj); + lv_chart_t * chart = (lv_chart_t *)obj; + + if(x < 0) return 0; + if(x > w) return chart->point_cnt - 1; + if(chart->type == LV_CHART_TYPE_LINE) return (x * (chart->point_cnt - 1) + w / 2) / w; + if(chart->type == LV_CHART_TYPE_COLUMN) return (x * chart->point_cnt) / w; + + return 0; +} /** * invalid area of the new line data lines on a chart * @param obj pointer to chart object */ -static void invalidate_lines(lv_obj_t * obj, uint16_t i) +static void invalidate_point(lv_obj_t * obj, uint16_t i) { lv_chart_t * chart = (lv_chart_t *)obj; if(i >= chart->point_cnt) return; + lv_coord_t w = lv_obj_get_width(obj); - lv_coord_t x_ofs = obj->coords.x1; + if(chart->type == LV_CHART_TYPE_LINE) { + lv_coord_t x_ofs = obj->coords.x1; - lv_coord_t line_width = lv_obj_get_style_line_width(obj, LV_PART_ITEMS); - lv_coord_t point_radius = 5;//lv_obj_get_style_size(chart, LV_PART_ITEMS); + lv_coord_t line_width = lv_obj_get_style_line_width(obj, LV_PART_ITEMS); + lv_coord_t point_radius = lv_obj_get_style_size(obj, LV_PART_ITEMS); - lv_area_t coords; - lv_area_copy(&coords, &obj->coords); - coords.y1 -= line_width + point_radius; - coords.y2 += line_width + point_radius; + lv_area_t coords; + lv_area_copy(&coords, &obj->coords); + coords.y1 -= line_width + point_radius; + coords.y2 += line_width + point_radius; - if(i < chart->point_cnt - 1) { - coords.x1 = ((w * i) / (chart->point_cnt - 1)) + x_ofs - line_width - point_radius; - coords.x2 = ((w * (i + 1)) / (chart->point_cnt - 1)) + x_ofs + line_width + point_radius; - lv_obj_invalidate_area(obj, &coords); + if(i < chart->point_cnt - 1) { + coords.x1 = ((w * i) / (chart->point_cnt - 1)) + x_ofs - line_width - point_radius; + coords.x2 = ((w * (i + 1)) / (chart->point_cnt - 1)) + x_ofs + line_width + point_radius; + lv_obj_invalidate_area(obj, &coords); + } + + if(i > 0) { + coords.x1 = ((w * (i - 1)) / (chart->point_cnt - 1)) + x_ofs - line_width - point_radius; + coords.x2 = ((w * i) / (chart->point_cnt - 1)) + x_ofs + line_width + point_radius; + lv_obj_invalidate_area(obj, &coords); + } } + else if(chart->type == LV_CHART_TYPE_COLUMN) { + lv_area_t col_a; + lv_coord_t col_w = w / ((_lv_ll_get_len(&chart->series_ll) + 1) * chart->point_cnt); /* Suppose + 1 series as separator*/ + lv_coord_t x_ofs = col_w / 2; /*Shift with a half col.*/ - if(i > 0) { - coords.x1 = ((w * (i - 1)) / (chart->point_cnt - 1)) + x_ofs - line_width - point_radius; - coords.x2 = ((w * i) / (chart->point_cnt - 1)) + x_ofs + line_width + point_radius; - lv_obj_invalidate_area(obj, &coords); + lv_coord_t x_act; + x_act = (int32_t)((int32_t)w * i) / chart->point_cnt; + x_act += obj->coords.x1 + x_ofs; + + lv_obj_get_coords(obj, &col_a); + col_a.x1 = x_act; + col_a.x2 = col_a.x1 + col_w; + + _lv_inv_area(lv_obj_get_disp(obj), &col_a); + } else { + lv_obj_invalidate(chart); } } - -/** - * invalid area of the new column data lines on a chart - * @param chart pointer to chart object - * @param mask mask, inherited from the draw function - */ -static void invalidate_columns(lv_obj_t * obj, uint16_t i) -{ - lv_chart_t * chart = (lv_chart_t *)obj; - - lv_area_t col_a; - lv_coord_t w = lv_obj_get_width(obj); - lv_coord_t col_w = w / ((_lv_ll_get_len(&chart->series_ll) + 1) * chart->point_cnt); /* Suppose + 1 series as separator*/ - lv_coord_t x_ofs = col_w / 2; /*Shift with a half col.*/ - - lv_coord_t x_act; - x_act = (int32_t)((int32_t)w * i) / chart->point_cnt; - x_act += obj->coords.x1 + x_ofs; - - lv_obj_get_coords(obj, &col_a); - col_a.x1 = x_act; - col_a.x2 = col_a.x1 + col_w; - - _lv_inv_area(lv_obj_get_disp(obj), &col_a); -} - #endif diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index 04e321c7e..c477b2155 100644 --- a/src/lv_widgets/lv_chart.h +++ b/src/lv_widgets/lv_chart.h @@ -83,6 +83,7 @@ typedef struct { lv_coord_t ymin[2]; lv_coord_t ymax[2]; lv_coord_t ext_size; + int32_t pressed_point_id; uint8_t hdiv_cnt; /*Number of horizontal division lines*/ uint8_t vdiv_cnt; /*Number of vertical division lines*/ uint8_t sub_tick_cnt[_LV_CHART_AXIS_LAST]; diff --git a/src/lv_widgets/lv_checkbox.c b/src/lv_widgets/lv_checkbox.c index 94b0c6817..638214b49 100644 --- a/src/lv_widgets/lv_checkbox.c +++ b/src/lv_widgets/lv_checkbox.c @@ -219,6 +219,7 @@ static lv_draw_res_t lv_checkbox_draw(lv_obj_t * obj, const lv_area_t * clip_are marker_area_transf.x2 += transf_w; marker_area_transf.y1 -= transf_h; marker_area_transf.y2 += transf_h; + lv_draw_rect(&marker_area_transf, clip_area, &marker_dsc); lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); @@ -239,7 +240,6 @@ static lv_draw_res_t lv_checkbox_draw(lv_obj_t * obj, const lv_area_t * clip_are txt_area.y2 = txt_area.y1 + txt_size.y; lv_draw_label(&txt_area, clip_area, &txt_dsc, cb->txt, NULL); - } else { lv_obj.draw_cb(obj, clip_area, mode); } @@ -283,12 +283,12 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * obj, lv_signal_t sign, void * para marker_size.y = font_h + marker_topp + marker_bottomp; p->x = marker_size.x + txt_size.x + bg_colp; - p->y = LV_MATH_MAX(marker_size.y, txt_size.y); + p->y = LV_MAX(marker_size.y, txt_size.y); } else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { lv_coord_t *s = param; lv_coord_t m = _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_MARKER); - *s = LV_MATH_MAX(*s, m); + *s = LV_MAX(*s, m); } return res; diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index 4fd4cd007..26350ef9e 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -41,10 +41,13 @@ * STATIC PROTOTYPES **********************/ static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); -static void lv_dropdown_destructor(void * obj); +static void lv_dropdown_destructor(lv_obj_t * obj); static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); -static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_dropdown_signal(lv_obj_t * obj, lv_signal_t sign, void * param); + +static void lv_dropdown_list_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_dropdown_list_destructor(lv_obj_t * obj); +static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_dropdown_list_signal(lv_obj_t * list, lv_signal_t sign, void * param); static void draw_box(lv_obj_t * dropdown_obj, const lv_area_t * clip_area, uint16_t id, lv_state_t state); static void draw_box_label(lv_obj_t * dropdown_obj, const lv_area_t * clip_area, uint16_t id, lv_state_t state); @@ -57,8 +60,23 @@ static lv_obj_t * get_label(const lv_obj_t * obj); /********************** * STATIC VARIABLES **********************/ -lv_dropdown_class_t lv_dropdown; -lv_dropdown_list_class_t lv_dropdown_list; +const lv_obj_class_t lv_dropdown = { + .constructor = lv_dropdown_constructor, + .destructor = lv_dropdown_destructor, + .signal_cb = lv_dropdown_signal, + .draw_cb = lv_dropdown_draw, + .instance_size = sizeof(lv_dropdown_t), + .base_class = &lv_obj +}; + +const lv_obj_class_t lv_dropdown_list = { + .constructor = lv_dropdown_list_constructor, + .destructor = lv_dropdown_list_destructor, + .signal_cb = lv_dropdown_list_signal, + .draw_cb = lv_dropdown_list_draw, + .instance_size = sizeof(lv_dropdown_list_t), + .base_class = &lv_obj +}; /********************** @@ -78,20 +96,7 @@ lv_dropdown_list_class_t lv_dropdown_list; */ lv_obj_t * lv_dropdown_create(lv_obj_t * parent, const lv_obj_t * copy) { - if(!lv_dropdown._inited) { - LV_CLASS_INIT(lv_dropdown, lv_obj); - lv_dropdown.constructor = lv_dropdown_constructor; - lv_dropdown.destructor = lv_dropdown_destructor; - lv_dropdown.draw_cb = lv_dropdown_draw; - lv_dropdown.signal_cb = lv_dropdown_signal; - } - - lv_obj_t * obj = lv_class_new(&lv_dropdown); - lv_dropdown.constructor(obj, parent, copy); - - lv_obj_create_finish(obj, parent, copy); - - return obj; + return lv_obj_create_from_class(&lv_dropdown, parent, copy); } /*===================== @@ -273,7 +278,7 @@ void lv_dropdown_add_option(lv_obj_t * obj, const char * option, uint32_t pos) _lv_txt_ins(dropdown->options, _lv_txt_encoded_get_char_id(dropdown->options, insert_pos++), "\n"); /*Insert the new option, adding \n if necessary*/ - char * ins_buf = _lv_mem_buf_get(ins_len + 2); /* + 2 for terminating NULL and possible \n */ + char * ins_buf = lv_mem_buf_get(ins_len + 2); /* + 2 for terminating NULL and possible \n */ LV_ASSERT_MEM(ins_buf); if(ins_buf == NULL) return; #if LV_USE_ARABIC_PERSIAN_CHARS == 0 @@ -284,7 +289,7 @@ void lv_dropdown_add_option(lv_obj_t * obj, const char * option, uint32_t pos) if(pos < dropdown->option_cnt) strcat(ins_buf, "\n"); _lv_txt_ins(dropdown->options, _lv_txt_encoded_get_char_id(dropdown->options, insert_pos), ins_buf); - _lv_mem_buf_release(ins_buf); + lv_mem_buf_release(ins_buf); dropdown->option_cnt++; @@ -346,7 +351,7 @@ void lv_dropdown_set_max_height(lv_obj_t * obj, lv_coord_t h) * @param ddlist pointer to drop down list object * @param symbol a text like `LV_SYMBOL_DOWN` or NULL to not draw icon */ -void lv_dropdown_set_symbol(lv_obj_t * obj, const char * symbol) +void lv_dropdown_set_symbol(lv_obj_t * obj, const void * symbol) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); @@ -524,27 +529,27 @@ void lv_dropdown_open(lv_obj_t * dropdown_obj) lv_dir_t dir = dropdown->dir; /*No space on the bottom? See if top is better.*/ if(dropdown->dir == LV_DIR_BOTTOM) { - if(dropdown->coords.y2 + list_h > LV_VER_RES) { - if(dropdown->coords.y1 > LV_VER_RES - dropdown->coords.y2) { + if(dropdown_obj->coords.y2 + list_h > LV_VER_RES) { + if(dropdown_obj->coords.y1 > LV_VER_RES - dropdown_obj->coords.y2) { /*There is more space on the top, so make it drop up*/ dir = LV_DIR_TOP; - list_h = dropdown->coords.y1; + list_h = dropdown_obj->coords.y1; } else { - list_h = LV_VER_RES - dropdown->coords.y2; + list_h = LV_VER_RES - dropdown_obj->coords.y2; } } } /*No space on the top? See if bottom is better.*/ else if(dropdown->dir == LV_DIR_TOP) { - if(dropdown->coords.y1 - list_h < 0) { - if(dropdown->coords.y1 < LV_VER_RES - dropdown->coords.y2) { + if(dropdown_obj->coords.y1 - list_h < 0) { + if(dropdown_obj->coords.y1 < LV_VER_RES - dropdown_obj->coords.y2) { /*There is more space on the top, so make it drop up*/ dir = LV_DIR_BOTTOM; - list_h = LV_VER_RES - dropdown->coords.y2; + list_h = LV_VER_RES - dropdown_obj->coords.y2; } else { - list_h = dropdown->coords.y1; + list_h = dropdown_obj->coords.y1; } } } @@ -567,8 +572,19 @@ void lv_dropdown_open(lv_obj_t * dropdown_obj) } } - if(lv_label_get_align(label) == LV_TEXT_ALIGN_RIGHT) { + lv_text_align_t align = lv_obj_get_style_text_align(label, LV_PART_MAIN); + switch(align) { + default: + case LV_TEXT_ALIGN_LEFT: + lv_obj_set_x(label, 0); + break; + case LV_TEXT_ALIGN_RIGHT: lv_obj_set_x(label, lv_obj_get_width_fit(dropdown->list) - lv_obj_get_width(label)); + break; + case LV_TEXT_ALIGN_CENTER: + lv_obj_set_x(label, lv_obj_get_width_fit(dropdown->list) / 2 - lv_obj_get_width(label) / 2); + break; + } } @@ -597,31 +613,14 @@ void lv_dropdown_close(lv_obj_t * obj) */ lv_obj_t * lv_dropdown_list_create(lv_obj_t * parent, const lv_obj_t * copy) { - if(!lv_dropdown_list._inited) { - LV_CLASS_INIT(lv_dropdown_list, lv_obj); - lv_dropdown_list.constructor = lv_obj.constructor; - lv_dropdown_list.destructor = lv_obj.destructor; - lv_dropdown_list.draw_cb = lv_dropdown_list_draw; - lv_dropdown_list.signal_cb = lv_dropdown_list_signal; - } - - lv_obj_t * obj = lv_class_new(&lv_dropdown_list); - lv_dropdown_list.constructor(obj, parent, copy); - - lv_obj_create_finish(obj, parent, copy); - - - lv_obj_t * label = lv_label_create(obj, NULL); - - return obj; + return lv_obj_create_from_class(&lv_dropdown_list, parent, copy); } static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) { LV_LOG_TRACE("dropdown create started"); - LV_CLASS_CONSTRUCTOR_BEGIN(obj, lv_dropdown) - lv_dropdown.base_p->constructor(obj, parent, copy); + lv_obj_construct_base(obj, parent, copy); lv_dropdown_t * dropdown = (lv_dropdown_t *) obj; @@ -642,6 +641,7 @@ static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ ((lv_dropdown_list_t*)list_obj)->dropdown = (lv_obj_t *) dropdown; dropdown->list = list_obj; lv_obj_add_flag(dropdown->list, LV_OBJ_FLAG_HIDDEN); + lv_obj_add_flag(obj, LV_OBJ_FLAG_CHECKABLE); if(copy == NULL) { lv_obj_set_width(obj, LV_DPX(150)); @@ -663,11 +663,10 @@ static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ // dropdown->dir = copy_dropdown->dir; } - LV_CLASS_CONSTRUCTOR_END(obj, lv_switch) LV_LOG_INFO("dropdown created"); } -static void lv_dropdown_destructor(void * obj) +static void lv_dropdown_destructor(lv_obj_t * obj) { // lv_bar_t * bar = obj; // @@ -690,11 +689,11 @@ static void lv_dropdown_destructor(void * obj) static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode) { /*Return false if the object is not covers the mask_p area*/ - if(mode == LV_DRAW_COVER_CHK) { + if(mode == LV_DRAW_MODE_COVER_CHECK) { return lv_obj.draw_cb(obj, clip_area, mode); } /*Draw the object*/ - else if(mode == LV_DRAW_DRAW_MAIN) { + else if(mode == LV_DRAW_MODE_MAIN_DRAW) { lv_obj.draw_cb(obj, clip_area, mode); lv_dropdown_t * dropdown = (lv_dropdown_t *) obj; @@ -707,70 +706,110 @@ static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_are lv_draw_label_dsc_init(&label_dsc); lv_obj_init_draw_label_dsc(obj, LV_PART_MAIN, &label_dsc); - lv_area_t txt_area; - lv_point_t txt_size; - /*If no text specified use the selected option*/ const char * opt_txt; if(dropdown->text) opt_txt = dropdown->text; else { - char * buf = _lv_mem_buf_get(128); + char * buf = lv_mem_buf_get(128); lv_dropdown_get_selected_str(obj, buf, 128); opt_txt = buf; } - const char * txt; + bool symbol_to_left = false; + if(dropdown->dir == LV_DIR_LEFT) symbol_to_left = true; + if(lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL) symbol_to_left = true; - bool rev = false; - if(dropdown->dir == LV_DIR_LEFT) rev = true; - if(lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL) rev = true; - - txt = rev ? dropdown->symbol : opt_txt; - if(txt) { - _lv_txt_get_size(&txt_size, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, - label_dsc.flag); - - txt_area.y1 = obj->coords.y1 + top; - txt_area.y2 = txt_area.y1 + txt_size.y; - - /*Center align the text if no symbol*/ - if(dropdown->symbol == NULL && txt == opt_txt) { - txt_area.x1 = obj->coords.x1 + (lv_obj_get_width(obj) - txt_size.x) / 2; - txt_area.x2 = txt_area.x1 + txt_size.x; + if(dropdown->symbol) { + lv_img_src_t symbol_type = lv_img_src_get_type(dropdown->symbol); + lv_coord_t symbol_w; + lv_coord_t symbol_h; + if(symbol_type == LV_IMG_SRC_SYMBOL) { + lv_point_t size; + _lv_txt_get_size(&size, dropdown->symbol, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, + label_dsc.flag); + symbol_w = size.x; + symbol_h = size.y; + } else { + lv_img_header_t header; + lv_res_t res = lv_img_decoder_get_info(dropdown->symbol, &header); + if(res == LV_RES_OK) { + symbol_w = header.w; + symbol_h = header.h; + } else { + symbol_w = -1; + symbol_h = -1; + } } - else { - txt_area.x1 = obj->coords.x1 + left; - txt_area.x2 = txt_area.x1 + txt_size.x; + + lv_area_t symbol_area; + symbol_area.y1 = obj->coords.y1 + top; + symbol_area.y2 = symbol_area.y1 + symbol_h - 1; + if(symbol_to_left) { + symbol_area.x1 = obj->coords.x1 + left; + symbol_area.x2 = symbol_area.x1 + symbol_w - 1; + } else { + symbol_area.x1 = obj->coords.x2 - right - symbol_w; + symbol_area.x2 = symbol_area.x1 + symbol_w - 1; + } + if(symbol_type == LV_IMG_SRC_SYMBOL) { + lv_draw_label(&symbol_area, clip_area, &label_dsc, dropdown->symbol, NULL); + } else { + lv_draw_img_dsc_t img_dsc; + lv_draw_img_dsc_init(&img_dsc); + lv_obj_init_draw_img_dsc(obj, LV_PART_MAIN, &img_dsc); + img_dsc.pivot.x = symbol_w / 2; + img_dsc.pivot.y = symbol_h / 2; + img_dsc.angle = lv_obj_get_style_transform_angle(obj, LV_PART_MAIN); + lv_draw_img(&symbol_area, clip_area, dropdown->symbol, &img_dsc); } - lv_draw_label(&txt_area, clip_area, &label_dsc, txt, NULL); } - txt = rev ? opt_txt : dropdown->symbol; - if(txt) { - _lv_txt_get_size(&txt_size, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, - label_dsc.flag); - txt_area.y1 = obj->coords.y1 + top; - txt_area.y2 = txt_area.y1 + txt_size.y; - - /*Center align the text if no symbol*/ - if(dropdown->symbol == NULL && txt == opt_txt) { - txt_area.x1 = obj->coords.x1 + (lv_obj_get_width(obj) - txt_size.x) / 2; - txt_area.x2 = txt_area.x1 + txt_size.x; - } - else { - txt_area.x1 = obj->coords.x2 - right - txt_size.x; - txt_area.x2 = txt_area.x1 + txt_size.x; - } - - lv_draw_label(&txt_area, clip_area, &label_dsc, txt, NULL); - } +// txt = rev ? dropdown->symbol : opt_txt; +// if(txt) { +// _lv_txt_get_size(&txt_size, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, +// label_dsc.flag); +// +// txt_area.y1 = obj->coords.y1 + top; +// txt_area.y2 = txt_area.y1 + txt_size.y; +// +// /*Center align the text if no symbol*/ +// if(dropdown->symbol == NULL && txt == opt_txt) { +// txt_area.x1 = obj->coords.x1 + (lv_obj_get_width(obj) - txt_size.x) / 2; +// txt_area.x2 = txt_area.x1 + txt_size.x; +// } +// else { +// txt_area.x1 = obj->coords.x1 + left; +// txt_area.x2 = txt_area.x1 + txt_size.x; +// } +// lv_draw_label(&txt_area, clip_area, &label_dsc, txt, NULL); +// } +// +// txt = rev ? opt_txt : dropdown->symbol; +// if(txt) { +// _lv_txt_get_size(&txt_size, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, +// label_dsc.flag); +// txt_area.y1 = obj->coords.y1 + top; +// txt_area.y2 = txt_area.y1 + txt_size.y; +// +// /*Center align the text if no symbol*/ +// if(dropdown->symbol == NULL && txt == opt_txt) { +// txt_area.x1 = obj->coords.x1 + (lv_obj_get_width(obj) - txt_size.x) / 2; +// txt_area.x2 = txt_area.x1 + txt_size.x; +// } +// else { +// txt_area.x1 = obj->coords.x2 - right - txt_size.x; +// txt_area.x2 = txt_area.x1 + txt_size.x; +// } +// +// lv_draw_label(&txt_area, clip_area, &label_dsc, txt, NULL); +// } if(dropdown->text == NULL) { - _lv_mem_buf_release((char *)opt_txt); + lv_mem_buf_release((char *)opt_txt); } } - else if(mode == LV_DRAW_DRAW_POST) { + else if(mode == LV_DRAW_MODE_POST_DRAW) { lv_obj.draw_cb(obj, clip_area, mode); } @@ -790,11 +829,11 @@ static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_are static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * list_obj, const lv_area_t * clip_area, lv_draw_mode_t mode) { /*Return false if the object is not covers the mask_p area*/ - if(mode == LV_DRAW_COVER_CHK) { + if(mode == LV_DRAW_MODE_COVER_CHECK) { return lv_obj.draw_cb(list_obj, clip_area, mode); } /*Draw the object*/ - else if(mode == LV_DRAW_DRAW_MAIN) { + else if(mode == LV_DRAW_MODE_MAIN_DRAW) { lv_obj.draw_cb(list_obj, clip_area, mode); lv_dropdown_list_t * list = (lv_dropdown_list_t *)list_obj; @@ -818,7 +857,7 @@ static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * list_obj, const lv_area_t } } /*Post draw when the children are drawn*/ - else if(mode == LV_DRAW_DRAW_POST) { + else if(mode == LV_DRAW_MODE_POST_DRAW) { lv_obj.draw_cb(list_obj, clip_area, mode); lv_dropdown_list_t * list = (lv_dropdown_list_t *)list_obj; @@ -845,6 +884,18 @@ static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * list_obj, const lv_area_t return LV_DRAW_RES_OK; } +static void lv_dropdown_list_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +{ + lv_obj_construct_base(obj, parent, copy); + + lv_label_create(obj, NULL); +} + +static void lv_dropdown_list_destructor(lv_obj_t * obj) +{ + +} + /** * Signal function of the drop down list * @param ddlist pointer to a drop down list object @@ -1042,11 +1093,6 @@ static void draw_box_label(lv_obj_t * dropdown_obj, const lv_area_t * clip_area, lv_obj_t * label = get_label(dropdown_obj); if(label == NULL) return; - lv_text_align_t align = lv_label_get_align(label); - - if(align == LV_TEXT_ALIGN_CENTER) label_dsc.flag |= LV_TEXT_FLAG_CENTER; - else if(align == LV_TEXT_ALIGN_RIGHT) label_dsc.flag |= LV_TEXT_FLAG_RIGHT; - lv_coord_t font_h = lv_font_get_line_height(label_dsc.font); lv_area_t area_sel; diff --git a/src/lv_widgets/lv_dropdown.h b/src/lv_widgets/lv_dropdown.h index 34a77a283..1ce6785ee 100644 --- a/src/lv_widgets/lv_dropdown.h +++ b/src/lv_widgets/lv_dropdown.h @@ -34,45 +34,28 @@ extern "C" { * TYPEDEFS **********************/ -LV_CLASS_DECLARE_START(lv_dropdown, lv_obj); +typedef struct { + lv_obj_t obj; + lv_obj_t * list; /*The dropped down list*/ + const char * text; /*Text to display on the ddlist's button*/ + const void * symbol; /*Arrow or other icon when the drop-down list is closed*/ + char * options; + lv_coord_t max_height; /*Height of the ddlist when opened. (0: auto-size)*/ + uint16_t option_cnt; /*Number of options*/ + uint16_t sel_opt_id; /*Index of the currently selected option*/ + uint16_t sel_opt_id_orig; /*Store the original index on focus*/ + uint16_t pr_opt_id; /*Index of the currently pressed option*/ + lv_dir_t dir : 4; + uint8_t static_txt : 1; +}lv_dropdown_t; -#define _lv_dropdown_constructor void (*constructor)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy) - -#define _lv_dropdown_data \ - _lv_obj_data \ - lv_obj_t * list; /*The dropped down list*/ \ - const char * text; /*Text to display on the ddlist's button*/ \ - const char * symbol; /*Arrow or other icon when the drop-down list is closed*/ \ - char * options; \ - lv_coord_t max_height; /*Height of the ddlist when opened. (0: auto-size)*/ \ - uint16_t option_cnt; /*Number of options*/ \ - uint16_t sel_opt_id; /*Index of the currently selected option*/ \ - uint16_t sel_opt_id_orig; /*Store the original index on focus*/ \ - uint16_t pr_opt_id; /*Index of the currently pressed option*/ \ - lv_dir_t dir : 4; \ - uint8_t static_txt : 1; - -#define _lv_dropdown_class_dsc \ - _lv_obj_class_dsc \ - -LV_CLASS_DECLARE_END(lv_dropdown, lv_obj); - -extern lv_dropdown_class_t lv_dropdown; - -LV_CLASS_DECLARE_START(lv_dropdown_list, lv_obj); - -#define _lv_dropdown_list_constructor void (*constructor)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy) - -#define _lv_dropdown_list_data \ - _lv_obj_data \ +typedef struct { + lv_obj_t obj; lv_obj_t * dropdown; +}lv_dropdown_list_t; -#define _lv_dropdown_list_class_dsc \ - _lv_obj_class_dsc \ - -LV_CLASS_DECLARE_END(lv_dropdown_list, lv_obj); - -extern lv_dropdown_list_class_t lv_dropdown_list; +extern const lv_obj_class_t lv_dropdown; +extern const lv_obj_class_t lv_dropdown_list; /********************** * GLOBAL PROTOTYPES @@ -153,7 +136,7 @@ void lv_dropdown_set_max_height(lv_obj_t * ddlist, lv_coord_t h); * @param ddlist pointer to drop down list object * @param symbol a text like `LV_SYMBOL_DOWN` or NULL to not draw icon */ -void lv_dropdown_set_symbol(lv_obj_t * ddlist, const char * symbol); +void lv_dropdown_set_symbol(lv_obj_t * ddlist, const void * symbol); /*===================== * Getter functions diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 226a2aab5..0a395ad35 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -9,11 +9,6 @@ #include "lv_img.h" #if LV_USE_IMG != 0 -/*Testing of dependencies*/ -#if LV_USE_LABEL == 0 - #error "lv_img: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) " -#endif - #include "../lv_misc/lv_debug.h" #include "../lv_themes/lv_theme.h" #include "../lv_draw/lv_img_decoder.h" @@ -549,8 +544,7 @@ static lv_draw_res_t lv_img_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv } #if LV_USE_BLEND_MODES - if(lv_obj_get_style_bg_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER; - if(lv_obj_get_style_img_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER; + if(lv_obj_get_style_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER; #endif return LV_DRAW_RES_COVER; @@ -705,10 +699,10 @@ static lv_res_t lv_img_signal(lv_obj_t * obj, lv_signal_t sign, void * param) lv_coord_t h = lv_obj_get_height(obj); _lv_img_buf_get_transformed_area(&a, w, h, transf_angle, transf_zoom, &img->pivot); lv_coord_t pad_ori = *s; - *s = LV_MATH_MAX(*s, pad_ori - a.x1); - *s = LV_MATH_MAX(*s, pad_ori - a.y1); - *s = LV_MATH_MAX(*s, pad_ori + a.x2 - w); - *s = LV_MATH_MAX(*s, pad_ori + a.y2 - h); + *s = LV_MAX(*s, pad_ori - a.x1); + *s = LV_MAX(*s, pad_ori - a.y1); + *s = LV_MAX(*s, pad_ori + a.x2 - w); + *s = LV_MAX(*s, pad_ori + a.y2 - h); } /*Handle the padding of the background*/ @@ -717,10 +711,10 @@ static lv_res_t lv_img_signal(lv_obj_t * obj, lv_signal_t sign, void * param) lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN); lv_coord_t bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN); - *s = LV_MATH_MAX(*s, left); - *s = LV_MATH_MAX(*s, right); - *s = LV_MATH_MAX(*s, top); - *s = LV_MATH_MAX(*s, bottom); + *s = LV_MAX(*s, left); + *s = LV_MAX(*s, right); + *s = LV_MAX(*s, top); + *s = LV_MAX(*s, bottom); } else if(sign == LV_SIGNAL_HIT_TEST) { lv_hit_test_info_t * info = param; diff --git a/src/lv_widgets/lv_img.h b/src/lv_widgets/lv_img.h index 32f66c6b4..7fac50b28 100644 --- a/src/lv_widgets/lv_img.h +++ b/src/lv_widgets/lv_img.h @@ -19,7 +19,6 @@ extern "C" { #include "../lv_core/lv_obj.h" #include "../lv_misc/lv_fs.h" -#include "lv_label.h" #include "../lv_draw/lv_draw.h" /********************* diff --git a/src/lv_widgets/lv_imgbtn.c b/src/lv_widgets/lv_imgbtn.c index dd03f4410..0d9be2d3b 100644 --- a/src/lv_widgets/lv_imgbtn.c +++ b/src/lv_widgets/lv_imgbtn.c @@ -75,10 +75,10 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy) if(ancestor_draw == NULL) ancestor_draw = lv_obj_get_draw_cb(imgbtn); /*Initialize the allocated 'ext' */ - _lv_memset_00((void *)ext->img_src_mid, sizeof(ext->img_src_mid)); + lv_memset_00((void *)ext->img_src_mid, sizeof(ext->img_src_mid)); #if LV_IMGBTN_TILED - _lv_memset_00(ext->img_src_left, sizeof(ext->img_src_left)); - _lv_memset_00(ext->img_src_right, sizeof(ext->img_src_right)); + lv_memset_00(ext->img_src_left, sizeof(ext->img_src_left)); + lv_memset_00(ext->img_src_right, sizeof(ext->img_src_right)); #endif ext->tiled = 0; @@ -95,10 +95,10 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy) /*Copy an existing image button*/ else { lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy); - _lv_memcpy((void *)ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid)); + lv_memcpy((void *)ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid)); #if LV_IMGBTN_TILED - _lv_memcpy((void *)ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left)); - _lv_memcpy((void *)ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right)); + lv_memcpy((void *)ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left)); + lv_memcpy((void *)ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right)); #endif ext->tiled = copy_ext->tiled; /*Refresh the style with new signal function*/ @@ -298,7 +298,7 @@ static lv_draw_res_t lv_imgbtn_draw(lv_obj_t * imgbtn, const lv_area_t * clip_ar lv_draw_rect(&bg_coords, clip_area, &bg_dsc); if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) { - lv_draw_mask_radius_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t)); + lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t)); lv_coord_t r = lv_obj_get_style_radius(imgbtn, LV_OBJ_PART_MAIN); @@ -409,7 +409,7 @@ static lv_draw_res_t lv_imgbtn_draw(lv_obj_t * imgbtn, const lv_area_t * clip_ar else if(mode == LV_DRAW_DRAW_POST) { if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) { lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(imgbtn + 8); - _lv_mem_buf_release(param); + lv_mem_buf_release(param); } lv_draw_rect_dsc_t draw_dsc; @@ -466,10 +466,10 @@ static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * par lv_coord_t bottom = lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN); lv_coord_t * s = param; - *s = LV_MATH_MAX(*s, left); - *s = LV_MATH_MAX(*s, right); - *s = LV_MATH_MAX(*s, top); - *s = LV_MATH_MAX(*s, bottom); + *s = LV_MAX(*s, left); + *s = LV_MAX(*s, right); + *s = LV_MAX(*s, top); + *s = LV_MAX(*s, bottom); } else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) { refr_img(imgbtn); diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index a02b24fbb..fdb39f3d7 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -454,7 +454,7 @@ void lv_label_get_letter_pos(const lv_obj_t * obj, uint32_t char_id, lv_point_t pos->y = y; #if LV_USE_BIDI - if(mutable_bidi_txt) _lv_mem_buf_release(mutable_bidi_txt); + if(mutable_bidi_txt) lv_mem_buf_release(mutable_bidi_txt); #endif } @@ -517,7 +517,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in) } #if LV_USE_BIDI - bidi_txt = _lv_mem_buf_get(new_line_start - line_start + 1); + bidi_txt = lv_mem_buf_get(new_line_start - line_start + 1); uint32_t txt_len = new_line_start - line_start; if(new_line_start > 0 && txt[new_line_start - 1] == '\0' && txt_len > 0) txt_len--; _lv_bidi_process_paragraph(txt + line_start, bidi_txt, txt_len, lv_obj_get_base_dir(label), NULL, 0); @@ -582,7 +582,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in) logical_pos = _lv_bidi_get_logical_pos(&txt[line_start], NULL, txt_len, lv_obj_get_base_dir(label), cid, &is_rtl); if(is_rtl) logical_pos++; - _lv_mem_buf_release(bidi_txt); + lv_mem_buf_release(bidi_txt); } #else logical_pos = _lv_txt_encoded_get_char_id(bidi_txt, i); @@ -756,14 +756,14 @@ void lv_label_ins_text(lv_obj_t * obj, uint32_t pos, const char * txt) } #if LV_USE_BIDI - char * bidi_buf = _lv_mem_buf_get(ins_len + 1); + char * bidi_buf = lv_mem_buf_get(ins_len + 1); LV_ASSERT_MEM(bidi_buf); if(bidi_buf == NULL) return; _lv_bidi_process(txt, bidi_buf, lv_obj_get_base_dir(label)); _lv_txt_ins(label->text, pos, bidi_buf); - _lv_mem_buf_release(bidi_buf); + lv_mem_buf_release(bidi_buf); #else _lv_txt_ins(label->text, pos, txt); #endif @@ -1286,14 +1286,14 @@ static bool lv_label_set_dot_tmp(lv_obj_t * obj, char * data, uint32_t len) LV_LOG_ERROR("Failed to allocate memory for dot_tmp_ptr"); return false; } - _lv_memcpy(label->dot.tmp_ptr, data, len); + lv_memcpy(label->dot.tmp_ptr, data, len); label->dot.tmp_ptr[len] = '\0'; label->dot_tmp_alloc = true; } else { /* Characters can be directly stored in object */ label->dot_tmp_alloc = false; - _lv_memcpy(label->dot.tmp, data, len); + lv_memcpy(label->dot.tmp, data, len); } return true; } diff --git a/src/lv_widgets/lv_line.c b/src/lv_widgets/lv_line.c index 9c70dabca..89210f191 100644 --- a/src/lv_widgets/lv_line.c +++ b/src/lv_widgets/lv_line.c @@ -248,8 +248,8 @@ static lv_res_t lv_line_signal(lv_obj_t * obj, lv_signal_t sign, void * param) if(line->point_num > 0) { uint16_t i; for(i = 0; i < line->point_num; i++) { - w = LV_MATH_MAX(line->point_array[i].x, w); - h = LV_MATH_MAX(line->point_array[i].y, h); + w = LV_MAX(line->point_array[i].x, w); + h = LV_MAX(line->point_array[i].y, h); } lv_coord_t line_width = lv_obj_get_style_line_width(obj, LV_PART_MAIN); diff --git a/src/lv_widgets/lv_meter.c b/src/lv_widgets/lv_meter.c index 77b36b87a..c76ade476 100644 --- a/src/lv_widgets/lv_meter.c +++ b/src/lv_widgets/lv_meter.c @@ -83,7 +83,7 @@ lv_meter_indicator_t * lv_meter_add_indicator(lv_obj_t * obj) lv_meter_t * meter = (lv_meter_t *) obj; lv_meter_indicator_t * indic = _lv_ll_ins_head(&meter->indic_ll); - _lv_memset_00(indic, sizeof(lv_meter_indicator_t)); + lv_memset_00(indic, sizeof(lv_meter_indicator_t)); indic->start_value = meter->min_value; indic->end_value = meter->min_value; indic->type = LV_METER_INDICATOR_TYPE_NEEDLE; @@ -438,8 +438,8 @@ static void draw_arcs(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area line_dsc.width = indic->width; line_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8; - int32_t start_angle = _lv_map(indic->start_value, meter->min_value, meter->max_value, 0, meter->scale_angle) + angle_ofs; - int32_t end_angle = _lv_map(indic->end_value, meter->min_value, meter->max_value, 0, meter->scale_angle) + angle_ofs; + int32_t start_angle = lv_map(indic->start_value, meter->min_value, meter->max_value, 0, meter->scale_angle) + angle_ofs; + int32_t end_angle = lv_map(indic->end_value, meter->min_value, meter->max_value, 0, meter->scale_angle) + angle_ofs; lv_draw_arc(scale_center.x + indic->arc_ofs.x, scale_center.y + indic->arc_ofs.y, r_out + indic->r_mod, start_angle, end_angle, clip_area, &line_dsc); } } @@ -496,12 +496,12 @@ static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c int32_t angle_rem = angle_upscale & 0xFF; /*Interpolate sine and cos*/ - int32_t sin_low = _lv_trigo_sin(angle_low + angle_ofs); - int32_t sin_high = _lv_trigo_sin(angle_high + angle_ofs); + int32_t sin_low = lv_trigo_sin(angle_low + angle_ofs); + int32_t sin_high = lv_trigo_sin(angle_high + angle_ofs); int32_t sin_mid = (sin_low * (256 - angle_rem) + sin_high * angle_rem) >> 8; - int32_t cos_low = _lv_trigo_cos(angle_low + angle_ofs); - int32_t cos_high = _lv_trigo_cos(angle_high + angle_ofs); + int32_t cos_low = lv_trigo_cos(angle_low + angle_ofs); + int32_t cos_high = lv_trigo_cos(angle_high + angle_ofs); int32_t cos_mid = (cos_low * (256 - angle_rem) + cos_high * angle_rem) >> 8; lv_point_t p_inner; @@ -518,7 +518,7 @@ static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c lv_draw_line_dsc_t * line_dsc_act; line_dsc_act = marker ? &line_marker_dsc : &line_sub_dsc; - int32_t value_of_line = _lv_map(i, 0, meter->line_cnt - 1, meter->min_value, meter->max_value); + int32_t value_of_line = lv_map(i, 0, meter->line_cnt - 1, meter->min_value, meter->max_value); lv_color_t line_color = line_dsc_act->color; lv_color_t line_color_ori = line_dsc_act->color; @@ -540,9 +540,9 @@ static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c } else { lv_opa_t ratio; if(indic->scale_color_local) { - ratio = _lv_map(value_of_line, indic->start_value, indic->end_value, LV_OPA_TRANSP, LV_OPA_COVER); + ratio = lv_map(value_of_line, indic->start_value, indic->end_value, LV_OPA_TRANSP, LV_OPA_COVER); } else { - ratio = _lv_map(value_of_line, meter->min_value, meter->max_value, LV_OPA_TRANSP, LV_OPA_COVER); + ratio = lv_map(value_of_line, meter->min_value, meter->max_value, LV_OPA_TRANSP, LV_OPA_COVER); } line_color = lv_color_mix(indic->grad_color, indic->color, ratio); } @@ -608,13 +608,13 @@ static void draw_needles(lv_obj_t * obj, const lv_area_t * clip_area, const lv_a _LV_LL_READ_BACK(&meter->indic_ll, indic) { if((indic->type & LV_METER_INDICATOR_TYPE_NEEDLE) == false) continue; - int32_t angle = _lv_map(indic->end_value, meter->min_value, meter->max_value, 0, meter->scale_angle) + angle_ofs; + int32_t angle = lv_map(indic->end_value, meter->min_value, meter->max_value, 0, meter->scale_angle) + angle_ofs; /*Draw a line*/ if(indic->img_src == NULL) { lv_point_t p_end; - p_end.y = (_lv_trigo_sin(angle) * (r_out + indic->r_mod)) / LV_TRIGO_SIN_MAX + scale_center.x; - p_end.x = (_lv_trigo_cos(angle) * (r_out + indic->r_mod)) / LV_TRIGO_SIN_MAX + scale_center.y; + p_end.y = (lv_trigo_sin(angle) * (r_out + indic->r_mod)) / LV_TRIGO_SIN_MAX + scale_center.x; + p_end.x = (lv_trigo_cos(angle) * (r_out + indic->r_mod)) / LV_TRIGO_SIN_MAX + scale_center.y; line_dsc.color = indic->color; line_dsc.width = indic->width; line_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8; diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 00286b5c3..01962cb33 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -127,7 +127,7 @@ void lv_roller_set_options(lv_obj_t * obj, const char * options, lv_roller_mode_ roller->mode = LV_ROLLER_MODE_INFINITE; size_t opt_len = strlen(options) + 1; /*+1 to add '\n' after option lists*/ - char * opt_extra = _lv_mem_buf_get(opt_len * LV_ROLLER_INF_PAGES); + char * opt_extra = lv_mem_buf_get(opt_len * LV_ROLLER_INF_PAGES); uint8_t i; for(i = 0; i < LV_ROLLER_INF_PAGES; i++) { strcpy(&opt_extra[opt_len * i], options); @@ -135,7 +135,7 @@ void lv_roller_set_options(lv_obj_t * obj, const char * options, lv_roller_mode_ } opt_extra[opt_len * LV_ROLLER_INF_PAGES - 1] = '\0'; lv_label_set_text(label, opt_extra); - _lv_mem_buf_release(opt_extra); + lv_mem_buf_release(opt_extra); roller->sel_opt_id = ((LV_ROLLER_INF_PAGES / 2) + 0) * roller->option_cnt; @@ -646,7 +646,7 @@ static lv_res_t lv_roller_label_signal(lv_obj_t * label, lv_signal_t sign, void lv_obj_t * obj = lv_obj_get_parent(label); lv_coord_t sel_w = get_selected_label_width(obj); lv_coord_t label_w = lv_obj_get_width(label); - *s = LV_MATH_MAX(*s, sel_w - label_w); + *s = LV_MAX(*s, sel_w - label_w); } return res; diff --git a/src/lv_widgets/lv_slider.c b/src/lv_widgets/lv_slider.c index 8eefb17aa..06fe03c35 100644 --- a/src/lv_widgets/lv_slider.c +++ b/src/lv_widgets/lv_slider.c @@ -219,8 +219,8 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param) } else { /* Calculate the distance from each knob */ - dist_left = LV_MATH_ABS((slider->left_knob_area.x1 + (slider->left_knob_area.x2 - slider->left_knob_area.x1) / 2) - p.x); - dist_right = LV_MATH_ABS((slider->right_knob_area.x1 + (slider->right_knob_area.x2 - slider->right_knob_area.x1) / 2) - p.x); + dist_left = LV_ABS((slider->left_knob_area.x1 + (slider->left_knob_area.x2 - slider->left_knob_area.x1) / 2) - p.x); + dist_right = LV_ABS((slider->right_knob_area.x1 + (slider->right_knob_area.x2 - slider->right_knob_area.x1) / 2) - p.x); /* Use whichever one is closer */ if(dist_right < dist_left)slider->value_to_set = &slider->bar.cur_value; @@ -236,8 +236,8 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param) } else { /* Calculate the distance from each knob */ - dist_left = LV_MATH_ABS((slider->left_knob_area.y1 + (slider->left_knob_area.y2 - slider->left_knob_area.y1) / 2) - p.y); - dist_right = LV_MATH_ABS((slider->right_knob_area.y1 + (slider->right_knob_area.y2 - slider->right_knob_area.y1) / 2) - p.y); + dist_left = LV_ABS((slider->left_knob_area.y1 + (slider->left_knob_area.y2 - slider->left_knob_area.y1) / 2) - p.y); + dist_right = LV_ABS((slider->right_knob_area.y1 + (slider->right_knob_area.y2 - slider->right_knob_area.y1) / 2) - p.y); /* Use whichever one is closer */ if(dist_right < dist_left)slider->value_to_set = &slider->bar.cur_value; @@ -348,15 +348,15 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param) /* The smaller size is the knob diameter*/ lv_coord_t trans_w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN); lv_coord_t trans_h = lv_obj_get_style_transform_height(obj, LV_PART_MAIN); - lv_coord_t knob_size = LV_MATH_MIN(lv_obj_get_width(obj) + 2 * trans_w, lv_obj_get_height(obj) + 2 * trans_h) >> 1; - knob_size += LV_MATH_MAX(LV_MATH_MAX(knob_left, knob_right), LV_MATH_MAX(knob_bottom, knob_top)); + lv_coord_t knob_size = LV_MIN(lv_obj_get_width(obj) + 2 * trans_w, lv_obj_get_height(obj) + 2 * trans_h) >> 1; + knob_size += LV_MAX(LV_MAX(knob_left, knob_right), LV_MAX(knob_bottom, knob_top)); knob_size += 2; /*For rounding error*/ knob_size += _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_KNOB); /*Indic. size is handled by bar*/ lv_coord_t * s = param; - *s = LV_MATH_MAX(*s, knob_size); + *s = LV_MAX(*s, knob_size); } else if(sign == LV_SIGNAL_CONTROL) { @@ -440,16 +440,8 @@ void draw_knob(lv_obj_t * obj, const lv_area_t * clip_area) lv_area_copy(&slider->right_knob_area, &knob_area); /*Handle custom drawer*/ - lv_obj_draw_hook_dsc_t hook_dsc; - lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area); - hook_dsc.draw_area = &slider->right_knob_area; - hook_dsc.part = LV_PART_KNOB; - lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc); - lv_draw_rect(&slider->right_knob_area, clip_area, &knob_rect_dsc); - lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc); - if(lv_slider_get_type(obj) == LV_SLIDER_TYPE_RANGE) { /* Draw a second knob for the start_value side */ if(hor) { @@ -462,12 +454,8 @@ void draw_knob(lv_obj_t * obj, const lv_area_t * clip_area) lv_area_copy(&slider->left_knob_area, &knob_area); - hook_dsc.draw_area = &slider->left_knob_area; - hook_dsc.id = 1; - lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc); /*Draw the knob if the custom drawer allows it*/ lv_draw_rect(&slider->left_knob_area, clip_area, &knob_rect_dsc); - lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc); } } diff --git a/src/lv_widgets/lv_switch.c b/src/lv_widgets/lv_switch.c index 936dadcde..f3b19e35f 100644 --- a/src/lv_widgets/lv_switch.c +++ b/src/lv_widgets/lv_switch.c @@ -228,15 +228,15 @@ static lv_res_t lv_switch_signal(lv_obj_t * obj, lv_signal_t sign, void * param) lv_coord_t knob_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_KNOB); /* The smaller size is the knob diameter*/ - lv_coord_t knob_size = LV_MATH_MIN(lv_obj_get_width(obj), lv_obj_get_height(obj)) >> 1; - knob_size += LV_MATH_MAX(LV_MATH_MAX(knob_left, knob_right), LV_MATH_MAX(knob_bottom, knob_top)); + lv_coord_t knob_size = LV_MIN(lv_obj_get_width(obj), lv_obj_get_height(obj)) >> 1; + knob_size += LV_MAX(LV_MAX(knob_left, knob_right), LV_MAX(knob_bottom, knob_top)); knob_size += 2; /*For rounding error*/ knob_size += _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_KNOB); lv_coord_t * s = param; - *s = LV_MATH_MAX(*s, knob_size); - *s = LV_MATH_MAX(*s, _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_INDICATOR)); + *s = LV_MAX(*s, knob_size); + *s = LV_MAX(*s, _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_INDICATOR)); } else if(sign == LV_SIGNAL_RELEASED) { lv_obj_invalidate(obj); diff --git a/src/lv_widgets/lv_table.c b/src/lv_widgets/lv_table.c index e9e58bada..25b0a2690 100644 --- a/src/lv_widgets/lv_table.c +++ b/src/lv_widgets/lv_table.c @@ -172,7 +172,7 @@ void lv_table_set_cell_value_fmt(lv_obj_t * obj, uint16_t row, uint16_t col, con #if LV_USE_ARABIC_PERSIAN_CHARS /*Put together the text according to the format string*/ - char * raw_txt = _lv_mem_buf_get(len + 1); + char * raw_txt = lv_mem_buf_get(len + 1); LV_ASSERT_MEM(raw_txt); if(raw_txt == NULL) { va_end(ap2); @@ -191,7 +191,7 @@ void lv_table_set_cell_value_fmt(lv_obj_t * obj, uint16_t row, uint16_t col, con } _lv_txt_ap_proc(raw_txt, &table->cell_data[cell][1]); - _lv_mem_buf_release(raw_txt); + lv_mem_buf_release(raw_txt); #else table->cell_data[cell] = lv_mem_realloc(table->cell_data[cell], len + 2); /*+1: trailing '\0; +1: format byte*/ LV_ASSERT_MEM(table->cell_data[cell]); @@ -236,7 +236,7 @@ void lv_table_set_row_cnt(lv_obj_t * obj, uint16_t row_cnt) if(old_row_cnt < row_cnt) { uint32_t old_cell_cnt = old_row_cnt * table->col_cnt; uint32_t new_cell_cnt = table->col_cnt * table->row_cnt; - _lv_memset_00(&table->cell_data[old_cell_cnt], (new_cell_cnt - old_cell_cnt) * sizeof(table->cell_data[0])); + lv_memset_00(&table->cell_data[old_cell_cnt], (new_cell_cnt - old_cell_cnt) * sizeof(table->cell_data[0])); } refr_size(obj) ; @@ -266,7 +266,7 @@ void lv_table_set_col_cnt(lv_obj_t * obj, uint16_t col_cnt) if(old_col_cnt < col_cnt) { uint32_t old_cell_cnt = old_col_cnt * table->row_cnt; uint32_t new_cell_cnt = table->col_cnt * table->row_cnt; - _lv_memset_00(&table->cell_data[old_cell_cnt], (new_cell_cnt - old_cell_cnt) * sizeof(table->cell_data[0])); + lv_memset_00(&table->cell_data[old_cell_cnt], (new_cell_cnt - old_cell_cnt) * sizeof(table->cell_data[0])); uint32_t col; for(col = old_cell_cnt; col < new_cell_cnt; col++) { @@ -737,8 +737,8 @@ static lv_draw_res_t lv_table_draw(lv_obj_t * obj, const lv_area_t * clip_area, cell_area_border.y2 += rect_dsc_base.border_width / 2 + (rect_dsc_base.border_width & 0x1); } - _lv_memcpy(&rect_dsc_act, &rect_dsc_base, sizeof(lv_draw_rect_dsc_t)); - _lv_memcpy(&label_dsc_act, &label_dsc_base, sizeof(lv_draw_label_dsc_t)); + lv_memcpy(&rect_dsc_act, &rect_dsc_base, sizeof(lv_draw_rect_dsc_t)); + lv_memcpy(&label_dsc_act, &label_dsc_base, sizeof(lv_draw_label_dsc_t)); hook_dsc.draw_area = &cell_area_border; hook_dsc.id = row * table->col_cnt + col; lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc); @@ -886,7 +886,7 @@ static lv_coord_t get_row_height(lv_obj_t * obj, uint16_t row_id, const lv_font_ /*With text crop assume 1 line*/ if(format.s.crop) { - h_max = LV_MATH_MAX(lv_font_get_line_height(font) + cell_top + cell_bottom, + h_max = LV_MAX(lv_font_get_line_height(font) + cell_top + cell_bottom, h_max); } /*Without text crop calculate the height of the text in the cell*/ @@ -896,7 +896,7 @@ static lv_coord_t get_row_height(lv_obj_t * obj, uint16_t row_id, const lv_font_ _lv_txt_get_size(&txt_size, table->cell_data[cell] + 1, font, letter_space, line_space, txt_w, LV_TEXT_FLAG_NONE); - h_max = LV_MATH_MAX(txt_size.y + cell_top + cell_bottom, h_max); + h_max = LV_MAX(txt_size.y + cell_top + cell_bottom, h_max); cell += col_merge; col += col_merge; } diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index cf501a59e..72cb67777 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -162,12 +162,12 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy) } if(copy_ext->pwd_tmp) { - uint32_t len = _lv_mem_get_size(copy_ext->pwd_tmp); + uint32_t len = lv_mem_get_size(copy_ext->pwd_tmp); ext->pwd_tmp = lv_mem_alloc(len); LV_ASSERT_MEM(ext->pwd_tmp); if(ext->pwd_tmp == NULL) return NULL; - _lv_memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len); + lv_memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len); } if(copy_ext->one_line) lv_textarea_set_one_line(ta, true); @@ -1447,16 +1447,16 @@ static void pwd_char_hider(lv_obj_t * ta) else bullet = "*"; size_t bullet_len = strlen(bullet); - char * txt_tmp = _lv_mem_buf_get(enc_len * bullet_len + 1); + char * txt_tmp = lv_mem_buf_get(enc_len * bullet_len + 1); int32_t i; for(i = 0; i < enc_len; i++) { - _lv_memcpy(&txt_tmp[i * bullet_len], bullet, bullet_len); + lv_memcpy(&txt_tmp[i * bullet_len], bullet, bullet_len); } txt_tmp[i * bullet_len] = '\0'; lv_label_set_text(ext->label, txt_tmp); - _lv_mem_buf_release(txt_tmp); + lv_mem_buf_release(txt_tmp); refr_cursor_area(ta); } } @@ -1771,7 +1771,7 @@ static void draw_cursor(lv_obj_t * ta, const lv_area_t * clip_area) lv_draw_rect(&cur_area, clip_area, &cur_dsc); char letter_buf[8] = {0}; - _lv_memcpy(letter_buf, &txt[ext->cursor.txt_byte_pos], _lv_txt_encoded_size(&txt[ext->cursor.txt_byte_pos])); + lv_memcpy(letter_buf, &txt[ext->cursor.txt_byte_pos], _lv_txt_encoded_size(&txt[ext->cursor.txt_byte_pos])); if(cur_dsc.bg_opa == LV_OPA_COVER) { lv_coord_t left = lv_obj_get_style_pad_left(ta, LV_TEXTAREA_PART_CURSOR);