draw tri: fix pixel overwrite with oapcity (from #1091)
This commit is contained in:
@@ -27,7 +27,6 @@ static void point_swap(lv_point_t * p1, lv_point_t * p2);
|
|||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
**********************/
|
**********************/
|
||||||
static uint8_t corr_value;
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
@@ -47,6 +46,7 @@ static uint8_t corr_value;
|
|||||||
void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const lv_style_t * style,
|
void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const lv_style_t * style,
|
||||||
lv_opa_t opa_scale)
|
lv_opa_t opa_scale)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*Return is the triangle is degenerated*/
|
/*Return is the triangle is degenerated*/
|
||||||
if(points[0].x == points[1].x && points[0].y == points[1].y) return;
|
if(points[0].x == points[1].x && points[0].y == points[1].y) return;
|
||||||
if(points[1].x == points[2].x && points[1].y == points[2].y) return;
|
if(points[1].x == points[2].x && points[1].y == points[2].y) return;
|
||||||
@@ -65,27 +65,19 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const l
|
|||||||
lv_coord_t y_min = LV_MATH_MIN(LV_MATH_MIN(points[0].y, points[1].y), points[2].y);
|
lv_coord_t y_min = LV_MATH_MIN(LV_MATH_MIN(points[0].y, points[1].y), points[2].y);
|
||||||
lv_coord_t y_max = LV_MATH_MAX(LV_MATH_MAX(points[0].y, points[1].y), points[2].y);
|
lv_coord_t y_max = LV_MATH_MAX(LV_MATH_MAX(points[0].y, points[1].y), points[2].y);
|
||||||
|
|
||||||
if(opa < LV_OPA_MAX) {
|
/* Draw the tall rectangles from vertical lines
|
||||||
/*Simply draw the triangles with opacity */
|
* and from the flat triangles from horizontal lines
|
||||||
corr_value = 1;
|
* to minimize the number of lines.
|
||||||
|
* Some pixels are overdrawn on the common edges of the triangles
|
||||||
|
* so use it only if the triangle has no opacity*/
|
||||||
|
|
||||||
|
/* Draw from horizontal lines*/
|
||||||
|
if(x_max - x_min < y_max - y_min) {
|
||||||
tri_draw_tall(points, mask, style, opa);
|
tri_draw_tall(points, mask, style, opa);
|
||||||
} else {
|
}
|
||||||
/* Draw the tall rectangles from vertical lines
|
/*Else flat so draw from vertical lines*/
|
||||||
* and from the flat triangles from horizontal lines
|
else {
|
||||||
* to minimize the number of lines.
|
tri_draw_flat(points, mask, style, opa);
|
||||||
* Some pixels are overdrawn on the common edges of the triangles
|
|
||||||
* so use it only if the triangle has no opacity*/
|
|
||||||
|
|
||||||
corr_value = 0;
|
|
||||||
|
|
||||||
/* Draw from horizontal lines*/
|
|
||||||
if(x_max - x_min < y_max - y_min) {
|
|
||||||
tri_draw_tall(points, mask, style, opa);
|
|
||||||
}
|
|
||||||
/*Else flat so draw from vertical lines*/
|
|
||||||
else {
|
|
||||||
tri_draw_flat(points, mask, style, opa);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +106,6 @@ void lv_draw_polygon(const lv_point_t * points, uint32_t point_cnt, const lv_are
|
|||||||
tri[2].y = points[i+1].y;
|
tri[2].y = points[i+1].y;
|
||||||
lv_draw_triangle(tri, mask, style, opa_scale);
|
lv_draw_triangle(tri, mask, style, opa_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@@ -193,10 +184,10 @@ void tri_draw_flat(const lv_point_t * points, const lv_area_t * mask, const lv_s
|
|||||||
|
|
||||||
/* Get the area of a line.
|
/* Get the area of a line.
|
||||||
* Adjust it a little bit to perfectly match (no redrawn pixels) with the adjacent triangles*/
|
* Adjust it a little bit to perfectly match (no redrawn pixels) with the adjacent triangles*/
|
||||||
draw_area.x1 = LV_MATH_MIN(act_area.x1, act_area.x2);
|
draw_area.x1 = LV_MATH_MIN(act_area.x1, act_area.x2) + 1;
|
||||||
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2) - corr_value;
|
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2);
|
||||||
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2) - 1;
|
||||||
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2);
|
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2) - 1;
|
||||||
|
|
||||||
lv_draw_fill(&draw_area, mask, style->body.main_color, opa);
|
lv_draw_fill(&draw_area, mask, style->body.main_color, opa);
|
||||||
|
|
||||||
@@ -298,7 +289,7 @@ void tri_draw_tall(const lv_point_t * points, const lv_area_t * mask, const lv_s
|
|||||||
draw_area.x1 = LV_MATH_MIN(act_area.x1, act_area.x2);
|
draw_area.x1 = LV_MATH_MIN(act_area.x1, act_area.x2);
|
||||||
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2);
|
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2);
|
||||||
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
||||||
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2) - corr_value;
|
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2) - 1;
|
||||||
|
|
||||||
lv_draw_fill(&draw_area, mask, style->body.main_color, opa);
|
lv_draw_fill(&draw_area, mask, style->body.main_color, opa);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user