> The idea was that default display configuration policy should try to select an
> opaque format where possible.
...
> Hm if there is no opaque format in the vector it takes the preconfigured one -
> blindly assuming that it is part of the vector. Which would then be a format
> with alpha channel.
>
> > So the return is one of mir_pixel_format_invalid, format, or the first alpha
> > format from formats.
>
> no the first non-alpha format - it uses find_if_not
I'd find it easier to follow like this:
MirPixelFormat select_opaque_format(MirPixelFormat format, std::vector<MirPixelFormat> const& formats)
{
auto const format_in_formats = formats.end() != std::find(formats.begin(), formats.end(), format);
if (!mg::contains_alpha(format) && format_in_formats)
return format;
// format is either unavailable or transparent
auto const first_opaque = std::find_if_not(formats.begin(), formats.end(), mg::contains_alpha);
if (first_opaque != formats.end())
return *first_opaque;
// only tranparent options - allow choice if available
if (format_in_formats)
return format;
> The idea was that default display configuration policy should try to select an format_ invalid, format, or the first alpha
> opaque format where possible.
...
> Hm if there is no opaque format in the vector it takes the preconfigured one -
> blindly assuming that it is part of the vector. Which would then be a format
> with alpha channel.
>
> > So the return is one of mir_pixel_
> > format from formats.
>
> no the first non-alpha format - it uses find_if_not
I'd find it easier to follow like this:
MirPixelFormat select_ opaque_ format( MirPixelFormat format, std::vector< MirPixelFormat> const& formats) formats. begin() , formats.end(), format);
{
auto const format_in_formats = formats.end() != std::find(
if (!mg::contains_ alpha(format) && format_in_formats)
return format;
// format is either unavailable or transparent if_not( formats. begin() , formats.end(), mg::contains_ alpha);
auto const first_opaque = std::find_
if (first_opaque != formats.end())
return *first_opaque;
// only tranparent options - allow choice if available
if (format_in_formats)
return format;
if (formats.size())
return formats.at(0);
return mir_pixel_ format_ invalid;
}