Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform/DRMFormat: Don't require a FormatInfo for each format. #3463

Merged
merged 7 commits into from
Jul 15, 2024
43 changes: 28 additions & 15 deletions include/platform/mir/graphics/drm_formats.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,47 @@ namespace mir::graphics
class DRMFormat
{
public:
struct RGBComponentInfo
struct FormatInfo;
class Info
{
uint32_t red_bits;
uint32_t green_bits;
uint32_t blue_bits;
std::optional<uint32_t> alpha_bits;
};
public:
struct RGBComponentInfo
{
uint32_t red_bits;
uint32_t green_bits;
uint32_t blue_bits;
std::optional<uint32_t> alpha_bits;
};

// This could be constexpr, at the cost of moving a bunch of implementation into the header
explicit DRMFormat(uint32_t fourcc_format);
auto opaque_equivalent() const -> std::optional<DRMFormat>;
auto alpha_equivalent() const -> std::optional<DRMFormat>;

auto name() const -> char const*;
bool has_alpha() const;

auto opaque_equivalent() const -> std::optional<DRMFormat> const;
auto alpha_equivalent() const -> std::optional<DRMFormat> const;
auto components() const -> std::optional<RGBComponentInfo> const&;
private:
friend class DRMFormat;
Info(FormatInfo const* info);

bool has_alpha() const;
FormatInfo const* info;
};

auto components() const -> std::optional<RGBComponentInfo> const&;
constexpr explicit DRMFormat(uint32_t fourcc_format)
: fourcc{fourcc_format}
{
}

auto name() const -> char const*;

auto info() const -> std::optional<Info const>;

operator uint32_t() const;

auto as_mir_format() const -> std::optional<MirPixelFormat>;
static auto from_mir_format(MirPixelFormat format) -> DRMFormat;

struct FormatInfo;
private:
FormatInfo const* info;
uint32_t fourcc;
};

auto drm_modifier_to_string(uint64_t modifier) -> std::string;
Expand Down
Loading