libcamera: geometry: Add two-point Rectangle constructor

Add a constructor to the Rectangle class that accepts two points.

The constructed Rectangle spans all the space between the two given
points.

Signed-off-by: Yudhistira Erlandinata <yerlandinata@chromium.org>
Co-developed-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Harvey Yang <chenghaoyang@chromium.org>
This commit is contained in:
Yudhistira Erlandinata 2024-09-25 08:12:24 +00:00 committed by Jacopo Mondi
parent 2f621920ea
commit 724bbf7d25
3 changed files with 30 additions and 0 deletions

View file

@ -481,6 +481,20 @@ protected:
return TestFail;
}
Point topLeft(3, 3);
Point bottomRight(30, 30);
Point topRight(30, 3);
Point bottomLeft(3, 30);
Rectangle rect1(topLeft, bottomRight);
Rectangle rect2(topRight, bottomLeft);
Rectangle rect3(bottomRight, topLeft);
Rectangle rect4(bottomLeft, topRight);
if (rect1 != rect2 || rect1 != rect3 || rect1 != rect4) {
cout << "Point-to-point construction failed" << endl;
return TestFail;
}
return TestPass;
}
};