mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-23 17:17:38 +00:00
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:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user