GRAPHICS: Make the Graphics::PixelFormat constructors constexpr

This commit is contained in:
Cameron Cawley 2023-12-26 16:31:18 +00:00 committed by Eugene Sandulenko
parent 30b977c272
commit 6522c6e11d

View File

@ -142,11 +142,10 @@ struct PixelFormat {
byte rShift, gShift, bShift, aShift; /**< Binary left shift of each color component in the pixel value. */
/** Default constructor that creates a null pixel format. */
inline PixelFormat() {
bytesPerPixel =
rLoss = gLoss = bLoss = aLoss =
rShift = gShift = bShift = aShift = 0;
}
constexpr PixelFormat() :
bytesPerPixel(0),
rLoss(0), gLoss(0), bLoss(0), aLoss(0),
rShift(0), gShift(0), bShift(0), aShift(0) {}
/** Construct a pixel format based on the provided arguments.
*
@ -166,19 +165,18 @@ struct PixelFormat {
* @endcode
*/
inline PixelFormat(byte BytesPerPixel,
constexpr PixelFormat(byte BytesPerPixel,
byte RBits, byte GBits, byte BBits, byte ABits,
byte RShift, byte GShift, byte BShift, byte AShift) {
bytesPerPixel = BytesPerPixel;
rLoss = 8 - RBits;
gLoss = 8 - GBits;
bLoss = 8 - BBits;
aLoss = 8 - ABits;
rShift = RShift;
gShift = GShift;
bShift = BShift;
aShift = AShift;
}
byte RShift, byte GShift, byte BShift, byte AShift) :
bytesPerPixel(BytesPerPixel),
rLoss(8 - RBits),
gLoss(8 - GBits),
bLoss(8 - BBits),
aLoss(8 - ABits),
rShift(RShift),
gShift(GShift),
bShift(BShift),
aShift(AShift) {}
/** Define a CLUT8 pixel format. */
static inline PixelFormat createFormatCLUT8() {