Merge lp:~afrantzis/mir/platform-operation-client-api-remove-opcode into lp:mir/0.11
- platform-operation-client-api-remove-opcode
- Merge into 0.11
Proposed by
Alexandros Frantzis
Status: | Superseded |
---|---|
Proposed branch: | lp:~afrantzis/mir/platform-operation-client-api-remove-opcode |
Merge into: | lp:mir/0.11 |
Diff against target: |
875 lines (+313/-159) 21 files modified
client-ABI-sha1sums (+1/-1) include/client/mir_toolkit/mir_connection.h (+1/-2) src/client/mir_connection.cpp (+9/-22) src/client/mir_connection.h (+0/-9) src/client/mir_connection_api.cpp (+37/-14) src/include/client/mir/client_platform.h (+11/-0) src/platforms/android/client/android_client_platform.cpp (+6/-0) src/platforms/android/client/android_client_platform.h (+1/-1) src/platforms/mesa/client/client_platform.cpp (+46/-1) src/platforms/mesa/client/client_platform.h (+4/-0) src/platforms/mesa/include/mir_toolkit/mesa/platform_operation.h (+19/-2) src/server/graphics/nested/mir_client_host_connection.cpp (+1/-1) tests/acceptance-tests/CMakeLists.txt (+0/-1) tests/acceptance-tests/test_client_library_drm.cpp (+0/-46) tests/acceptance-tests/test_client_library_errors.cpp (+5/-0) tests/acceptance-tests/test_client_platform_operation.cpp (+2/-2) tests/include/mir_test_framework/client_platform_factory.h (+3/-9) tests/mir_test_framework/stub_client_platform_factory.cpp (+5/-0) tests/unit-tests/client/mesa/test_client_platform.cpp (+77/-6) tests/unit-tests/client/test_client_mir_surface.cpp (+6/-0) tests/unit-tests/client/test_mir_connection.cpp (+79/-42) |
To merge this branch: | bzr merge lp:~afrantzis/mir/platform-operation-client-api-remove-opcode |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email: mp+248255@code.launchpad.net |
This proposal has been superseded by a proposal from 2015-02-02.
Commit message
client: Remove redundant opcode parameter from platform operation API
Description of the change
client: Remove redundant opcode parameter from platform operation API
During development/
This is a client API/ABI break, but since the platform operation API is not currently used by external code (and could not have been used because we didn't expose any operations), we can get away with it.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'client-ABI-sha1sums' | |||
2 | --- client-ABI-sha1sums 2015-01-29 04:34:12 +0000 | |||
3 | +++ client-ABI-sha1sums 2015-02-02 14:38:00 +0000 | |||
4 | @@ -1,7 +1,7 @@ | |||
5 | 1 | afd66e984f4f8c0303fd25fb6fea32fa47bbd37f include/client/mir_toolkit/debug/surface.h | 1 | afd66e984f4f8c0303fd25fb6fea32fa47bbd37f include/client/mir_toolkit/debug/surface.h |
6 | 2 | b53736bcb22ddc09aab8275cfdd05c109fdd0f12 include/client/mir_toolkit/mir_client_library_drm.h | 2 | b53736bcb22ddc09aab8275cfdd05c109fdd0f12 include/client/mir_toolkit/mir_client_library_drm.h |
7 | 3 | 532af89e0f48d8d2a7cf01621db25d3338ae3abf include/client/mir_toolkit/mir_client_library.h | 3 | 532af89e0f48d8d2a7cf01621db25d3338ae3abf include/client/mir_toolkit/mir_client_library.h |
9 | 4 | 750aa35e6a5173bcba47cb524c508d05a4df746c include/client/mir_toolkit/mir_connection.h | 4 | 615df675ffba805fb0594e19fb006f514f2100a7 include/client/mir_toolkit/mir_connection.h |
10 | 5 | 1ef8f51a3e3f8d1559266c5af58fbfde7cfabf0a include/client/mir_toolkit/mir_cursor_configuration.h | 5 | 1ef8f51a3e3f8d1559266c5af58fbfde7cfabf0a include/client/mir_toolkit/mir_cursor_configuration.h |
11 | 6 | d739af6e64db6b314a727b5fb00be662b98ccd57 include/client/mir_toolkit/mir_platform_message.h | 6 | d739af6e64db6b314a727b5fb00be662b98ccd57 include/client/mir_toolkit/mir_platform_message.h |
12 | 7 | 9d50df5a141ca03ee8a79f7e844ed4b8b3b7d5d3 include/client/mir_toolkit/mir_prompt_session.h | 7 | 9d50df5a141ca03ee8a79f7e844ed4b8b3b7d5d3 include/client/mir_toolkit/mir_prompt_session.h |
13 | 8 | 8 | ||
14 | === modified file 'include/client/mir_toolkit/mir_connection.h' | |||
15 | --- include/client/mir_toolkit/mir_connection.h 2015-01-14 06:39:13 +0000 | |||
16 | +++ include/client/mir_toolkit/mir_connection.h 2015-02-02 14:38:00 +0000 | |||
17 | @@ -178,14 +178,13 @@ | |||
18 | 178 | * until this operation finishes. | 178 | * until this operation finishes. |
19 | 179 | * | 179 | * |
20 | 180 | * \param [in] connection The connection | 180 | * \param [in] connection The connection |
21 | 181 | * \param [in] opcode The opcode of the operation to perform | ||
22 | 182 | * \param [in] request The message used for this operation | 181 | * \param [in] request The message used for this operation |
23 | 183 | * \param [in] callback The callback to call when the operation finishes | 182 | * \param [in] callback The callback to call when the operation finishes |
24 | 184 | * \param [in,out] context User data passed to the callback function | 183 | * \param [in,out] context User data passed to the callback function |
25 | 185 | * \return A handle that can be passed to mir_wait_for | 184 | * \return A handle that can be passed to mir_wait_for |
26 | 186 | */ | 185 | */ |
27 | 187 | MirWaitHandle* mir_connection_platform_operation( | 186 | MirWaitHandle* mir_connection_platform_operation( |
29 | 188 | MirConnection* connection, unsigned int opcode, | 187 | MirConnection* connection, |
30 | 189 | MirPlatformMessage const* request, | 188 | MirPlatformMessage const* request, |
31 | 190 | mir_platform_operation_callback callback, void* context); | 189 | mir_platform_operation_callback callback, void* context); |
32 | 191 | 190 | ||
33 | 192 | 191 | ||
34 | === modified file 'src/client/mir_connection.cpp' | |||
35 | --- src/client/mir_connection.cpp 2015-01-30 14:24:06 +0000 | |||
36 | +++ src/client/mir_connection.cpp 2015-02-02 14:38:00 +0000 | |||
37 | @@ -357,13 +357,20 @@ | |||
38 | 357 | } | 357 | } |
39 | 358 | 358 | ||
40 | 359 | MirWaitHandle* MirConnection::platform_operation( | 359 | MirWaitHandle* MirConnection::platform_operation( |
41 | 360 | unsigned int opcode, | ||
42 | 361 | MirPlatformMessage const* request, | 360 | MirPlatformMessage const* request, |
43 | 362 | mir_platform_operation_callback callback, void* context) | 361 | mir_platform_operation_callback callback, void* context) |
44 | 363 | { | 362 | { |
45 | 363 | auto const client_response = platform->platform_operation(request); | ||
46 | 364 | if (client_response) | ||
47 | 365 | { | ||
48 | 366 | set_error_message(""); | ||
49 | 367 | callback(this, client_response, context); | ||
50 | 368 | return nullptr; | ||
51 | 369 | } | ||
52 | 370 | |||
53 | 364 | mir::protobuf::PlatformOperationMessage protobuf_request; | 371 | mir::protobuf::PlatformOperationMessage protobuf_request; |
54 | 365 | 372 | ||
56 | 366 | protobuf_request.set_opcode(opcode); | 373 | protobuf_request.set_opcode(mir_platform_message_get_opcode(request)); |
57 | 367 | auto const request_data = mir_platform_message_get_data(request); | 374 | auto const request_data = mir_platform_message_get_data(request); |
58 | 368 | auto const request_fds = mir_platform_message_get_fds(request); | 375 | auto const request_fds = mir_platform_message_get_fds(request); |
59 | 369 | 376 | ||
60 | @@ -420,11 +427,6 @@ | |||
61 | 420 | platform_package.fd_items = platform.fd_size(); | 427 | platform_package.fd_items = platform.fd_size(); |
62 | 421 | for (int i = 0; i != platform.fd_size(); ++i) | 428 | for (int i = 0; i != platform.fd_size(); ++i) |
63 | 422 | platform_package.fd[i] = platform.fd(i); | 429 | platform_package.fd[i] = platform.fd(i); |
64 | 423 | |||
65 | 424 | // TODO: Replace the extra platform data mechanism with a | ||
66 | 425 | // client side, platform specific operation | ||
67 | 426 | for (auto d : extra_platform_data) | ||
68 | 427 | platform_package.data[platform_package.data_items++] = d; | ||
69 | 428 | } | 430 | } |
70 | 429 | else | 431 | else |
71 | 430 | { | 432 | { |
72 | @@ -567,21 +569,6 @@ | |||
73 | 567 | return &configure_display_wait_handle; | 569 | return &configure_display_wait_handle; |
74 | 568 | } | 570 | } |
75 | 569 | 571 | ||
76 | 570 | bool MirConnection::set_extra_platform_data( | ||
77 | 571 | std::vector<int> const& extra_platform_data_arg) | ||
78 | 572 | { | ||
79 | 573 | std::lock_guard<decltype(mutex)> lock(mutex); | ||
80 | 574 | |||
81 | 575 | auto const total_data_size = | ||
82 | 576 | connect_result.platform().data_size() + extra_platform_data_arg.size(); | ||
83 | 577 | |||
84 | 578 | if (total_data_size > mir_platform_package_max) | ||
85 | 579 | return false; | ||
86 | 580 | |||
87 | 581 | extra_platform_data = extra_platform_data_arg; | ||
88 | 582 | return true; | ||
89 | 583 | } | ||
90 | 584 | |||
91 | 585 | mir::protobuf::DisplayServer& MirConnection::display_server() | 572 | mir::protobuf::DisplayServer& MirConnection::display_server() |
92 | 586 | { | 573 | { |
93 | 587 | return server; | 574 | return server; |
94 | 588 | 575 | ||
95 | === modified file 'src/client/mir_connection.h' | |||
96 | --- src/client/mir_connection.h 2015-01-30 14:24:06 +0000 | |||
97 | +++ src/client/mir_connection.h 2015-02-02 14:38:00 +0000 | |||
98 | @@ -107,12 +107,7 @@ | |||
99 | 107 | 107 | ||
100 | 108 | MirWaitHandle* disconnect(); | 108 | MirWaitHandle* disconnect(); |
101 | 109 | 109 | ||
102 | 110 | MirWaitHandle* drm_auth_magic(unsigned int magic, | ||
103 | 111 | mir_drm_auth_magic_callback callback, | ||
104 | 112 | void* context); | ||
105 | 113 | |||
106 | 114 | MirWaitHandle* platform_operation( | 110 | MirWaitHandle* platform_operation( |
107 | 115 | unsigned int opcode, | ||
108 | 116 | MirPlatformMessage const* request, | 111 | MirPlatformMessage const* request, |
109 | 117 | mir_platform_operation_callback callback, void* context); | 112 | mir_platform_operation_callback callback, void* context); |
110 | 118 | 113 | ||
111 | @@ -137,8 +132,6 @@ | |||
112 | 137 | MirWaitHandle* configure_display(MirDisplayConfiguration* configuration); | 132 | MirWaitHandle* configure_display(MirDisplayConfiguration* configuration); |
113 | 138 | void done_display_configure(); | 133 | void done_display_configure(); |
114 | 139 | 134 | ||
115 | 140 | bool set_extra_platform_data(std::vector<int> const& extra_platform_data); | ||
116 | 141 | |||
117 | 142 | std::shared_ptr<google::protobuf::RpcChannel> rpc_channel() const | 135 | std::shared_ptr<google::protobuf::RpcChannel> rpc_channel() const |
118 | 143 | { | 136 | { |
119 | 144 | return channel; | 137 | return channel; |
120 | @@ -197,8 +190,6 @@ | |||
121 | 197 | std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register; | 190 | std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register; |
122 | 198 | 191 | ||
123 | 199 | std::unique_ptr<mir::dispatch::SimpleDispatchThread> const eventloop; | 192 | std::unique_ptr<mir::dispatch::SimpleDispatchThread> const eventloop; |
124 | 200 | |||
125 | 201 | std::vector<int> extra_platform_data; | ||
126 | 202 | 193 | ||
127 | 203 | std::shared_ptr<mir::client::ClientBufferStreamFactory> buffer_stream_factory; | 194 | std::shared_ptr<mir::client::ClientBufferStreamFactory> buffer_stream_factory; |
128 | 204 | 195 | ||
129 | 205 | 196 | ||
130 | === modified file 'src/client/mir_connection_api.cpp' | |||
131 | --- src/client/mir_connection_api.cpp 2015-01-26 15:53:18 +0000 | |||
132 | +++ src/client/mir_connection_api.cpp 2015-02-02 14:38:00 +0000 | |||
133 | @@ -51,11 +51,6 @@ | |||
134 | 51 | *context = result; | 51 | *context = result; |
135 | 52 | } | 52 | } |
136 | 53 | 53 | ||
137 | 54 | size_t division_ceiling(size_t a, size_t b) | ||
138 | 55 | { | ||
139 | 56 | return ((a - 1) / b) + 1; | ||
140 | 57 | } | ||
141 | 58 | |||
142 | 59 | class DefaultMirConnectionAPI : public mcl::MirConnectionAPI | 54 | class DefaultMirConnectionAPI : public mcl::MirConnectionAPI |
143 | 60 | { | 55 | { |
144 | 61 | public: | 56 | public: |
145 | @@ -311,13 +306,13 @@ | |||
146 | 311 | } | 306 | } |
147 | 312 | 307 | ||
148 | 313 | MirWaitHandle* mir_connection_platform_operation( | 308 | MirWaitHandle* mir_connection_platform_operation( |
150 | 314 | MirConnection* connection, unsigned int opcode, | 309 | MirConnection* connection, |
151 | 315 | MirPlatformMessage const* request, | 310 | MirPlatformMessage const* request, |
152 | 316 | mir_platform_operation_callback callback, void* context) | 311 | mir_platform_operation_callback callback, void* context) |
153 | 317 | { | 312 | { |
154 | 318 | try | 313 | try |
155 | 319 | { | 314 | { |
157 | 320 | return connection->platform_operation(opcode, request, callback, context); | 315 | return connection->platform_operation(request, callback, context); |
158 | 321 | } | 316 | } |
159 | 322 | catch (std::exception const& ex) | 317 | catch (std::exception const& ex) |
160 | 323 | { | 318 | { |
161 | @@ -356,6 +351,21 @@ | |||
162 | 356 | auth_magic_context->callback(auth_response->status, auth_magic_context->context); | 351 | auth_magic_context->callback(auth_response->status, auth_magic_context->context); |
163 | 357 | } | 352 | } |
164 | 358 | 353 | ||
165 | 354 | void assign_set_gbm_device_status( | ||
166 | 355 | MirConnection*, MirPlatformMessage* response, void* context) | ||
167 | 356 | { | ||
168 | 357 | auto const response_msg = mir::raii::deleter_for( | ||
169 | 358 | response, | ||
170 | 359 | &mir_platform_message_release); | ||
171 | 360 | |||
172 | 361 | auto const response_data = mir_platform_message_get_data(response_msg.get()); | ||
173 | 362 | auto const set_gbm_device_response_ptr = | ||
174 | 363 | reinterpret_cast<MirMesaSetGBMDeviceResponse const*>(response_data.data); | ||
175 | 364 | |||
176 | 365 | auto status_ptr = static_cast<int*>(context); | ||
177 | 366 | *status_ptr = set_gbm_device_response_ptr->status; | ||
178 | 367 | } | ||
179 | 368 | |||
180 | 359 | } | 369 | } |
181 | 360 | 370 | ||
182 | 361 | MirWaitHandle* mir_connection_drm_auth_magic(MirConnection* connection, | 371 | MirWaitHandle* mir_connection_drm_auth_magic(MirConnection* connection, |
183 | @@ -377,7 +387,6 @@ | |||
184 | 377 | 387 | ||
185 | 378 | return mir_connection_platform_operation( | 388 | return mir_connection_platform_operation( |
186 | 379 | connection, | 389 | connection, |
187 | 380 | MirMesaPlatformOperation::auth_magic, | ||
188 | 381 | msg.get(), | 390 | msg.get(), |
189 | 382 | platform_operation_to_auth_magic_callback, | 391 | platform_operation_to_auth_magic_callback, |
190 | 383 | auth_magic_op_context); | 392 | auth_magic_op_context); |
191 | @@ -386,10 +395,24 @@ | |||
192 | 386 | int mir_connection_drm_set_gbm_device(MirConnection* connection, | 395 | int mir_connection_drm_set_gbm_device(MirConnection* connection, |
193 | 387 | struct gbm_device* gbm_dev) | 396 | struct gbm_device* gbm_dev) |
194 | 388 | { | 397 | { |
201 | 389 | size_t const pointer_size_in_ints = division_ceiling(sizeof(gbm_dev), sizeof(int)); | 398 | MirMesaSetGBMDeviceRequest const request{gbm_dev}; |
202 | 390 | std::vector<int> extra_data(pointer_size_in_ints); | 399 | |
203 | 391 | 400 | auto const msg = mir::raii::deleter_for( | |
204 | 392 | memcpy(extra_data.data(), &gbm_dev, sizeof(gbm_dev)); | 401 | mir_platform_message_create(MirMesaPlatformOperation::set_gbm_device), |
205 | 393 | 402 | &mir_platform_message_release); | |
206 | 394 | return connection->set_extra_platform_data(extra_data); | 403 | |
207 | 404 | mir_platform_message_set_data(msg.get(), &request, sizeof(request)); | ||
208 | 405 | |||
209 | 406 | static int const success{0}; | ||
210 | 407 | int status{-1}; | ||
211 | 408 | |||
212 | 409 | auto wh = mir_connection_platform_operation( | ||
213 | 410 | connection, | ||
214 | 411 | msg.get(), | ||
215 | 412 | assign_set_gbm_device_status, | ||
216 | 413 | &status); | ||
217 | 414 | |||
218 | 415 | mir_wait_for(wh); | ||
219 | 416 | |||
220 | 417 | return status == success; | ||
221 | 395 | } | 418 | } |
222 | 396 | 419 | ||
223 | === modified file 'src/include/client/mir/client_platform.h' | |||
224 | --- src/include/client/mir/client_platform.h 2015-01-29 14:57:00 +0000 | |||
225 | +++ src/include/client/mir/client_platform.h 2015-02-02 14:38:00 +0000 | |||
226 | @@ -49,6 +49,17 @@ | |||
227 | 49 | 49 | ||
228 | 50 | virtual MirPlatformType platform_type() const = 0; | 50 | virtual MirPlatformType platform_type() const = 0; |
229 | 51 | virtual void populate(MirPlatformPackage& package) const = 0; | 51 | virtual void populate(MirPlatformPackage& package) const = 0; |
230 | 52 | /** | ||
231 | 53 | * Perform a platform operation. | ||
232 | 54 | * | ||
233 | 55 | * The returned platform message is owned by the caller and should be | ||
234 | 56 | * released with mir_platform_message_release(). | ||
235 | 57 | * | ||
236 | 58 | * \param [in] request The platform operation request | ||
237 | 59 | * \return The platform operation reply, or a nullptr if the | ||
238 | 60 | * requested operation is not supported | ||
239 | 61 | */ | ||
240 | 62 | virtual MirPlatformMessage* platform_operation(MirPlatformMessage const* request) = 0; | ||
241 | 52 | virtual std::shared_ptr<ClientBufferFactory> create_buffer_factory() = 0; | 63 | virtual std::shared_ptr<ClientBufferFactory> create_buffer_factory() = 0; |
242 | 53 | virtual std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) = 0; | 64 | virtual std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) = 0; |
243 | 54 | virtual std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() = 0; | 65 | virtual std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() = 0; |
244 | 55 | 66 | ||
245 | === modified file 'src/platforms/android/client/android_client_platform.cpp' | |||
246 | --- src/platforms/android/client/android_client_platform.cpp 2015-01-29 14:57:00 +0000 | |||
247 | +++ src/platforms/android/client/android_client_platform.cpp 2015-02-02 14:38:00 +0000 | |||
248 | @@ -112,6 +112,12 @@ | |||
249 | 112 | context->populate_server_package(package); | 112 | context->populate_server_package(package); |
250 | 113 | } | 113 | } |
251 | 114 | 114 | ||
252 | 115 | MirPlatformMessage* mcla::AndroidClientPlatform::platform_operation( | ||
253 | 116 | MirPlatformMessage const*) | ||
254 | 117 | { | ||
255 | 118 | return nullptr; | ||
256 | 119 | } | ||
257 | 120 | |||
258 | 115 | MirNativeBuffer* mcla::AndroidClientPlatform::convert_native_buffer(graphics::NativeBuffer* buf) const | 121 | MirNativeBuffer* mcla::AndroidClientPlatform::convert_native_buffer(graphics::NativeBuffer* buf) const |
259 | 116 | { | 122 | { |
260 | 117 | return buf->anwb(); | 123 | return buf->anwb(); |
261 | 118 | 124 | ||
262 | === modified file 'src/platforms/android/client/android_client_platform.h' | |||
263 | --- src/platforms/android/client/android_client_platform.h 2015-01-30 14:25:39 +0000 | |||
264 | +++ src/platforms/android/client/android_client_platform.h 2015-02-02 14:38:00 +0000 | |||
265 | @@ -35,6 +35,7 @@ | |||
266 | 35 | AndroidClientPlatform(ClientContext* const context); | 35 | AndroidClientPlatform(ClientContext* const context); |
267 | 36 | MirPlatformType platform_type() const override; | 36 | MirPlatformType platform_type() const override; |
268 | 37 | void populate(MirPlatformPackage& package) const override; | 37 | void populate(MirPlatformPackage& package) const override; |
269 | 38 | MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override; | ||
270 | 38 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; | 39 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; |
271 | 39 | std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) override; | 40 | std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) override; |
272 | 40 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; | 41 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; |
273 | @@ -42,7 +43,6 @@ | |||
274 | 42 | 43 | ||
275 | 43 | private: | 44 | private: |
276 | 44 | ClientContext* const context; | 45 | ClientContext* const context; |
277 | 45 | |||
278 | 46 | }; | 46 | }; |
279 | 47 | 47 | ||
280 | 48 | } | 48 | } |
281 | 49 | 49 | ||
282 | === modified file 'src/platforms/mesa/client/client_platform.cpp' | |||
283 | --- src/platforms/mesa/client/client_platform.cpp 2015-01-29 14:57:00 +0000 | |||
284 | +++ src/platforms/mesa/client/client_platform.cpp 2015-02-02 14:38:00 +0000 | |||
285 | @@ -23,6 +23,9 @@ | |||
286 | 23 | #include "native_surface.h" | 23 | #include "native_surface.h" |
287 | 24 | #include "mir/client_buffer_factory.h" | 24 | #include "mir/client_buffer_factory.h" |
288 | 25 | #include "mir/client_context.h" | 25 | #include "mir/client_context.h" |
289 | 26 | #include "mir_toolkit/mesa/platform_operation.h" | ||
290 | 27 | |||
291 | 28 | #include <cstring> | ||
292 | 26 | 29 | ||
293 | 27 | namespace mcl=mir::client; | 30 | namespace mcl=mir::client; |
294 | 28 | namespace mclm=mir::client::mesa; | 31 | namespace mclm=mir::client::mesa; |
295 | @@ -47,6 +50,11 @@ | |||
296 | 47 | mcl::EGLNativeDisplayContainer& container; | 50 | mcl::EGLNativeDisplayContainer& container; |
297 | 48 | }; | 51 | }; |
298 | 49 | 52 | ||
299 | 53 | constexpr size_t division_ceiling(size_t a, size_t b) | ||
300 | 54 | { | ||
301 | 55 | return ((a - 1) / b) + 1; | ||
302 | 56 | } | ||
303 | 57 | |||
304 | 50 | } | 58 | } |
305 | 51 | 59 | ||
306 | 52 | mclm::ClientPlatform::ClientPlatform( | 60 | mclm::ClientPlatform::ClientPlatform( |
307 | @@ -55,7 +63,8 @@ | |||
308 | 55 | mcl::EGLNativeDisplayContainer& display_container) | 63 | mcl::EGLNativeDisplayContainer& display_container) |
309 | 56 | : context{context}, | 64 | : context{context}, |
310 | 57 | buffer_file_ops{buffer_file_ops}, | 65 | buffer_file_ops{buffer_file_ops}, |
312 | 58 | display_container(display_container) | 66 | display_container(display_container), |
313 | 67 | gbm_dev{nullptr} | ||
314 | 59 | { | 68 | { |
315 | 60 | } | 69 | } |
316 | 61 | 70 | ||
317 | @@ -108,7 +117,43 @@ | |||
318 | 108 | 117 | ||
319 | 109 | void mclm::ClientPlatform::populate(MirPlatformPackage& package) const | 118 | void mclm::ClientPlatform::populate(MirPlatformPackage& package) const |
320 | 110 | { | 119 | { |
321 | 120 | size_t constexpr pointer_size_in_ints = division_ceiling(sizeof(gbm_dev), sizeof(int)); | ||
322 | 121 | |||
323 | 111 | context->populate_server_package(package); | 122 | context->populate_server_package(package); |
324 | 123 | |||
325 | 124 | auto const total_data_size = package.data_items + pointer_size_in_ints; | ||
326 | 125 | if (gbm_dev && total_data_size <= mir_platform_package_max) | ||
327 | 126 | { | ||
328 | 127 | int gbm_ptr[pointer_size_in_ints]{}; | ||
329 | 128 | std::memcpy(&gbm_ptr, &gbm_dev, sizeof(gbm_dev)); | ||
330 | 129 | |||
331 | 130 | for (auto i : gbm_ptr) | ||
332 | 131 | package.data[package.data_items++] = i; | ||
333 | 132 | } | ||
334 | 133 | } | ||
335 | 134 | |||
336 | 135 | MirPlatformMessage* mclm::ClientPlatform::platform_operation( | ||
337 | 136 | MirPlatformMessage const* msg) | ||
338 | 137 | { | ||
339 | 138 | auto const op = mir_platform_message_get_opcode(msg); | ||
340 | 139 | |||
341 | 140 | if (op == MirMesaPlatformOperation::set_gbm_device) | ||
342 | 141 | { | ||
343 | 142 | auto const msg_data = mir_platform_message_get_data(msg); | ||
344 | 143 | auto const set_gbm_device_request_ptr = | ||
345 | 144 | reinterpret_cast<MirMesaSetGBMDeviceRequest const*>(msg_data.data); | ||
346 | 145 | |||
347 | 146 | gbm_dev = set_gbm_device_request_ptr->device; | ||
348 | 147 | |||
349 | 148 | static int const success{0}; | ||
350 | 149 | MirMesaSetGBMDeviceResponse const response{success}; | ||
351 | 150 | auto const response_msg = mir_platform_message_create(op); | ||
352 | 151 | mir_platform_message_set_data(response_msg, &response, sizeof(response)); | ||
353 | 152 | |||
354 | 153 | return response_msg; | ||
355 | 154 | } | ||
356 | 155 | |||
357 | 156 | return nullptr; | ||
358 | 112 | } | 157 | } |
359 | 113 | 158 | ||
360 | 114 | MirNativeBuffer* mclm::ClientPlatform::convert_native_buffer(graphics::NativeBuffer* buf) const | 159 | MirNativeBuffer* mclm::ClientPlatform::convert_native_buffer(graphics::NativeBuffer* buf) const |
361 | 115 | 160 | ||
362 | === modified file 'src/platforms/mesa/client/client_platform.h' | |||
363 | --- src/platforms/mesa/client/client_platform.h 2015-01-30 14:25:39 +0000 | |||
364 | +++ src/platforms/mesa/client/client_platform.h 2015-02-02 14:38:00 +0000 | |||
365 | @@ -20,6 +20,8 @@ | |||
366 | 20 | 20 | ||
367 | 21 | #include "mir/client_platform.h" | 21 | #include "mir/client_platform.h" |
368 | 22 | 22 | ||
369 | 23 | struct gbm_device; | ||
370 | 24 | |||
371 | 23 | namespace mir | 25 | namespace mir |
372 | 24 | { | 26 | { |
373 | 25 | namespace client | 27 | namespace client |
374 | @@ -41,6 +43,7 @@ | |||
375 | 41 | 43 | ||
376 | 42 | MirPlatformType platform_type() const override; | 44 | MirPlatformType platform_type() const override; |
377 | 43 | void populate(MirPlatformPackage& package) const override; | 45 | void populate(MirPlatformPackage& package) const override; |
378 | 46 | MirPlatformMessage* platform_operation(MirPlatformMessage const* request) override; | ||
379 | 44 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; | 47 | std::shared_ptr<ClientBufferFactory> create_buffer_factory() override; |
380 | 45 | std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) override; | 48 | std::shared_ptr<EGLNativeWindowType> create_egl_native_window(EGLNativeSurface *surface) override; |
381 | 46 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; | 49 | std::shared_ptr<EGLNativeDisplayType> create_egl_native_display() override; |
382 | @@ -50,6 +53,7 @@ | |||
383 | 50 | ClientContext* const context; | 53 | ClientContext* const context; |
384 | 51 | std::shared_ptr<BufferFileOps> const buffer_file_ops; | 54 | std::shared_ptr<BufferFileOps> const buffer_file_ops; |
385 | 52 | EGLNativeDisplayContainer& display_container; | 55 | EGLNativeDisplayContainer& display_container; |
386 | 56 | gbm_device* gbm_dev; | ||
387 | 53 | }; | 57 | }; |
388 | 54 | 58 | ||
389 | 55 | } | 59 | } |
390 | 56 | 60 | ||
391 | === modified file 'src/platforms/mesa/include/mir_toolkit/mesa/platform_operation.h' | |||
392 | --- src/platforms/mesa/include/mir_toolkit/mesa/platform_operation.h 2015-01-27 14:59:08 +0000 | |||
393 | +++ src/platforms/mesa/include/mir_toolkit/mesa/platform_operation.h 2015-02-02 14:38:00 +0000 | |||
394 | @@ -35,7 +35,8 @@ | |||
395 | 35 | enum MirMesaPlatformOperation | 35 | enum MirMesaPlatformOperation |
396 | 36 | { | 36 | { |
397 | 37 | auth_magic = 1, | 37 | auth_magic = 1, |
399 | 38 | auth_fd = 2 | 38 | auth_fd = 2, |
400 | 39 | set_gbm_device = 3 | ||
401 | 39 | }; | 40 | }; |
402 | 40 | 41 | ||
403 | 41 | /* | 42 | /* |
404 | @@ -49,7 +50,23 @@ | |||
405 | 49 | 50 | ||
406 | 50 | struct MirMesaAuthMagicResponse | 51 | struct MirMesaAuthMagicResponse |
407 | 51 | { | 52 | { |
409 | 52 | int status; | 53 | int status; /* 0 on success, a positive error number on failure */ |
410 | 54 | }; | ||
411 | 55 | |||
412 | 56 | /* | ||
413 | 57 | * MesaPlatformOperation::set_gbm_device related structures | ||
414 | 58 | */ | ||
415 | 59 | |||
416 | 60 | struct gbm_device; | ||
417 | 61 | |||
418 | 62 | struct MirMesaSetGBMDeviceRequest | ||
419 | 63 | { | ||
420 | 64 | struct gbm_device* device; | ||
421 | 65 | }; | ||
422 | 66 | |||
423 | 67 | struct MirMesaSetGBMDeviceResponse | ||
424 | 68 | { | ||
425 | 69 | int status; /* 0 on success, a positive error number on failure */ | ||
426 | 53 | }; | 70 | }; |
427 | 54 | 71 | ||
428 | 55 | #ifdef __cplusplus | 72 | #ifdef __cplusplus |
429 | 56 | 73 | ||
430 | === modified file 'src/server/graphics/nested/mir_client_host_connection.cpp' | |||
431 | --- src/server/graphics/nested/mir_client_host_connection.cpp 2015-01-26 15:53:18 +0000 | |||
432 | +++ src/server/graphics/nested/mir_client_host_connection.cpp 2015-02-02 14:38:00 +0000 | |||
433 | @@ -185,7 +185,7 @@ | |||
434 | 185 | MirPlatformMessage* raw_reply{nullptr}; | 185 | MirPlatformMessage* raw_reply{nullptr}; |
435 | 186 | 186 | ||
436 | 187 | auto const wh = mir_connection_platform_operation( | 187 | auto const wh = mir_connection_platform_operation( |
438 | 188 | mir_connection, op, msg.get(), platform_operation_callback, &raw_reply); | 188 | mir_connection, msg.get(), platform_operation_callback, &raw_reply); |
439 | 189 | mir_wait_for(wh); | 189 | mir_wait_for(wh); |
440 | 190 | 190 | ||
441 | 191 | auto const reply = mir::raii::deleter_for( | 191 | auto const reply = mir::raii::deleter_for( |
442 | 192 | 192 | ||
443 | === modified file 'tests/acceptance-tests/CMakeLists.txt' | |||
444 | --- tests/acceptance-tests/CMakeLists.txt 2015-01-19 06:55:41 +0000 | |||
445 | +++ tests/acceptance-tests/CMakeLists.txt 2015-02-02 14:38:00 +0000 | |||
446 | @@ -25,7 +25,6 @@ | |||
447 | 25 | test_display_configuration.cpp | 25 | test_display_configuration.cpp |
448 | 26 | test_surfaces_with_output_id.cpp | 26 | test_surfaces_with_output_id.cpp |
449 | 27 | test_server_disconnect.cpp | 27 | test_server_disconnect.cpp |
450 | 28 | test_client_library_drm.cpp | ||
451 | 29 | test_prompt_session_client_api.cpp | 28 | test_prompt_session_client_api.cpp |
452 | 30 | test_client_screencast.cpp | 29 | test_client_screencast.cpp |
453 | 31 | test_client_surface_visibility.cpp | 30 | test_client_surface_visibility.cpp |
454 | 32 | 31 | ||
455 | === removed file 'tests/acceptance-tests/test_client_library_drm.cpp' | |||
456 | --- tests/acceptance-tests/test_client_library_drm.cpp 2015-01-14 06:39:13 +0000 | |||
457 | +++ tests/acceptance-tests/test_client_library_drm.cpp 1970-01-01 00:00:00 +0000 | |||
458 | @@ -1,46 +0,0 @@ | |||
459 | 1 | /* | ||
460 | 2 | * Copyright © 2013-2014 Canonical Ltd. | ||
461 | 3 | * | ||
462 | 4 | * This program is free software: you can redistribute it and/or modify | ||
463 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
464 | 6 | * published by the Free Software Foundation. | ||
465 | 7 | * | ||
466 | 8 | * This program is distributed in the hope that it will be useful, | ||
467 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
468 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
469 | 11 | * GNU General Public License for more details. | ||
470 | 12 | * | ||
471 | 13 | * You should have received a copy of the GNU General Public License | ||
472 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
473 | 15 | * | ||
474 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | ||
475 | 17 | */ | ||
476 | 18 | |||
477 | 19 | #include "mir_toolkit/mir_client_library_drm.h" | ||
478 | 20 | |||
479 | 21 | #include "mir_test_framework/connected_client_headless_server.h" | ||
480 | 22 | |||
481 | 23 | #include <gtest/gtest.h> | ||
482 | 24 | #include <gmock/gmock.h> | ||
483 | 25 | |||
484 | 26 | namespace mtf = mir_test_framework; | ||
485 | 27 | using namespace testing; | ||
486 | 28 | |||
487 | 29 | using MirClientLibraryDrmTest = mtf::ConnectedClientHeadlessServer; | ||
488 | 30 | |||
489 | 31 | TEST_F(MirClientLibraryDrmTest, sets_gbm_device_in_platform_data) | ||
490 | 32 | { | ||
491 | 33 | struct gbm_device* dev = reinterpret_cast<struct gbm_device*>(connection); | ||
492 | 34 | |||
493 | 35 | MirPlatformPackage pkg; | ||
494 | 36 | |||
495 | 37 | mir_connection_get_platform(connection, &pkg); | ||
496 | 38 | int const previous_data_count{pkg.data_items}; | ||
497 | 39 | |||
498 | 40 | mir_connection_drm_set_gbm_device(connection, dev); | ||
499 | 41 | mir_connection_get_platform(connection, &pkg); | ||
500 | 42 | |||
501 | 43 | EXPECT_THAT(pkg.data_items, Eq(previous_data_count + (sizeof(dev) / sizeof(int)))); | ||
502 | 44 | EXPECT_THAT(reinterpret_cast<struct gbm_device*>(pkg.data[previous_data_count]), | ||
503 | 45 | Eq(dev)); | ||
504 | 46 | } | ||
505 | 47 | 0 | ||
506 | === modified file 'tests/acceptance-tests/test_client_library_errors.cpp' | |||
507 | --- tests/acceptance-tests/test_client_library_errors.cpp 2015-01-29 14:57:00 +0000 | |||
508 | +++ tests/acceptance-tests/test_client_library_errors.cpp 2015-02-02 14:38:00 +0000 | |||
509 | @@ -77,6 +77,11 @@ | |||
510 | 77 | { | 77 | { |
511 | 78 | } | 78 | } |
512 | 79 | 79 | ||
513 | 80 | MirPlatformMessage* platform_operation(MirPlatformMessage const*) override | ||
514 | 81 | { | ||
515 | 82 | return nullptr; | ||
516 | 83 | } | ||
517 | 84 | |||
518 | 80 | MirPlatformType platform_type() const | 85 | MirPlatformType platform_type() const |
519 | 81 | { | 86 | { |
520 | 82 | BOOST_THROW_EXCEPTION(std::runtime_error{exception_text}); | 87 | BOOST_THROW_EXCEPTION(std::runtime_error{exception_text}); |
521 | 83 | 88 | ||
522 | === modified file 'tests/acceptance-tests/test_client_platform_operation.cpp' | |||
523 | --- tests/acceptance-tests/test_client_platform_operation.cpp 2014-12-11 08:54:04 +0000 | |||
524 | +++ tests/acceptance-tests/test_client_platform_operation.cpp 2015-02-02 14:38:00 +0000 | |||
525 | @@ -39,7 +39,7 @@ | |||
526 | 39 | MirPlatformMessage* reply; | 39 | MirPlatformMessage* reply; |
527 | 40 | 40 | ||
528 | 41 | auto const platform_op_done = mir_connection_platform_operation( | 41 | auto const platform_op_done = mir_connection_platform_operation( |
530 | 42 | connection, add_opcode, request, assign_reply, &reply); | 42 | connection, request, assign_reply, &reply); |
531 | 43 | mir_wait_for(platform_op_done); | 43 | mir_wait_for(platform_op_done); |
532 | 44 | 44 | ||
533 | 45 | mir_platform_message_release(request); | 45 | mir_platform_message_release(request); |
534 | @@ -57,7 +57,7 @@ | |||
535 | 57 | MirPlatformMessage* reply; | 57 | MirPlatformMessage* reply; |
536 | 58 | 58 | ||
537 | 59 | auto const platform_op_done = mir_connection_platform_operation( | 59 | auto const platform_op_done = mir_connection_platform_operation( |
539 | 60 | connection, echo_fd_opcode, request, assign_reply, &reply); | 60 | connection, request, assign_reply, &reply); |
540 | 61 | mir_wait_for(platform_op_done); | 61 | mir_wait_for(platform_op_done); |
541 | 62 | 62 | ||
542 | 63 | mir_platform_message_release(request); | 63 | mir_platform_message_release(request); |
543 | 64 | 64 | ||
544 | === modified file 'tests/include/mir_test_framework/client_platform_factory.h' | |||
545 | --- tests/include/mir_test_framework/client_platform_factory.h 2015-01-29 14:57:00 +0000 | |||
546 | +++ tests/include/mir_test_framework/client_platform_factory.h 2015-02-02 14:38:00 +0000 | |||
547 | @@ -42,19 +42,13 @@ | |||
548 | 42 | return platform_factory(&ctx); | 42 | return platform_factory(&ctx); |
549 | 43 | } | 43 | } |
550 | 44 | 44 | ||
552 | 45 | std::shared_ptr<mir::client::ClientPlatform> create_mesa_client_platform() | 45 | std::shared_ptr<mir::client::ClientPlatform> create_mesa_client_platform( |
553 | 46 | mir::client::ClientContext* client_context) | ||
554 | 46 | { | 47 | { |
555 | 47 | using namespace testing; | 48 | using namespace testing; |
556 | 48 | mtd::MockClientContext ctx; | ||
557 | 49 | ON_CALL(ctx, populate_server_package(_)) | ||
558 | 50 | .WillByDefault(Invoke([](MirPlatformPackage& package) | ||
559 | 51 | { | ||
560 | 52 | ::memset(&package, 0, sizeof(package)); | ||
561 | 53 | package.fd_items = 1; | ||
562 | 54 | })); | ||
563 | 55 | platform_library = std::make_shared<mir::SharedLibrary>(client_platform("mesa.so")); | 49 | platform_library = std::make_shared<mir::SharedLibrary>(client_platform("mesa.so")); |
564 | 56 | auto platform_factory = platform_library->load_function<mir::client::CreateClientPlatform>("create_client_platform"); | 50 | auto platform_factory = platform_library->load_function<mir::client::CreateClientPlatform>("create_client_platform"); |
566 | 57 | return platform_factory(&ctx); | 51 | return platform_factory(client_context); |
567 | 58 | } | 52 | } |
568 | 59 | 53 | ||
569 | 60 | std::shared_ptr<mir::SharedLibrary> | 54 | std::shared_ptr<mir::SharedLibrary> |
570 | 61 | 55 | ||
571 | === modified file 'tests/mir_test_framework/stub_client_platform_factory.cpp' | |||
572 | --- tests/mir_test_framework/stub_client_platform_factory.cpp 2015-01-29 14:57:00 +0000 | |||
573 | +++ tests/mir_test_framework/stub_client_platform_factory.cpp 2015-02-02 14:38:00 +0000 | |||
574 | @@ -50,6 +50,11 @@ | |||
575 | 50 | context->populate_server_package(package); | 50 | context->populate_server_package(package); |
576 | 51 | } | 51 | } |
577 | 52 | 52 | ||
578 | 53 | MirPlatformMessage* platform_operation(MirPlatformMessage const*) override | ||
579 | 54 | { | ||
580 | 55 | return nullptr; | ||
581 | 56 | } | ||
582 | 57 | |||
583 | 53 | std::shared_ptr<mcl::ClientBufferFactory> create_buffer_factory() | 58 | std::shared_ptr<mcl::ClientBufferFactory> create_buffer_factory() |
584 | 54 | { | 59 | { |
585 | 55 | return std::make_shared<mtd::StubClientBufferFactory>(); | 60 | return std::make_shared<mtd::StubClientBufferFactory>(); |
586 | 56 | 61 | ||
587 | === modified file 'tests/unit-tests/client/mesa/test_client_platform.cpp' | |||
588 | --- tests/unit-tests/client/mesa/test_client_platform.cpp 2015-01-22 21:42:26 +0000 | |||
589 | +++ tests/unit-tests/client/mesa/test_client_platform.cpp 2015-02-02 14:38:00 +0000 | |||
590 | @@ -18,23 +18,56 @@ | |||
591 | 18 | 18 | ||
592 | 19 | #include "mir/client_platform.h" | 19 | #include "mir/client_platform.h" |
593 | 20 | #include "mir/shared_library.h" | 20 | #include "mir/shared_library.h" |
594 | 21 | #include "mir/raii.h" | ||
595 | 21 | #include "src/platforms/mesa/client/mesa_native_display_container.h" | 22 | #include "src/platforms/mesa/client/mesa_native_display_container.h" |
596 | 22 | #include "mir_test_framework/client_platform_factory.h" | 23 | #include "mir_test_framework/client_platform_factory.h" |
597 | 23 | #include "mir_test_doubles/mock_egl_native_surface.h" | ||
598 | 24 | 24 | ||
599 | 25 | #include "mir_toolkit/mir_client_library.h" | ||
600 | 25 | #include "mir_toolkit/mesa/native_display.h" | 26 | #include "mir_toolkit/mesa/native_display.h" |
601 | 27 | #include "mir_toolkit/mesa/platform_operation.h" | ||
602 | 26 | 28 | ||
603 | 27 | #include <gtest/gtest.h> | 29 | #include <gtest/gtest.h> |
604 | 30 | #include <gmock/gmock.h> | ||
605 | 28 | 31 | ||
606 | 29 | namespace mcl = mir::client; | 32 | namespace mcl = mir::client; |
607 | 30 | namespace mclm = mir::client::mesa; | 33 | namespace mclm = mir::client::mesa; |
608 | 31 | namespace mt = mir::test; | ||
609 | 32 | namespace mtd = mir::test::doubles; | ||
610 | 33 | namespace mtf = mir_test_framework; | 34 | namespace mtf = mir_test_framework; |
611 | 34 | 35 | ||
615 | 35 | TEST(MesaClientPlatformTest, egl_native_display_is_valid_until_released) | 36 | namespace |
616 | 36 | { | 37 | { |
617 | 37 | auto platform = mtf::create_mesa_client_platform(); | 38 | |
618 | 39 | struct StubClientContext : mcl::ClientContext | ||
619 | 40 | { | ||
620 | 41 | void populate_server_package(MirPlatformPackage& platform_package) override | ||
621 | 42 | { | ||
622 | 43 | platform_package.data_items = 0; | ||
623 | 44 | platform_package.fd_items = 1; | ||
624 | 45 | } | ||
625 | 46 | |||
626 | 47 | }; | ||
627 | 48 | |||
628 | 49 | struct MesaClientPlatformTest : testing::Test | ||
629 | 50 | { | ||
630 | 51 | MirPlatformMessage* set_gbm_device(gbm_device* dev) | ||
631 | 52 | { | ||
632 | 53 | auto request_msg = mir::raii::deleter_for( | ||
633 | 54 | mir_platform_message_create(MirMesaPlatformOperation::set_gbm_device), | ||
634 | 55 | &mir_platform_message_release); | ||
635 | 56 | MirMesaSetGBMDeviceRequest const request{dev}; | ||
636 | 57 | mir_platform_message_set_data(request_msg.get(), &request, sizeof(request)); | ||
637 | 58 | |||
638 | 59 | return platform->platform_operation(request_msg.get()); | ||
639 | 60 | } | ||
640 | 61 | |||
641 | 62 | StubClientContext client_context; | ||
642 | 63 | std::shared_ptr<mir::client::ClientPlatform> platform = | ||
643 | 64 | mtf::create_mesa_client_platform(&client_context); | ||
644 | 65 | }; | ||
645 | 66 | |||
646 | 67 | } | ||
647 | 68 | |||
648 | 69 | TEST_F(MesaClientPlatformTest, egl_native_display_is_valid_until_released) | ||
649 | 70 | { | ||
650 | 38 | auto platform_lib = mtf::get_platform_library(); | 71 | auto platform_lib = mtf::get_platform_library(); |
651 | 39 | 72 | ||
652 | 40 | MirMesaEGLNativeDisplay* nd; | 73 | MirMesaEGLNativeDisplay* nd; |
653 | @@ -47,3 +80,41 @@ | |||
654 | 47 | } | 80 | } |
655 | 48 | EXPECT_EQ(MIR_MESA_FALSE, mclm::mir_client_mesa_egl_native_display_is_valid(nd)); | 81 | EXPECT_EQ(MIR_MESA_FALSE, mclm::mir_client_mesa_egl_native_display_is_valid(nd)); |
656 | 49 | } | 82 | } |
657 | 83 | |||
658 | 84 | TEST_F(MesaClientPlatformTest, handles_set_gbm_device_platform_operation) | ||
659 | 85 | { | ||
660 | 86 | using namespace testing; | ||
661 | 87 | |||
662 | 88 | int const success{0}; | ||
663 | 89 | auto const gbm_dev_dummy = reinterpret_cast<gbm_device*>(this); | ||
664 | 90 | |||
665 | 91 | auto response_msg = mir::raii::deleter_for( | ||
666 | 92 | set_gbm_device(gbm_dev_dummy), | ||
667 | 93 | &mir_platform_message_release); | ||
668 | 94 | |||
669 | 95 | ASSERT_THAT(response_msg, NotNull()); | ||
670 | 96 | auto const response_data = mir_platform_message_get_data(response_msg.get()); | ||
671 | 97 | ASSERT_THAT(response_data.size, Eq(sizeof(MirMesaSetGBMDeviceResponse))); | ||
672 | 98 | auto const response_ptr = | ||
673 | 99 | reinterpret_cast<MirMesaSetGBMDeviceResponse const*>(response_data.data); | ||
674 | 100 | EXPECT_THAT(response_ptr->status, Eq(success)); | ||
675 | 101 | } | ||
676 | 102 | |||
677 | 103 | TEST_F(MesaClientPlatformTest, appends_gbm_device_to_platform_package) | ||
678 | 104 | { | ||
679 | 105 | using namespace testing; | ||
680 | 106 | |||
681 | 107 | MirPlatformPackage pkg; | ||
682 | 108 | platform->populate(pkg); | ||
683 | 109 | int const previous_data_count{pkg.data_items}; | ||
684 | 110 | auto const gbm_dev_dummy = reinterpret_cast<gbm_device*>(this); | ||
685 | 111 | |||
686 | 112 | auto response_msg = mir::raii::deleter_for( | ||
687 | 113 | set_gbm_device(gbm_dev_dummy), | ||
688 | 114 | &mir_platform_message_release); | ||
689 | 115 | |||
690 | 116 | platform->populate(pkg); | ||
691 | 117 | EXPECT_THAT(pkg.data_items, Eq(previous_data_count + (sizeof(gbm_dev_dummy) / sizeof(int)))); | ||
692 | 118 | EXPECT_THAT(reinterpret_cast<struct gbm_device*>(pkg.data[previous_data_count]), | ||
693 | 119 | Eq(gbm_dev_dummy)); | ||
694 | 120 | } | ||
695 | 50 | 121 | ||
696 | === modified file 'tests/unit-tests/client/test_client_mir_surface.cpp' | |||
697 | --- tests/unit-tests/client/test_client_mir_surface.cpp 2015-01-29 14:57:00 +0000 | |||
698 | +++ tests/unit-tests/client/test_client_mir_surface.cpp 2015-02-02 14:38:00 +0000 | |||
699 | @@ -211,6 +211,12 @@ | |||
700 | 211 | { | 211 | { |
701 | 212 | } | 212 | } |
702 | 213 | 213 | ||
703 | 214 | MirPlatformMessage* platform_operation( | ||
704 | 215 | MirPlatformMessage const*) override | ||
705 | 216 | { | ||
706 | 217 | return nullptr; | ||
707 | 218 | } | ||
708 | 219 | |||
709 | 214 | std::shared_ptr<mcl::ClientBufferFactory> create_buffer_factory() | 220 | std::shared_ptr<mcl::ClientBufferFactory> create_buffer_factory() |
710 | 215 | { | 221 | { |
711 | 216 | return std::make_shared<mtd::StubClientBufferFactory>(); | 222 | return std::make_shared<mtd::StubClientBufferFactory>(); |
712 | 217 | 223 | ||
713 | === modified file 'tests/unit-tests/client/test_mir_connection.cpp' | |||
714 | --- tests/unit-tests/client/test_mir_connection.cpp 2015-01-30 14:24:06 +0000 | |||
715 | +++ tests/unit-tests/client/test_mir_connection.cpp 2015-02-02 14:38:00 +0000 | |||
716 | @@ -28,6 +28,7 @@ | |||
717 | 28 | #include "src/client/mir_surface.h" | 28 | #include "src/client/mir_surface.h" |
718 | 29 | #include "mir/client_buffer_factory.h" | 29 | #include "mir/client_buffer_factory.h" |
719 | 30 | #include "mir/dispatch/dispatchable.h" | 30 | #include "mir/dispatch/dispatchable.h" |
720 | 31 | #include "mir/raii.h" | ||
721 | 31 | 32 | ||
722 | 32 | #include "src/server/frontend/resource_cache.h" /* needed by test_server.h */ | 33 | #include "src/server/frontend/resource_cache.h" /* needed by test_server.h */ |
723 | 33 | #include "mir_test/test_protobuf_server.h" | 34 | #include "mir_test/test_protobuf_server.h" |
724 | @@ -74,12 +75,19 @@ | |||
725 | 74 | { | 75 | { |
726 | 75 | configure_display_sent(static_cast<mp::DisplayConfiguration const*>(parameters)); | 76 | configure_display_sent(static_cast<mp::DisplayConfiguration const*>(parameters)); |
727 | 76 | } | 77 | } |
728 | 78 | else if (method->name() == "platform_operation") | ||
729 | 79 | { | ||
730 | 80 | platform_operation(static_cast<mp::PlatformOperationMessage const*>(parameters), | ||
731 | 81 | static_cast<mp::PlatformOperationMessage*>(response)); | ||
732 | 82 | } | ||
733 | 77 | 83 | ||
734 | 78 | complete->Run(); | 84 | complete->Run(); |
735 | 79 | } | 85 | } |
736 | 80 | 86 | ||
737 | 81 | MOCK_METHOD2(connect, void(mp::ConnectParameters const*,mp::Connection*)); | 87 | MOCK_METHOD2(connect, void(mp::ConnectParameters const*,mp::Connection*)); |
738 | 82 | MOCK_METHOD1(configure_display_sent, void(mp::DisplayConfiguration const*)); | 88 | MOCK_METHOD1(configure_display_sent, void(mp::DisplayConfiguration const*)); |
739 | 89 | MOCK_METHOD2(platform_operation, | ||
740 | 90 | void(mp::PlatformOperationMessage const*, mp::PlatformOperationMessage*)); | ||
741 | 83 | 91 | ||
742 | 84 | MOCK_CONST_METHOD0(watch_fd, mir::Fd()); | 92 | MOCK_CONST_METHOD0(watch_fd, mir::Fd()); |
743 | 85 | MOCK_METHOD1(dispatch, bool(md::FdEvents)); | 93 | MOCK_METHOD1(dispatch, bool(md::FdEvents)); |
744 | @@ -101,6 +109,8 @@ | |||
745 | 101 | .WillByDefault(Return(std::make_shared<mtd::StubClientBufferFactory>())); | 109 | .WillByDefault(Return(std::make_shared<mtd::StubClientBufferFactory>())); |
746 | 102 | ON_CALL(*this, create_egl_native_window(_)) | 110 | ON_CALL(*this, create_egl_native_window(_)) |
747 | 103 | .WillByDefault(Return(std::shared_ptr<EGLNativeWindowType>())); | 111 | .WillByDefault(Return(std::shared_ptr<EGLNativeWindowType>())); |
748 | 112 | ON_CALL(*this, platform_operation(_)) | ||
749 | 113 | .WillByDefault(Return(nullptr)); | ||
750 | 104 | } | 114 | } |
751 | 105 | 115 | ||
752 | 106 | void set_client_context(mcl::ClientContext* ctx) | 116 | void set_client_context(mcl::ClientContext* ctx) |
753 | @@ -115,6 +125,7 @@ | |||
754 | 115 | 125 | ||
755 | 116 | MOCK_CONST_METHOD1(convert_native_buffer, MirNativeBuffer*(mir::graphics::NativeBuffer*)); | 126 | MOCK_CONST_METHOD1(convert_native_buffer, MirNativeBuffer*(mir::graphics::NativeBuffer*)); |
756 | 117 | MOCK_CONST_METHOD0(platform_type, MirPlatformType()); | 127 | MOCK_CONST_METHOD0(platform_type, MirPlatformType()); |
757 | 128 | MOCK_METHOD1(platform_operation, MirPlatformMessage*(MirPlatformMessage const*)); | ||
758 | 118 | MOCK_METHOD0(create_buffer_factory, std::shared_ptr<mcl::ClientBufferFactory>()); | 129 | MOCK_METHOD0(create_buffer_factory, std::shared_ptr<mcl::ClientBufferFactory>()); |
759 | 119 | MOCK_METHOD1(create_egl_native_window, std::shared_ptr<EGLNativeWindowType>(mcl::EGLNativeSurface*)); | 130 | MOCK_METHOD1(create_egl_native_window, std::shared_ptr<EGLNativeWindowType>(mcl::EGLNativeSurface*)); |
760 | 120 | MOCK_METHOD0(create_egl_native_display, std::shared_ptr<EGLNativeDisplayType>()); | 131 | MOCK_METHOD0(create_egl_native_display, std::shared_ptr<EGLNativeDisplayType>()); |
761 | @@ -568,46 +579,72 @@ | |||
762 | 568 | namespace | 579 | namespace |
763 | 569 | { | 580 | { |
764 | 570 | 581 | ||
807 | 571 | ACTION_P(FillPlatformDataWith, sample_data) | 582 | void assign_response(MirConnection*, MirPlatformMessage* response, void* context) |
808 | 572 | { | 583 | { |
809 | 573 | for (auto d : sample_data) | 584 | auto response_ptr = static_cast<MirPlatformMessage**>(context); |
810 | 574 | arg1->mutable_platform()->add_data(d); | 585 | *response_ptr = response; |
811 | 575 | } | 586 | } |
812 | 576 | 587 | ||
813 | 577 | } | 588 | ACTION(CopyRequestToResponse) |
814 | 578 | 589 | { | |
815 | 579 | TEST_F(MirConnectionTest, sets_extra_platform_data) | 590 | *arg1 = *arg0; |
816 | 580 | { | 591 | } |
817 | 581 | using namespace testing; | 592 | } |
818 | 582 | std::vector<int> const initial_data{0x66, 0x67, 0x68}; | 593 | |
819 | 583 | std::vector<int> const extra_data{0x11, 0x12, 0x13}; | 594 | TEST_F(MirConnectionTest, uses_client_platform_for_platform_operation) |
820 | 584 | 595 | { | |
821 | 585 | EXPECT_CALL(*mock_channel, connect(_,_)) | 596 | using namespace testing; |
822 | 586 | .WillOnce(FillPlatformDataWith(initial_data)); | 597 | |
823 | 587 | 598 | unsigned int const opcode{42}; | |
824 | 588 | MirWaitHandle *wait_handle = | 599 | auto const request = mir::raii::deleter_for( |
825 | 589 | connection->connect("MirClientSurfaceTest", &connected_callback, nullptr); | 600 | mir_platform_message_create(opcode), |
826 | 590 | wait_handle->wait_for_all(); | 601 | &mir_platform_message_release); |
827 | 591 | 602 | auto const response = mir::raii::deleter_for( | |
828 | 592 | MirPlatformPackage pkg; | 603 | mir_platform_message_create(opcode), |
829 | 593 | 604 | &mir_platform_message_release); | |
830 | 594 | /* Check initial data */ | 605 | |
831 | 595 | connection->populate(pkg); | 606 | EXPECT_CALL(*mock_platform, platform_operation(request.get())) |
832 | 596 | 607 | .WillOnce(Return(response.get())); | |
833 | 597 | EXPECT_EQ(initial_data.size(), static_cast<size_t>(pkg.data_items)); | 608 | EXPECT_CALL(*mock_channel, platform_operation(_,_)) |
834 | 598 | for (size_t i = 0; i < initial_data.size(); i++) | 609 | .Times(0); |
835 | 599 | EXPECT_EQ(initial_data[i], pkg.data[i]) << " i=" << i; | 610 | |
836 | 600 | 611 | auto connect_wh = | |
837 | 601 | /* Check initial data plus extra data*/ | 612 | connection->connect("MirClientSurfaceTest", &connected_callback, nullptr); |
838 | 602 | connection->set_extra_platform_data(extra_data); | 613 | mir_wait_for(connect_wh); |
839 | 603 | connection->populate(pkg); | 614 | |
840 | 604 | 615 | MirPlatformMessage* returned_response{nullptr}; | |
841 | 605 | EXPECT_EQ(initial_data.size() + extra_data.size(), | 616 | |
842 | 606 | static_cast<size_t>(pkg.data_items)); | 617 | auto op_wh = connection->platform_operation( |
843 | 607 | 618 | request.get(), assign_response, &returned_response); | |
844 | 608 | for (size_t i = 0; i < initial_data.size(); i++) | 619 | mir_wait_for(op_wh); |
845 | 609 | EXPECT_EQ(initial_data[i], pkg.data[i]) << " i=" << i; | 620 | |
846 | 610 | 621 | EXPECT_THAT(returned_response, Eq(response.get())); | |
847 | 611 | for (size_t i = 0; i < extra_data.size(); i++) | 622 | } |
848 | 612 | EXPECT_EQ(extra_data[i], pkg.data[i + initial_data.size()]) << " i=" << i; | 623 | |
849 | 624 | TEST_F(MirConnectionTest, contacts_server_if_client_platform_cannot_handle_platform_operation) | ||
850 | 625 | { | ||
851 | 626 | using namespace testing; | ||
852 | 627 | |||
853 | 628 | unsigned int const opcode{42}; | ||
854 | 629 | auto const request = mir::raii::deleter_for( | ||
855 | 630 | mir_platform_message_create(opcode), | ||
856 | 631 | &mir_platform_message_release); | ||
857 | 632 | |||
858 | 633 | EXPECT_CALL(*mock_platform, platform_operation(_)) | ||
859 | 634 | .WillOnce(Return(nullptr)); | ||
860 | 635 | EXPECT_CALL(*mock_channel, platform_operation(_,_)) | ||
861 | 636 | .WillOnce(CopyRequestToResponse()); | ||
862 | 637 | |||
863 | 638 | auto connect_wh = | ||
864 | 639 | connection->connect("MirClientSurfaceTest", &connected_callback, nullptr); | ||
865 | 640 | mir_wait_for(connect_wh); | ||
866 | 641 | |||
867 | 642 | MirPlatformMessage* returned_response{nullptr}; | ||
868 | 643 | |||
869 | 644 | auto op_wh = connection->platform_operation( | ||
870 | 645 | request.get(), assign_response, &returned_response); | ||
871 | 646 | mir_wait_for(op_wh); | ||
872 | 647 | |||
873 | 648 | EXPECT_THAT(mir_platform_message_get_opcode(returned_response), Eq(opcode)); | ||
874 | 649 | mir_platform_message_release(returned_response); | ||
875 | 613 | } | 650 | } |