Make util/geometry.h C++20 friendly

- Move header to base/include to make it applicable for base types
  like 'Affinity' down the road.
- Represent 'Rect' as typle of point and area, which is the most
  common form of initialization, creates in valid 'Rect' by default.
- Turn Point, Area, and Rect into compound types, making x, y, w, h, at,
  area accessible without a method call
- 'Rect::Compound' function for constructing a 'Rect' from two points,
  replacing a former constructor
- Use result type 'Rect::Cut_remainder' instead of out parameters.

Fixes #5239
This commit is contained in:
Norman Feske
2024-06-05 12:40:13 +02:00
parent bb06d879aa
commit c629c54153
131 changed files with 1200 additions and 1218 deletions

View File

@ -209,17 +209,17 @@ class Polygon::Painter_base
template <typename POINT>
static Rect bounding_box(POINT const points[], int num_points, Area area)
{
int x_min = area.w() - 1, x_max = 0;
int y_min = area.h() - 1, y_max = 0;
int x_min = area.w - 1, x_max = 0;
int y_min = area.h - 1, y_max = 0;
for (int i = 0; i < num_points; i++) {
x_min = Genode::min(x_min, points[i].x());
x_max = Genode::max(x_max, points[i].x());
y_min = Genode::min(y_min, points[i].y());
y_max = Genode::max(y_max, points[i].y());
x_min = Genode::min(x_min, points[i].x);
x_max = Genode::max(x_max, points[i].x);
y_min = Genode::min(y_min, points[i].y);
y_max = Genode::max(y_max, points[i].y);
}
return Rect(Point_base(x_min, y_min), Point_base(x_max, y_max));
return Rect::compound(Point_base(x_min, y_min), Point_base(x_max, y_max));
}
@ -248,15 +248,15 @@ class Polygon::Painter_base
int const p2_attr = p2.edge_attr(i);
/* horizontal edge */
if (p1.y() == p2.y());
if (p1.y == p2.y);
/* right edge */
else if (p1.y() < p2.y())
_interpolate(p1_attr, p2_attr, r_edge + p1.y(), p2.y() - p1.y());
else if (p1.y < p2.y)
_interpolate(p1_attr, p2_attr, r_edge + p1.y, p2.y - p1.y);
/* left edge */
else
_interpolate(p2_attr, p1_attr, l_edge + p2.y(), p1.y() - p2.y());
_interpolate(p2_attr, p1_attr, l_edge + p2.y, p1.y - p2.y);
}
}
}