merge dev-7.0
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user