Update lvgl to v8.4.0

This commit is contained in:
lewisxhe
2024-09-13 11:35:47 +08:00
parent 1a57bfcf2b
commit f285d52d61
641 changed files with 25425 additions and 30726 deletions
+50 -76
View File
@@ -9,6 +9,7 @@
#include "lv_img.h"
#if LV_USE_IMG != 0
#include "../core/lv_disp.h"
#include "../misc/lv_assert.h"
#include "../draw/lv_img_decoder.h"
#include "../misc/lv_fs.h"
@@ -165,8 +166,6 @@ void lv_img_set_offset_x(lv_obj_t * obj, lv_coord_t x)
lv_img_t * img = (lv_img_t *)obj;
x = x % img->w;
img->offset.x = x;
lv_obj_invalidate(obj);
}
@@ -177,29 +176,23 @@ void lv_img_set_offset_y(lv_obj_t * obj, lv_coord_t y)
lv_img_t * img = (lv_img_t *)obj;
y = y % img->h;
img->offset.y = y;
lv_obj_invalidate(obj);
}
void lv_img_set_angle(lv_obj_t * obj, int16_t angle)
{
if(angle < 0 || angle >= 3600) angle = angle % 3600;
while(angle >= 3600) angle -= 3600;
while(angle < 0) angle += 3600;
lv_img_t * img = (lv_img_t *)obj;
if(angle == img->angle) return;
lv_coord_t transf_zoom = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
transf_zoom = ((int32_t)transf_zoom * img->zoom) >> 8;
lv_coord_t transf_angle = lv_obj_get_style_transform_angle(obj, LV_PART_MAIN);
lv_obj_update_layout(obj); /*Be sure the object's size is calculated*/
lv_coord_t w = lv_obj_get_width(obj);
lv_coord_t h = lv_obj_get_height(obj);
lv_area_t a;
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle + img->angle, transf_zoom, &img->pivot);
_lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &img->pivot);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@@ -207,9 +200,15 @@ void lv_img_set_angle(lv_obj_t * obj, int16_t angle)
lv_obj_invalidate_area(obj, &a);
img->angle = angle;
lv_obj_refresh_ext_draw_size(obj);
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle + img->angle, transf_zoom, &img->pivot);
/* Disable invalidations because lv_obj_refresh_ext_draw_size would invalidate
* the whole ext draw area */
lv_disp_t * disp = lv_obj_get_disp(obj);
lv_disp_enable_invalidation(disp, false);
lv_obj_refresh_ext_draw_size(obj);
lv_disp_enable_invalidation(disp, true);
_lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &img->pivot);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@@ -222,17 +221,11 @@ void lv_img_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
lv_img_t * img = (lv_img_t *)obj;
if(img->pivot.x == x && img->pivot.y == y) return;
lv_coord_t transf_zoom = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
transf_zoom = ((int32_t)transf_zoom * img->zoom) >> 8;
lv_coord_t transf_angle = lv_obj_get_style_transform_angle(obj, LV_PART_MAIN);
transf_angle += img->angle;
lv_obj_update_layout(obj); /*Be sure the object's size is calculated*/
lv_coord_t w = lv_obj_get_width(obj);
lv_coord_t h = lv_obj_get_height(obj);
lv_area_t a;
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle, transf_zoom, &img->pivot);
_lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &img->pivot);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@@ -241,9 +234,15 @@ void lv_img_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
img->pivot.x = x;
img->pivot.y = y;
lv_obj_refresh_ext_draw_size(obj);
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle, transf_zoom, &img->pivot);
/* Disable invalidations because lv_obj_refresh_ext_draw_size would invalidate
* the whole ext draw area */
lv_disp_t * disp = lv_obj_get_disp(obj);
lv_disp_enable_invalidation(disp, false);
lv_obj_refresh_ext_draw_size(obj);
lv_disp_enable_invalidation(disp, true);
_lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &img->pivot);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@@ -258,16 +257,11 @@ void lv_img_set_zoom(lv_obj_t * obj, uint16_t zoom)
if(zoom == 0) zoom = 1;
lv_coord_t transf_zoom = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
lv_coord_t transf_angle = lv_obj_get_style_transform_angle(obj, LV_PART_MAIN);
transf_angle += img->angle;
lv_obj_update_layout(obj); /*Be sure the object's size is calculated*/
lv_coord_t w = lv_obj_get_width(obj);
lv_coord_t h = lv_obj_get_height(obj);
lv_area_t a;
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle, ((int32_t)transf_zoom * img->zoom) >> 8, &img->pivot);
_lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom >> 8, &img->pivot);
a.x1 += obj->coords.x1 - 1;
a.y1 += obj->coords.y1 - 1;
a.x2 += obj->coords.x1 + 1;
@@ -275,9 +269,15 @@ void lv_img_set_zoom(lv_obj_t * obj, uint16_t zoom)
lv_obj_invalidate_area(obj, &a);
img->zoom = zoom;
lv_obj_refresh_ext_draw_size(obj);
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle, ((int32_t)transf_zoom * img->zoom) >> 8, &img->pivot);
/* Disable invalidations because lv_obj_refresh_ext_draw_size would invalidate
* the whole ext draw area */
lv_disp_t * disp = lv_obj_get_disp(obj);
lv_disp_enable_invalidation(disp, false);
lv_obj_refresh_ext_draw_size(obj);
lv_disp_enable_invalidation(disp, true);
_lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &img->pivot);
a.x1 += obj->coords.x1 - 1;
a.y1 += obj->coords.y1 - 1;
a.x2 += obj->coords.x1 + 1;
@@ -424,14 +424,9 @@ static lv_point_t lv_img_get_transformed_size(lv_obj_t * obj)
{
lv_img_t * img = (lv_img_t *)obj;
int32_t zoom_final = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
zoom_final = (zoom_final * img->zoom) >> 8;
int32_t angle_final = lv_obj_get_style_transform_angle(obj, LV_PART_MAIN);
angle_final += img->angle;
lv_area_t area_transform;
_lv_img_buf_get_transformed_area(&area_transform, img->w, img->h,
angle_final, zoom_final, &img->pivot);
img->angle, img->zoom, &img->pivot);
return (lv_point_t) {
lv_area_get_width(&area_transform), lv_area_get_height(&area_transform)
@@ -467,42 +462,31 @@ static void lv_img_event(const lv_obj_class_t * class_p, lv_event_t * e)
else if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
lv_coord_t * s = lv_event_get_param(e);
lv_coord_t transf_zoom = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
transf_zoom = ((int32_t)transf_zoom * img->zoom) >> 8;
lv_coord_t transf_angle = lv_obj_get_style_transform_angle(obj, LV_PART_MAIN);
transf_angle += img->angle;
/*If the image has angle provide enough room for the rotated corners*/
if(transf_angle || transf_zoom != LV_IMG_ZOOM_NONE) {
if(img->angle || img->zoom != LV_IMG_ZOOM_NONE) {
lv_area_t a;
lv_coord_t w = lv_obj_get_width(obj);
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_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);
_lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &img->pivot);
*s = LV_MAX(*s, -a.x1);
*s = LV_MAX(*s, -a.y1);
*s = LV_MAX(*s, a.x2 - w);
*s = LV_MAX(*s, a.y2 - h);
}
}
else if(code == LV_EVENT_HIT_TEST) {
lv_hit_test_info_t * info = lv_event_get_param(e);
lv_coord_t zoom = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
zoom = (zoom * img->zoom) >> 8;
lv_coord_t angle = lv_obj_get_style_transform_angle(obj, LV_PART_MAIN);
angle += img->angle;
/*If the object is exactly image sized (not cropped, not mosaic) and transformed
*perform hit test on its transformed area*/
if(img->w == lv_obj_get_width(obj) && img->h == lv_obj_get_height(obj) &&
(zoom != LV_IMG_ZOOM_NONE || angle != 0 || img->pivot.x != img->w / 2 || img->pivot.y != img->h / 2)) {
(img->zoom != LV_IMG_ZOOM_NONE || img->angle != 0 || img->pivot.x != img->w / 2 || img->pivot.y != img->h / 2)) {
lv_coord_t w = lv_obj_get_width(obj);
lv_coord_t h = lv_obj_get_height(obj);
lv_area_t coords;
_lv_img_buf_get_transformed_area(&coords, w, h, angle, zoom, &img->pivot);
_lv_img_buf_get_transformed_area(&coords, w, h, img->angle, img->zoom, &img->pivot);
coords.x1 += obj->coords.x1;
coords.y1 += obj->coords.y1;
coords.x2 += obj->coords.x1;
@@ -556,19 +540,13 @@ static void draw_img(lv_event_t * e)
return;
}
int32_t angle_final = lv_obj_get_style_transform_angle(obj, LV_PART_MAIN);
angle_final += img->angle;
if(angle_final != 0) {
if(img->angle != 0) {
info->res = LV_COVER_RES_NOT_COVER;
return;
}
int32_t zoom_final = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
zoom_final = (zoom_final * img->zoom) >> 8;
const lv_area_t * clip_area = lv_event_get_param(e);
if(zoom_final == LV_IMG_ZOOM_NONE) {
if(img->zoom == LV_IMG_ZOOM_NONE) {
if(_lv_area_is_in(clip_area, &obj->coords, 0) == false) {
info->res = LV_COVER_RES_NOT_COVER;
return;
@@ -576,7 +554,7 @@ static void draw_img(lv_event_t * e)
}
else {
lv_area_t a;
_lv_img_buf_get_transformed_area(&a, lv_obj_get_width(obj), lv_obj_get_height(obj), 0, zoom_final, &img->pivot);
_lv_img_buf_get_transformed_area(&a, lv_obj_get_width(obj), lv_obj_get_height(obj), 0, img->zoom, &img->pivot);
a.x1 += obj->coords.x1;
a.y1 += obj->coords.y1;
a.x2 += obj->coords.x1;
@@ -590,12 +568,6 @@ static void draw_img(lv_event_t * e)
}
else if(code == LV_EVENT_DRAW_MAIN || code == LV_EVENT_DRAW_POST) {
int32_t zoom_final = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
zoom_final = (zoom_final * img->zoom) >> 8;
int32_t angle_final = lv_obj_get_style_transform_angle(obj, LV_PART_MAIN);
angle_final += img->angle;
lv_coord_t obj_w = lv_obj_get_width(obj);
lv_coord_t obj_h = lv_obj_get_height(obj);
@@ -616,7 +588,7 @@ static void draw_img(lv_event_t * e)
}
else {
_lv_img_buf_get_transformed_area(&bg_coords, obj_w, obj_h,
angle_final, zoom_final, &bg_pivot);
img->angle, img->zoom, &bg_pivot);
/*Modify the coordinates to draw the background for the rotated and scaled coordinates*/
bg_coords.x1 += obj->coords.x1;
@@ -636,7 +608,7 @@ static void draw_img(lv_event_t * e)
if(code == LV_EVENT_DRAW_MAIN) {
if(img->h == 0 || img->w == 0) return;
if(zoom_final == 0) return;
if(img->zoom == 0) return;
lv_draw_ctx_t * draw_ctx = lv_event_get_draw_ctx(e);
@@ -666,8 +638,8 @@ static void draw_img(lv_event_t * e)
lv_draw_img_dsc_init(&img_dsc);
lv_obj_init_draw_img_dsc(obj, LV_PART_MAIN, &img_dsc);
img_dsc.zoom = zoom_final;
img_dsc.angle = angle_final;
img_dsc.zoom = img->zoom;
img_dsc.angle = img->angle;
img_dsc.pivot.x = img->pivot.x;
img_dsc.pivot.y = img->pivot.y;
img_dsc.antialias = img->antialias;
@@ -683,12 +655,14 @@ static void draw_img(lv_event_t * e)
draw_ctx->clip_area = &img_clip_area;
lv_area_t coords_tmp;
coords_tmp.y1 = img_max_area.y1 + img->offset.y;
lv_coord_t offset_x = img->offset.x % img->w;
lv_coord_t offset_y = img->offset.y % img->h;
coords_tmp.y1 = img_max_area.y1 + offset_y;
if(coords_tmp.y1 > img_max_area.y1) coords_tmp.y1 -= img->h;
coords_tmp.y2 = coords_tmp.y1 + img->h - 1;
for(; coords_tmp.y1 < img_max_area.y2; coords_tmp.y1 += img_size_final.y, coords_tmp.y2 += img_size_final.y) {
coords_tmp.x1 = img_max_area.x1 + img->offset.x;
coords_tmp.x1 = img_max_area.x1 + offset_x;
if(coords_tmp.x1 > img_max_area.x1) coords_tmp.x1 -= img->w;
coords_tmp.x2 = coords_tmp.x1 + img->w - 1;