mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
draw_triange/line optimization: return if the coords are out of the mask
This commit is contained in:
parent
1ddf659631
commit
0f6f2accb6
@ -85,6 +85,12 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
if(style->line.width == 0) return;
|
||||
if(point1->x == point2->x && point1->y == point2->y) return;
|
||||
|
||||
/*Return if the points are out of the mask*/
|
||||
if(point1->x < mask->x1 && point2->x < mask->x1) return;
|
||||
if(point1->x > mask->x2 && point2->x > mask->x2) return;
|
||||
if(point1->y < mask->y1 && point2->y < mask->y1) return;
|
||||
if(point1->y > mask->y2 && point2->y > mask->y2) return;
|
||||
|
||||
line_draw_t main_line;
|
||||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
|
@ -44,6 +44,31 @@ static void point_swap(lv_point_t * p1, lv_point_t * p2);
|
||||
void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const lv_style_t * style,
|
||||
lv_opa_t opa_scale)
|
||||
{
|
||||
/*Return if the points are out of the mask*/
|
||||
if(points[0].x < mask->x1 &&
|
||||
points[1].x < mask->x1 &&
|
||||
points[2].x < mask->x1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(points[0].x > mask->x2 &&
|
||||
points[1].x > mask->x2 &&
|
||||
points[2].x > mask->x2) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(points[0].y < mask->y1 &&
|
||||
points[1].y < mask->y1 &&
|
||||
points[2].y < mask->y1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(points[0].y > mask->y2 &&
|
||||
points[1].y > mask->y2 &&
|
||||
points[2].y > mask->y2) {
|
||||
return;
|
||||
}
|
||||
|
||||
lv_point_t tri[3];
|
||||
|
||||
memcpy(tri, points, sizeof(tri));
|
||||
|
Loading…
x
Reference in New Issue
Block a user