Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
stub_display_configuration.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
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.
12  *
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/>.
15  *
16  * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 #ifndef MIR_TEST_DOUBLES_STUB_DISPLAY_CONFIGURATION_H_
20 #define MIR_TEST_DOUBLES_STUB_DISPLAY_CONFIGURATION_H_
21 
23 #include "mir/geometry/rectangle.h"
25 
26 #include <vector>
27 
28 namespace mir
29 {
30 namespace test
31 {
32 namespace doubles
33 {
34 
36 {
37 public:
40  {
41  }
42 
43  StubDisplayConfig(unsigned int num_displays)
44  {
45  /* construct a non-trivial dummy display config to send */
46  int mode_index = 0;
47  for (auto i = 0u; i < num_displays; i++)
48  {
49  std::vector<graphics::DisplayConfigurationMode> modes;
50  std::vector<geometry::PixelFormat> pfs{
51  geometry::PixelFormat::bgr_888,
52  geometry::PixelFormat::abgr_8888,
53  geometry::PixelFormat::xbgr_8888};
54 
55  for (auto j = 0u; j <= i; j++)
56  {
57  geometry::Size sz{mode_index*4, mode_index*3};
58  graphics::DisplayConfigurationMode mode{sz, 10.0f * mode_index };
59  mode_index++;
60  modes.push_back(mode);
61  }
62 
63  size_t mode_index = modes.size() - 1;
64  geometry::Size physical_size{};
65  geometry::Point top_left{};
67  graphics::DisplayConfigurationOutputId{static_cast<int>(i + 1)},
68  graphics::DisplayConfigurationCardId{static_cast<int>(i)},
69  graphics::DisplayConfigurationOutputType::vga,
70  pfs, modes, i,
71  physical_size,
72  ((i % 2) == 0),
73  ((i % 2) == 1),
74  top_left,
75  mode_index, 1u,
77  };
78 
79  outputs.push_back(output);
80 
82  graphics::DisplayConfigurationCardId{static_cast<int>(i)},
83  i + 1
84  };
85 
86  cards.push_back(card);
87  }
88 
89  };
90 
91  StubDisplayConfig(std::vector<geometry::Rectangle> const& rects)
92  {
93  int id = 1;
94  for (auto const& rect : rects)
95  {
97  {
100  graphics::DisplayConfigurationOutputType::vga,
101  std::vector<geometry::PixelFormat>{geometry::PixelFormat::abgr_8888},
102  {{rect.size, 60.0}},
103  0, geometry::Size{}, true, true, rect.top_left, 0, 0, mir_power_mode_on
104  };
105 
106  outputs.push_back(output);
107  ++id;
108  }
109 
111  graphics::DisplayConfigurationCardId{static_cast<int>(1)},
112  rects.size()
113  };
114 
115  cards.push_back(card);
116  }
117 
118  void for_each_card(std::function<void(graphics::DisplayConfigurationCard const&)> f) const
119  {
120  for (auto const& card : cards)
121  f(card);
122  }
123 
124  void for_each_output(std::function<void(graphics::DisplayConfigurationOutput const&)> f) const
125  {
126  for (auto& disp : outputs)
127  {
128  f(disp);
129  }
130  }
131 
133  {
134  }
135 
136  std::vector<graphics::DisplayConfigurationCard> cards;
137  std::vector<graphics::DisplayConfigurationOutput> outputs;
138 };
139 
140 }
141 }
142 }
143 
144 #endif /* MIR_TEST_DOUBLES_STUB_DISPLAY_CONFIGURATION_H_ */

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Oct 15 00:23:28 UTC 2013