mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
merge dev-7.0
This commit is contained in:
commit
47f9e42f9a
@ -14,7 +14,7 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define SPLIT_RADIUS_LIMIT 10 /*With radius greater then this the arc will drawn in quarters. A quarter is drawn only if there is arc in it */
|
||||
#define SPLIT_ANGLE_GAP_LIMIT 60 /*With small gaps in the arc don't bother with splitting because there is nothing to skip.
|
||||
#define SPLIT_ANGLE_GAP_LIMIT 60 /*With small gaps in the arc don't bother with splitting because there is nothing to skip.*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -33,6 +33,7 @@ typedef struct {
|
||||
const lv_area_t * clip_area;
|
||||
}quarter_draw_dsc_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
@ -42,6 +43,7 @@ static void draw_quarter_2(quarter_draw_dsc_t* q);
|
||||
static void draw_quarter_3(quarter_draw_dsc_t* q);
|
||||
static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness, lv_area_t * res_area);
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
@ -118,7 +120,6 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
|
||||
} else {
|
||||
lv_draw_rect(&area, clip_area, &cir_dsc);
|
||||
}
|
||||
|
||||
lv_draw_mask_remove_id(mask_angle_id);
|
||||
|
||||
if(dsc->round_start || dsc->round_end) {
|
||||
@ -150,10 +151,10 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void draw_quarter_0(quarter_draw_dsc_t * q)
|
||||
{
|
||||
lv_area_t quarter_area;
|
||||
@ -368,6 +369,8 @@ static void draw_quarter_3(quarter_draw_dsc_t * q)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness, lv_area_t * res_area)
|
||||
{
|
||||
const uint8_t ps = 8;
|
||||
@ -414,3 +417,4 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness,
|
||||
res_area->y2 = cir_y + thick_half - thick_corr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,9 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res)
|
||||
{
|
||||
|
||||
#if LV_USE_GPU
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
#endif
|
||||
|
||||
/*Get the width of the `disp_area` it will be used to go to the next line*/
|
||||
int32_t disp_w = lv_area_get_width(disp_area);
|
||||
@ -518,6 +520,9 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
||||
#if LV_COLOR_SCREEN_TRANSP
|
||||
lv_opa_t opa_composed;
|
||||
#endif
|
||||
#if LV_COLOR_SCREEN_TRANSP || LV_USE_GPU
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
#endif
|
||||
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
@ -527,7 +532,6 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
||||
/*Go to the first px of the row*/
|
||||
map_buf_tmp += (draw_area->x1 - (map_area->x1 - disp_area->x1));
|
||||
#if LV_USE_GPU
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
if(disp->driver.gpu_blend_cb &&
|
||||
((draw_area_w > GPU_WIDTH_LIMIT * 4 && opa == LV_OPA_COVER) ||
|
||||
(draw_area_w > GPU_WIDTH_LIMIT && opa != LV_OPA_COVER))) {
|
||||
|
@ -31,8 +31,8 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
|
||||
static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i);
|
||||
static void shadow_draw_corner_buf(const lv_area_t * coords, lv_opa_t * sh_buf, lv_coord_t s, lv_coord_t r);
|
||||
static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, lv_opa_t * res_buf, uint16_t * sh_ups_buf);
|
||||
static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf, lv_coord_t s, lv_coord_t r);
|
||||
static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups_buf);
|
||||
static void draw_img(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
|
||||
/**********************
|
||||
@ -578,8 +578,8 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
|
||||
int32_t corner_size = sw + r_sh;
|
||||
|
||||
lv_opa_t * sh_buf = lv_mem_buf_get(corner_size * corner_size);
|
||||
shadow_draw_corner_buf(&sh_rect_area, sh_buf, dsc->shadow_width, r_sh);
|
||||
lv_opa_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);
|
||||
|
||||
bool simple_mode = true;
|
||||
if(lv_draw_mask_get_cnt() > 0) simple_mode = false;
|
||||
@ -889,7 +889,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
||||
lv_mem_buf_release(sh_buf);
|
||||
}
|
||||
|
||||
static void shadow_draw_corner_buf(const lv_area_t * coords, lv_opa_t * sh_buf, lv_coord_t sw, lv_coord_t r)
|
||||
static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf, lv_coord_t sw, lv_coord_t r)
|
||||
{
|
||||
int32_t sw_ori = sw;
|
||||
int32_t size = sw_ori + r;
|
||||
@ -916,13 +916,12 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, lv_opa_t * sh_buf,
|
||||
lv_draw_mask_res_t mask_res;
|
||||
int32_t y;
|
||||
lv_opa_t * mask_line = lv_mem_buf_get(size);
|
||||
uint16_t * sh_ups_buf = lv_mem_buf_get(size * size * sizeof(uint16_t));
|
||||
uint16_t * sh_ups_tmp_buf = sh_ups_buf;
|
||||
uint16_t * sh_ups_tmp_buf = (uint16_t *)sh_buf;
|
||||
for(y = 0; y < size; y++) {
|
||||
memset(mask_line, 0xFF, size);
|
||||
mask_res = mask_param.dsc.cb(mask_line, 0, y, size, &mask_param);
|
||||
if(mask_res == LV_DRAW_MASK_RES_FULL_TRANSP) {
|
||||
memset(sh_ups_tmp_buf, 0x00, size * sizeof(sh_ups_buf[0]));
|
||||
memset(sh_ups_tmp_buf, 0x00, size * sizeof(sh_ups_tmp_buf[0]));
|
||||
} else {
|
||||
int32_t i;
|
||||
sh_ups_tmp_buf[0] = (mask_line[0] << SHADOW_UPSACALE_SHIFT) / sw;
|
||||
@ -937,57 +936,62 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, lv_opa_t * sh_buf,
|
||||
lv_mem_buf_release(mask_line);
|
||||
|
||||
if(sw == 1) {
|
||||
int32_t i;
|
||||
uint32_t i;
|
||||
lv_opa_t * res_buf = (lv_opa_t *)sh_buf;
|
||||
for(i = 0; i < size * size; i++) {
|
||||
sh_buf[i] = (sh_ups_buf[i] >> SHADOW_UPSACALE_SHIFT);
|
||||
res_buf[i] = (sh_buf[i] >> SHADOW_UPSACALE_SHIFT);
|
||||
}
|
||||
lv_mem_buf_release(sh_ups_buf);
|
||||
return;
|
||||
}
|
||||
|
||||
shadow_blur_corner(size, sw, sh_buf, sh_ups_buf);
|
||||
shadow_blur_corner(size, sw, sh_buf);
|
||||
|
||||
#if SHADOW_ENHANCE
|
||||
#if SHADOW_ENHANCE == 0
|
||||
/*The result is required in lv_opa_t not uint16_t*/
|
||||
uint32_t x;
|
||||
lv_opa_t * res_buf = (lv_opa_t *)sh_buf;
|
||||
for(x = 0; x < size * size; x++) {
|
||||
res_buf[x] = sh_buf[x];
|
||||
}
|
||||
#else
|
||||
sw = sw_ori - sw;
|
||||
if(sw <= 1) {
|
||||
lv_mem_buf_release(sh_ups_buf);
|
||||
return;
|
||||
}
|
||||
if(sw > 1) {
|
||||
uint32_t i;
|
||||
sh_buf[0] = (sh_buf[0] << SHADOW_UPSACALE_SHIFT) / sw;
|
||||
for(i = 1; i < (uint32_t) size * size; i++) {
|
||||
if(sh_buf[i] == sh_buf[i-1]) sh_buf[i] = sh_buf[i-1];
|
||||
else sh_buf[i] = (sh_buf[i] << SHADOW_UPSACALE_SHIFT) / sw;
|
||||
}
|
||||
|
||||
uint32_t i;
|
||||
sh_ups_buf[0] = (sh_buf[0] << SHADOW_UPSACALE_SHIFT) / sw;
|
||||
for(i = 1; i < (uint32_t) size * size; i++) {
|
||||
if(sh_buf[i] == sh_buf[i-1]) sh_ups_buf[i] = sh_ups_buf[i-1];
|
||||
else sh_ups_buf[i] = (sh_buf[i] << SHADOW_UPSACALE_SHIFT) / sw;
|
||||
shadow_blur_corner(size, sw, sh_buf);
|
||||
}
|
||||
uint32_t x;
|
||||
lv_opa_t * res_buf = (lv_opa_t *)sh_buf;
|
||||
for(x = 0; x < size * size; x++) {
|
||||
res_buf[x] = sh_buf[x];
|
||||
}
|
||||
|
||||
shadow_blur_corner(size, sw, sh_buf, sh_ups_buf);
|
||||
#endif
|
||||
|
||||
lv_mem_buf_release(sh_ups_buf);
|
||||
|
||||
}
|
||||
|
||||
static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, lv_opa_t * res_buf, uint16_t * sh_ups_buf)
|
||||
static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups_buf)
|
||||
{
|
||||
int32_t s_left = sw >> 1;
|
||||
int32_t s_right = (sw >> 1);
|
||||
if((sw & 1) == 0) s_left--;
|
||||
|
||||
/*Horizontal blur*/
|
||||
uint16_t * sh_ups_hor_buf = lv_mem_buf_get(size * size * sizeof(uint16_t));
|
||||
uint16_t * sh_ups_hor_buf_tmp;
|
||||
uint16_t * sh_ups_blur_buf = lv_mem_buf_get(size * sizeof(uint16_t));
|
||||
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
|
||||
uint16_t * sh_ups_tmp_buf = sh_ups_buf;
|
||||
sh_ups_hor_buf_tmp = sh_ups_hor_buf;
|
||||
|
||||
for(y = 0; y < size; y++) {
|
||||
int32_t v = sh_ups_tmp_buf[size-1] * sw;
|
||||
for(x = size - 1; x >=0; x--) {
|
||||
sh_ups_hor_buf_tmp[x] = v;
|
||||
sh_ups_blur_buf[x] = v;
|
||||
|
||||
/*Forget the right pixel*/
|
||||
uint32_t right_val = 0;
|
||||
@ -1000,43 +1004,45 @@ static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, lv_opa_t * res_bu
|
||||
else left_val = sh_ups_tmp_buf[x - s_left - 1];
|
||||
v += left_val;
|
||||
}
|
||||
|
||||
memcpy(sh_ups_tmp_buf, sh_ups_blur_buf, size * sizeof(uint16_t));
|
||||
sh_ups_tmp_buf += size;
|
||||
sh_ups_hor_buf_tmp += size;
|
||||
}
|
||||
|
||||
/*Vertical blur*/
|
||||
uint32_t i;
|
||||
sh_ups_hor_buf[0] = sh_ups_hor_buf[0] / sw;
|
||||
sh_ups_buf[0] = sh_ups_buf[0] / sw;
|
||||
for(i = 1; i < (uint32_t)size * size; i++) {
|
||||
if(sh_ups_hor_buf[i] == sh_ups_hor_buf[i-1]) sh_ups_hor_buf[i] = sh_ups_hor_buf[i-1];
|
||||
else sh_ups_hor_buf[i] = sh_ups_hor_buf[i] / sw;
|
||||
if(sh_ups_buf[i] == sh_ups_buf[i-1]) sh_ups_buf[i] = sh_ups_buf[i-1];
|
||||
else sh_ups_buf[i] = sh_ups_buf[i] / sw;
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(x = 0; x < size; x++) {
|
||||
sh_ups_hor_buf_tmp = &sh_ups_hor_buf[x];
|
||||
lv_opa_t * sh_buf_tmp = &res_buf[x];
|
||||
int32_t v = sh_ups_hor_buf_tmp[0] * sw;
|
||||
for(y = 0; y < size ; y++, sh_ups_hor_buf_tmp += size, sh_buf_tmp += size) {
|
||||
sh_buf_tmp[0] = v < 0 ? 0 : (v >> SHADOW_UPSACALE_SHIFT);
|
||||
sh_ups_tmp_buf = &sh_ups_buf[x];
|
||||
int32_t v = sh_ups_tmp_buf[0] * sw;
|
||||
for(y = 0; y < size ; y++, sh_ups_tmp_buf += size) {
|
||||
sh_ups_blur_buf[y] = v < 0 ? 0 : (v >> SHADOW_UPSACALE_SHIFT);
|
||||
|
||||
/*Forget the top pixel*/
|
||||
uint32_t top_val;
|
||||
if(y - s_right <= 0) top_val = sh_ups_hor_buf_tmp[0];
|
||||
else top_val = sh_ups_hor_buf[(y - s_right) * size + x];
|
||||
if(y - s_right <= 0) top_val = sh_ups_tmp_buf[0];
|
||||
else top_val = sh_ups_buf[(y - s_right) * size + x];
|
||||
v -= top_val;
|
||||
|
||||
/*Add the bottom pixel*/
|
||||
uint32_t bottom_val;
|
||||
if(y + s_left + 1 < size) bottom_val = sh_ups_hor_buf[(y + s_left + 1) * size + x];
|
||||
else bottom_val = sh_ups_hor_buf[(size - 1) * size + x];
|
||||
if(y + s_left + 1 < size) bottom_val = sh_ups_buf[(y + s_left + 1) * size + x];
|
||||
else bottom_val = sh_ups_buf[(size - 1) * size + x];
|
||||
v += bottom_val;
|
||||
}
|
||||
|
||||
/*Write back the result into `sh_ups_buf`*/
|
||||
sh_ups_tmp_buf = &sh_ups_buf[x];
|
||||
for(y = 0; y < size; y++, sh_ups_tmp_buf += size) {
|
||||
(*sh_ups_tmp_buf) = sh_ups_blur_buf[y];
|
||||
}
|
||||
}
|
||||
|
||||
lv_mem_buf_release(sh_ups_hor_buf);
|
||||
lv_mem_buf_release(sh_ups_blur_buf);
|
||||
}
|
||||
|
||||
static void draw_img(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
|
||||
|
@ -654,6 +654,8 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa)
|
||||
lv_img_buf_set_px_alpha(dsc, x, y, opa);
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_invalidate(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -723,6 +725,8 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
lv_draw_rect(&coords, &mask, rect_dsc);
|
||||
|
||||
lv_refr_set_disp_refreshing(refr_ori);
|
||||
|
||||
lv_obj_invalidate(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -792,6 +796,8 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
lv_draw_label(&coords, &mask, label_draw_dsc, txt, NULL);
|
||||
|
||||
lv_refr_set_disp_refreshing(refr_ori);
|
||||
|
||||
lv_obj_invalidate(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -853,6 +859,8 @@ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const voi
|
||||
lv_draw_img(&coords, &mask, src, img_draw_dsc);
|
||||
|
||||
lv_refr_set_disp_refreshing(refr_ori);
|
||||
|
||||
lv_obj_invalidate(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -914,6 +922,8 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t
|
||||
}
|
||||
|
||||
lv_refr_set_disp_refreshing(refr_ori);
|
||||
|
||||
lv_obj_invalidate(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -973,6 +983,8 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32
|
||||
// lv_draw_polygon(points, point_cnt, &mask, poly_draw_dsc);
|
||||
|
||||
lv_refr_set_disp_refreshing(refr_ori);
|
||||
|
||||
lv_obj_invalidate(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1036,6 +1048,8 @@ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_
|
||||
lv_draw_arc(x, y, r, start_angle, end_angle, &mask, arc_draw_dsc);
|
||||
|
||||
lv_refr_set_disp_refreshing(refr_ori);
|
||||
|
||||
lv_obj_invalidate(canvas);
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
@ -277,8 +277,8 @@ static void basic_init(void)
|
||||
lv_style_set_border_opa(&btn, LV_STYLE_STATE_NORMAL, LV_OPA_50);
|
||||
lv_style_set_shadow_width(&btn, LV_STYLE_STATE_NORMAL, 10);
|
||||
// lv_style_set_shadow_width(&btn, LV_STYLE_STATE_PRESSED, 2);
|
||||
lv_style_set_shadow_offset_x(&btn, LV_STYLE_STATE_NORMAL, 35);
|
||||
lv_style_set_shadow_offset_y(&btn, LV_STYLE_STATE_NORMAL, 80);
|
||||
// lv_style_set_shadow_offset_x(&btn, LV_STYLE_STATE_NORMAL, 35);
|
||||
lv_style_set_shadow_offset_y(&btn, LV_STYLE_STATE_NORMAL, 8);
|
||||
lv_style_set_shadow_offset_y(&btn, LV_STYLE_STATE_PRESSED, 1);
|
||||
lv_style_set_shadow_color(&btn, LV_STYLE_STATE_NORMAL, LV_COLOR_BLUE);
|
||||
// lv_style_set_shadow_spread(&btn, LV_STYLE_STATE_NORMAL, 5);
|
||||
|
Loading…
x
Reference in New Issue
Block a user