[libcamera-devel] [PATCH] libcamera: geometry: Add isNull() function to Size class

Laurent Pinchart laurent.pinchart at ideasonboard.com
Thu Jun 25 02:25:47 CEST 2020


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 at ideasonboard.com>
---
 include/libcamera/geometry.h | 1 +
 src/libcamera/geometry.cpp   | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h
index edda42cf34cc..7d4b8bcfe3d8 100644
--- a/include/libcamera/geometry.h
+++ b/include/libcamera/geometry.h
@@ -41,6 +41,7 @@ struct Size {
 	unsigned int width;
 	unsigned int height;
 
+	bool isNull() const { return !width && !height; }
 	const std::string toString() const;
 };
 
diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp
index fd78cf2c0ab7..24c44fb43acf 100644
--- a/src/libcamera/geometry.cpp
+++ b/src/libcamera/geometry.cpp
@@ -107,6 +107,12 @@ bool operator==(const Rectangle &lhs, const Rectangle &rhs)
  * \brief The Size height
  */
 
+/**
+ * \fn bool Size::isNull() const
+ * \brief Check if the size is null
+ * \return True if both the width and height are 0, or false otherwise
+ */
+
 /**
  * \brief Assemble and return a string describing the size
  * \return A string describing the size
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list