From 4be4cb6eee01422913658b6a48622599006e9db3 Mon Sep 17 00:00:00 2001 From: _VIFEXTech Date: Tue, 12 Dec 2023 16:18:01 +0800 Subject: [PATCH] feat(style): add skew style (#4886) Signed-off-by: pengyiqiang Co-authored-by: pengyiqiang --- docs/overview/style-props.md | 32 ++++++++++++++++++++------ scripts/style_api_gen.py | 8 +++++++ src/core/lv_obj_style.c | 22 ++++++++++-------- src/core/lv_obj_style_gen.c | 24 ++++++++++++++++---- src/core/lv_obj_style_gen.h | 44 ++++++++++++++++++++---------------- src/core/lv_refr.c | 2 ++ src/draw/lv_draw_image.h | 2 ++ src/draw/sw/lv_draw_sw.c | 15 ++++++++++++ src/misc/lv_style.c | 2 ++ src/misc/lv_style.h | 34 +++++++++++++++------------- src/misc/lv_style_gen.c | 20 ++++++++++++++++ src/misc/lv_style_gen.h | 14 ++++++++++++ 12 files changed, 163 insertions(+), 56 deletions(-) diff --git a/docs/overview/style-props.md b/docs/overview/style-props.md index 466c519fb..ba8af602e 100644 --- a/docs/overview/style-props.md +++ b/docs/overview/style-props.md @@ -165,6 +165,24 @@ Set the pivot point's Y coordinate for transformations. Relative to the object's
  • Ext. draw No
  • +### transform_skew_x +Skew an object horizontally. The value is interpreted in 0.1 degree units. E.g. 450 means 45 deg. +
      +
    • Default 0
    • +
    • Inherited No
    • +
    • Layout Yes
    • +
    • Ext. draw Yes
    • +
    + +### transform_skew_y +Skew an object vertically. The value is interpreted in 0.1 degree units. E.g. 450 means 45 deg. +
      +
    • Default 0
    • +
    • Inherited No
    • +
    • Layout Yes
    • +
    • Ext. draw Yes
    • +
    + ## Padding Properties to describe spacing between the parent's sides and the children and among the children. Very similar to the padding properties in HTML. @@ -226,7 +244,7 @@ Sets the padding between the columns. Used by the layouts. Properties to describe spacing around an object. Very similar to the margin properties in HTML. ### margin_top -Sets the margin on the top. The object will keep this space from its siblings in layouts. +Sets the margin on the top. The object will keep this space from its siblings in layouts.
    • Default 0
    • Inherited No
    • @@ -442,7 +460,7 @@ Sets whether the border should be drawn before or after the children are drawn. Properties to describe the outline. It's like a border but drawn outside of the rectangles. ### outline_width -Set the width of the outline in pixels. +Set the width of the outline in pixels.
      • Default 0
      • Inherited No
      • @@ -490,7 +508,7 @@ Set the width of the shadow in pixels. The value should be >= 0.
      ### shadow_offset_x -Set an offset on the shadow in pixels in X direction. +Set an offset on the shadow in pixels in X direction.
      • Default 0
      • Inherited No
      • @@ -499,7 +517,7 @@ Set an offset on the shadow in pixels in X direction.
      ### shadow_offset_y -Set an offset on the shadow in pixels in Y direction. +Set an offset on the shadow in pixels in Y direction.
      • Default 0
      • Inherited No
      • @@ -595,7 +613,7 @@ Set the gap between dashes in pixel. Note that dash works only on horizontal and
      ### line_rounded -Make the end points of the lines rounded. `true`: rounded, `false`: perpendicular line ending +Make the end points of the lines rounded. `true`: rounded, `false`: perpendicular line ending
      • Default 0
      • Inherited No
      • @@ -634,7 +652,7 @@ Set the width (thickness) of the arcs in pixel.
      ### arc_rounded -Make the end points of the arcs rounded. `true`: rounded, `false`: perpendicular line ending +Make the end points of the arcs rounded. `true`: rounded, `false`: perpendicular line ending
      • Default 0
      • Inherited No
      • @@ -691,7 +709,7 @@ Set the opacity of the text. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully
      ### text_font -Set the font of the text (a pointer `lv_font_t *`). +Set the font of the text (a pointer `lv_font_t *`).
      • Default `LV_FONT_DEFAULT`
      • Inherited Yes
      • diff --git a/scripts/style_api_gen.py b/scripts/style_api_gen.py index 2e3d23e99..0cd4d78c6 100755 --- a/scripts/style_api_gen.py +++ b/scripts/style_api_gen.py @@ -78,6 +78,14 @@ props = [ 'style_type': 'num', 'var_type': 'int32_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, 'dsc': "Set the pivot point's Y coordinate for transformations. Relative to the object's top left corner'"}, +{'name': 'TRANSFORM_SKEW_X', + 'style_type': 'num', 'var_type': 'int32_t', 'default':0, 'inherited': 0, 'layout': 1, 'ext_draw': 1, + 'dsc': "Skew an object horizontally. The value is interpreted in 0.1 degree units. E.g. 450 means 45 deg."}, + +{'name': 'TRANSFORM_SKEW_Y', + 'style_type': 'num', 'var_type': 'int32_t', 'default':0, 'inherited': 0, 'layout': 1, 'ext_draw': 1, + 'dsc': "Skew an object vertically. The value is interpreted in 0.1 degree units. E.g. 450 means 45 deg."}, + {'section': 'Padding', 'dsc' : "Properties to describe spacing between the parent's sides and the children and among the children. Very similar to the padding properties in HTML."}, {'name': 'PAD_TOP', 'style_type': 'num', 'var_type': 'int32_t', 'default':0, 'inherited': 0, 'layout': 1, 'ext_draw': 0, diff --git a/src/core/lv_obj_style.c b/src/core/lv_obj_style.c index efbc99630..ce01d5304 100644 --- a/src/core/lv_obj_style.c +++ b/src/core/lv_obj_style.c @@ -19,6 +19,7 @@ #define style_refr LV_GLOBAL_DEFAULT()->style_refresh #define style_trans_ll_p &(LV_GLOBAL_DEFAULT()->style_trans_ll) #define _style_custom_prop_flag_lookup_table LV_GLOBAL_DEFAULT()->style_custom_prop_flag_lookup_table +#define STYLE_PROP_SHIFTED(prop) ((uint32_t)1 << ((prop) >> 3)) /********************** * TYPEDEFS @@ -133,13 +134,13 @@ void lv_obj_add_style(lv_obj_t * obj, const lv_style_t * style, lv_style_selecto if(lv_style_is_const(style)) { lv_style_const_prop_t * props = style->values_and_props; for(i = 0; props[i].prop_ptr; i++) { - (*prop_is_set) |= (uint32_t)1 << ((*props[i].prop_ptr) >> 2); + (*prop_is_set) |= STYLE_PROP_SHIFTED(*props[i].prop_ptr); } } else { lv_style_prop_t * props = (lv_style_prop_t *)style->values_and_props + style->prop_cnt * sizeof(lv_style_value_t); for(i = 0; i < style->prop_cnt; i++) { - (*prop_is_set) |= (uint32_t)1 << (props[i] >> 2); + (*prop_is_set) |= STYLE_PROP_SHIFTED(props[i]); } } #endif @@ -394,7 +395,7 @@ lv_style_value_t lv_obj_get_style_prop(const lv_obj_t * obj, lv_part_t part, lv_ /*The happy path*/ #if LV_OBJ_STYLE_CACHE - const uint32_t prop_shifted = (uint32_t)1 << (prop >> 2); + const uint32_t prop_shifted = STYLE_PROP_SHIFTED(prop); if((part == LV_PART_MAIN ? obj->style_main_prop_is_set : obj->style_other_prop_is_set) & prop_shifted) #endif { @@ -466,11 +467,12 @@ void lv_obj_set_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_ lv_style_set_prop(style, prop, value); #if LV_OBJ_STYLE_CACHE + uint32_t prop_shifted = STYLE_PROP_SHIFTED(prop); if(lv_obj_style_get_selector_part(selector) == LV_PART_MAIN) { - obj->style_main_prop_is_set |= (uint32_t)1 << (prop >> 2); + obj->style_main_prop_is_set |= prop_shifted; } else { - obj->style_other_prop_is_set |= (uint32_t)1 << (prop >> 2); + obj->style_other_prop_is_set |= prop_shifted; } #endif @@ -1049,6 +1051,8 @@ static lv_layer_type_t calculate_layer_type(lv_obj_t * obj) if(lv_obj_get_style_transform_rotation(obj, 0) != 0) return LV_LAYER_TYPE_TRANSFORM; if(lv_obj_get_style_transform_scale_x(obj, 0) != 256) return LV_LAYER_TYPE_TRANSFORM; if(lv_obj_get_style_transform_scale_y(obj, 0) != 256) return LV_LAYER_TYPE_TRANSFORM; + if(lv_obj_get_style_transform_skew_x(obj, 0) != 0) return LV_LAYER_TYPE_TRANSFORM; + if(lv_obj_get_style_transform_skew_y(obj, 0) != 0) return LV_LAYER_TYPE_TRANSFORM; if(lv_obj_get_style_opa_layered(obj, 0) != LV_OPA_COVER) return LV_LAYER_TYPE_SIMPLE; if(lv_obj_get_style_blend_mode(obj, 0) != LV_BLEND_MODE_NORMAL) return LV_LAYER_TYPE_SIMPLE; return LV_LAYER_TYPE_NONE; @@ -1067,13 +1071,13 @@ static void full_cache_refresh(lv_obj_t * obj, lv_part_t part) if(lv_style_is_const(style)) { lv_style_const_prop_t * props = style->values_and_props; for(j = 0; props[j].prop_ptr; j++) { - obj->style_main_prop_is_set |= (uint32_t)1 << ((*props[j].prop_ptr) >> 2); + obj->style_main_prop_is_set |= STYLE_PROP_SHIFTED(*props[j].prop_ptr); } } else { lv_style_prop_t * props = (lv_style_prop_t *)style->values_and_props + style->prop_cnt * sizeof(lv_style_value_t); for(j = 0; j < style->prop_cnt; j++) { - obj->style_main_prop_is_set |= (uint32_t)1 << (props[j] >> 2); + obj->style_main_prop_is_set |= STYLE_PROP_SHIFTED(props[j]); } } } @@ -1087,13 +1091,13 @@ static void full_cache_refresh(lv_obj_t * obj, lv_part_t part) if(lv_style_is_const(style)) { lv_style_const_prop_t * props = style->values_and_props; for(j = 0; props[j].prop_ptr; j++) { - obj->style_other_prop_is_set |= (uint32_t)1 << ((*props[j].prop_ptr) >> 2); + obj->style_other_prop_is_set |= STYLE_PROP_SHIFTED(*props[j].prop_ptr); } } else { lv_style_prop_t * props = (lv_style_prop_t *)style->values_and_props + style->prop_cnt * sizeof(lv_style_value_t); for(j = 0; j < style->prop_cnt; j++) { - obj->style_other_prop_is_set |= (uint32_t)1 << (props[j] >> 2); + obj->style_other_prop_is_set |= STYLE_PROP_SHIFTED(props[j]); } } } diff --git a/src/core/lv_obj_style_gen.c b/src/core/lv_obj_style_gen.c index 434f63429..dd80cf3aa 100644 --- a/src/core/lv_obj_style_gen.c +++ b/src/core/lv_obj_style_gen.c @@ -6,8 +6,10 @@ ********************************************************************** */ + #include "lv_obj.h" + void lv_obj_set_style_width(struct _lv_obj_t * obj, int32_t value, lv_style_selector_t selector) { lv_style_value_t v = { @@ -152,6 +154,22 @@ void lv_obj_set_style_transform_pivot_y(struct _lv_obj_t * obj, int32_t value, l lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_PIVOT_Y, v, selector); } +void lv_obj_set_style_transform_skew_x(struct _lv_obj_t * obj, int32_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_SKEW_X, v, selector); +} + +void lv_obj_set_style_transform_skew_y(struct _lv_obj_t * obj, int32_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_SKEW_Y, v, selector); +} + void lv_obj_set_style_pad_top(struct _lv_obj_t * obj, int32_t value, lv_style_selector_t selector) { lv_style_value_t v = { @@ -664,8 +682,7 @@ void lv_obj_set_style_opa_layered(struct _lv_obj_t * obj, lv_opa_t value, lv_sty lv_obj_set_local_style_prop(obj, LV_STYLE_OPA_LAYERED, v, selector); } -void lv_obj_set_style_color_filter_dsc(struct _lv_obj_t * obj, const lv_color_filter_dsc_t * value, - lv_style_selector_t selector) +void lv_obj_set_style_color_filter_dsc(struct _lv_obj_t * obj, const lv_color_filter_dsc_t * value, lv_style_selector_t selector) { lv_style_value_t v = { .ptr = value @@ -697,8 +714,7 @@ void lv_obj_set_style_anim_time(struct _lv_obj_t * obj, uint32_t value, lv_style lv_obj_set_local_style_prop(obj, LV_STYLE_ANIM_TIME, v, selector); } -void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_style_transition_dsc_t * value, - lv_style_selector_t selector) +void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_style_transition_dsc_t * value, lv_style_selector_t selector) { lv_style_value_t v = { .ptr = value diff --git a/src/core/lv_obj_style_gen.h b/src/core/lv_obj_style_gen.h index 3017e4071..4aca6c8fd 100644 --- a/src/core/lv_obj_style_gen.h +++ b/src/core/lv_obj_style_gen.h @@ -122,6 +122,18 @@ static inline int32_t lv_obj_get_style_transform_pivot_y(const struct _lv_obj_t return (int32_t)v.num; } +static inline int32_t lv_obj_get_style_transform_skew_x(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_SKEW_X); + return (int32_t)v.num; +} + +static inline int32_t lv_obj_get_style_transform_skew_y(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_SKEW_Y); + return (int32_t)v.num; +} + static inline int32_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); @@ -208,8 +220,7 @@ static inline lv_color_t lv_obj_get_style_bg_grad_color(const struct _lv_obj_t * 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_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, - LV_STYLE_BG_GRAD_COLOR)); + lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_COLOR)); return v.color; } @@ -269,8 +280,7 @@ static inline lv_color_t lv_obj_get_style_bg_image_recolor(const struct _lv_obj_ static inline lv_color_t lv_obj_get_style_bg_image_recolor_filtered(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, - LV_STYLE_BG_IMAGE_RECOLOR)); + lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMAGE_RECOLOR)); return v.color; } @@ -294,8 +304,7 @@ static inline lv_color_t lv_obj_get_style_border_color(const struct _lv_obj_t * 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_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, - LV_STYLE_BORDER_COLOR)); + lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_COLOR)); return v.color; } @@ -337,8 +346,7 @@ static inline lv_color_t lv_obj_get_style_outline_color(const struct _lv_obj_t * 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_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, - LV_STYLE_OUTLINE_COLOR)); + lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_COLOR)); return v.color; } @@ -386,8 +394,7 @@ static inline lv_color_t lv_obj_get_style_shadow_color(const struct _lv_obj_t * 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_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, - LV_STYLE_SHADOW_COLOR)); + lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_COLOR)); return v.color; } @@ -411,8 +418,7 @@ static inline lv_color_t lv_obj_get_style_image_recolor(const struct _lv_obj_t * static inline lv_color_t lv_obj_get_style_image_recolor_filtered(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, - LV_STYLE_IMAGE_RECOLOR)); + lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_IMAGE_RECOLOR)); return v.color; } @@ -572,8 +578,7 @@ static inline lv_opa_t lv_obj_get_style_opa_layered(const struct _lv_obj_t * obj return (lv_opa_t)v.num; } -static inline const lv_color_filter_dsc_t * lv_obj_get_style_color_filter_dsc(const struct _lv_obj_t * obj, - uint32_t part) +static inline const lv_color_filter_dsc_t * lv_obj_get_style_color_filter_dsc(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_DSC); return (const lv_color_filter_dsc_t *)v.ptr; @@ -729,6 +734,8 @@ void lv_obj_set_style_transform_scale_y(struct _lv_obj_t * obj, int32_t value, l void lv_obj_set_style_transform_rotation(struct _lv_obj_t * obj, int32_t value, lv_style_selector_t selector); void lv_obj_set_style_transform_pivot_x(struct _lv_obj_t * obj, int32_t value, lv_style_selector_t selector); void lv_obj_set_style_transform_pivot_y(struct _lv_obj_t * obj, int32_t value, lv_style_selector_t selector); +void lv_obj_set_style_transform_skew_x(struct _lv_obj_t * obj, int32_t value, lv_style_selector_t selector); +void lv_obj_set_style_transform_skew_y(struct _lv_obj_t * obj, int32_t value, lv_style_selector_t selector); void lv_obj_set_style_pad_top(struct _lv_obj_t * obj, int32_t value, lv_style_selector_t selector); void lv_obj_set_style_pad_bottom(struct _lv_obj_t * obj, int32_t value, lv_style_selector_t selector); void lv_obj_set_style_pad_left(struct _lv_obj_t * obj, int32_t value, lv_style_selector_t selector); @@ -793,13 +800,11 @@ void lv_obj_set_style_radius(struct _lv_obj_t * obj, int32_t value, lv_style_sel void lv_obj_set_style_clip_corner(struct _lv_obj_t * obj, bool value, lv_style_selector_t selector); void lv_obj_set_style_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector); void lv_obj_set_style_opa_layered(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector); -void lv_obj_set_style_color_filter_dsc(struct _lv_obj_t * obj, const lv_color_filter_dsc_t * value, - lv_style_selector_t selector); +void lv_obj_set_style_color_filter_dsc(struct _lv_obj_t * obj, const lv_color_filter_dsc_t * value, lv_style_selector_t selector); void lv_obj_set_style_color_filter_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector); void lv_obj_set_style_anim(struct _lv_obj_t * obj, const lv_anim_t * value, lv_style_selector_t selector); void lv_obj_set_style_anim_time(struct _lv_obj_t * obj, uint32_t value, lv_style_selector_t selector); -void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_style_transition_dsc_t * value, - lv_style_selector_t selector); +void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_style_transition_dsc_t * value, lv_style_selector_t selector); void lv_obj_set_style_blend_mode(struct _lv_obj_t * obj, lv_blend_mode_t value, lv_style_selector_t selector); void lv_obj_set_style_layout(struct _lv_obj_t * obj, uint16_t value, lv_style_selector_t selector); void lv_obj_set_style_base_dir(struct _lv_obj_t * obj, lv_base_dir_t value, lv_style_selector_t selector); @@ -808,8 +813,7 @@ void lv_obj_set_style_flex_main_place(struct _lv_obj_t * obj, lv_flex_align_t va void lv_obj_set_style_flex_cross_place(struct _lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector); void lv_obj_set_style_flex_track_place(struct _lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector); void lv_obj_set_style_flex_grow(struct _lv_obj_t * obj, uint8_t value, lv_style_selector_t selector); -void lv_obj_set_style_grid_column_dsc_array(struct _lv_obj_t * obj, const int32_t * value, - lv_style_selector_t selector); +void lv_obj_set_style_grid_column_dsc_array(struct _lv_obj_t * obj, const int32_t * value, lv_style_selector_t selector); void lv_obj_set_style_grid_column_align(struct _lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector); void lv_obj_set_style_grid_row_dsc_array(struct _lv_obj_t * obj, const int32_t * value, lv_style_selector_t selector); void lv_obj_set_style_grid_row_align(struct _lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector); diff --git a/src/core/lv_refr.c b/src/core/lv_refr.c index ba5315209..02e482385 100644 --- a/src/core/lv_refr.c +++ b/src/core/lv_refr.c @@ -938,6 +938,8 @@ void refr_obj(lv_layer_t * layer, lv_obj_t * obj) while(layer_draw_dsc.rotation < 0) layer_draw_dsc.rotation += 3600; layer_draw_dsc.scale_x = lv_obj_get_style_transform_scale_x(obj, 0); layer_draw_dsc.scale_y = lv_obj_get_style_transform_scale_y(obj, 0); + layer_draw_dsc.skew_x = lv_obj_get_style_transform_skew_x(obj, 0); + layer_draw_dsc.skew_y = lv_obj_get_style_transform_skew_y(obj, 0); layer_draw_dsc.blend_mode = lv_obj_get_style_blend_mode(obj, 0); layer_draw_dsc.antialias = disp_refr->antialiasing; layer_draw_dsc.src = new_layer; diff --git a/src/draw/lv_draw_image.h b/src/draw/lv_draw_image.h index fe7a54962..1b52c2f46 100644 --- a/src/draw/lv_draw_image.h +++ b/src/draw/lv_draw_image.h @@ -45,6 +45,8 @@ typedef struct _lv_draw_image_dsc_t { int32_t rotation; int32_t scale_x; int32_t scale_y; + int32_t skew_x; + int32_t skew_y; lv_point_t pivot; lv_color_t recolor; diff --git a/src/draw/sw/lv_draw_sw.c b/src/draw/sw/lv_draw_sw.c index 1387dd230..eccb0614f 100644 --- a/src/draw/sw/lv_draw_sw.c +++ b/src/draw/sw/lv_draw_sw.c @@ -205,6 +205,21 @@ static int32_t evaluate(lv_draw_unit_t * draw_unit, lv_draw_task_t * task) { LV_UNUSED(draw_unit); + switch(task->type) { + case LV_DRAW_TASK_TYPE_IMAGE: + case LV_DRAW_TASK_TYPE_LAYER: { + lv_draw_image_dsc_t * draw_dsc = task->draw_dsc; + + /* not support skew */ + if(draw_dsc->skew_x != 0 || draw_dsc->skew_y != 0) { + return 0; + } + } + break; + default: + break; + } + if(task->preference_score >= 100) { task->preference_score = 100; task->preferred_draw_unit_id = DRAW_UNIT_ID_SW; diff --git a/src/misc/lv_style.c b/src/misc/lv_style.c index 59d1d9a3c..e85699010 100644 --- a/src/misc/lv_style.c +++ b/src/misc/lv_style.c @@ -50,6 +50,8 @@ const uint8_t _lv_style_builtin_prop_flag_lookup_table[_LV_STYLE_NUM_BUILT_IN_PR [LV_STYLE_TRANSLATE_Y] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE | LV_STYLE_PROP_FLAG_PARENT_LAYOUT_UPDATE, [LV_STYLE_TRANSFORM_SCALE_X] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYER_UPDATE | LV_STYLE_PROP_FLAG_TRANSFORM, [LV_STYLE_TRANSFORM_SCALE_Y] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYER_UPDATE | LV_STYLE_PROP_FLAG_TRANSFORM, + [LV_STYLE_TRANSFORM_SKEW_X] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYER_UPDATE | LV_STYLE_PROP_FLAG_TRANSFORM, + [LV_STYLE_TRANSFORM_SKEW_Y] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYER_UPDATE | LV_STYLE_PROP_FLAG_TRANSFORM, [LV_STYLE_TRANSFORM_ROTATION] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYER_UPDATE | LV_STYLE_PROP_FLAG_TRANSFORM, [LV_STYLE_PAD_TOP] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, diff --git a/src/misc/lv_style.h b/src/misc/lv_style.h index cce73bf03..8c98e2047 100644 --- a/src/misc/lv_style.h +++ b/src/misc/lv_style.h @@ -295,29 +295,31 @@ enum _lv_style_prop_t { LV_STYLE_TRANSFORM_ROTATION = 110, LV_STYLE_TRANSFORM_PIVOT_X = 111, LV_STYLE_TRANSFORM_PIVOT_Y = 112, + LV_STYLE_TRANSFORM_SKEW_X = 113, + LV_STYLE_TRANSFORM_SKEW_Y = 114, #if LV_USE_FLEX - LV_STYLE_FLEX_FLOW = 113, - LV_STYLE_FLEX_MAIN_PLACE = 114, - LV_STYLE_FLEX_CROSS_PLACE = 115, - LV_STYLE_FLEX_TRACK_PLACE = 116, - LV_STYLE_FLEX_GROW = 117, + LV_STYLE_FLEX_FLOW = 115, + LV_STYLE_FLEX_MAIN_PLACE = 116, + LV_STYLE_FLEX_CROSS_PLACE = 117, + LV_STYLE_FLEX_TRACK_PLACE = 118, + LV_STYLE_FLEX_GROW = 119, #endif #if LV_USE_GRID - LV_STYLE_GRID_COLUMN_ALIGN = 118, - LV_STYLE_GRID_ROW_ALIGN = 119, - LV_STYLE_GRID_ROW_DSC_ARRAY = 120, - LV_STYLE_GRID_COLUMN_DSC_ARRAY = 121, - LV_STYLE_GRID_CELL_COLUMN_POS = 122, - LV_STYLE_GRID_CELL_COLUMN_SPAN = 123, - LV_STYLE_GRID_CELL_X_ALIGN = 124, - LV_STYLE_GRID_CELL_ROW_POS = 125, - LV_STYLE_GRID_CELL_ROW_SPAN = 126, - LV_STYLE_GRID_CELL_Y_ALIGN = 127, + LV_STYLE_GRID_COLUMN_ALIGN = 120, + LV_STYLE_GRID_ROW_ALIGN = 121, + LV_STYLE_GRID_ROW_DSC_ARRAY = 122, + LV_STYLE_GRID_COLUMN_DSC_ARRAY = 123, + LV_STYLE_GRID_CELL_COLUMN_POS = 124, + LV_STYLE_GRID_CELL_COLUMN_SPAN = 125, + LV_STYLE_GRID_CELL_X_ALIGN = 126, + LV_STYLE_GRID_CELL_ROW_POS = 127, + LV_STYLE_GRID_CELL_ROW_SPAN = 128, + LV_STYLE_GRID_CELL_Y_ALIGN = 129, #endif - _LV_STYLE_LAST_BUILT_IN_PROP = 128, + _LV_STYLE_LAST_BUILT_IN_PROP = 130, _LV_STYLE_NUM_BUILT_IN_PROPS = _LV_STYLE_LAST_BUILT_IN_PROP + 1, diff --git a/src/misc/lv_style_gen.c b/src/misc/lv_style_gen.c index 80f3b6fd6..3634a0f90 100644 --- a/src/misc/lv_style_gen.c +++ b/src/misc/lv_style_gen.c @@ -188,6 +188,26 @@ void lv_style_set_transform_pivot_y(lv_style_t * style, int32_t value) const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_PIVOT_Y = LV_STYLE_TRANSFORM_PIVOT_Y; +void lv_style_set_transform_skew_x(lv_style_t * style, int32_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_TRANSFORM_SKEW_X, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_SKEW_X = LV_STYLE_TRANSFORM_SKEW_X; + +void lv_style_set_transform_skew_y(lv_style_t * style, int32_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_TRANSFORM_SKEW_Y, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_SKEW_Y = LV_STYLE_TRANSFORM_SKEW_Y; + void lv_style_set_pad_top(lv_style_t * style, int32_t value) { lv_style_value_t v = { diff --git a/src/misc/lv_style_gen.h b/src/misc/lv_style_gen.h index ee8d10327..58fb407ac 100644 --- a/src/misc/lv_style_gen.h +++ b/src/misc/lv_style_gen.h @@ -45,6 +45,10 @@ void lv_style_set_transform_pivot_x(lv_style_t * style, int32_t value); extern const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_PIVOT_X; void lv_style_set_transform_pivot_y(lv_style_t * style, int32_t value); extern const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_PIVOT_Y; +void lv_style_set_transform_skew_x(lv_style_t * style, int32_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_SKEW_X; +void lv_style_set_transform_skew_y(lv_style_t * style, int32_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_TRANSFORM_SKEW_Y; void lv_style_set_pad_top(lv_style_t * style, int32_t value); extern const lv_style_prop_t _lv_style_const_prop_id_PAD_TOP; void lv_style_set_pad_bottom(lv_style_t * style, int32_t value); @@ -310,6 +314,16 @@ extern const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_ROW_SPAN; .prop_ptr = &_lv_style_const_prop_id_TRANSFORM_PIVOT_Y, .value = { .num = (int32_t)val } \ } +#define LV_STYLE_CONST_TRANSFORM_SKEW_X(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_TRANSFORM_SKEW_X, .value = { .num = (int32_t)val } \ + } + +#define LV_STYLE_CONST_TRANSFORM_SKEW_Y(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_TRANSFORM_SKEW_Y, .value = { .num = (int32_t)val } \ + } + #define LV_STYLE_CONST_PAD_TOP(val) \ { \ .prop_ptr = &_lv_style_const_prop_id_PAD_TOP, .value = { .num = (int32_t)val } \