From 79f96256071eec9ecf7fd2ebb7261d26e5344f9f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 22 May 2020 03:54:29 +0300 Subject: libcamera: pixel_format: Make PixelFormat usable as a constexpr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PixelFormat class is a lightweight wrapper around a 32-bit FourCC and a 64-bit modifier. Make is usable as a constexpr. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- include/libcamera/pixel_format.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'include/libcamera/pixel_format.h') diff --git a/include/libcamera/pixel_format.h b/include/libcamera/pixel_format.h index e3b371ef..8dfeb892 100644 --- a/include/libcamera/pixel_format.h +++ b/include/libcamera/pixel_format.h @@ -18,18 +18,25 @@ namespace libcamera { class PixelFormat { public: - PixelFormat(); - explicit PixelFormat(uint32_t fourcc, uint64_t modifier = 0); + constexpr PixelFormat() + : fourcc_(0), modifier_(0) + { + } + + explicit constexpr PixelFormat(uint32_t fourcc, uint64_t modifier = 0) + : fourcc_(fourcc), modifier_(modifier) + { + } bool operator==(const PixelFormat &other) const; bool operator!=(const PixelFormat &other) const { return !(*this == other); } bool operator<(const PixelFormat &other) const; - bool isValid() const { return fourcc_ != 0; } + constexpr bool isValid() const { return fourcc_ != 0; } - operator uint32_t() const { return fourcc_; } - uint32_t fourcc() const { return fourcc_; } - uint64_t modifier() const { return modifier_; } + constexpr operator uint32_t() const { return fourcc_; } + constexpr uint32_t fourcc() const { return fourcc_; } + constexpr uint64_t modifier() const { return modifier_; } std::string toString() const; -- cgit v1.2.1