fix(pos): fix invalidate area problem with transform (#4285)

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
Benign X
2023-06-14 03:16:22 +08:00
committed by GitHub
parent 4404bc4d34
commit caf9d16dc9
12 changed files with 27 additions and 21 deletions

View File

@@ -811,7 +811,6 @@ void lv_obj_get_transformed_area(const lv_obj_t * obj, lv_area_t * area, bool re
area->x2 = LV_MAX4(p[0].x, p[1].x, p[2].x, p[3].x); area->x2 = LV_MAX4(p[0].x, p[1].x, p[2].x, p[3].x);
area->y1 = LV_MIN4(p[0].y, p[1].y, p[2].y, p[3].y); area->y1 = LV_MIN4(p[0].y, p[1].y, p[2].y, p[3].y);
area->y2 = LV_MAX4(p[0].y, p[1].y, p[2].y, p[3].y); area->y2 = LV_MAX4(p[0].y, p[1].y, p[2].y, p[3].y);
lv_area_increase(area, 5, 5);
} }

View File

@@ -81,6 +81,9 @@ void lv_obj_add_style(lv_obj_t * obj, const lv_style_t * style, lv_style_selecto
trans_del(obj, selector, LV_STYLE_PROP_ANY, NULL); trans_del(obj, selector, LV_STYLE_PROP_ANY, NULL);
if(style && selector == LV_PART_MAIN && lv_style_prop_has_flag(style->prop1, LV_STYLE_PROP_FLAG_TRANSFORM))
lv_obj_invalidate(obj);
/*Try removing the style first to be sure it won't be added twice*/ /*Try removing the style first to be sure it won't be added twice*/
lv_obj_remove_style(obj, style, selector); lv_obj_remove_style(obj, style, selector);
@@ -164,6 +167,9 @@ void lv_obj_remove_style(lv_obj_t * obj, const lv_style_t * style, lv_style_sele
lv_style_prop_t prop = LV_STYLE_PROP_ANY; lv_style_prop_t prop = LV_STYLE_PROP_ANY;
if(style && style->prop_cnt == 0) prop = LV_STYLE_PROP_INV; if(style && style->prop_cnt == 0) prop = LV_STYLE_PROP_INV;
if(style && selector == LV_PART_MAIN && lv_style_prop_has_flag(style->prop1, LV_STYLE_PROP_FLAG_TRANSFORM))
lv_obj_invalidate(obj);
uint32_t i = 0; uint32_t i = 0;
bool deleted = false; bool deleted = false;
while(i < obj->style_cnt) { while(i < obj->style_cnt) {
@@ -330,6 +336,8 @@ void lv_obj_set_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_
lv_style_selector_t selector) lv_style_selector_t selector)
{ {
lv_style_t * style = get_local_style(obj, selector); lv_style_t * style = get_local_style(obj, selector);
if(selector == LV_PART_MAIN && lv_style_prop_has_flag(prop, LV_STYLE_PROP_FLAG_TRANSFORM))
lv_obj_invalidate(obj);
lv_style_set_prop(style, prop, value); lv_style_set_prop(style, prop, value);
lv_obj_refresh_style(obj, selector, prop); lv_obj_refresh_style(obj, selector, prop);
} }
@@ -342,7 +350,6 @@ void lv_obj_set_local_style_prop_meta(lv_obj_t * obj, lv_style_prop_t prop, uint
lv_obj_refresh_style(obj, selector, prop); lv_obj_refresh_style(obj, selector, prop);
} }
lv_style_res_t lv_obj_get_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t * value, lv_style_res_t lv_obj_get_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t * value,
lv_style_selector_t selector) lv_style_selector_t selector)
{ {
@@ -924,4 +931,3 @@ static void fade_in_anim_ready(lv_anim_t * a)
lv_obj_remove_local_style_prop(a->var, LV_STYLE_OPA, 0); lv_obj_remove_local_style_prop(a->var, LV_STYLE_OPA, 0);
} }

View File

@@ -72,9 +72,9 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t
lv_point_t p[4] = { lv_point_t p[4] = {
{0, 0}, {0, 0},
{w, 0}, {w - 1, 0},
{0, h}, {0, h - 1},
{w, h}, {w - 1, h - 1},
}; };
lv_point_transform(&p[0], angle, zoom, pivot); lv_point_transform(&p[0], angle, zoom, pivot);
lv_point_transform(&p[1], angle, zoom, pivot); lv_point_transform(&p[1], angle, zoom, pivot);

View File

