Merge lp:~afrantzis/mir/abstract-host-connection into lp:mir
- abstract-host-connection
- Merge into development-branch
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Kevin DuBois | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 1568 | ||||
Proposed branch: | lp:~afrantzis/mir/abstract-host-connection | ||||
Merge into: | lp:mir | ||||
Diff against target: |
923 lines (+331/-245) 15 files modified
src/server/graphics/default_configuration.cpp (+2/-2) src/server/graphics/nested/CMakeLists.txt (+1/-1) src/server/graphics/nested/host_connection.cpp (+0/-32) src/server/graphics/nested/host_connection.h (+38/-12) src/server/graphics/nested/mir_api_wrappers.h (+0/-66) src/server/graphics/nested/mir_client_host_connection.cpp (+169/-0) src/server/graphics/nested/mir_client_host_connection.h (+60/-0) src/server/graphics/nested/nested_display.cpp (+8/-37) src/server/graphics/nested/nested_display.h (+1/-2) src/server/graphics/nested/nested_display_configuration.cpp (+9/-10) src/server/graphics/nested/nested_display_configuration.h (+7/-5) src/server/graphics/nested/nested_output.cpp (+5/-16) src/server/graphics/nested/nested_output.h (+4/-19) src/server/graphics/nested/nested_platform.cpp (+4/-38) tests/unit-tests/graphics/nested/test_nested_display_configuration.cpp (+23/-5) |
||||
To merge this branch: | bzr merge lp:~afrantzis/mir/abstract-host-connection | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Carr (community) | Approve | ||
Alan Griffiths | Approve | ||
Kevin DuBois (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+216290@code.launchpad.net |
Commit message
nested: Abstract communication with host server
Description of the change
nested: Abstract communication with host server
Abstract communication with the host server to make it possible to write unit tests for the nested platform.
PS Jenkins bot (ps-jenkins) wrote : | # |
Robert Carr (robertcarr) wrote : | # |
l883: Why not display config destroy?
Kevin DuBois (kdub) wrote : | # |
okay overall, like the promise of tests :)
MirClientHostCo
perhaps NestedConnection?
Alexandros Frantzis (afrantzis) wrote : | # |
> l883: Why not display config destroy?
We are populating the struct manually, so it's safer and more future proof to release it manually, too. If we use mir_display_
Alan Griffiths (alan-griffiths) wrote : | # |
Ill go along for now - but what I really want to see are the promised tests
Kevin DuBois (kdub) wrote : | # |
looks good to top-approve
Preview Diff
1 | === modified file 'src/server/graphics/default_configuration.cpp' |
2 | --- src/server/graphics/default_configuration.cpp 2014-03-27 09:52:04 +0000 |
3 | +++ src/server/graphics/default_configuration.cpp 2014-04-17 11:09:02 +0000 |
4 | @@ -21,7 +21,7 @@ |
5 | #include "mir/options/option.h" |
6 | |
7 | #include "default_display_configuration_policy.h" |
8 | -#include "nested/host_connection.h" |
9 | +#include "nested/mir_client_host_connection.h" |
10 | #include "nested/nested_platform.h" |
11 | #include "offscreen/display.h" |
12 | |
13 | @@ -145,7 +145,7 @@ |
14 | options->get<std::string>(options::name_opt) : |
15 | "nested-mir@:" + server_socket; |
16 | |
17 | - return std::make_shared<graphics::nested::HostConnection>( |
18 | + return std::make_shared<graphics::nested::MirClientHostConnection>( |
19 | host_socket, |
20 | my_name); |
21 | }); |
22 | |
23 | === modified file 'src/server/graphics/nested/CMakeLists.txt' |
24 | --- src/server/graphics/nested/CMakeLists.txt 2013-08-30 16:49:22 +0000 |
25 | +++ src/server/graphics/nested/CMakeLists.txt 2014-04-17 11:09:02 +0000 |
26 | @@ -9,7 +9,7 @@ |
27 | nested_display_configuration.cpp |
28 | nested_output.cpp |
29 | nested_platform.cpp |
30 | - host_connection.cpp |
31 | + mir_client_host_connection.cpp |
32 | ) |
33 | |
34 | target_link_libraries( |
35 | |
36 | === removed file 'src/server/graphics/nested/host_connection.cpp' |
37 | --- src/server/graphics/nested/host_connection.cpp 2014-03-06 06:05:17 +0000 |
38 | +++ src/server/graphics/nested/host_connection.cpp 1970-01-01 00:00:00 +0000 |
39 | @@ -1,32 +0,0 @@ |
40 | -/* |
41 | - * Copyright © 2013 Canonical Ltd. |
42 | - * |
43 | - * This program is free software: you can redistribute it and/or modify it |
44 | - * under the terms of the GNU General Public License version 3, |
45 | - * as published by the Free Software Foundation. |
46 | - * |
47 | - * This program is distributed in the hope that it will be useful, |
48 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
49 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
50 | - * GNU General Public License for more details. |
51 | - * |
52 | - * You should have received a copy of the GNU General Public License |
53 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
54 | - * |
55 | - * Authored by: Eleni Maria Stea <elenimaria.stea@canonical.com> |
56 | - */ |
57 | - |
58 | -#include "host_connection.h" |
59 | -#include "mir_toolkit/mir_client_library.h" |
60 | - |
61 | -namespace mgn = mir::graphics::nested; |
62 | - |
63 | -mgn::HostConnection::HostConnection(std::string const& host_socket, std::string const& name) |
64 | - : connection{mir_connect_sync(host_socket.c_str(), name.c_str())} |
65 | -{ |
66 | -} |
67 | - |
68 | -mgn::HostConnection::~HostConnection() |
69 | -{ |
70 | - mir_connection_release(connection); |
71 | -} |
72 | |
73 | === modified file 'src/server/graphics/nested/host_connection.h' |
74 | --- src/server/graphics/nested/host_connection.h 2014-03-06 06:05:17 +0000 |
75 | +++ src/server/graphics/nested/host_connection.h 2014-04-17 11:09:02 +0000 |
76 | @@ -19,9 +19,15 @@ |
77 | #ifndef MIR_GRAPHICS_NESTED_HOST_CONNECTION_H_ |
78 | #define MIR_GRAPHICS_NESTED_HOST_CONNECTION_H_ |
79 | |
80 | -#include <string> |
81 | - |
82 | -struct MirConnection; |
83 | +#include "mir_toolkit/client_types.h" |
84 | + |
85 | +#include <memory> |
86 | +#include <vector> |
87 | +#include <functional> |
88 | + |
89 | +#include <EGL/egl.h> |
90 | + |
91 | +struct gbm_device; |
92 | |
93 | namespace mir |
94 | { |
95 | @@ -30,19 +36,39 @@ |
96 | namespace nested |
97 | { |
98 | |
99 | +class HostSurface |
100 | +{ |
101 | +public: |
102 | + virtual ~HostSurface() = default; |
103 | + |
104 | + virtual EGLNativeWindowType egl_native_window() = 0; |
105 | + virtual void set_event_handler(MirEventDelegate const* handler) = 0; |
106 | + |
107 | +protected: |
108 | + HostSurface() = default; |
109 | + HostSurface(HostSurface const&) = delete; |
110 | + HostSurface& operator=(HostSurface const&) = delete; |
111 | +}; |
112 | + |
113 | class HostConnection |
114 | { |
115 | public: |
116 | - HostConnection(std::string const& host_socket, std::string const& name); |
117 | - ~HostConnection(); |
118 | - |
119 | + virtual ~HostConnection() = default; |
120 | + |
121 | + virtual std::vector<int> platform_fd_items() = 0; |
122 | + virtual EGLNativeDisplayType egl_native_display() = 0; |
123 | + virtual std::shared_ptr<MirDisplayConfiguration> create_display_config() = 0; |
124 | + virtual void set_display_config_change_callback(std::function<void()> const& cb) = 0; |
125 | + virtual void apply_display_config(MirDisplayConfiguration&) = 0; |
126 | + virtual std::shared_ptr<HostSurface> create_surface(MirSurfaceParameters const&) = 0; |
127 | + |
128 | + virtual void drm_auth_magic(int magic) = 0; |
129 | + virtual void drm_set_gbm_device(struct gbm_device* dev) = 0; |
130 | + |
131 | +protected: |
132 | + HostConnection() = default; |
133 | HostConnection(HostConnection const&) = delete; |
134 | - HostConnection& operator=(HostConnection const& connection_handle) = delete; |
135 | - |
136 | - operator MirConnection*() const {return (MirConnection*)connection;} |
137 | - |
138 | -private: |
139 | - MirConnection* const connection; |
140 | + HostConnection& operator=(HostConnection const&) = delete; |
141 | }; |
142 | |
143 | } |
144 | |
145 | === removed file 'src/server/graphics/nested/mir_api_wrappers.h' |
146 | --- src/server/graphics/nested/mir_api_wrappers.h 2013-08-22 11:22:12 +0000 |
147 | +++ src/server/graphics/nested/mir_api_wrappers.h 1970-01-01 00:00:00 +0000 |
148 | @@ -1,66 +0,0 @@ |
149 | -/* |
150 | - * Copyright © 2013 Canonical Ltd. |
151 | - * |
152 | - * This program is free software: you can redistribute it and/or modify it |
153 | - * under the terms of the GNU General Public License version 3, |
154 | - * as published by the Free Software Foundation. |
155 | - * |
156 | - * This program is distributed in the hope that it will be useful, |
157 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
158 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
159 | - * GNU General Public License for more details. |
160 | - * |
161 | - * You should have received a copy of the GNU General Public License |
162 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
163 | - * |
164 | - * Authored by: Alan Griffiths <alan@octopull.co.uk> |
165 | - */ |
166 | - |
167 | - |
168 | -#ifndef MIR_GRAPHICS_NESTED_MIR_API_WRAPPERS_H_ |
169 | -#define MIR_GRAPHICS_NESTED_MIR_API_WRAPPERS_H_ |
170 | - |
171 | -#include "mir_toolkit/mir_client_library.h" |
172 | - |
173 | -namespace mir |
174 | -{ |
175 | -namespace graphics |
176 | -{ |
177 | -namespace nested |
178 | -{ |
179 | -/// Utilities for making the Mir "toolkit" API more C++ friendly |
180 | -namespace mir_api_wrappers |
181 | -{ |
182 | -class MirDisplayConfigHandle |
183 | -{ |
184 | -public: |
185 | - explicit MirDisplayConfigHandle(MirDisplayConfiguration* display_config) : |
186 | - display_config{display_config} |
187 | - { |
188 | - } |
189 | - |
190 | - explicit MirDisplayConfigHandle(MirConnection* connection) : |
191 | - MirDisplayConfigHandle{mir_connection_create_display_config(connection)} |
192 | - { |
193 | - } |
194 | - |
195 | - ~MirDisplayConfigHandle() noexcept |
196 | - { |
197 | - mir_display_config_destroy(display_config); |
198 | - } |
199 | - |
200 | - MirDisplayConfiguration* operator->() const { return display_config; } |
201 | - operator MirDisplayConfiguration*() const { return display_config; } |
202 | - |
203 | -private: |
204 | - MirDisplayConfiguration* const display_config; |
205 | - |
206 | - MirDisplayConfigHandle(MirDisplayConfigHandle const&) = delete; |
207 | - MirDisplayConfigHandle operator=(MirDisplayConfigHandle const&) = delete; |
208 | -}; |
209 | -} |
210 | -} |
211 | -} |
212 | -} |
213 | - |
214 | -#endif /* MIR_GRAPHICS_NESTED_MIR_API_WRAPPERS_H_ */ |
215 | |
216 | === added file 'src/server/graphics/nested/mir_client_host_connection.cpp' |
217 | --- src/server/graphics/nested/mir_client_host_connection.cpp 1970-01-01 00:00:00 +0000 |
218 | +++ src/server/graphics/nested/mir_client_host_connection.cpp 2014-04-17 11:09:02 +0000 |
219 | @@ -0,0 +1,169 @@ |
220 | +/* |
221 | + * Copyright © 2014 Canonical Ltd. |
222 | + * |
223 | + * This program is free software: you can redistribute it and/or modify it |
224 | + * under the terms of the GNU General Public License version 3, |
225 | + * as published by the Free Software Foundation. |
226 | + * |
227 | + * This program is distributed in the hope that it will be useful, |
228 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
229 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
230 | + * GNU General Public License for more details. |
231 | + * |
232 | + * You should have received a copy of the GNU General Public License |
233 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
234 | + * |
235 | + * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
236 | + */ |
237 | + |
238 | +#include "mir_client_host_connection.h" |
239 | +#include "mir_toolkit/mir_client_library.h" |
240 | +#include "mir_toolkit/mir_client_library_drm.h" |
241 | + |
242 | +#include <boost/throw_exception.hpp> |
243 | +#include <boost/exception/errinfo_errno.hpp> |
244 | +#include <stdexcept> |
245 | + |
246 | +namespace mgn = mir::graphics::nested; |
247 | + |
248 | +namespace |
249 | +{ |
250 | + |
251 | +void drm_auth_magic_callback(int status, void* context) |
252 | +{ |
253 | + int* status_ret = static_cast<int*>(context); |
254 | + *status_ret = status; |
255 | +} |
256 | + |
257 | +void display_config_callback_thunk(MirConnection* /*connection*/, void* context) |
258 | +{ |
259 | + (*static_cast<std::function<void()>*>(context))(); |
260 | +} |
261 | + |
262 | +class MirClientHostSurface : public mgn::HostSurface |
263 | +{ |
264 | +public: |
265 | + MirClientHostSurface( |
266 | + MirConnection* mir_connection, |
267 | + MirSurfaceParameters const& surface_parameters) |
268 | + : mir_surface{ |
269 | + mir_connection_create_surface_sync(mir_connection, &surface_parameters)} |
270 | + { |
271 | + if (!mir_surface_is_valid(mir_surface)) |
272 | + { |
273 | + BOOST_THROW_EXCEPTION( |
274 | + std::runtime_error(mir_surface_get_error_message(mir_surface))); |
275 | + } |
276 | + } |
277 | + |
278 | + ~MirClientHostSurface() |
279 | + { |
280 | + mir_surface_release_sync(mir_surface); |
281 | + } |
282 | + |
283 | + EGLNativeWindowType egl_native_window() override |
284 | + { |
285 | + return reinterpret_cast<EGLNativeWindowType>( |
286 | + mir_surface_get_egl_native_window(mir_surface)); |
287 | + } |
288 | + |
289 | + void set_event_handler(MirEventDelegate const* handler) override |
290 | + { |
291 | + mir_surface_set_event_handler(mir_surface, handler); |
292 | + } |
293 | + |
294 | +private: |
295 | + MirSurface* const mir_surface; |
296 | + |
297 | +}; |
298 | + |
299 | +} |
300 | + |
301 | +mgn::MirClientHostConnection::MirClientHostConnection( |
302 | + std::string const& host_socket, std::string const& name) |
303 | + : mir_connection{mir_connect_sync(host_socket.c_str(), name.c_str())}, |
304 | + conf_change_callback{[]{}} |
305 | +{ |
306 | + if (!mir_connection_is_valid(mir_connection)) |
307 | + { |
308 | + std::string const msg = |
309 | + "Nested Mir Platform Connection Error: " + |
310 | + std::string(mir_connection_get_error_message(mir_connection)); |
311 | + |
312 | + BOOST_THROW_EXCEPTION(std::runtime_error(msg)); |
313 | + } |
314 | +} |
315 | + |
316 | +mgn::MirClientHostConnection::~MirClientHostConnection() |
317 | +{ |
318 | + mir_connection_release(mir_connection); |
319 | +} |
320 | + |
321 | +std::vector<int> mgn::MirClientHostConnection::platform_fd_items() |
322 | +{ |
323 | + MirPlatformPackage pkg; |
324 | + mir_connection_get_platform(mir_connection, &pkg); |
325 | + return std::vector<int>(pkg.fd, pkg.fd + pkg.fd_items); |
326 | +} |
327 | + |
328 | +EGLNativeDisplayType mgn::MirClientHostConnection::egl_native_display() |
329 | +{ |
330 | + return reinterpret_cast<EGLNativeDisplayType>( |
331 | + mir_connection_get_egl_native_display(mir_connection)); |
332 | +} |
333 | + |
334 | +auto mgn::MirClientHostConnection::create_display_config() |
335 | + -> std::shared_ptr<MirDisplayConfiguration> |
336 | +{ |
337 | + return std::shared_ptr<MirDisplayConfiguration>( |
338 | + mir_connection_create_display_config(mir_connection), |
339 | + [] (MirDisplayConfiguration* c) |
340 | + { |
341 | + if (c) mir_display_config_destroy(c); |
342 | + }); |
343 | +} |
344 | + |
345 | +void mgn::MirClientHostConnection::set_display_config_change_callback( |
346 | + std::function<void()> const& callback) |
347 | +{ |
348 | + mir_connection_set_display_config_change_callback( |
349 | + mir_connection, |
350 | + &display_config_callback_thunk, |
351 | + &(conf_change_callback = callback)); |
352 | +} |
353 | + |
354 | +void mgn::MirClientHostConnection::apply_display_config( |
355 | + MirDisplayConfiguration& display_config) |
356 | +{ |
357 | + mir_connection_apply_display_config(mir_connection, &display_config); |
358 | +} |
359 | + |
360 | +std::shared_ptr<mgn::HostSurface> mgn::MirClientHostConnection::create_surface( |
361 | + MirSurfaceParameters const& surface_parameters) |
362 | +{ |
363 | + return std::make_shared<MirClientHostSurface>( |
364 | + mir_connection, surface_parameters); |
365 | +} |
366 | + |
367 | +void mgn::MirClientHostConnection::drm_auth_magic(int magic) |
368 | +{ |
369 | + int status{-1}; |
370 | + mir_wait_for(mir_connection_drm_auth_magic(mir_connection, magic, |
371 | + drm_auth_magic_callback, &status)); |
372 | + if (status) |
373 | + { |
374 | + std::string const msg("Nested Mir failed to authenticate magic"); |
375 | + BOOST_THROW_EXCEPTION( |
376 | + boost::enable_error_info( |
377 | + std::runtime_error(msg)) << boost::errinfo_errno(status)); |
378 | + } |
379 | +} |
380 | + |
381 | +void mgn::MirClientHostConnection::drm_set_gbm_device(struct gbm_device* dev) |
382 | +{ |
383 | + if (!mir_connection_drm_set_gbm_device(mir_connection, dev)) |
384 | + { |
385 | + std::string const msg("Nested Mir failed to set the gbm device"); |
386 | + BOOST_THROW_EXCEPTION(std::runtime_error(msg)); |
387 | + } |
388 | +} |
389 | |
390 | === added file 'src/server/graphics/nested/mir_client_host_connection.h' |
391 | --- src/server/graphics/nested/mir_client_host_connection.h 1970-01-01 00:00:00 +0000 |
392 | +++ src/server/graphics/nested/mir_client_host_connection.h 2014-04-17 11:09:02 +0000 |
393 | @@ -0,0 +1,60 @@ |
394 | +/* |
395 | + * Copyright © 2014 Canonical Ltd. |
396 | + * |
397 | + * This program is free software: you can redistribute it and/or modify it |
398 | + * under the terms of the GNU General Public License version 3, |
399 | + * as published by the Free Software Foundation. |
400 | + * |
401 | + * This program is distributed in the hope that it will be useful, |
402 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
403 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
404 | + * GNU General Public License for more details. |
405 | + * |
406 | + * You should have received a copy of the GNU General Public License |
407 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
408 | + * |
409 | + * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
410 | + */ |
411 | + |
412 | +#ifndef MIR_GRAPHICS_NESTED_MIR_CLIENT_HOST_CONNECTION_H_ |
413 | +#define MIR_GRAPHICS_NESTED_MIR_CLIENT_HOST_CONNECTION_H_ |
414 | + |
415 | +#include "host_connection.h" |
416 | + |
417 | +#include <string> |
418 | + |
419 | +struct MirConnection; |
420 | + |
421 | +namespace mir |
422 | +{ |
423 | +namespace graphics |
424 | +{ |
425 | +namespace nested |
426 | +{ |
427 | + |
428 | +class MirClientHostConnection : public HostConnection |
429 | +{ |
430 | +public: |
431 | + MirClientHostConnection(std::string const& host_socket, std::string const& name); |
432 | + ~MirClientHostConnection(); |
433 | + |
434 | + std::vector<int> platform_fd_items() override; |
435 | + EGLNativeDisplayType egl_native_display() override; |
436 | + std::shared_ptr<MirDisplayConfiguration> create_display_config() override; |
437 | + std::shared_ptr<HostSurface> create_surface(MirSurfaceParameters const&) override; |
438 | + void set_display_config_change_callback(std::function<void()> const& cb) override; |
439 | + void apply_display_config(MirDisplayConfiguration&) override; |
440 | + |
441 | + void drm_auth_magic(int magic) override; |
442 | + void drm_set_gbm_device(struct gbm_device* dev) override; |
443 | + |
444 | +private: |
445 | + MirConnection* const mir_connection; |
446 | + std::function<void()> conf_change_callback; |
447 | +}; |
448 | + |
449 | +} |
450 | +} |
451 | +} |
452 | + |
453 | +#endif /* MIR_GRAPHICS_NESTED_MIR_CLIENT_HOST_CONNECTION_H_ */ |
454 | |
455 | === modified file 'src/server/graphics/nested/nested_display.cpp' |
456 | --- src/server/graphics/nested/nested_display.cpp 2014-04-15 05:31:19 +0000 |
457 | +++ src/server/graphics/nested/nested_display.cpp 2014-04-17 11:09:02 +0000 |
458 | @@ -19,7 +19,7 @@ |
459 | #include "nested_display.h" |
460 | #include "nested_display_configuration.h" |
461 | #include "nested_output.h" |
462 | -#include "mir_api_wrappers.h" |
463 | +#include "host_connection.h" |
464 | |
465 | #include "mir/geometry/rectangle.h" |
466 | #include "mir/graphics/pixel_format_utils.h" |
467 | @@ -28,14 +28,12 @@ |
468 | #include "mir/graphics/display_configuration_policy.h" |
469 | #include "mir/graphics/overlapping_output_grouping.h" |
470 | #include "mir/graphics/gl_config.h" |
471 | -#include "host_connection.h" |
472 | |
473 | #include <boost/throw_exception.hpp> |
474 | #include <stdexcept> |
475 | |
476 | namespace mg = mir::graphics; |
477 | namespace mgn = mir::graphics::nested; |
478 | -namespace mgnw = mir::graphics::nested::mir_api_wrappers; |
479 | namespace geom = mir::geometry; |
480 | |
481 | EGLint const mgn::detail::nested_egl_context_attribs[] = |
482 | @@ -60,13 +58,12 @@ |
483 | } |
484 | |
485 | mgn::detail::EGLDisplayHandle::EGLDisplayHandle( |
486 | - MirConnection* connection, |
487 | + EGLNativeDisplayType native_display, |
488 | std::shared_ptr<GLConfig> const& gl_config) |
489 | : egl_display(EGL_NO_DISPLAY), |
490 | egl_context_(EGL_NO_CONTEXT), |
491 | gl_config{gl_config} |
492 | { |
493 | - auto const native_display = (EGLNativeDisplayType) mir_connection_get_egl_native_display(connection); |
494 | egl_display = eglGetDisplay(native_display); |
495 | if (egl_display == EGL_NO_DISPLAY) |
496 | BOOST_THROW_EXCEPTION(std::runtime_error("Nested Mir Display Error: Failed to fetch EGL display.")); |
497 | @@ -112,16 +109,6 @@ |
498 | return result; |
499 | } |
500 | |
501 | -EGLNativeWindowType mgn::detail::EGLDisplayHandle::native_window(EGLConfig /*egl_config*/, MirSurface* mir_surface) const |
502 | -{ |
503 | - auto const native_window = |
504 | - reinterpret_cast<EGLNativeWindowType>(mir_surface_get_egl_native_window(mir_surface)); |
505 | - if (!native_window) |
506 | - BOOST_THROW_EXCEPTION(std::runtime_error("Nested Mir Display Error: Failed to fetch EGL native window.")); |
507 | - |
508 | - return native_window; |
509 | -} |
510 | - |
511 | EGLContext mgn::detail::EGLDisplayHandle::egl_context() const |
512 | { |
513 | return egl_context_; |
514 | @@ -141,7 +128,7 @@ |
515 | connection{connection}, |
516 | event_handler{event_handler}, |
517 | display_report{display_report}, |
518 | - egl_display{*connection, gl_config}, |
519 | + egl_display{connection->egl_native_display(), gl_config}, |
520 | outputs{} |
521 | { |
522 | std::shared_ptr<DisplayConfiguration> conf(configuration()); |
523 | @@ -164,7 +151,7 @@ |
524 | { |
525 | return std::unique_ptr<mg::DisplayConfiguration>( |
526 | new NestedDisplayConfiguration( |
527 | - mir_connection_create_display_config(*connection) |
528 | + connection->create_display_config() |
529 | ) |
530 | ); |
531 | } |
532 | @@ -215,16 +202,11 @@ |
533 | static_cast<uint32_t>(output.id.as_value()) |
534 | }; |
535 | |
536 | - auto const mir_surface = |
537 | - mir_connection_create_surface_sync(*connection, &request_params); |
538 | - |
539 | - if (!mir_surface_is_valid(mir_surface)) |
540 | - BOOST_THROW_EXCEPTION( |
541 | - std::runtime_error(mir_surface_get_error_message(mir_surface))); |
542 | + auto const host_surface = connection->create_surface(request_params); |
543 | |
544 | result[output.id] = std::make_shared<mgn::detail::NestedOutput>( |
545 | egl_display, |
546 | - mir_surface, |
547 | + host_surface, |
548 | area, |
549 | event_handler, |
550 | output.current_format); |
551 | @@ -247,25 +229,14 @@ |
552 | { |
553 | auto const& conf = dynamic_cast<NestedDisplayConfiguration const&>(configuration); |
554 | |
555 | - mir_connection_apply_display_config(*connection, conf); |
556 | -} |
557 | - |
558 | -namespace |
559 | -{ |
560 | -void display_config_callback_thunk(MirConnection* /*connection*/, void* context) |
561 | -{ |
562 | - (*static_cast<mg::DisplayConfigurationChangeHandler*>(context))(); |
563 | -} |
564 | + connection->apply_display_config(*conf); |
565 | } |
566 | |
567 | void mgn::NestedDisplay::register_configuration_change_handler( |
568 | EventHandlerRegister& /*handlers*/, |
569 | DisplayConfigurationChangeHandler const& conf_change_handler) |
570 | { |
571 | - mir_connection_set_display_config_change_callback( |
572 | - *connection, |
573 | - &display_config_callback_thunk, |
574 | - &(my_conf_change_handler = conf_change_handler)); |
575 | + connection->set_display_config_change_callback(conf_change_handler); |
576 | } |
577 | |
578 | void mgn::NestedDisplay::register_pause_resume_handlers( |
579 | |
580 | === modified file 'src/server/graphics/nested/nested_display.h' |
581 | --- src/server/graphics/nested/nested_display.h 2014-04-15 05:31:19 +0000 |
582 | +++ src/server/graphics/nested/nested_display.h 2014-04-17 11:09:02 +0000 |
583 | @@ -66,13 +66,12 @@ |
584 | class EGLDisplayHandle |
585 | { |
586 | public: |
587 | - EGLDisplayHandle(MirConnection* connection, |
588 | + EGLDisplayHandle(EGLNativeDisplayType native_display, |
589 | std::shared_ptr<GLConfig> const& gl_config); |
590 | ~EGLDisplayHandle() noexcept; |
591 | |
592 | void initialize(MirPixelFormat format); |
593 | EGLConfig choose_windowed_es_config(MirPixelFormat format) const; |
594 | - EGLNativeWindowType native_window(EGLConfig egl_config, MirSurface* mir_surface) const; |
595 | EGLContext egl_context() const; |
596 | operator EGLDisplay() const { return egl_display; } |
597 | |
598 | |
599 | === modified file 'src/server/graphics/nested/nested_display_configuration.cpp' |
600 | --- src/server/graphics/nested/nested_display_configuration.cpp 2014-03-26 05:48:59 +0000 |
601 | +++ src/server/graphics/nested/nested_display_configuration.cpp 2014-04-17 11:09:02 +0000 |
602 | @@ -17,6 +17,7 @@ |
603 | */ |
604 | |
605 | #include "nested_display_configuration.h" |
606 | +#include "host_connection.h" |
607 | |
608 | #include "mir/graphics/pixel_format_utils.h" |
609 | |
610 | @@ -29,16 +30,14 @@ |
611 | namespace mg = mir::graphics; |
612 | namespace mgn = mg::nested; |
613 | |
614 | -mgn::NestedDisplayConfiguration::NestedDisplayConfiguration(MirDisplayConfiguration* connection) : |
615 | -display_config{connection} |
616 | -{ |
617 | -} |
618 | - |
619 | -mgn::NestedDisplayConfiguration::~NestedDisplayConfiguration() noexcept |
620 | -{ |
621 | -} |
622 | - |
623 | -void mgn::NestedDisplayConfiguration::for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const |
624 | +mgn::NestedDisplayConfiguration::NestedDisplayConfiguration( |
625 | + std::shared_ptr<MirDisplayConfiguration> const& display_config) |
626 | + : display_config{display_config} |
627 | +{ |
628 | +} |
629 | + |
630 | +void mgn::NestedDisplayConfiguration::for_each_card( |
631 | + std::function<void(DisplayConfigurationCard const&)> f) const |
632 | { |
633 | std::for_each( |
634 | display_config->cards, |
635 | |
636 | === modified file 'src/server/graphics/nested/nested_display_configuration.h' |
637 | --- src/server/graphics/nested/nested_display_configuration.h 2014-03-26 05:48:59 +0000 |
638 | +++ src/server/graphics/nested/nested_display_configuration.h 2014-04-17 11:09:02 +0000 |
639 | @@ -20,7 +20,8 @@ |
640 | #define MIR_GRAPHICS_NESTED_NESTED_DISPLAY_CONFIGURATION_H_ |
641 | |
642 | #include "mir/graphics/display_configuration.h" |
643 | -#include "mir_api_wrappers.h" |
644 | +#include "mir_toolkit/client_types.h" |
645 | +#include <memory> |
646 | |
647 | namespace mir |
648 | { |
649 | @@ -31,16 +32,17 @@ |
650 | class NestedDisplayConfiguration : public DisplayConfiguration |
651 | { |
652 | public: |
653 | - explicit NestedDisplayConfiguration(MirDisplayConfiguration* display_config); |
654 | - virtual ~NestedDisplayConfiguration() noexcept; |
655 | + NestedDisplayConfiguration( |
656 | + std::shared_ptr<MirDisplayConfiguration> const& display_config); |
657 | |
658 | void for_each_card(std::function<void(DisplayConfigurationCard const&)>) const override; |
659 | void for_each_output(std::function<void(DisplayConfigurationOutput const&)>) const override; |
660 | void for_each_output(std::function<void(UserDisplayConfigurationOutput&)>) override; |
661 | |
662 | - operator MirDisplayConfiguration*() const { return display_config; } |
663 | + operator MirDisplayConfiguration*() const { return display_config.get(); } |
664 | + |
665 | private: |
666 | - mir_api_wrappers::MirDisplayConfigHandle display_config; |
667 | + std::shared_ptr<MirDisplayConfiguration> const display_config; |
668 | }; |
669 | } |
670 | } |
671 | |
672 | === modified file 'src/server/graphics/nested/nested_output.cpp' |
673 | --- src/server/graphics/nested/nested_output.cpp 2014-03-26 05:48:59 +0000 |
674 | +++ src/server/graphics/nested/nested_output.cpp 2014-04-17 11:09:02 +0000 |
675 | @@ -17,42 +17,31 @@ |
676 | */ |
677 | |
678 | #include "nested_output.h" |
679 | +#include "host_connection.h" |
680 | #include "mir/input/event_filter.h" |
681 | |
682 | -#include "mir_toolkit/mir_client_library.h" |
683 | - |
684 | #include <boost/throw_exception.hpp> |
685 | #include <stdexcept> |
686 | |
687 | namespace mgn = mir::graphics::nested; |
688 | namespace geom = mir::geometry; |
689 | |
690 | -mgn::detail::MirSurfaceHandle::MirSurfaceHandle(MirSurface* mir_surface) : |
691 | - mir_surface(mir_surface) |
692 | -{ |
693 | -} |
694 | - |
695 | -mgn::detail::MirSurfaceHandle::~MirSurfaceHandle() noexcept |
696 | -{ |
697 | - mir_surface_release_sync(mir_surface); |
698 | -} |
699 | - |
700 | mgn::detail::NestedOutput::NestedOutput( |
701 | EGLDisplayHandle const& egl_display, |
702 | - MirSurface* mir_surface, |
703 | + std::shared_ptr<HostSurface> const& host_surface, |
704 | geometry::Rectangle const& area, |
705 | std::shared_ptr<input::EventFilter> const& event_handler, |
706 | MirPixelFormat preferred_format) : |
707 | egl_display(egl_display), |
708 | - mir_surface{mir_surface}, |
709 | + host_surface{host_surface}, |
710 | egl_config{egl_display.choose_windowed_es_config(preferred_format)}, |
711 | egl_context{egl_display, eglCreateContext(egl_display, egl_config, egl_display.egl_context(), nested_egl_context_attribs)}, |
712 | area{area.top_left, area.size}, |
713 | event_handler{event_handler}, |
714 | - egl_surface{egl_display, egl_display.native_window(egl_config, mir_surface), egl_config} |
715 | + egl_surface{egl_display, host_surface->egl_native_window(), egl_config} |
716 | { |
717 | MirEventDelegate ed = {event_thunk, this}; |
718 | - mir_surface_set_event_handler(mir_surface, &ed); |
719 | + host_surface->set_event_handler(&ed); |
720 | } |
721 | |
722 | geom::Rectangle mgn::detail::NestedOutput::view_area() const |
723 | |
724 | === modified file 'src/server/graphics/nested/nested_output.h' |
725 | --- src/server/graphics/nested/nested_output.h 2014-03-26 05:48:59 +0000 |
726 | +++ src/server/graphics/nested/nested_output.h 2014-04-17 11:09:02 +0000 |
727 | @@ -27,32 +27,17 @@ |
728 | { |
729 | namespace nested |
730 | { |
731 | +class HostSurface; |
732 | + |
733 | namespace detail |
734 | { |
735 | |
736 | -class EGLSurfaceHandle; |
737 | -class MirSurfaceHandle |
738 | -{ |
739 | -public: |
740 | - explicit MirSurfaceHandle(MirSurface* mir_surface); |
741 | - |
742 | - ~MirSurfaceHandle() noexcept; |
743 | - |
744 | - operator MirSurface*() const { return mir_surface; } |
745 | - |
746 | -private: |
747 | - MirSurface* mir_surface; |
748 | - |
749 | - MirSurfaceHandle(MirSurfaceHandle const&) = delete; |
750 | - MirSurfaceHandle operator=(MirSurfaceHandle const&) = delete; |
751 | -}; |
752 | - |
753 | class NestedOutput : public DisplayBuffer |
754 | { |
755 | public: |
756 | NestedOutput( |
757 | EGLDisplayHandle const& egl_display, |
758 | - MirSurface* mir_surface, |
759 | + std::shared_ptr<HostSurface> const& host_surface, |
760 | geometry::Rectangle const& area, |
761 | std::shared_ptr<input::EventFilter> const& event_handler, |
762 | MirPixelFormat preferred_format); |
763 | @@ -74,7 +59,7 @@ |
764 | NestedOutput operator=(NestedOutput const&) = delete; |
765 | private: |
766 | EGLDisplayHandle const& egl_display; |
767 | - MirSurfaceHandle const mir_surface; |
768 | + std::shared_ptr<HostSurface> const host_surface; |
769 | EGLConfig const egl_config; |
770 | EGLContextStore const egl_context; |
771 | geometry::Rectangle const area; |
772 | |
773 | === modified file 'src/server/graphics/nested/nested_platform.cpp' |
774 | --- src/server/graphics/nested/nested_platform.cpp 2014-03-28 16:15:40 +0000 |
775 | +++ src/server/graphics/nested/nested_platform.cpp 2014-04-17 11:09:02 +0000 |
776 | @@ -19,18 +19,11 @@ |
777 | #include "nested_platform.h" |
778 | #include "host_connection.h" |
779 | #include "mir/graphics/nested_context.h" |
780 | -#include "mir_toolkit/mir_client_library.h" |
781 | -#include "mir_toolkit/mir_client_library_drm.h" |
782 | |
783 | #include "nested_display.h" |
784 | |
785 | -#include <boost/throw_exception.hpp> |
786 | -#include <boost/exception/errinfo_errno.hpp> |
787 | -#include <stdexcept> |
788 | - |
789 | namespace mg = mir::graphics; |
790 | namespace mgn = mir::graphics::nested; |
791 | -namespace mo = mir::options; |
792 | |
793 | namespace |
794 | { |
795 | @@ -45,38 +38,17 @@ |
796 | |
797 | std::vector<int> platform_fd_items() |
798 | { |
799 | - MirPlatformPackage pkg; |
800 | - mir_connection_get_platform(*connection, &pkg); |
801 | - return std::vector<int>(pkg.fd, pkg.fd + pkg.fd_items); |
802 | + return connection->platform_fd_items(); |
803 | } |
804 | |
805 | void drm_auth_magic(int magic) |
806 | { |
807 | - int status; |
808 | - mir_wait_for(mir_connection_drm_auth_magic(*connection, magic, |
809 | - drm_auth_magic_callback, &status)); |
810 | - if (status) |
811 | - { |
812 | - std::string const msg("Nested Mir failed to authenticate magic"); |
813 | - BOOST_THROW_EXCEPTION( |
814 | - boost::enable_error_info( |
815 | - std::runtime_error(msg)) << boost::errinfo_errno(status)); |
816 | - } |
817 | + connection->drm_auth_magic(magic); |
818 | } |
819 | |
820 | void drm_set_gbm_device(struct gbm_device* dev) |
821 | { |
822 | - if (!mir_connection_drm_set_gbm_device(*connection, dev)) |
823 | - { |
824 | - std::string const msg("Nested Mir failed to set the gbm device"); |
825 | - BOOST_THROW_EXCEPTION(std::runtime_error(msg)); |
826 | - } |
827 | - } |
828 | - |
829 | - static void drm_auth_magic_callback(int status, void* context) |
830 | - { |
831 | - int* status_ret = static_cast<int*>(context); |
832 | - *status_ret = status; |
833 | + connection->drm_set_gbm_device(dev); |
834 | } |
835 | |
836 | private: |
837 | @@ -95,11 +67,6 @@ |
838 | display_report{display_report}, |
839 | connection{connection} |
840 | { |
841 | - if (!mir_connection_is_valid(*connection)) |
842 | - { |
843 | - BOOST_THROW_EXCEPTION(std::runtime_error("Nested Mir Platform Connection Error: " + std::string(mir_connection_get_error_message(*connection)))); |
844 | - } |
845 | - |
846 | native_platform->initialize(std::make_shared<MirConnectionNestedContext>(connection)); |
847 | } |
848 | |
849 | @@ -138,6 +105,5 @@ |
850 | |
851 | EGLNativeDisplayType mgn::NestedPlatform::egl_native_display() const |
852 | { |
853 | - return reinterpret_cast<EGLNativeDisplayType>( |
854 | - mir_connection_get_egl_native_display(*connection)); |
855 | + return connection->egl_native_display(); |
856 | } |
857 | |
858 | === modified file 'tests/unit-tests/graphics/nested/test_nested_display_configuration.cpp' |
859 | --- tests/unit-tests/graphics/nested/test_nested_display_configuration.cpp 2014-03-26 05:48:59 +0000 |
860 | +++ tests/unit-tests/graphics/nested/test_nested_display_configuration.cpp 2014-04-17 11:09:02 +0000 |
861 | @@ -53,7 +53,7 @@ |
862 | struct NestedDisplayConfiguration : public ::testing::Test |
863 | { |
864 | template<int NoOfOutputs, int NoOfCards> |
865 | - MirDisplayConfiguration* build_test_config( |
866 | + std::shared_ptr<MirDisplayConfiguration> build_test_config( |
867 | MirDisplayOutput const (&outputs)[NoOfOutputs], |
868 | MirDisplayCard const (&cards)[NoOfCards]) |
869 | { |
870 | @@ -63,7 +63,22 @@ |
871 | auto card_tmp = new MirDisplayCard[NoOfCards]; |
872 | std::copy(cards, cards+NoOfCards, card_tmp); |
873 | |
874 | - return new MirDisplayConfiguration{ NoOfOutputs, out_tmp, NoOfCards, card_tmp }; |
875 | + return std::shared_ptr<MirDisplayConfiguration>( |
876 | + new MirDisplayConfiguration{NoOfOutputs, out_tmp, NoOfCards, card_tmp}, |
877 | + [] (MirDisplayConfiguration* conf) |
878 | + { |
879 | + std::for_each( |
880 | + conf->outputs, conf->outputs + conf->num_outputs, |
881 | + [] (MirDisplayOutput const& output) |
882 | + { |
883 | + delete[] output.modes; |
884 | + delete[] output.output_formats; |
885 | + }); |
886 | + |
887 | + delete[] conf->outputs; |
888 | + delete[] conf->cards; |
889 | + delete conf; |
890 | + }); |
891 | } |
892 | |
893 | template<int NoOfModes, int NoOfFormats> |
894 | @@ -97,7 +112,7 @@ |
895 | init_output(output, modes, formats); |
896 | } |
897 | |
898 | - MirDisplayConfiguration* build_trivial_configuration() |
899 | + std::shared_ptr<MirDisplayConfiguration> build_trivial_configuration() |
900 | { |
901 | static MirDisplayCard const cards[] {{default_card_id,1}}; |
902 | static MirDisplayMode const modes[] = {{ 1080, 1920, 4.33f }}; |
903 | @@ -129,7 +144,7 @@ |
904 | return build_test_config(outputs, cards); |
905 | } |
906 | |
907 | - MirDisplayConfiguration* build_non_trivial_configuration() |
908 | + std::shared_ptr<MirDisplayConfiguration> build_non_trivial_configuration() |
909 | { |
910 | static MirDisplayCard const cards[] { |
911 | {default_card_id,1}, |
912 | @@ -228,7 +243,10 @@ |
913 | |
914 | TEST_F(NestedDisplayConfiguration, empty_configuration_is_read_correctly) |
915 | { |
916 | - auto empty_configuration = new MirDisplayConfiguration{ 0, nullptr, 0, nullptr }; |
917 | + auto empty_configuration = |
918 | + std::shared_ptr<MirDisplayConfiguration>( |
919 | + new MirDisplayConfiguration{0, nullptr, 0, nullptr}); |
920 | + |
921 | mgn::NestedDisplayConfiguration config(empty_configuration); |
922 | |
923 | config.for_each_card([](mg::DisplayConfigurationCard const&) { FAIL(); }); |
PASSED: Continuous integration, rev:1564 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- ci/1356/ jenkins. qa.ubuntu. com/job/ mir-android- trusty- i386-build/ 1647 jenkins. qa.ubuntu. com/job/ mir-clang- trusty- amd64-build/ 1645 jenkins. qa.ubuntu. com/job/ mir-mediumtests -trusty- touch/1220 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- trusty- amd64-ci/ 1088 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- trusty- amd64-ci/ 1088/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- trusty- armhf-ci/ 1093 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- trusty- armhf-ci/ 1093/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- trusty- armhf/1221 jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- trusty- armhf/1221/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -runner- mako/1129 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 6166
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/mir- team-mir- development- branch- ci/1356/ rebuild
http://