libcamera: pixel_format: Make PixelFormat usable as a constexpr
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
4bd09795a1
commit
79f9625607
2 changed files with 15 additions and 14 deletions
|
@ -18,18 +18,25 @@ namespace libcamera {
|
||||||
class PixelFormat
|
class PixelFormat
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PixelFormat();
|
constexpr PixelFormat()
|
||||||
explicit PixelFormat(uint32_t fourcc, uint64_t modifier = 0);
|
: 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;
|
||||||
bool operator!=(const PixelFormat &other) const { return !(*this == other); }
|
bool operator!=(const PixelFormat &other) const { return !(*this == other); }
|
||||||
bool operator<(const PixelFormat &other) const;
|
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_; }
|
constexpr operator uint32_t() const { return fourcc_; }
|
||||||
uint32_t fourcc() const { return fourcc_; }
|
constexpr uint32_t fourcc() const { return fourcc_; }
|
||||||
uint64_t modifier() const { return modifier_; }
|
constexpr uint64_t modifier() const { return modifier_; }
|
||||||
|
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
|
|
|
@ -25,25 +25,19 @@ namespace libcamera {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* \fn PixelFormat::PixelFormat()
|
||||||
* \brief Construct a PixelFormat with an invalid format
|
* \brief Construct a PixelFormat with an invalid format
|
||||||
*
|
*
|
||||||
* PixelFormat instances constructed with the default constructor are
|
* PixelFormat instances constructed with the default constructor are
|
||||||
* invalid, calling the isValid() function returns false.
|
* invalid, calling the isValid() function returns false.
|
||||||
*/
|
*/
|
||||||
PixelFormat::PixelFormat()
|
|
||||||
: fourcc_(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* \fn PixelFormat::PixelFormat(uint32_t fourcc, uint64_t modifier)
|
||||||
* \brief Construct a PixelFormat from a DRM FourCC and a modifier
|
* \brief Construct a PixelFormat from a DRM FourCC and a modifier
|
||||||
* \param[in] fourcc A DRM FourCC
|
* \param[in] fourcc A DRM FourCC
|
||||||
* \param[in] modifier A DRM FourCC modifier
|
* \param[in] modifier A DRM FourCC modifier
|
||||||
*/
|
*/
|
||||||
PixelFormat::PixelFormat(uint32_t fourcc, uint64_t modifier)
|
|
||||||
: fourcc_(fourcc), modifier_(modifier)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Compare pixel formats for equality
|
* \brief Compare pixel formats for equality
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue