Commit graph

5 commits

Author SHA1 Message Date
Jacopo Mondi
dd0793ed1b libcamera: geometry: Add isNull() function to Rectangle class
It's common for code to check if a rectangle is null. Add a helper function
to do so and test the function in test/geometry.cpp

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 11:16:16 +02:00
Laurent Pinchart
d5446e9f32 libcamera: geometry: Provide in-place versions of the Size helpers
Add alignDownTo(), alignUpTo(), boundTo() and expandTo() helper
functions to the Size class. These are in-place versions of the existing
alignedDownTo(), alignedUpTo(), boundedTo() and expandedTo() functions.

The new helpers return a reference to the size, to allow chaining the
functions. One can thus write

	size.alignDownTo(16, 16).alignUpTo(32, 32)
	    .boundTo({ 40, 80 }).expandTo({ 16, 80 });

instead of

	size.alignDownTo(16, 16);
	size.alignUpTo(32, 32);
	size.boundTo({ 40, 80 });
	size.expandTo({ 16, 80 });

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-07-15 17:33:54 +03:00
Laurent Pinchart
6c0afb8b33 libcamera: geometry: Add helper functions to the Size class
Pipeline handlers commonly have to calculate the minimum or maximum of
multiple sizes, or align a size's width and height. Add helper functions
to the Size class to perform those tasks.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-07-15 00:27:26 +03:00
Laurent Pinchart
7fc65e9680 libcamera: geometry: Add isNull() function to Size class
It's common for code to check if a size is null. Add a helper function
to do so.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-06-29 16:17:34 +02:00
Laurent Pinchart
2059b857e1 test: geometry: Add tests for Size class comparison operators
Add a test that exercises all the comparison operators for the Size
class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-18 18:13:10 +03:00