fix crash when drawing gradient to the same color

This commit is contained in:
Gabor Kiss-Vamosi
2020-06-16 12:47:09 +02:00
parent f61f045135
commit d6e7187d01
2 changed files with 13 additions and 9 deletions

View File

@@ -185,10 +185,13 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
/*Create a mask if there is a radius*/
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w);
lv_grad_dir_t grad_dir = dsc->bg_grad_dir;
if(dsc->bg_color.full == dsc->bg_grad_color.full) grad_dir = LV_GRAD_DIR_NONE;
uint16_t other_mask_cnt = lv_draw_mask_get_cnt();
bool simple_mode = true;
if(other_mask_cnt) simple_mode = false;
else if(dsc->bg_grad_dir == LV_GRAD_DIR_HOR) simple_mode = false;
else if(grad_dir == LV_GRAD_DIR_HOR) simple_mode = false;
int16_t mask_rout_id = LV_MASK_ID_INV;
@@ -201,7 +204,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
if(rout > short_side >> 1) rout = short_side >> 1;
/*Most simple case: just a plain rectangle*/
if(simple_mode && rout == 0 && (dsc->bg_grad_dir == LV_GRAD_DIR_NONE)) {
if(simple_mode && rout == 0 && (grad_dir == LV_GRAD_DIR_NONE)) {
_lv_blend_fill(clip, &coords_bg,
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
dsc->bg_blend_mode);
@@ -222,7 +225,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
lv_color_t * grad_map = NULL;
/*In case of horizontal gradient pre-compute a line with a gradient*/
if(dsc->bg_grad_dir == LV_GRAD_DIR_HOR && dsc->bg_color.full != dsc->bg_grad_color.full) {
if(grad_dir == LV_GRAD_DIR_HOR) {
grad_map = _lv_mem_buf_get(coords_w * sizeof(lv_color_t));
int32_t i;
@@ -267,7 +270,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
}
/*Get the current line color*/
if(dsc->bg_grad_dir == LV_GRAD_DIR_VER && dsc->bg_color.full != dsc->bg_grad_color.full) {
if(grad_dir == LV_GRAD_DIR_VER) {
grad_color = grad_get(dsc, lv_area_get_height(&coords_bg), y - coords_bg.y1);
}
@@ -288,7 +291,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
grad_color, mask_buf, mask_res, opa2, dsc->bg_blend_mode);
/*Center part*/
if(dsc->bg_grad_dir == LV_GRAD_DIR_VER) {
if(grad_dir == LV_GRAD_DIR_VER) {
fill_area2.x1 = coords_bg.x1 + rout;
fill_area2.x2 = coords_bg.x2 - rout;
_lv_blend_fill(clip, &fill_area2,
@@ -307,10 +310,10 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
}
else {
if(dsc->bg_grad_dir == LV_GRAD_DIR_HOR) {
if(grad_dir == LV_GRAD_DIR_HOR) {
_lv_blend_map(clip, &fill_area, grad_map, mask_buf, mask_res, opa2, dsc->bg_blend_mode);
}
else if(dsc->bg_grad_dir == LV_GRAD_DIR_VER) {
else if(grad_dir == LV_GRAD_DIR_VER) {
_lv_blend_fill(clip, &fill_area,
grad_color, mask_buf, mask_res, opa2, dsc->bg_blend_mode);
}
@@ -323,7 +326,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
fill_area.y2++;
}
if(dsc->bg_grad_dir == LV_GRAD_DIR_NONE && other_mask_cnt == 0 && split) {
if(grad_dir == LV_GRAD_DIR_NONE && other_mask_cnt == 0 && split) {
/*Central part*/
fill_area.x1 = coords_bg.x1 + rout;
fill_area.x2 = coords_bg.x2 - rout;