Status: | Merged |
---|---|
Approved by: | Alberto Aguirre |
Approved revision: | 2555 |
Merged at revision: | 1233 |
Proposed branch: | lp:mir/0.13 |
Merge into: | lp:mir/ubuntu |
Diff against target: |
1462 lines (+320/-240) 16 files modified
CMakeLists.txt (+1/-1) debian/changelog (+9/-0) debian/control (+1/-1) src/client/buffer_stream.cpp (+41/-40) src/client/buffer_stream.h (+3/-3) src/client/make_protobuf_object.h (+42/-0) src/client/mir_buffer_stream_api.cpp (+7/-6) src/client/mir_connection.cpp (+47/-40) src/client/mir_connection.h (+8/-6) src/client/mir_prompt_session.cpp (+21/-15) src/client/mir_prompt_session.h (+5/-5) src/client/mir_screencast.cpp (+24/-21) src/client/mir_screencast.h (+4/-2) src/client/mir_surface.cpp (+76/-70) src/client/mir_surface.h (+6/-6) src/client/rpc/mir_protobuf_rpc_channel.cpp (+25/-24) |
To merge this branch: | bzr merge lp:mir/0.13 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel van Vugt | Approve | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Kevin DuBois (community) | Approve | ||
Review via email: mp+262262@code.launchpad.net |
Commit message
Mir 0.13.3 release
Description of the change
Mir 0.13.3 release
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2555
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Alberto Aguirre (albaguirre) wrote : | # |
Umm it's always these tests:
[ FAILED ] GLibMainLoopAla
[ FAILED ] SimpleDispatchT
But they don't fail in the silo build...ummm.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2555
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Daniel van Vugt (vanvugt) wrote : | # |
Apparently not landed yet, but is released already (!?) :)
https:/
https:/
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2015-06-02 23:18:42 +0000 |
3 | +++ CMakeLists.txt 2015-06-17 19:19:38 +0000 |
4 | @@ -28,7 +28,7 @@ |
5 | |
6 | set(MIR_VERSION_MAJOR 0) |
7 | set(MIR_VERSION_MINOR 13) # This should change at least with every MIRSERVER_ABI |
8 | -set(MIR_VERSION_PATCH 2) |
9 | +set(MIR_VERSION_PATCH 3) |
10 | |
11 | add_definitions(-DMIR_VERSION_MAJOR=${MIR_VERSION_MAJOR}) |
12 | add_definitions(-DMIR_VERSION_MINOR=${MIR_VERSION_MINOR}) |
13 | |
14 | === modified file 'debian/changelog' |
15 | --- debian/changelog 2015-06-05 17:51:41 +0000 |
16 | +++ debian/changelog 2015-06-17 19:19:38 +0000 |
17 | @@ -1,3 +1,12 @@ |
18 | +mir (0.13.3) UNRELEASED; urgency=medium |
19 | + |
20 | + * New upstream release 0.13.3 (https://launchpad.net/mir/+milestone/0.13.3) |
21 | + - Bug fixes: |
22 | + . mir-client-platform-mesa-dev package dep is incorrect (LP: #1465642) |
23 | + . Avoid allocating mir protobuf message objects on stack (LP: #1465883) |
24 | + |
25 | + -- Alberto Aguirre <alberto.aguirre@canonical.com> Wed, 17 Jun 2015 14:11:53 -0500 |
26 | + |
27 | mir (0.13.2+15.10.20150605-0ubuntu1) wily; urgency=medium |
28 | |
29 | [ Alberto Aguirre ] |
30 | |
31 | === modified file 'debian/control' |
32 | --- debian/control 2015-06-05 17:48:17 +0000 |
33 | +++ debian/control 2015-06-17 19:19:38 +0000 |
34 | @@ -317,7 +317,7 @@ |
35 | Architecture: i386 amd64 armhf arm64 powerpc ppc64el |
36 | Multi-Arch: same |
37 | Pre-Depends: ${misc:Pre-Depends} |
38 | -Depends: libmircommon-dev, |
39 | +Depends: libmirclient-dev, |
40 | ${misc:Depends}, |
41 | Description: Display server for Ubuntu - client platform library for Mesa development files |
42 | Mir is a display server running on linux systems, with a focus on efficiency, |
43 | |
44 | === modified file 'src/client/buffer_stream.cpp' |
45 | --- src/client/buffer_stream.cpp 2015-04-23 14:09:57 +0000 |
46 | +++ src/client/buffer_stream.cpp 2015-06-17 19:19:38 +0000 |
47 | @@ -19,6 +19,7 @@ |
48 | #define MIR_LOG_COMPONENT "MirBufferStream" |
49 | |
50 | #include "buffer_stream.h" |
51 | +#include "make_protobuf_object.h" |
52 | |
53 | #include "mir/frontend/client_constants.h" |
54 | |
55 | @@ -96,11 +97,11 @@ |
56 | : display_server(server), |
57 | mode(mode), |
58 | client_platform(client_platform), |
59 | - protobuf_bs(protobuf_bs), |
60 | + protobuf_bs{mcl::make_protobuf_object<mir::protobuf::BufferStream>(protobuf_bs)}, |
61 | buffer_depository{client_platform->create_buffer_factory(), mir::frontend::client_buffer_cache_size}, |
62 | swap_interval_(1), |
63 | - perf_report(perf_report) |
64 | - |
65 | + perf_report(perf_report), |
66 | + protobuf_void{mcl::make_protobuf_object<mir::protobuf::Void>()} |
67 | { |
68 | created(nullptr, nullptr); |
69 | perf_report->name_surface(surface_name.c_str()); |
70 | @@ -115,21 +116,23 @@ |
71 | : display_server(server), |
72 | mode(BufferStreamMode::Producer), |
73 | client_platform(client_platform), |
74 | + protobuf_bs{mcl::make_protobuf_object<mir::protobuf::BufferStream>()}, |
75 | buffer_depository{client_platform->create_buffer_factory(), mir::frontend::client_buffer_cache_size}, |
76 | swap_interval_(1), |
77 | - perf_report(perf_report) |
78 | + perf_report(perf_report), |
79 | + protobuf_void{mcl::make_protobuf_object<mir::protobuf::Void>()} |
80 | { |
81 | perf_report->name_surface(std::to_string(reinterpret_cast<long int>(this)).c_str()); |
82 | |
83 | create_wait_handle.expect_result(); |
84 | try |
85 | { |
86 | - server.create_buffer_stream(0, ¶meters, &protobuf_bs, gp::NewCallback(this, &mcl::BufferStream::created, callback, |
87 | + server.create_buffer_stream(0, ¶meters, protobuf_bs.get(), gp::NewCallback(this, &mcl::BufferStream::created, callback, |
88 | context)); |
89 | } |
90 | catch (std::exception const& ex) |
91 | { |
92 | - protobuf_bs.set_error(std::string{"Error invoking create buffer stream: "} + |
93 | + protobuf_bs->set_error(std::string{"Error invoking create buffer stream: "} + |
94 | boost::diagnostic_information(ex)); |
95 | } |
96 | |
97 | @@ -137,12 +140,12 @@ |
98 | |
99 | void mcl::BufferStream::created(mir_buffer_stream_callback callback, void *context) |
100 | { |
101 | - if (!protobuf_bs.has_id() || protobuf_bs.has_error()) |
102 | - BOOST_THROW_EXCEPTION(std::runtime_error("Can not create buffer stream: " + std::string(protobuf_bs.error()))); |
103 | - if (!protobuf_bs.has_buffer()) |
104 | + if (!protobuf_bs->has_id() || protobuf_bs->has_error()) |
105 | + BOOST_THROW_EXCEPTION(std::runtime_error("Can not create buffer stream: " + std::string(protobuf_bs->error()))); |
106 | + if (!protobuf_bs->has_buffer()) |
107 | BOOST_THROW_EXCEPTION(std::runtime_error("Buffer stream did not come with a buffer")); |
108 | |
109 | - process_buffer(protobuf_bs.buffer()); |
110 | + process_buffer(protobuf_bs->buffer()); |
111 | egl_native_window_ = client_platform->create_egl_native_window(this); |
112 | |
113 | if (callback) |
114 | @@ -173,7 +176,7 @@ |
115 | |
116 | try |
117 | { |
118 | - auto pixel_format = static_cast<MirPixelFormat>(protobuf_bs.pixel_format()); |
119 | + auto pixel_format = static_cast<MirPixelFormat>(protobuf_bs->pixel_format()); |
120 | buffer_depository.deposit_package(buffer_package, |
121 | buffer.buffer_id(), |
122 | cached_buffer_size, pixel_format); |
123 | @@ -192,40 +195,37 @@ |
124 | |
125 | secured_region.reset(); |
126 | |
127 | - mir::protobuf::BufferStreamId buffer_stream_id; |
128 | - buffer_stream_id.set_value(protobuf_bs.id().value()); |
129 | - |
130 | -// TODO: We can fix the strange "ID casting" used below in the second phase |
131 | -// of buffer stream which generalizes and clarifies the server side logic. |
132 | + // TODO: We can fix the strange "ID casting" used below in the second phase |
133 | + // of buffer stream which generalizes and clarifies the server side logic. |
134 | if (mode == mcl::BufferStreamMode::Producer) |
135 | { |
136 | - mp::BufferRequest request; |
137 | - request.mutable_id()->set_value(protobuf_bs.id().value()); |
138 | - request.mutable_buffer()->set_buffer_id(protobuf_bs.buffer().buffer_id()); |
139 | + auto request = mcl::make_protobuf_object<mp::BufferRequest>(); |
140 | + request->mutable_id()->set_value(protobuf_bs->id().value()); |
141 | + request->mutable_buffer()->set_buffer_id(protobuf_bs->buffer().buffer_id()); |
142 | |
143 | lock.unlock(); |
144 | next_buffer_wait_handle.expect_result(); |
145 | |
146 | display_server.exchange_buffer( |
147 | nullptr, |
148 | - &request, |
149 | - protobuf_bs.mutable_buffer(), |
150 | + request.get(), |
151 | + protobuf_bs->mutable_buffer(), |
152 | google::protobuf::NewCallback( |
153 | this, &mcl::BufferStream::next_buffer_received, |
154 | done)); |
155 | } |
156 | else |
157 | { |
158 | - mp::ScreencastId screencast_id; |
159 | - screencast_id.set_value(protobuf_bs.id().value()); |
160 | + auto screencast_id = mcl::make_protobuf_object<mp::ScreencastId>(); |
161 | + screencast_id->set_value(protobuf_bs->id().value()); |
162 | |
163 | lock.unlock(); |
164 | next_buffer_wait_handle.expect_result(); |
165 | |
166 | display_server.screencast_buffer( |
167 | nullptr, |
168 | - &screencast_id, |
169 | - protobuf_bs.mutable_buffer(), |
170 | + screencast_id.get(), |
171 | + protobuf_bs->mutable_buffer(), |
172 | google::protobuf::NewCallback( |
173 | this, &mcl::BufferStream::next_buffer_received, |
174 | done)); |
175 | @@ -263,7 +263,7 @@ |
176 | void mcl::BufferStream::next_buffer_received( |
177 | std::function<void()> done) |
178 | { |
179 | - process_buffer(protobuf_bs.buffer()); |
180 | + process_buffer(protobuf_bs->buffer()); |
181 | |
182 | done(); |
183 | |
184 | @@ -278,8 +278,8 @@ |
185 | "", |
186 | cached_buffer_size.width.as_int(), |
187 | cached_buffer_size.height.as_int(), |
188 | - static_cast<MirPixelFormat>(protobuf_bs.pixel_format()), |
189 | - static_cast<MirBufferUsage>(protobuf_bs.buffer_usage()), |
190 | + static_cast<MirPixelFormat>(protobuf_bs->pixel_format()), |
191 | + static_cast<MirBufferUsage>(protobuf_bs->buffer_usage()), |
192 | mir_display_output_id_invalid}; |
193 | } |
194 | |
195 | @@ -311,20 +311,21 @@ |
196 | BOOST_THROW_EXCEPTION(std::logic_error("Attempt to set swap interval on screencast is invalid")); |
197 | } |
198 | |
199 | - mp::SurfaceSetting setting, result; |
200 | - setting.mutable_surfaceid()->set_value(protobuf_bs.id().value()); |
201 | - setting.set_attrib(attrib); |
202 | - setting.set_ivalue(value); |
203 | + auto setting = mcl::make_protobuf_object<mp::SurfaceSetting>(); |
204 | + auto result = mcl::make_protobuf_object<mp::SurfaceSetting>(); |
205 | + setting->mutable_surfaceid()->set_value(protobuf_bs->id().value()); |
206 | + setting->set_attrib(attrib); |
207 | + setting->set_ivalue(value); |
208 | lock.unlock(); |
209 | |
210 | configure_wait_handle.expect_result(); |
211 | - display_server.configure_surface(0, &setting, &result, |
212 | + display_server.configure_surface(0, setting.get(), result.get(), |
213 | google::protobuf::NewCallback(this, &mcl::BufferStream::on_configured)); |
214 | |
215 | configure_wait_handle.wait_for_all(); |
216 | |
217 | lock.lock(); |
218 | - swap_interval_ = result.ivalue(); |
219 | + swap_interval_ = result->ivalue(); |
220 | } |
221 | |
222 | uint32_t mcl::BufferStream::get_current_buffer_id() |
223 | @@ -364,14 +365,14 @@ |
224 | MirWaitHandle* mcl::BufferStream::release( |
225 | mir_buffer_stream_callback callback, void* context) |
226 | { |
227 | - mir::protobuf::BufferStreamId buffer_stream_id; |
228 | - buffer_stream_id.set_value(protobuf_bs.id().value()); |
229 | + auto buffer_stream_id = mcl::make_protobuf_object<mir::protobuf::BufferStreamId>(); |
230 | + buffer_stream_id->set_value(protobuf_bs->id().value()); |
231 | |
232 | release_wait_handle.expect_result(); |
233 | display_server.release_buffer_stream( |
234 | nullptr, |
235 | - &buffer_stream_id, |
236 | - &protobuf_void, |
237 | + buffer_stream_id.get(), |
238 | + protobuf_void.get(), |
239 | google::protobuf::NewCallback( |
240 | this, &mcl::BufferStream::released, callback, context)); |
241 | |
242 | @@ -390,13 +391,13 @@ |
243 | { |
244 | std::unique_lock<decltype(mutex)> lock(mutex); |
245 | |
246 | - return mf::BufferStreamId(protobuf_bs.id().value()); |
247 | + return mf::BufferStreamId(protobuf_bs->id().value()); |
248 | } |
249 | |
250 | bool mcl::BufferStream::valid() const |
251 | { |
252 | std::unique_lock<decltype(mutex)> lock(mutex); |
253 | - return protobuf_bs.has_id() && !protobuf_bs.has_error(); |
254 | + return protobuf_bs->has_id() && !protobuf_bs->has_error(); |
255 | } |
256 | |
257 | void mcl::BufferStream::set_buffer_cache_size(unsigned int cache_size) |
258 | |
259 | === modified file 'src/client/buffer_stream.h' |
260 | --- src/client/buffer_stream.h 2015-04-23 14:09:57 +0000 |
261 | +++ src/client/buffer_stream.h 2015-06-17 19:19:38 +0000 |
262 | @@ -60,7 +60,7 @@ |
263 | BufferStream(mir::protobuf::DisplayServer& server, |
264 | BufferStreamMode mode, |
265 | std::shared_ptr<ClientPlatform> const& native_window_factory, |
266 | - protobuf::BufferStream const& protobuf_bs, |
267 | + mir::protobuf::BufferStream const& protobuf_bs, |
268 | std::shared_ptr<PerfReport> const& perf_report, |
269 | std::string const& surface_name); |
270 | // For surfaceless buffer streams |
271 | @@ -121,7 +121,7 @@ |
272 | BufferStreamMode const mode; |
273 | std::shared_ptr<ClientPlatform> const client_platform; |
274 | |
275 | - mir::protobuf::BufferStream protobuf_bs; |
276 | + std::unique_ptr<mir::protobuf::BufferStream> protobuf_bs; |
277 | mir::client::ClientBufferDepository buffer_depository; |
278 | |
279 | int swap_interval_; |
280 | @@ -134,7 +134,7 @@ |
281 | MirWaitHandle release_wait_handle; |
282 | MirWaitHandle next_buffer_wait_handle; |
283 | MirWaitHandle configure_wait_handle; |
284 | - mir::protobuf::Void protobuf_void; |
285 | + std::unique_ptr<mir::protobuf::Void> protobuf_void; |
286 | |
287 | std::shared_ptr<MemoryRegion> secured_region; |
288 | |
289 | |
290 | === added file 'src/client/make_protobuf_object.h' |
291 | --- src/client/make_protobuf_object.h 1970-01-01 00:00:00 +0000 |
292 | +++ src/client/make_protobuf_object.h 2015-06-17 19:19:38 +0000 |
293 | @@ -0,0 +1,42 @@ |
294 | +/* |
295 | + * Copyright © 2015 Canonical Ltd. |
296 | + * |
297 | + * This program is free software: you can redistribute it and/or modify it |
298 | + * under the terms of the GNU Lesser General Public License version 3, |
299 | + * as published by the Free Software Foundation. |
300 | + * |
301 | + * This program is distributed in the hope that it will be useful, |
302 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
303 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
304 | + * GNU Lesser General Public License for more details. |
305 | + * |
306 | + * You should have received a copy of the GNU Lesser General Public License |
307 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
308 | + * |
309 | + * Authored by: Alberto Aguirre <alberto.aguirre@canonical.com> |
310 | + */ |
311 | + |
312 | +#ifndef MIR_CLIENT_MAKE_PROTOBUF_OBJECT_ |
313 | +#define MIR_CLIENT_MAKE_PROTOBUF_OBJECT_ |
314 | + |
315 | +namespace mir |
316 | +{ |
317 | +namespace client |
318 | +{ |
319 | +template <typename ProtobufType> |
320 | +auto make_protobuf_object() |
321 | +{ |
322 | + return std::unique_ptr<ProtobufType>{ProtobufType::default_instance().New()}; |
323 | +} |
324 | + |
325 | +template <typename ProtobufType> |
326 | +auto make_protobuf_object(ProtobufType const& from) |
327 | +{ |
328 | + auto object = make_protobuf_object<ProtobufType>(); |
329 | + object->CopyFrom(from); |
330 | + return object; |
331 | +} |
332 | +} |
333 | +} |
334 | + |
335 | +#endif |
336 | |
337 | === modified file 'src/client/mir_buffer_stream_api.cpp' |
338 | --- src/client/mir_buffer_stream_api.cpp 2015-03-31 02:35:42 +0000 |
339 | +++ src/client/mir_buffer_stream_api.cpp 2015-06-17 19:19:38 +0000 |
340 | @@ -23,6 +23,7 @@ |
341 | #include "mir_connection.h" |
342 | #include "buffer_stream.h" |
343 | #include "client_buffer_stream_factory.h" |
344 | +#include "make_protobuf_object.h" |
345 | |
346 | #include "mir/client_buffer.h" |
347 | |
348 | @@ -68,13 +69,13 @@ |
349 | void *context) |
350 | try |
351 | { |
352 | - mp::BufferStreamParameters params; |
353 | - params.set_width(width); |
354 | - params.set_height(height); |
355 | - params.set_pixel_format(format); |
356 | - params.set_buffer_usage(buffer_usage); |
357 | + auto params = mcl::make_protobuf_object<mp::BufferStreamParameters>(); |
358 | + params->set_width(width); |
359 | + params->set_height(height); |
360 | + params->set_pixel_format(format); |
361 | + params->set_buffer_usage(buffer_usage); |
362 | |
363 | - return connection->get_client_buffer_stream_factory()->make_producer_stream(connection->display_server(), params, callback, context) |
364 | + return connection->get_client_buffer_stream_factory()->make_producer_stream(connection->display_server(), *params, callback, context) |
365 | ->get_create_wait_handle(); |
366 | } |
367 | catch (std::exception const& ex) |
368 | |
369 | === modified file 'src/client/mir_connection.cpp' |
370 | --- src/client/mir_connection.cpp 2015-04-01 19:39:19 +0000 |
371 | +++ src/client/mir_connection.cpp 2015-06-17 19:19:38 +0000 |
372 | @@ -20,6 +20,7 @@ |
373 | #include "mir_surface.h" |
374 | #include "mir_prompt_session.h" |
375 | #include "default_client_buffer_stream_factory.h" |
376 | +#include "make_protobuf_object.h" |
377 | #include "mir_toolkit/mir_platform_message.h" |
378 | #include "mir/client_platform.h" |
379 | #include "mir/client_platform_factory.h" |
380 | @@ -106,7 +107,13 @@ |
381 | server(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL), |
382 | debug(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL), |
383 | logger(conf.the_logger()), |
384 | + void_response{mcl::make_protobuf_object<mir::protobuf::Void>()}, |
385 | + connect_result{mcl::make_protobuf_object<mir::protobuf::Connection>()}, |
386 | connect_done{false}, |
387 | + ignored{mcl::make_protobuf_object<mir::protobuf::Void>()}, |
388 | + connect_parameters{mcl::make_protobuf_object<mir::protobuf::ConnectParameters>()}, |
389 | + platform_operation_reply{mcl::make_protobuf_object<mir::protobuf::PlatformOperationMessage>()}, |
390 | + display_configuration_response{mcl::make_protobuf_object<mir::protobuf::DisplayConfiguration>()}, |
391 | client_platform_factory(conf.the_client_platform_factory()), |
392 | input_platform(conf.the_input_platform()), |
393 | display_configuration(conf.the_display_configuration()), |
394 | @@ -115,7 +122,7 @@ |
395 | event_handler_register(conf.the_event_handler_register()), |
396 | eventloop{new md::SimpleDispatchThread{std::dynamic_pointer_cast<md::Dispatchable>(channel)}} |
397 | { |
398 | - connect_result.set_error("connect not called"); |
399 | + connect_result->set_error("connect not called"); |
400 | { |
401 | std::lock_guard<std::mutex> lock(connection_guard); |
402 | next_valid = valid_connections; |
403 | @@ -130,9 +137,9 @@ |
404 | connect_wait_handle.wait_for_pending(std::chrono::milliseconds(500)); |
405 | |
406 | std::lock_guard<decltype(mutex)> lock(mutex); |
407 | - if (connect_result.has_platform()) |
408 | + if (connect_result && connect_result->has_platform()) |
409 | { |
410 | - auto const& platform = connect_result.platform(); |
411 | + auto const& platform = connect_result->platform(); |
412 | for (int i = 0, end = platform.fd_size(); i != end; ++i) |
413 | close(platform.fd(i)); |
414 | } |
415 | @@ -153,9 +160,9 @@ |
416 | { |
417 | std::lock_guard<decltype(mutex)> lock(mutex); |
418 | |
419 | - if (connect_result.has_error()) |
420 | + if (connect_result && connect_result->has_error()) |
421 | { |
422 | - return connect_result.error().c_str(); |
423 | + return connect_result->error().c_str(); |
424 | } |
425 | |
426 | return error_message.c_str(); |
427 | @@ -202,8 +209,8 @@ |
428 | |
429 | SurfaceRelease surf_release{surface, new_wait_handle, callback, context}; |
430 | |
431 | - mir::protobuf::SurfaceId message; |
432 | - message.set_value(surface->id()); |
433 | + auto message = mcl::make_protobuf_object<mir::protobuf::SurfaceId>(); |
434 | + message->set_value(surface->id()); |
435 | |
436 | { |
437 | std::lock_guard<decltype(release_wait_handle_guard)> rel_lock(release_wait_handle_guard); |
438 | @@ -211,7 +218,7 @@ |
439 | } |
440 | |
441 | new_wait_handle->expect_result(); |
442 | - server.release_surface(0, &message, &void_response, |
443 | + server.release_surface(0, message.get(), void_response.get(), |
444 | gp::NewCallback(this, &MirConnection::released, surf_release)); |
445 | |
446 | |
447 | @@ -230,9 +237,9 @@ |
448 | { |
449 | std::lock_guard<decltype(mutex)> lock(mutex); |
450 | |
451 | - if (!connect_result.has_platform() || !connect_result.has_display_configuration()) |
452 | + if (!connect_result->has_platform() || !connect_result->has_display_configuration()) |
453 | { |
454 | - if (!connect_result.has_error()) |
455 | + if (!connect_result->has_error()) |
456 | { |
457 | // We're handling an error scenario that means we're not sync'd |
458 | // with the client code - a callback isn't safe (or needed) |
459 | @@ -263,12 +270,12 @@ |
460 | |
461 | platform = client_platform_factory->create_client_platform(this); |
462 | native_display = platform->create_egl_native_display(); |
463 | - display_configuration->set_configuration(connect_result.display_configuration()); |
464 | + display_configuration->set_configuration(connect_result->display_configuration()); |
465 | lifecycle_control->set_lifecycle_event_handler(default_lifecycle_event_handler); |
466 | } |
467 | catch (std::exception const& e) |
468 | { |
469 | - connect_result.set_error(std::string{"Failed to process connect response: "} + |
470 | + connect_result->set_error(std::string{"Failed to process connect response: "} + |
471 | boost::diagnostic_information(e)); |
472 | } |
473 | |
474 | @@ -284,14 +291,14 @@ |
475 | { |
476 | std::lock_guard<decltype(mutex)> lock(mutex); |
477 | |
478 | - connect_parameters.set_application_name(app_name); |
479 | + connect_parameters->set_application_name(app_name); |
480 | connect_wait_handle.expect_result(); |
481 | } |
482 | |
483 | server.connect( |
484 | 0, |
485 | - &connect_parameters, |
486 | - &connect_result, |
487 | + connect_parameters.get(), |
488 | + connect_result.get(), |
489 | google::protobuf::NewCallback( |
490 | this, &MirConnection::connected, callback, context)); |
491 | return &connect_wait_handle; |
492 | @@ -319,7 +326,7 @@ |
493 | disconnecting = true; |
494 | } |
495 | disconnect_wait_handle.expect_result(); |
496 | - server.disconnect(0, &ignored, &ignored, |
497 | + server.disconnect(0, ignored.get(), ignored.get(), |
498 | google::protobuf::NewCallback(this, &MirConnection::done_disconnect)); |
499 | |
500 | return &disconnect_wait_handle; |
501 | @@ -328,19 +335,19 @@ |
502 | void MirConnection::done_platform_operation( |
503 | mir_platform_operation_callback callback, void* context) |
504 | { |
505 | - auto reply = mir_platform_message_create(platform_operation_reply.opcode()); |
506 | + auto reply = mir_platform_message_create(platform_operation_reply->opcode()); |
507 | |
508 | - set_error_message(platform_operation_reply.error()); |
509 | + set_error_message(platform_operation_reply->error()); |
510 | |
511 | mir_platform_message_set_data( |
512 | reply, |
513 | - platform_operation_reply.data().data(), |
514 | - platform_operation_reply.data().size()); |
515 | + platform_operation_reply->data().data(), |
516 | + platform_operation_reply->data().size()); |
517 | |
518 | mir_platform_message_set_fds( |
519 | reply, |
520 | - platform_operation_reply.fd().data(), |
521 | - platform_operation_reply.fd().size()); |
522 | + platform_operation_reply->fd().data(), |
523 | + platform_operation_reply->fd().size()); |
524 | |
525 | callback(this, reply, context); |
526 | |
527 | @@ -359,21 +366,21 @@ |
528 | return nullptr; |
529 | } |
530 | |
531 | - mir::protobuf::PlatformOperationMessage protobuf_request; |
532 | + auto protobuf_request = mcl::make_protobuf_object<mir::protobuf::PlatformOperationMessage>(); |
533 | |
534 | - protobuf_request.set_opcode(mir_platform_message_get_opcode(request)); |
535 | + protobuf_request->set_opcode(mir_platform_message_get_opcode(request)); |
536 | auto const request_data = mir_platform_message_get_data(request); |
537 | auto const request_fds = mir_platform_message_get_fds(request); |
538 | |
539 | - protobuf_request.set_data(request_data.data, request_data.size); |
540 | + protobuf_request->set_data(request_data.data, request_data.size); |
541 | for (size_t i = 0; i != request_fds.num_fds; ++i) |
542 | - protobuf_request.add_fd(request_fds.fds[i]); |
543 | + protobuf_request->add_fd(request_fds.fds[i]); |
544 | |
545 | platform_operation_wait_handle.expect_result(); |
546 | server.platform_operation( |
547 | 0, |
548 | - &protobuf_request, |
549 | - &platform_operation_reply, |
550 | + protobuf_request.get(), |
551 | + platform_operation_reply.get(), |
552 | google::protobuf::NewCallback(this, &MirConnection::done_platform_operation, |
553 | callback, context)); |
554 | |
555 | @@ -391,7 +398,7 @@ |
556 | { |
557 | lock.unlock(); |
558 | std::lock_guard<decltype(connection->mutex)> lock(connection->mutex); |
559 | - return !connection->connect_result.has_error(); |
560 | + return !connection->connect_result->has_error(); |
561 | } |
562 | } |
563 | } |
564 | @@ -407,9 +414,9 @@ |
565 | { |
566 | // connect_result is write-once: once it's valid, we don't need to lock |
567 | // to use it. |
568 | - if (connect_done && !connect_result.has_error() && connect_result.has_platform()) |
569 | + if (connect_done && !connect_result->has_error() && connect_result->has_platform()) |
570 | { |
571 | - auto const& platform = connect_result.platform(); |
572 | + auto const& platform = connect_result->platform(); |
573 | |
574 | platform_package.data_items = platform.data_size(); |
575 | for (int i = 0; i != platform.data_size(); ++i) |
576 | @@ -440,15 +447,15 @@ |
577 | valid_formats = 0; |
578 | |
579 | std::lock_guard<decltype(mutex)> lock(mutex); |
580 | - if (!connect_result.has_error()) |
581 | + if (!connect_result->has_error()) |
582 | { |
583 | valid_formats = std::min( |
584 | - static_cast<unsigned int>(connect_result.surface_pixel_format_size()), |
585 | + static_cast<unsigned int>(connect_result->surface_pixel_format_size()), |
586 | formats_size); |
587 | |
588 | for (auto i = 0u; i < valid_formats; i++) |
589 | { |
590 | - formats[i] = static_cast<MirPixelFormat>(connect_result.surface_pixel_format(i)); |
591 | + formats[i] = static_cast<MirPixelFormat>(connect_result->surface_pixel_format(i)); |
592 | } |
593 | } |
594 | } |
595 | @@ -518,10 +525,10 @@ |
596 | { |
597 | std::lock_guard<decltype(mutex)> lock(mutex); |
598 | |
599 | - set_error_message(display_configuration_response.error()); |
600 | + set_error_message(display_configuration_response->error()); |
601 | |
602 | - if (!display_configuration_response.has_error()) |
603 | - display_configuration->set_configuration(display_configuration_response); |
604 | + if (!display_configuration_response->has_error()) |
605 | + display_configuration->set_configuration(*display_configuration_response); |
606 | |
607 | return configure_display_wait_handle.result_received(); |
608 | } |
609 | @@ -533,14 +540,14 @@ |
610 | return NULL; |
611 | } |
612 | |
613 | - mir::protobuf::DisplayConfiguration request; |
614 | + auto request = mcl::make_protobuf_object<mir::protobuf::DisplayConfiguration>(); |
615 | { |
616 | std::lock_guard<decltype(mutex)> lock(mutex); |
617 | |
618 | for (auto i=0u; i < config->num_outputs; i++) |
619 | { |
620 | auto output = config->outputs[i]; |
621 | - auto display_request = request.add_display_output(); |
622 | + auto display_request = request->add_display_output(); |
623 | display_request->set_output_id(output.output_id); |
624 | display_request->set_used(output.used); |
625 | display_request->set_current_mode(output.current_mode); |
626 | @@ -553,7 +560,7 @@ |
627 | } |
628 | |
629 | configure_display_wait_handle.expect_result(); |
630 | - server.configure_display(0, &request, &display_configuration_response, |
631 | + server.configure_display(0, request.get(), display_configuration_response.get(), |
632 | google::protobuf::NewCallback(this, &MirConnection::done_display_configure)); |
633 | |
634 | return &configure_display_wait_handle; |
635 | |
636 | === modified file 'src/client/mir_connection.h' |
637 | --- src/client/mir_connection.h 2015-03-31 02:35:42 +0000 |
638 | +++ src/client/mir_connection.h 2015-06-17 19:19:38 +0000 |
639 | @@ -36,6 +36,8 @@ |
640 | |
641 | #include "mir_wait_handle.h" |
642 | |
643 | +#include <memory> |
644 | + |
645 | namespace mir |
646 | { |
647 | class SharedLibrary; |
648 | @@ -156,13 +158,13 @@ |
649 | mir::protobuf::DisplayServer::Stub server; |
650 | mir::protobuf::Debug::Stub debug; |
651 | std::shared_ptr<mir::logging::Logger> const logger; |
652 | - mir::protobuf::Void void_response; |
653 | - mir::protobuf::Connection connect_result; |
654 | + std::unique_ptr<mir::protobuf::Void> void_response; |
655 | + std::unique_ptr<mir::protobuf::Connection> connect_result; |
656 | std::atomic<bool> connect_done; |
657 | - mir::protobuf::Void ignored; |
658 | - mir::protobuf::ConnectParameters connect_parameters; |
659 | - mir::protobuf::PlatformOperationMessage platform_operation_reply; |
660 | - mir::protobuf::DisplayConfiguration display_configuration_response; |
661 | + std::unique_ptr<mir::protobuf::Void> ignored; |
662 | + std::unique_ptr<mir::protobuf::ConnectParameters> connect_parameters; |
663 | + std::unique_ptr<mir::protobuf::PlatformOperationMessage> platform_operation_reply; |
664 | + std::unique_ptr<mir::protobuf::DisplayConfiguration> display_configuration_response; |
665 | std::atomic<bool> disconnecting{false}; |
666 | |
667 | std::shared_ptr<mir::client::ClientPlatformFactory> const client_platform_factory; |
668 | |
669 | === modified file 'src/client/mir_prompt_session.cpp' |
670 | --- src/client/mir_prompt_session.cpp 2015-03-31 02:35:42 +0000 |
671 | +++ src/client/mir_prompt_session.cpp 2015-06-17 19:19:38 +0000 |
672 | @@ -18,6 +18,7 @@ |
673 | |
674 | #include "mir_prompt_session.h" |
675 | #include "event_handler_register.h" |
676 | +#include "make_protobuf_object.h" |
677 | |
678 | namespace mp = mir::protobuf; |
679 | namespace mcl = mir::client; |
680 | @@ -26,6 +27,10 @@ |
681 | mp::DisplayServer& server, |
682 | std::shared_ptr<mcl::EventHandlerRegister> const& event_handler_register) : |
683 | server(server), |
684 | + parameters(mcl::make_protobuf_object<mir::protobuf::PromptSessionParameters>()), |
685 | + add_result(mcl::make_protobuf_object<mir::protobuf::Void>()), |
686 | + protobuf_void(mcl::make_protobuf_object<mir::protobuf::Void>()), |
687 | + socket_fd_response(mcl::make_protobuf_object<mir::protobuf::SocketFD>()), |
688 | event_handler_register(event_handler_register), |
689 | event_handler_register_id{event_handler_register->register_event_handler( |
690 | [this](MirEvent const& event) |
691 | @@ -34,6 +39,7 @@ |
692 | set_state(mir_prompt_session_event_get_state(mir_event_get_prompt_session_event(&event))); |
693 | })}, |
694 | state(mir_prompt_session_state_stopped), |
695 | + session(mcl::make_protobuf_object<mir::protobuf::Void>()), |
696 | handle_prompt_session_state_change{[](MirPromptSessionState){}} |
697 | { |
698 | } |
699 | @@ -64,14 +70,14 @@ |
700 | { |
701 | { |
702 | std::lock_guard<decltype(mutex)> lock(mutex); |
703 | - parameters.set_application_pid(application_pid); |
704 | + parameters->set_application_pid(application_pid); |
705 | } |
706 | |
707 | start_wait_handle.expect_result(); |
708 | server.start_prompt_session( |
709 | 0, |
710 | - ¶meters, |
711 | - &session, |
712 | + parameters.get(), |
713 | + session.get(), |
714 | google::protobuf::NewCallback(this, &MirPromptSession::done_start, |
715 | callback, context)); |
716 | |
717 | @@ -84,8 +90,8 @@ |
718 | |
719 | server.stop_prompt_session( |
720 | 0, |
721 | - &protobuf_void, |
722 | - &protobuf_void, |
723 | + protobuf_void.get(), |
724 | + protobuf_void.get(), |
725 | google::protobuf::NewCallback(this, &MirPromptSession::done_stop, |
726 | callback, context)); |
727 | |
728 | @@ -110,7 +116,7 @@ |
729 | { |
730 | std::lock_guard<decltype(session_mutex)> lock(session_mutex); |
731 | |
732 | - state = session.has_error() ? mir_prompt_session_state_stopped : mir_prompt_session_state_started; |
733 | + state = session->has_error() ? mir_prompt_session_state_stopped : mir_prompt_session_state_started; |
734 | } |
735 | |
736 | callback(this, context); |
737 | @@ -129,10 +135,10 @@ |
738 | { |
739 | std::lock_guard<decltype(session_mutex)> lock(session_mutex); |
740 | |
741 | - if (!session.has_error()) |
742 | - session.set_error(std::string{}); |
743 | + if (!session->has_error()) |
744 | + session->set_error(std::string{}); |
745 | |
746 | - return session.error().c_str(); |
747 | + return session->error().c_str(); |
748 | } |
749 | |
750 | MirWaitHandle* MirPromptSession::new_fds_for_prompt_providers( |
751 | @@ -140,15 +146,15 @@ |
752 | mir_client_fd_callback callback, |
753 | void * context) |
754 | { |
755 | - mir::protobuf::SocketFDRequest request; |
756 | - request.set_number(no_of_fds); |
757 | + auto request = mcl::make_protobuf_object<mir::protobuf::SocketFDRequest>(); |
758 | + request->set_number(no_of_fds); |
759 | |
760 | fds_for_prompt_providers_wait_handle.expect_result(); |
761 | |
762 | server.new_fds_for_prompt_providers( |
763 | nullptr, |
764 | - &request, |
765 | - &socket_fd_response, |
766 | + request.get(), |
767 | + socket_fd_response.get(), |
768 | google::protobuf::NewCallback(this, &MirPromptSession::done_fds_for_prompt_providers, |
769 | callback, context)); |
770 | |
771 | @@ -159,13 +165,13 @@ |
772 | mir_client_fd_callback callback, |
773 | void* context) |
774 | { |
775 | - auto const size = socket_fd_response.fd_size(); |
776 | + auto const size = socket_fd_response->fd_size(); |
777 | |
778 | std::vector<int> fds; |
779 | fds.reserve(size); |
780 | |
781 | for (auto i = 0; i != size; ++i) |
782 | - fds.push_back(socket_fd_response.fd(i)); |
783 | + fds.push_back(socket_fd_response->fd(i)); |
784 | |
785 | callback(this, size, fds.data(), context); |
786 | fds_for_prompt_providers_wait_handle.result_received(); |
787 | |
788 | === modified file 'src/client/mir_prompt_session.h' |
789 | --- src/client/mir_prompt_session.h 2015-01-21 07:34:50 +0000 |
790 | +++ src/client/mir_prompt_session.h 2015-06-17 19:19:38 +0000 |
791 | @@ -60,10 +60,10 @@ |
792 | private: |
793 | std::mutex mutable mutex; // Protects parameters, wait_handles & results |
794 | mir::protobuf::DisplayServer& server; |
795 | - mir::protobuf::PromptSessionParameters parameters; |
796 | - mir::protobuf::Void add_result; |
797 | - mir::protobuf::Void protobuf_void; |
798 | - mir::protobuf::SocketFD socket_fd_response; |
799 | + std::unique_ptr<mir::protobuf::PromptSessionParameters> parameters; |
800 | + std::unique_ptr<mir::protobuf::Void> add_result; |
801 | + std::unique_ptr<mir::protobuf::Void> protobuf_void; |
802 | + std::unique_ptr<mir::protobuf::SocketFD> socket_fd_response; |
803 | std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register; |
804 | int const event_handler_register_id; |
805 | |
806 | @@ -73,7 +73,7 @@ |
807 | std::atomic<MirPromptSessionState> state; |
808 | |
809 | std::mutex mutable session_mutex; // Protects session |
810 | - mir::protobuf::Void session; |
811 | + std::unique_ptr<mir::protobuf::Void> session; |
812 | |
813 | std::mutex mutable event_handler_mutex; // Need another mutex for callback access to members |
814 | std::function<void(MirPromptSessionState)> handle_prompt_session_state_change; |
815 | |
816 | === modified file 'src/client/mir_screencast.cpp' |
817 | --- src/client/mir_screencast.cpp 2015-04-25 11:38:31 +0000 |
818 | +++ src/client/mir_screencast.cpp 2015-06-17 19:19:38 +0000 |
819 | @@ -18,6 +18,7 @@ |
820 | |
821 | #include "mir_screencast.h" |
822 | #include "client_buffer_stream_factory.h" |
823 | +#include "make_protobuf_object.h" |
824 | #include "client_buffer_stream.h" |
825 | #include "mir/frontend/client_constants.h" |
826 | #include "mir_toolkit/mir_native_buffer.h" |
827 | @@ -38,7 +39,9 @@ |
828 | mir_screencast_callback callback, void* context) |
829 | : server(server), |
830 | output_size{size}, |
831 | - buffer_stream_factory{buffer_stream_factory} |
832 | + buffer_stream_factory{buffer_stream_factory}, |
833 | + protobuf_screencast{mcl::make_protobuf_object<mir::protobuf::Screencast>()}, |
834 | + protobuf_void{mcl::make_protobuf_object<mir::protobuf::Void>()} |
835 | { |
836 | if (output_size.width.as_int() == 0 || |
837 | output_size.height.as_int() == 0 || |
838 | @@ -48,23 +51,23 @@ |
839 | { |
840 | BOOST_THROW_EXCEPTION(std::runtime_error("Invalid parameters")); |
841 | } |
842 | - protobuf_screencast.set_error("Not initialized"); |
843 | - |
844 | - mir::protobuf::ScreencastParameters parameters; |
845 | - |
846 | - parameters.mutable_region()->set_left(region.top_left.x.as_int()); |
847 | - parameters.mutable_region()->set_top(region.top_left.y.as_int()); |
848 | - parameters.mutable_region()->set_width(region.size.width.as_uint32_t()); |
849 | - parameters.mutable_region()->set_height(region.size.height.as_uint32_t()); |
850 | - parameters.set_width(output_size.width.as_uint32_t()); |
851 | - parameters.set_height(output_size.height.as_uint32_t()); |
852 | - parameters.set_pixel_format(pixel_format); |
853 | + protobuf_screencast->set_error("Not initialized"); |
854 | + |
855 | + auto parameters = mcl::make_protobuf_object<mir::protobuf::ScreencastParameters>(); |
856 | + |
857 | + parameters->mutable_region()->set_left(region.top_left.x.as_int()); |
858 | + parameters->mutable_region()->set_top(region.top_left.y.as_int()); |
859 | + parameters->mutable_region()->set_width(region.size.width.as_uint32_t()); |
860 | + parameters->mutable_region()->set_height(region.size.height.as_uint32_t()); |
861 | + parameters->set_width(output_size.width.as_uint32_t()); |
862 | + parameters->set_height(output_size.height.as_uint32_t()); |
863 | + parameters->set_pixel_format(pixel_format); |
864 | |
865 | create_screencast_wait_handle.expect_result(); |
866 | server.create_screencast( |
867 | nullptr, |
868 | - ¶meters, |
869 | - &protobuf_screencast, |
870 | + parameters.get(), |
871 | + protobuf_screencast.get(), |
872 | google::protobuf::NewCallback( |
873 | this, &MirScreencast::screencast_created, |
874 | callback, context)); |
875 | @@ -77,20 +80,20 @@ |
876 | |
877 | bool MirScreencast::valid() |
878 | { |
879 | - return !protobuf_screencast.has_error(); |
880 | + return !protobuf_screencast->has_error(); |
881 | } |
882 | |
883 | MirWaitHandle* MirScreencast::release( |
884 | mir_screencast_callback callback, void* context) |
885 | { |
886 | - mir::protobuf::ScreencastId screencast_id; |
887 | - screencast_id.set_value(protobuf_screencast.screencast_id().value()); |
888 | + auto screencast_id = mcl::make_protobuf_object<mir::protobuf::ScreencastId>(); |
889 | + screencast_id->set_value(protobuf_screencast->screencast_id().value()); |
890 | |
891 | release_wait_handle.expect_result(); |
892 | server.release_screencast( |
893 | nullptr, |
894 | - &screencast_id, |
895 | - &protobuf_void, |
896 | + screencast_id.get(), |
897 | + protobuf_void.get(), |
898 | google::protobuf::NewCallback( |
899 | this, &MirScreencast::released, callback, context)); |
900 | |
901 | @@ -104,10 +107,10 @@ |
902 | void MirScreencast::screencast_created( |
903 | mir_screencast_callback callback, void* context) |
904 | { |
905 | - if (!protobuf_screencast.has_error()) |
906 | + if (!protobuf_screencast->has_error()) |
907 | { |
908 | buffer_stream = buffer_stream_factory->make_consumer_stream(server, |
909 | - protobuf_screencast.buffer_stream(), "MirScreencast"); |
910 | + protobuf_screencast->buffer_stream(), "MirScreencast"); |
911 | } |
912 | |
913 | callback(this, context); |
914 | |
915 | === modified file 'src/client/mir_screencast.h' |
916 | --- src/client/mir_screencast.h 2015-03-31 02:35:42 +0000 |
917 | +++ src/client/mir_screencast.h 2015-06-17 19:19:38 +0000 |
918 | @@ -27,6 +27,8 @@ |
919 | |
920 | #include <EGL/eglplatform.h> |
921 | |
922 | +#include <memory> |
923 | + |
924 | namespace mir |
925 | { |
926 | namespace protobuf { class DisplayServer; } |
927 | @@ -72,8 +74,8 @@ |
928 | |
929 | std::shared_ptr<mir::client::ClientBufferStream> buffer_stream; |
930 | |
931 | - mir::protobuf::Screencast protobuf_screencast; |
932 | - mir::protobuf::Void protobuf_void; |
933 | + std::unique_ptr<mir::protobuf::Screencast> protobuf_screencast; |
934 | + std::unique_ptr<mir::protobuf::Void> protobuf_void; |
935 | |
936 | MirWaitHandle create_screencast_wait_handle; |
937 | MirWaitHandle release_wait_handle; |
938 | |
939 | === modified file 'src/client/mir_surface.cpp' |
940 | --- src/client/mir_surface.cpp 2015-04-28 10:30:44 +0000 |
941 | +++ src/client/mir_surface.cpp 2015-06-17 19:19:38 +0000 |
942 | @@ -16,12 +16,13 @@ |
943 | * Authored by: Thomas Guest <thomas.guest@canonical.com> |
944 | */ |
945 | |
946 | +#include "mir_surface.h" |
947 | +#include "cursor_configuration.h" |
948 | +#include "client_buffer_stream_factory.h" |
949 | +#include "make_protobuf_object.h" |
950 | #include "mir_toolkit/mir_client_library.h" |
951 | #include "mir/frontend/client_constants.h" |
952 | #include "mir/client_buffer.h" |
953 | -#include "mir_surface.h" |
954 | -#include "cursor_configuration.h" |
955 | -#include "client_buffer_stream_factory.h" |
956 | #include "mir_connection.h" |
957 | #include "mir/dispatch/simple_dispatch_thread.h" |
958 | #include "mir/input/input_platform.h" |
959 | @@ -41,7 +42,7 @@ |
960 | |
961 | #define SERIALIZE_OPTION_IF_SET(option, message) \ |
962 | if (option.is_set()) \ |
963 | - message.set_##option(option.value()); |
964 | + message->set_##option(option.value()); |
965 | |
966 | namespace |
967 | { |
968 | @@ -78,9 +79,9 @@ |
969 | { |
970 | } |
971 | |
972 | -mir::protobuf::SurfaceParameters MirSurfaceSpec::serialize() const |
973 | +std::unique_ptr<mir::protobuf::SurfaceParameters> MirSurfaceSpec::serialize() const |
974 | { |
975 | - mir::protobuf::SurfaceParameters message; |
976 | + auto message = mcl::make_protobuf_object<mp::SurfaceParameters>(); |
977 | |
978 | SERIALIZE_OPTION_IF_SET(width, message); |
979 | SERIALIZE_OPTION_IF_SET(height, message); |
980 | @@ -102,34 +103,35 @@ |
981 | // max_aspect is a special case (below) |
982 | |
983 | if (parent.is_set() && parent.value() != nullptr) |
984 | - message.set_parent_id(parent.value()->id()); |
985 | + message->set_parent_id(parent.value()->id()); |
986 | |
987 | if (aux_rect.is_set()) |
988 | { |
989 | - message.mutable_aux_rect()->set_left(aux_rect.value().left); |
990 | - message.mutable_aux_rect()->set_top(aux_rect.value().top); |
991 | - message.mutable_aux_rect()->set_width(aux_rect.value().width); |
992 | - message.mutable_aux_rect()->set_height(aux_rect.value().height); |
993 | + message->mutable_aux_rect()->set_left(aux_rect.value().left); |
994 | + message->mutable_aux_rect()->set_top(aux_rect.value().top); |
995 | + message->mutable_aux_rect()->set_width(aux_rect.value().width); |
996 | + message->mutable_aux_rect()->set_height(aux_rect.value().height); |
997 | } |
998 | |
999 | if (min_aspect.is_set()) |
1000 | { |
1001 | - message.mutable_min_aspect()->set_width(min_aspect.value().width); |
1002 | - message.mutable_min_aspect()->set_height(min_aspect.value().height); |
1003 | + message->mutable_min_aspect()->set_width(min_aspect.value().width); |
1004 | + message->mutable_min_aspect()->set_height(min_aspect.value().height); |
1005 | } |
1006 | |
1007 | if (max_aspect.is_set()) |
1008 | { |
1009 | - message.mutable_max_aspect()->set_width(max_aspect.value().width); |
1010 | - message.mutable_max_aspect()->set_height(max_aspect.value().height); |
1011 | + message->mutable_max_aspect()->set_width(max_aspect.value().width); |
1012 | + message->mutable_max_aspect()->set_height(max_aspect.value().height); |
1013 | } |
1014 | |
1015 | return message; |
1016 | } |
1017 | |
1018 | MirSurface::MirSurface(std::string const& error) |
1019 | + : surface{mcl::make_protobuf_object<mir::protobuf::Surface>()} |
1020 | { |
1021 | - surface.set_error(error); |
1022 | + surface->set_error(error); |
1023 | |
1024 | std::lock_guard<decltype(handle_mutex)> lock(handle_mutex); |
1025 | valid_surfaces.insert(this); |
1026 | @@ -145,11 +147,16 @@ |
1027 | mir_surface_callback callback, void * context) |
1028 | : server{&the_server}, |
1029 | debug{debug}, |
1030 | + surface{mcl::make_protobuf_object<mir::protobuf::Surface>()}, |
1031 | + buffer_request{mcl::make_protobuf_object<mir::protobuf::BufferRequest>()}, |
1032 | name{spec.surface_name.value()}, |
1033 | + void_response{mcl::make_protobuf_object<mir::protobuf::Void>()}, |
1034 | + modify_result{mcl::make_protobuf_object<mir::protobuf::Void>()}, |
1035 | connection(allocating_connection), |
1036 | buffer_stream_factory(buffer_stream_factory), |
1037 | input_platform(input_platform), |
1038 | - keymapper(std::make_shared<mircv::XKBMapper>()) |
1039 | + keymapper(std::make_shared<mircv::XKBMapper>()), |
1040 | + configure_result{mcl::make_protobuf_object<mir::protobuf::SurfaceSetting>()} |
1041 | { |
1042 | for (int i = 0; i < mir_surface_attribs; i++) |
1043 | attrib_cache[i] = -1; |
1044 | @@ -158,11 +165,11 @@ |
1045 | create_wait_handle.expect_result(); |
1046 | try |
1047 | { |
1048 | - server->create_surface(0, &message, &surface, gp::NewCallback(this, &MirSurface::created, callback, context)); |
1049 | + server->create_surface(0, message.get(), surface.get(), gp::NewCallback(this, &MirSurface::created, callback, context)); |
1050 | } |
1051 | catch (std::exception const& ex) |
1052 | { |
1053 | - surface.set_error(std::string{"Error invoking create surface: "} + |
1054 | + surface->set_error(std::string{"Error invoking create surface: "} + |
1055 | boost::diagnostic_information(ex)); |
1056 | } |
1057 | |
1058 | @@ -181,8 +188,8 @@ |
1059 | |
1060 | input_thread.reset(); |
1061 | |
1062 | - for (auto i = 0, end = surface.fd_size(); i != end; ++i) |
1063 | - close(surface.fd(i)); |
1064 | + for (auto i = 0, end = surface->fd_size(); i != end; ++i) |
1065 | + close(surface->fd(i)); |
1066 | } |
1067 | |
1068 | MirSurfaceParameters MirSurface::get_parameters() const |
1069 | @@ -196,9 +203,9 @@ |
1070 | { |
1071 | std::lock_guard<decltype(mutex)> lock(mutex); |
1072 | |
1073 | - if (surface.has_error()) |
1074 | + if (surface->has_error()) |
1075 | { |
1076 | - return surface.error().c_str(); |
1077 | + return surface->error().c_str(); |
1078 | } |
1079 | return error_message.c_str(); |
1080 | } |
1081 | @@ -207,7 +214,7 @@ |
1082 | { |
1083 | std::lock_guard<decltype(mutex)> lock(mutex); |
1084 | |
1085 | - return surface.id().value(); |
1086 | + return surface->id().value(); |
1087 | } |
1088 | |
1089 | bool MirSurface::is_valid(MirSurface* query) |
1090 | @@ -215,7 +222,7 @@ |
1091 | std::lock_guard<decltype(handle_mutex)> lock(handle_mutex); |
1092 | |
1093 | if (valid_surfaces.count(query)) |
1094 | - return !query->surface.has_error(); |
1095 | + return !query->surface->has_error(); |
1096 | |
1097 | return false; |
1098 | } |
1099 | @@ -236,10 +243,10 @@ |
1100 | { |
1101 | { |
1102 | std::lock_guard<decltype(mutex)> lock(mutex); |
1103 | - if (!surface.has_id()) |
1104 | + if (!surface->has_id()) |
1105 | { |
1106 | - if (!surface.has_error()) |
1107 | - surface.set_error("Error processing surface create response, no ID (disconnected?)"); |
1108 | + if (!surface->has_error()) |
1109 | + surface->set_error("Error processing surface create response, no ID (disconnected?)"); |
1110 | |
1111 | callback(this, context); |
1112 | create_wait_handle.result_received(); |
1113 | @@ -252,11 +259,11 @@ |
1114 | std::lock_guard<decltype(mutex)> lock(mutex); |
1115 | |
1116 | buffer_stream = buffer_stream_factory-> |
1117 | - make_producer_stream(*server, surface.buffer_stream(), name); |
1118 | + make_producer_stream(*server, surface->buffer_stream(), name); |
1119 | |
1120 | - for(int i = 0; i < surface.attributes_size(); i++) |
1121 | + for(int i = 0; i < surface->attributes_size(); i++) |
1122 | { |
1123 | - auto const& attrib = surface.attributes(i); |
1124 | + auto const& attrib = surface->attributes(i); |
1125 | attrib_cache[attrib.attrib()] = attrib.ivalue(); |
1126 | } |
1127 | } |
1128 | @@ -265,7 +272,7 @@ |
1129 | } |
1130 | catch (std::exception const& error) |
1131 | { |
1132 | - surface.set_error(std::string{"Error processing Surface creating response:"} + |
1133 | + surface->set_error(std::string{"Error processing Surface creating response:"} + |
1134 | boost::diagnostic_information(error)); |
1135 | } |
1136 | |
1137 | @@ -284,7 +291,7 @@ |
1138 | was_valid = true; |
1139 | valid_surfaces.erase(this); |
1140 | } |
1141 | - if (this->surface.has_error()) |
1142 | + if (this->surface->has_error()) |
1143 | was_valid = false; |
1144 | |
1145 | MirWaitHandle* wait_handle{nullptr}; |
1146 | @@ -303,29 +310,28 @@ |
1147 | |
1148 | MirWaitHandle* MirSurface::configure_cursor(MirCursorConfiguration const* cursor) |
1149 | { |
1150 | - mp::CursorSetting setting; |
1151 | + auto setting = mcl::make_protobuf_object<mp::CursorSetting>(); |
1152 | |
1153 | { |
1154 | std::unique_lock<decltype(mutex)> lock(mutex); |
1155 | - setting.mutable_surfaceid()->CopyFrom(surface.id()); |
1156 | + setting->mutable_surfaceid()->CopyFrom(surface->id()); |
1157 | if (cursor) |
1158 | { |
1159 | if (cursor->stream != nullptr) |
1160 | { |
1161 | - setting.mutable_buffer_stream()->set_value(cursor->stream->rpc_id().as_value()); |
1162 | - setting.set_hotspot_x(cursor->hotspot_x); |
1163 | - setting.set_hotspot_y(cursor->hotspot_y); |
1164 | + setting->mutable_buffer_stream()->set_value(cursor->stream->rpc_id().as_value()); |
1165 | + setting->set_hotspot_x(cursor->hotspot_x); |
1166 | + setting->set_hotspot_y(cursor->hotspot_y); |
1167 | } |
1168 | else if (cursor->name != mir_disabled_cursor_name) |
1169 | { |
1170 | - setting.set_name(cursor->name.c_str()); |
1171 | + setting->set_name(cursor->name.c_str()); |
1172 | } |
1173 | - |
1174 | } |
1175 | } |
1176 | |
1177 | configure_cursor_wait_handle.expect_result(); |
1178 | - server->configure_cursor(0, &setting, &void_response, |
1179 | + server->configure_cursor(0, setting.get(), void_response.get(), |
1180 | google::protobuf::NewCallback(this, &MirSurface::on_cursor_configured)); |
1181 | |
1182 | return &configure_cursor_wait_handle; |
1183 | @@ -345,14 +351,14 @@ |
1184 | |
1185 | std::unique_lock<decltype(mutex)> lock(mutex); |
1186 | |
1187 | - mp::SurfaceSetting setting; |
1188 | - setting.mutable_surfaceid()->CopyFrom(surface.id()); |
1189 | - setting.set_attrib(at); |
1190 | - setting.set_ivalue(value); |
1191 | + auto setting = mcl::make_protobuf_object<mp::SurfaceSetting>(); |
1192 | + setting->mutable_surfaceid()->CopyFrom(surface->id()); |
1193 | + setting->set_attrib(at); |
1194 | + setting->set_ivalue(value); |
1195 | lock.unlock(); |
1196 | |
1197 | configure_wait_handle.expect_result(); |
1198 | - server->configure_surface(0, &setting, &configure_result, |
1199 | + server->configure_surface(0, setting.get(), configure_result.get(), |
1200 | google::protobuf::NewCallback(this, &MirSurface::on_configured)); |
1201 | |
1202 | return &configure_wait_handle; |
1203 | @@ -374,12 +380,12 @@ |
1204 | return false; |
1205 | } |
1206 | |
1207 | - mp::CoordinateTranslationRequest request; |
1208 | + auto request = mcl::make_protobuf_object<mp::CoordinateTranslationRequest>(); |
1209 | |
1210 | - request.set_x(x); |
1211 | - request.set_y(y); |
1212 | - *request.mutable_surfaceid() = surface.id(); |
1213 | - mp::CoordinateTranslationResponse response; |
1214 | + request->set_x(x); |
1215 | + request->set_y(y); |
1216 | + *request->mutable_surfaceid() = surface->id(); |
1217 | + auto response = mcl::make_protobuf_object<mp::CoordinateTranslationResponse>(); |
1218 | |
1219 | MirWaitHandle signal; |
1220 | signal.expect_result(); |
1221 | @@ -389,27 +395,27 @@ |
1222 | |
1223 | debug->translate_surface_to_screen( |
1224 | nullptr, |
1225 | - &request, |
1226 | - &response, |
1227 | + request.get(), |
1228 | + response.get(), |
1229 | google::protobuf::NewCallback(&signal_response_received, &signal)); |
1230 | } |
1231 | |
1232 | signal.wait_for_one(); |
1233 | |
1234 | - *screen_x = response.x(); |
1235 | - *screen_y = response.y(); |
1236 | - return !response.has_error(); |
1237 | + *screen_x = response->x(); |
1238 | + *screen_y = response->y(); |
1239 | + return !response->has_error(); |
1240 | } |
1241 | |
1242 | void MirSurface::on_configured() |
1243 | { |
1244 | std::lock_guard<decltype(mutex)> lock(mutex); |
1245 | |
1246 | - if (configure_result.has_surfaceid() && |
1247 | - configure_result.surfaceid().value() == surface.id().value() && |
1248 | - configure_result.has_attrib()) |
1249 | + if (configure_result->has_surfaceid() && |
1250 | + configure_result->surfaceid().value() == surface->id().value() && |
1251 | + configure_result->has_attrib()) |
1252 | { |
1253 | - int a = configure_result.attrib(); |
1254 | + int a = configure_result->attrib(); |
1255 | |
1256 | switch (a) |
1257 | { |
1258 | @@ -418,10 +424,10 @@ |
1259 | case mir_surface_attrib_focus: |
1260 | case mir_surface_attrib_dpi: |
1261 | case mir_surface_attrib_preferred_orientation: |
1262 | - if (configure_result.has_ivalue()) |
1263 | - attrib_cache[a] = configure_result.ivalue(); |
1264 | + if (configure_result->has_ivalue()) |
1265 | + attrib_cache[a] = configure_result->ivalue(); |
1266 | else |
1267 | - assert(configure_result.has_error()); |
1268 | + assert(configure_result->has_error()); |
1269 | break; |
1270 | default: |
1271 | assert(false); |
1272 | @@ -466,9 +472,9 @@ |
1273 | std::placeholders::_1, |
1274 | context); |
1275 | |
1276 | - if (surface.fd_size() > 0 && handle_event_callback) |
1277 | + if (surface->fd_size() > 0 && handle_event_callback) |
1278 | { |
1279 | - auto input_dispatcher = input_platform->create_input_receiver(surface.fd(0), |
1280 | + auto input_dispatcher = input_platform->create_input_receiver(surface->fd(0), |
1281 | keymapper, |
1282 | handle_event_callback); |
1283 | input_thread = std::make_shared<md::SimpleDispatchThread>(input_dispatcher); |
1284 | @@ -540,7 +546,7 @@ |
1285 | { |
1286 | { |
1287 | std::lock_guard<decltype(mutex)> lock(mutex); |
1288 | - if (modify_result.has_error()) |
1289 | + if (modify_result->has_error()) |
1290 | { |
1291 | // TODO return errors like lp:~vanvugt/mir/wait-result |
1292 | } |
1293 | @@ -550,14 +556,14 @@ |
1294 | |
1295 | MirWaitHandle* MirSurface::modify(MirSurfaceSpec const& spec) |
1296 | { |
1297 | - mp::SurfaceModifications mods; |
1298 | + auto mods = mcl::make_protobuf_object<mp::SurfaceModifications>(); |
1299 | |
1300 | { |
1301 | std::unique_lock<decltype(mutex)> lock(mutex); |
1302 | - mods.mutable_surface_id()->set_value(surface.id().value()); |
1303 | + mods->mutable_surface_id()->set_value(surface->id().value()); |
1304 | } |
1305 | |
1306 | - auto const surface_specification = mods.mutable_surface_specification(); |
1307 | + auto const surface_specification = mods->mutable_surface_specification(); |
1308 | |
1309 | #define COPY_IF_SET(field)\ |
1310 | if (spec.field.is_set())\ |
1311 | @@ -619,7 +625,7 @@ |
1312 | } |
1313 | |
1314 | modify_wait_handle.expect_result(); |
1315 | - server->modify_surface(0, &mods, &modify_result, |
1316 | + server->modify_surface(0, mods.get(), modify_result.get(), |
1317 | google::protobuf::NewCallback(this, &MirSurface::on_modified)); |
1318 | |
1319 | return &modify_wait_handle; |
1320 | |
1321 | === modified file 'src/client/mir_surface.h' |
1322 | --- src/client/mir_surface.h 2015-04-28 08:59:22 +0000 |
1323 | +++ src/client/mir_surface.h 2015-06-17 19:19:38 +0000 |
1324 | @@ -65,7 +65,7 @@ |
1325 | MirSurfaceSpec(MirConnection* connection, int width, int height, MirPixelFormat format); |
1326 | MirSurfaceSpec(MirConnection* connection, MirSurfaceParameters const& params); |
1327 | |
1328 | - mir::protobuf::SurfaceParameters serialize() const; |
1329 | + std::unique_ptr<mir::protobuf::SurfaceParameters> serialize() const; |
1330 | |
1331 | struct AspectRatio { unsigned width; unsigned height; }; |
1332 | |
1333 | @@ -163,15 +163,15 @@ |
1334 | |
1335 | mir::protobuf::DisplayServer::Stub* server{nullptr}; |
1336 | mir::protobuf::Debug::Stub* debug{nullptr}; |
1337 | - mir::protobuf::Surface surface; |
1338 | - mir::protobuf::BufferRequest buffer_request; |
1339 | + std::unique_ptr<mir::protobuf::Surface> surface; |
1340 | + std::unique_ptr<mir::protobuf::BufferRequest> buffer_request; |
1341 | std::string error_message; |
1342 | std::string name; |
1343 | - mir::protobuf::Void void_response; |
1344 | + std::unique_ptr<mir::protobuf::Void> void_response; |
1345 | |
1346 | void on_modified(); |
1347 | MirWaitHandle modify_wait_handle; |
1348 | - mir::protobuf::Void modify_result; |
1349 | + std::unique_ptr<mir::protobuf::Void> modify_result; |
1350 | |
1351 | MirConnection* const connection{nullptr}; |
1352 | |
1353 | @@ -184,7 +184,7 @@ |
1354 | std::shared_ptr<mir::input::receiver::InputPlatform> const input_platform; |
1355 | std::shared_ptr<mir::input::receiver::XKBMapper> const keymapper; |
1356 | |
1357 | - mir::protobuf::SurfaceSetting configure_result; |
1358 | + std::unique_ptr<mir::protobuf::SurfaceSetting> configure_result; |
1359 | |
1360 | // Cache of latest SurfaceSettings returned from the server |
1361 | int attrib_cache[mir_surface_attribs]; |
1362 | |
1363 | === modified file 'src/client/rpc/mir_protobuf_rpc_channel.cpp' |
1364 | --- src/client/rpc/mir_protobuf_rpc_channel.cpp 2015-04-25 11:38:31 +0000 |
1365 | +++ src/client/rpc/mir_protobuf_rpc_channel.cpp 2015-06-17 19:19:38 +0000 |
1366 | @@ -25,6 +25,7 @@ |
1367 | #include "../display_configuration.h" |
1368 | #include "../lifecycle_control.h" |
1369 | #include "../event_sink.h" |
1370 | +#include "../make_protobuf_object.h" |
1371 | #include "mir/variable_length_array.h" |
1372 | #include "mir/events/event_private.h" |
1373 | |
1374 | @@ -233,24 +234,24 @@ |
1375 | |
1376 | void mclr::MirProtobufRpcChannel::process_event_sequence(std::string const& event) |
1377 | { |
1378 | - mir::protobuf::EventSequence seq; |
1379 | - |
1380 | - seq.ParseFromString(event); |
1381 | - |
1382 | - if (seq.has_display_configuration()) |
1383 | - { |
1384 | - display_configuration->update_configuration(seq.display_configuration()); |
1385 | - } |
1386 | - |
1387 | - if (seq.has_lifecycle_event()) |
1388 | - { |
1389 | - lifecycle_control->call_lifecycle_event_handler(seq.lifecycle_event().new_state()); |
1390 | - } |
1391 | - |
1392 | - int const nevents = seq.event_size(); |
1393 | + auto seq = mcl::make_protobuf_object<mir::protobuf::EventSequence>(); |
1394 | + |
1395 | + seq->ParseFromString(event); |
1396 | + |
1397 | + if (seq->has_display_configuration()) |
1398 | + { |
1399 | + display_configuration->update_configuration(seq->display_configuration()); |
1400 | + } |
1401 | + |
1402 | + if (seq->has_lifecycle_event()) |
1403 | + { |
1404 | + lifecycle_control->call_lifecycle_event_handler(seq->lifecycle_event().new_state()); |
1405 | + } |
1406 | + |
1407 | + int const nevents = seq->event_size(); |
1408 | for (int i = 0; i != nevents; ++i) |
1409 | { |
1410 | - mir::protobuf::Event const& event = seq.event(i); |
1411 | + mir::protobuf::Event const& event = seq->event(i); |
1412 | if (event.has_raw()) |
1413 | { |
1414 | std::string const& raw_event = event.raw(); |
1415 | @@ -317,7 +318,7 @@ |
1416 | */ |
1417 | std::lock_guard<decltype(read_mutex)> lock(read_mutex); |
1418 | |
1419 | - mir::protobuf::wire::Result result; |
1420 | + auto result = mcl::make_protobuf_object<mir::protobuf::wire::Result>(); |
1421 | try |
1422 | { |
1423 | uint16_t message_size; |
1424 | @@ -327,9 +328,9 @@ |
1425 | body_bytes.resize(message_size); |
1426 | transport->receive_data(body_bytes.data(), message_size); |
1427 | |
1428 | - result.ParseFromArray(body_bytes.data(), message_size); |
1429 | + result->ParseFromArray(body_bytes.data(), message_size); |
1430 | |
1431 | - rpc_report->result_receipt_succeeded(result); |
1432 | + rpc_report->result_receipt_succeeded(*result); |
1433 | } |
1434 | catch (std::exception const& x) |
1435 | { |
1436 | @@ -339,14 +340,14 @@ |
1437 | |
1438 | try |
1439 | { |
1440 | - for (int i = 0; i != result.events_size(); ++i) |
1441 | + for (int i = 0; i != result->events_size(); ++i) |
1442 | { |
1443 | - process_event_sequence(result.events(i)); |
1444 | + process_event_sequence(result->events(i)); |
1445 | } |
1446 | |
1447 | - if (result.has_id()) |
1448 | + if (result->has_id()) |
1449 | { |
1450 | - pending_calls.complete_response(result); |
1451 | + pending_calls.complete_response(*result); |
1452 | } |
1453 | } |
1454 | catch (std::exception const& x) |
1455 | @@ -354,7 +355,7 @@ |
1456 | // TODO: This is dangerous as an error in result processing could cause a wait handle |
1457 | // to never fire. Could perhaps fix by catching and setting error on the response before invoking |
1458 | // callback ~racarr |
1459 | - rpc_report->result_processing_failed(result, x); |
1460 | + rpc_report->result_processing_failed(*result, x); |
1461 | } |
1462 | } |
1463 |
lgtm