@@ -23,13 +23,13 @@
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
**********************/ **********************/
static const int16_t sin0_90_table[] = { static const uint16_t sin0_90_table[] = {
0, 572, 1144, 1715, 2286, 2856, 3425, 3993, 4560, 5126, 5690, 6252, 6813, 7371, 7927, 8481, 0, 572, 1144, 1715, 2286, 2856, 3425, 3993, 4560, 5126, 5690, 6252, 6813, 7371, 7927, 8481,
9032, 9580, 10126, 10668, 11207, 11743, 12275, 12803, 13328, 13848, 14364, 14876, 15383, 15886, 16383, 16876, 9032, 9580, 10126, 10668, 11207, 11743, 12275, 12803, 13328, 13848, 14365, 14876, 15384, 15886, 16384, 16877,
17364, 17846, 18323, 18794, 19260, 19720, 20173, 20621, 21062, 21497, 21925, 22347, 22762, 23170, 23571, 23964, 17364, 17847, 18324, 18795, 19261, 19720, 20174, 20622, 21063, 21498, 21926, 22348, 22763, 23170, 23571, 23965,
24351, 24730, 25101, 25465, 25821, 26169, 26509, 26841, 27165, 27481, 27788, 28087, 28377, 28659, 28932, 29196, 24351, 24730, 25102, 25466, 25822, 26170, 26510, 26842, 27166, 27482, 27789, 28088, 28378, 28660, 28932, 29197,
29451, 29697, 29934, 30162, 30381, 30591, 30791, 30982, 31163, 31335, 31498, 31650, 31794, 31927, 32051, 32165, 29452, 29698, 29935, 30163, 30382, 30592, 30792, 30983, 31164, 31336, 31499, 31651, 31795, 31928, 32052, 32166,
32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762, 32767 32270, 32365, 32449, 32524, 32588, 32643, 32688, 32723, 32748, 32763, 32768
}; };
/********************** /**********************
@@ -45,9 +45,9 @@ static const int16_t sin0_90_table[] = {
* @param angle * @param angle
* @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 * @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 int32_t lv_trigo_sin(int16_t angle)
{ {
int16_t ret = 0; int32_t ret = 0;
angle = angle % 360; angle = angle % 360;
if(angle < 0) angle = 360 + angle; if(angle < 0) angle = 360 + angle;

View File

@@ -44,9 +44,9 @@ typedef struct {
* @param angle * @param angle
* @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 * @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 int32_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 int32_t lv_trigo_cos(int16_t angle)
{ {
return lv_trigo_sin(angle + 90); return lv_trigo_sin(angle + 90);
} }

View File

@@ -47,12 +47,12 @@ const uint8_t _lv_style_builtin_prop_flag_lookup_table[_LV_STYLE_NUM_BUILT_IN_PR
[LV_STYLE_X] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, [LV_STYLE_X] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE,
[LV_STYLE_Y] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, [LV_STYLE_Y] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE,
[LV_STYLE_ALIGN] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, [LV_STYLE_ALIGN] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE,
[LV_STYLE_TRANSFORM_WIDTH] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE, [LV_STYLE_TRANSFORM_WIDTH] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_TRANSFORM,
[LV_STYLE_TRANSFORM_HEIGHT] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE, [LV_STYLE_TRANSFORM_HEIGHT] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_TRANSFORM,
[LV_STYLE_TRANSLATE_X] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE | LV_STYLE_PROP_FLAG_PARENT_LAYOUT_UPDATE, [LV_STYLE_TRANSLATE_X] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE | LV_STYLE_PROP_FLAG_PARENT_LAYOUT_UPDATE,
[LV_STYLE_TRANSLATE_Y] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE | LV_STYLE_PROP_FLAG_PARENT_LAYOUT_UPDATE, [LV_STYLE_TRANSLATE_Y] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE | LV_STYLE_PROP_FLAG_PARENT_LAYOUT_UPDATE,
[LV_STYLE_TRANSFORM_ZOOM] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYER_UPDATE, [LV_STYLE_TRANSFORM_ZOOM] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYER_UPDATE | LV_STYLE_PROP_FLAG_TRANSFORM,
[LV_STYLE_TRANSFORM_ANGLE] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYER_UPDATE, [LV_STYLE_TRANSFORM_ANGLE] = 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, [LV_STYLE_PAD_TOP] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYOUT_UPDATE,
[LV_STYLE_PAD_BOTTOM] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, [LV_STYLE_PAD_BOTTOM] = LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE | LV_STYLE_PROP_FLAG_LAYOUT_UPDATE,

View File

@@ -41,7 +41,8 @@ extern "C" {
#define LV_STYLE_PROP_FLAG_LAYOUT_UPDATE (1 << 2) /*Requires layout update when changed*/ #define LV_STYLE_PROP_FLAG_LAYOUT_UPDATE (1 << 2) /*Requires layout update when changed*/
#define LV_STYLE_PROP_FLAG_PARENT_LAYOUT_UPDATE (1 << 3) /*Requires layout update on parent when changed*/ #define LV_STYLE_PROP_FLAG_PARENT_LAYOUT_UPDATE (1 << 3) /*Requires layout update on parent when changed*/
#define LV_STYLE_PROP_FLAG_LAYER_UPDATE (1 << 4) /*Affects layer handling*/ #define LV_STYLE_PROP_FLAG_LAYER_UPDATE (1 << 4) /*Affects layer handling*/
#define LV_STYLE_PROP_FLAG_ALL (0x1F) /*Indicating all flags*/ #define LV_STYLE_PROP_FLAG_TRANSFORM (1 << 5) /*Affects the object's transformation*/
#define LV_STYLE_PROP_FLAG_ALL (0x3F) /*Indicating all flags*/
/** /**
* Other constants * Other constants

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB