2
* Copyright © 2014 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
19
#include "pixel_format_selector.h"
21
#include "mir/graphics/display_configuration.h"
22
#include "mir/graphics/pixel_format_utils.h"
33
PixelFormatSelector::PixelFormatSelector(std::shared_ptr<DisplayConfigurationPolicy> const& base_policy,
35
: base_policy{base_policy},
36
with_alpha{with_alpha}
39
void PixelFormatSelector::apply_to(graphics::DisplayConfiguration & conf)
41
base_policy->apply_to(conf);
43
[&](graphics::DisplayConfigurationOutput const& conf_output)
45
if (!conf_output.connected || !conf_output.used) return;
47
auto const& pos = find_if(conf_output.pixel_formats.begin(),
48
conf_output.pixel_formats.end(),
49
[&](MirPixelFormat format) -> bool
51
return graphics::contains_alpha(format) == with_alpha;
55
// keep the default settings if nothing was found
56
if (pos == conf_output.pixel_formats.end())
59
conf.configure_output(conf_output.id, true, conf_output.top_left,
60
conf_output.current_mode_index,
62
conf_output.power_mode,
63
conf_output.orientation