Skip to content

Commit

Permalink
Fix Point::min/max and change it to static
Browse files Browse the repository at this point in the history
* Test suite evaluated locally
  • Loading branch information
lpugin committed Feb 8, 2025
1 parent 56c851f commit 22b77ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions include/vrv/devicecontextbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,17 @@ class Point {

Point operator-() const { return { -x, -y }; }

Point min(const Point &p) const
static Point Min(const Point &p1, const Point &p2)
{
int x = std::min(this->x, p.x);
int y = std::min(this->y, p.y);
int x = std::min(p1.x, p2.x);
int y = std::min(p1.y, p2.y);
return { x, y };
}

Point max(const Point &p) const
static Point Max(const Point &p1, const Point &p2)
{
int x = std::max(this->x, p.x);
int y = std::max(this->y, p.y);
int x = std::max(p1.x, p2.x);
int y = std::max(p1.y, p2.y);
return { x, y };
}
};
Expand Down
8 changes: 4 additions & 4 deletions src/bboxdevicecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ Point BBoxDeviceContext::GetLogicalOrigin()
// calculated better
void BBoxDeviceContext::DrawQuadBezierPath(Point bezier[3])
{
Point pMin = bezier[0].min(bezier[2]);
Point pMax = bezier[0].max(bezier[2]);
Point pMin = Point::Min(bezier[0], bezier[2]);
Point pMax = Point::Max(bezier[0], bezier[2]);

// From https://iquilezles.org/www/articles/bezierbbox/bezierbbox.htm
if ((bezier[1].x < pMin.x) || (bezier[1].x > pMax.x) || (bezier[1].y < pMin.y) || (bezier[1].y > pMax.y)) {
Expand All @@ -140,8 +140,8 @@ void BBoxDeviceContext::DrawQuadBezierPath(Point bezier[3])
// vec2 q = s*s*p0 + 2.0*s*t*p1 + t*t*p2;
int qx = sx * sx * bezier[0].x + 2.0 * sx * tx * bezier[1].x + tx * tx * bezier[2].x;
int qy = sy * sy * bezier[0].y + 2.0 * sy * ty * bezier[1].y + ty * ty * bezier[2].y;
pMin = pMin.min(Point(qx, qy));
pMax = pMax.max(Point(qx, qy));
pMin = Point::Min(pMin, Point(qx, qy));
pMax = Point::Max(pMax, Point(qx, qy));
}

this->UpdateBB(pMin.x, pMin.y, pMax.x, pMax.y);
Expand Down

0 comments on commit 22b77ab

Please sign in to comment.