Mir

Merge lp:~mir-team/mir/bstream-constructor-cleanup into lp:mir

Proposed by Kevin DuBois
Status: Work in progress
Proposed branch: lp:~mir-team/mir/bstream-constructor-cleanup
Merge into: lp:mir
Prerequisite: lp:~cemil-azizoglu/mir/remove-dead-rs-support-code
Diff against target: 1052 lines (+195/-283)
11 files modified
src/client/buffer_stream.cpp (+35/-84)
src/client/buffer_stream.h (+9/-11)
src/client/mir_buffer_stream_api.cpp (+1/-1)
src/client/mir_connection.cpp (+53/-37)
src/client/mir_connection.h (+5/-8)
src/client/render_surface.cpp (+3/-4)
src/client/screencast_stream.cpp (+0/-5)
src/client/screencast_stream.h (+0/-1)
src/include/client/mir/mir_buffer_stream.h (+0/-1)
tests/unit-tests/client/test_client_buffer_stream.cpp (+63/-125)
tests/unit-tests/client/test_mir_connection.cpp (+26/-6)
To merge this branch: bzr merge lp:~mir-team/mir/bstream-constructor-cleanup
Reviewer Review Type Date Requested Status
Cemil Azizoglu (community) Needs Fixing
Daniel van Vugt Abstain
Alan Griffiths Approve
Chris Halse Rogers Approve
Mir CI Bot continuous-integration Needs Fixing
Review via email: mp+311491@code.launchpad.net

Commit message

client: unify the constructors for mcl::BufferStream. Could be scrubbed again to reduce the number of parameters.

Description of the change

client: unify the constructors for mcl::BufferStream. Could be scrubbed again to reduce the number of parameters.

To post a comment you must log in.
Revision history for this message
Kevin DuBois (kdub) wrote :

the few conflicts are in base, probably not too hard to review while conflicts get resolved.

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3807
https://mir-jenkins.ubuntu.com/job/mir-ci/2245/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/2904/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2969
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2962
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2962
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2962
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2934/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2934/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2934/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2934
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2934/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2934
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2934/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2934/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2245/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

> the few conflicts are in base, probably not too hard to review while conflicts
> get resolved.

The prereq has been updated to remove the conflict.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Conflicts still

review: Needs Fixing
3808. By Kevin DuBois

merge, fix up teh conflicts

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3808
https://mir-jenkins.ubuntu.com/job/mir-ci/2320/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/3018/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3083
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3075
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3075
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/3075
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3047/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3047/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3047/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3047/console
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3047/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3047
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3047/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3047/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2320/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

LGTM.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

^^^
Jenkins failures are crashing tests. Seems like this branch needs some fixing.

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) :
review: Abstain
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Needs an update.

Needs to remove other instances of render_surface(), e.g..

review: Needs Fixing

Unmerged revisions

3808. By Kevin DuBois

merge, fix up teh conflicts

3807. By Kevin DuBois

better handling of default steram

3806. By Kevin DuBois

merge in base

3805. By Kevin DuBois

cleanup another function, corrects int/acc tests

3804. By Kevin DuBois

port unit tests to new constructor

3803. By Kevin DuBois

fix up commented out coed

3802. By Kevin DuBois

merge in base

3801. By Kevin DuBois

need to restack on branch that removes one of constructors

3800. By Kevin DuBois

merge in mir

3799. By Kevin DuBois

merge in mir

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/client/buffer_stream.cpp'
2--- src/client/buffer_stream.cpp 2016-11-30 08:13:49 +0000
3+++ src/client/buffer_stream.cpp 2016-12-02 14:27:14 +0000
4@@ -56,7 +56,7 @@
5 class Requests : public mcl::ServerBufferRequests
6 {
7 public:
8- Requests(mclr::DisplayServer& server, int stream_id) :
9+ Requests(mclr::DisplayServer& server, mf::BufferStreamId stream_id) :
10 server(server),
11 stream_id(stream_id)
12 {
13@@ -65,7 +65,7 @@
14 void allocate_buffer(geom::Size size, MirPixelFormat format, int usage) override
15 {
16 mp::BufferAllocation request;
17- request.mutable_id()->set_value(stream_id);
18+ request.mutable_id()->set_value(stream_id.as_value());
19 auto buf_params = request.add_buffer_requests();
20 buf_params->set_width(size.width.as_int());
21 buf_params->set_height(size.height.as_int());
22@@ -80,7 +80,7 @@
23 void free_buffer(int buffer_id) override
24 {
25 mp::BufferRelease request;
26- request.mutable_id()->set_value(stream_id);
27+ request.mutable_id()->set_value(stream_id.as_value());
28 request.add_buffers()->set_buffer_id(buffer_id);
29
30 auto protobuf_void = std::make_shared<mp::Void>();
31@@ -91,7 +91,7 @@
32 void submit_buffer(mcl::MirBuffer& buffer) override
33 {
34 mp::BufferRequest request;
35- request.mutable_id()->set_value(stream_id);
36+ request.mutable_id()->set_value(stream_id.as_value());
37 request.mutable_buffer()->set_buffer_id(buffer.rpc_id());
38
39 auto protobuf_void = std::make_shared<mp::Void>();
40@@ -105,7 +105,7 @@
41
42 private:
43 mclr::DisplayServer& server;
44- int stream_id;
45+ mf::BufferStreamId const stream_id;
46 };
47
48 mir::optional_value<int> parse_env_for_swap_interval()
49@@ -238,80 +238,48 @@
50
51 mcl::BufferStream::BufferStream(
52 MirConnection* connection,
53- MirRenderSurface* render_surface,
54+ mf::BufferStreamId id,
55 std::shared_ptr<MirWaitHandle> creation_wait_handle,
56 mclr::DisplayServer& server,
57 std::shared_ptr<mcl::ClientPlatform> const& client_platform,
58 std::weak_ptr<mcl::SurfaceMap> const& map,
59 std::shared_ptr<mcl::AsyncBufferFactory> const& factory,
60- mp::BufferStream const& a_protobuf_bs,
61 std::shared_ptr<mcl::PerfReport> const& perf_report,
62 std::string const& surface_name,
63 geom::Size ideal_size,
64+ MirPixelFormat format,
65+ MirBufferUsage usage,
66 size_t nbuffers)
67 : connection_(connection),
68 client_platform(client_platform),
69- protobuf_bs{mcl::make_protobuf_object<mir::protobuf::BufferStream>(a_protobuf_bs)},
70 user_swap_interval(parse_env_for_swap_interval()),
71- interval_config{server, frontend::BufferStreamId{a_protobuf_bs.id().value()}},
72+ interval_config{server, id},
73 scale_(1.0f),
74 perf_report(perf_report),
75 protobuf_void{mcl::make_protobuf_object<mir::protobuf::Void>()},
76+ id(id),
77 ideal_buffer_size(ideal_size),
78+ format(format),
79+ usage(usage),
80 nbuffers(nbuffers),
81 creation_wait_handle(creation_wait_handle),
82 map(map),
83- factory(factory),
84- render_surface_(render_surface)
85+ factory(factory)
86 {
87- if (!protobuf_bs->has_id())
88- {
89- if (!protobuf_bs->has_error())
90- protobuf_bs->set_error("Error processing buffer stream create response, no ID (disconnected?)");
91- }
92-
93- if (protobuf_bs->has_error())
94- {
95- if (protobuf_bs->has_buffer())
96- {
97- for (int i = 0; i < protobuf_bs->buffer().fd_size(); i++)
98- ::close(protobuf_bs->buffer().fd(i));
99- }
100-
101- BOOST_THROW_EXCEPTION(std::runtime_error("Can not create buffer stream: " + std::string(protobuf_bs->error())));
102- }
103-
104- try
105- {
106- buffer_depository = std::make_unique<BufferDepository>(
107- client_platform->create_buffer_factory(), factory,
108- std::make_shared<Requests>(server, protobuf_bs->id().value()), map,
109- ideal_buffer_size, static_cast<MirPixelFormat>(protobuf_bs->pixel_format()),
110- protobuf_bs->buffer_usage(), nbuffers);
111-
112- egl_native_window_ = client_platform->create_egl_native_window(this);
113-
114- // This might seem like something to provide during creation but
115- // knowing the swap interval is not a precondition to creation. It's
116- // only a precondition to your second and subsequent swaps, so don't
117- // bother the creation parameters with this stuff...
118- if (user_swap_interval.is_set())
119- set_swap_interval(user_swap_interval.value());
120- }
121- catch (std::exception const& error)
122- {
123- protobuf_bs->set_error(std::string{"Error processing buffer stream creating response:"} +
124- boost::diagnostic_information(error));
125-
126- if (!buffer_depository)
127- {
128- for (int i = 0; i < protobuf_bs->buffer().fd_size(); i++)
129- ::close(protobuf_bs->buffer().fd(i));
130- }
131- }
132-
133- if (!valid())
134- BOOST_THROW_EXCEPTION(std::runtime_error("Can not create buffer stream: " + std::string(protobuf_bs->error())));
135+ buffer_depository = std::make_unique<BufferDepository>(
136+ client_platform->create_buffer_factory(), factory,
137+ std::make_shared<Requests>(server, id), map,
138+ ideal_buffer_size, format, usage, nbuffers);
139+
140+ egl_native_window_ = client_platform->create_egl_native_window(this);
141+
142+ // This might seem like something to provide during creation but
143+ // knowing the swap interval is not a precondition to creation. It's
144+ // only a precondition to your second and subsequent swaps, so don't
145+ // bother the creation parameters with this stuff...
146+ if (user_swap_interval.is_set())
147+ set_swap_interval(user_swap_interval.value());
148+
149 perf_report->name_surface(surface_name.c_str());
150 }
151
152@@ -338,9 +306,8 @@
153
154 try
155 {
156- auto pixel_format = static_cast<MirPixelFormat>(protobuf_bs->pixel_format());
157 lk.unlock();
158- buffer_depository->deposit(buffer, size, pixel_format);
159+ buffer_depository->deposit(buffer, size, format);
160 }
161 catch (const std::runtime_error& err)
162 {
163@@ -359,8 +326,7 @@
164 // TODO: We can fix the strange "ID casting" used below in the second phase
165 // of buffer stream which generalizes and clarifies the server side logic.
166 lock.unlock();
167- return buffer_depository->submit(done,
168- static_cast<MirPixelFormat>(protobuf_bs->pixel_format()), protobuf_bs->id().value());
169+ return buffer_depository->submit(done, format, id);
170 }
171
172 std::shared_ptr<mcl::ClientBuffer> mcl::BufferStream::get_current_buffer()
173@@ -401,8 +367,8 @@
174 "",
175 size.width.as_int(),
176 size.height.as_int(),
177- static_cast<MirPixelFormat>(protobuf_bs->pixel_format()),
178- static_cast<MirBufferUsage>(protobuf_bs->buffer_usage()),
179+ format,
180+ usage,
181 mir_display_output_id_invalid};
182 }
183
184@@ -454,15 +420,12 @@
185
186 mf::BufferStreamId mcl::BufferStream::rpc_id() const
187 {
188- std::unique_lock<decltype(mutex)> lock(mutex);
189-
190- return mf::BufferStreamId(protobuf_bs->id().value());
191+ return id;
192 }
193
194 bool mcl::BufferStream::valid() const
195 {
196- std::unique_lock<decltype(mutex)> lock(mutex);
197- return protobuf_bs->has_id() && !protobuf_bs->has_error();
198+ return id.as_value() >= 0;
199 }
200
201 void mcl::BufferStream::set_buffer_cache_size(unsigned int)
202@@ -493,27 +456,15 @@
203
204 MirWaitHandle* mcl::BufferStream::set_scale(float scale)
205 {
206- return buffer_depository->set_scale(scale, mf::BufferStreamId(protobuf_bs->id().value()));
207+ return buffer_depository->set_scale(scale, id);
208 }
209
210 char const * mcl::BufferStream::get_error_message() const
211 {
212- std::lock_guard<decltype(mutex)> lock(mutex);
213-
214- if (protobuf_bs->has_error())
215- {
216- return protobuf_bs->error().c_str();
217- }
218-
219- return error_message.c_str();
220+ return "";
221 }
222
223 MirConnection* mcl::BufferStream::connection() const
224 {
225 return connection_;
226 }
227-
228-MirRenderSurface* mcl::BufferStream::render_surface() const
229-{
230- return render_surface_;
231-}
232
233=== modified file 'src/client/buffer_stream.h'
234--- src/client/buffer_stream.h 2016-12-02 05:05:06 +0000
235+++ src/client/buffer_stream.h 2016-12-02 14:27:14 +0000
236@@ -73,22 +73,20 @@
237 {
238 public:
239 BufferStream(
240- mir::client::rpc::DisplayServer& server,
241- std::weak_ptr<SurfaceMap> const& map);
242- BufferStream(
243 MirConnection* connection,
244- MirRenderSurface* render_surface,
245+ frontend::BufferStreamId id,
246 std::shared_ptr<MirWaitHandle> creation_wait_handle,
247 mir::client::rpc::DisplayServer& server,
248 std::shared_ptr<ClientPlatform> const& native_window_factory,
249 std::weak_ptr<SurfaceMap> const& map,
250 std::shared_ptr<AsyncBufferFactory> const& factory,
251- mir::protobuf::BufferStream const& protobuf_bs,
252 std::shared_ptr<PerfReport> const& perf_report,
253 std::string const& surface_name,
254- geometry::Size ideal_size, size_t nbuffers);
255-
256- virtual ~BufferStream();
257+ geometry::Size ideal_size,
258+ MirPixelFormat format,
259+ MirBufferUsage usage,
260+ size_t nbuffers);
261+ ~BufferStream();
262
263 MirWaitHandle* swap_buffers(std::function<void()> const& done) override;
264 std::shared_ptr<mir::client::ClientBuffer> get_current_buffer() override;
265@@ -122,7 +120,6 @@
266 MirWaitHandle* set_scale(float scale) override;
267 char const* get_error_message() const override;
268 MirConnection* connection() const override;
269- MirRenderSurface* render_surface() const override;
270
271 protected:
272 BufferStream(BufferStream const&) = delete;
273@@ -140,7 +137,6 @@
274
275 MirConnection* connection_;
276 std::shared_ptr<ClientPlatform> const client_platform;
277- std::unique_ptr<mir::protobuf::BufferStream> protobuf_bs;
278
279 optional_value<int> user_swap_interval;
280 BufferStreamConfiguration interval_config;
281@@ -154,13 +150,15 @@
282 std::shared_ptr<MemoryRegion> secured_region;
283
284 std::unique_ptr<BufferDepository> buffer_depository;
285+ frontend::BufferStreamId const id;
286 geometry::Size ideal_buffer_size;
287+ MirPixelFormat const format;
288+ MirBufferUsage const usage;
289 size_t const nbuffers;
290 std::string error_message;
291 std::shared_ptr<MirWaitHandle> creation_wait_handle;
292 std::weak_ptr<SurfaceMap> const map;
293 std::shared_ptr<AsyncBufferFactory> const factory;
294- MirRenderSurface* render_surface_;
295 };
296
297 }
298
299=== modified file 'src/client/mir_buffer_stream_api.cpp'
300--- src/client/mir_buffer_stream_api.cpp 2016-12-02 05:05:06 +0000
301+++ src/client/mir_buffer_stream_api.cpp 2016-12-02 14:27:14 +0000
302@@ -58,7 +58,7 @@
303 try
304 {
305 return connection->create_client_buffer_stream(
306- width, height, format, buffer_usage, nullptr, callback, context);
307+ width, height, format, buffer_usage, callback, context);
308 }
309 catch (std::exception const& ex)
310 {
311
312=== modified file 'src/client/mir_connection.cpp'
313--- src/client/mir_connection.cpp 2016-12-02 05:05:06 +0000
314+++ src/client/mir_connection.cpp 2016-12-02 14:27:14 +0000
315@@ -242,6 +242,24 @@
316 }
317 }
318
319+bool validate_buffer_stream(mp::BufferStream& msg)
320+{
321+ if (!msg.has_id())
322+ {
323+ if (!msg.has_error())
324+ msg.set_error("no ID in response (disconnected?)");
325+ }
326+
327+ if (msg.has_error())
328+ {
329+ for (int i = 0; i < msg.buffer().fd_size(); i++)
330+ ::close(msg.buffer().fd(i));
331+ return false;
332+ }
333+ return true;
334+}
335+
336+
337 std::mutex connection_guard;
338 MirConnection* valid_connections{nullptr};
339 }
340@@ -385,16 +403,24 @@
341 auto const& spec = request->spec;
342 std::string name{spec.surface_name.is_set() ?
343 spec.surface_name.value() : ""};
344+ auto pf = static_cast<MirPixelFormat>(surface_proto->pixel_format());
345+ auto usage = static_cast<MirBufferUsage>(surface_proto->buffer_usage());
346+ auto size = mir::geometry::Size{surface_proto->width(), surface_proto->height()};
347
348 std::shared_ptr<MirBufferStream> default_stream {nullptr};
349- if (surface_proto->buffer_stream().has_id())
350+
351+ if (surface_proto->has_buffer_stream() && surface_proto->buffer_stream().has_id())
352 {
353 try
354 {
355+ if (!validate_buffer_stream(*surface_proto->mutable_buffer_stream()))
356+ throw std::invalid_argument(surface_proto->buffer_stream().error());
357+
358 default_stream = std::make_shared<mcl::BufferStream>(
359- this, nullptr, request->wh, server, platform, surface_map, buffer_factory,
360- surface_proto->buffer_stream(), make_perf_report(logger), name,
361- mir::geometry::Size{surface_proto->width(), surface_proto->height()}, nbuffers);
362+ this, mf::BufferStreamId{surface_proto->buffer_stream().id().value()},
363+ request->wh, server, platform, surface_map, buffer_factory,
364+ make_perf_report(logger), name,
365+ size, pf, usage, nbuffers);
366 surface_map->insert(default_stream->rpc_id(), default_stream);
367 }
368 catch (std::exception const& error)
369@@ -405,6 +431,10 @@
370 // surface_proto->buffer_stream()
371 for (auto i = 0; i < surface_proto->fd_size(); i++)
372 ::close(surface_proto->fd(i));
373+
374+ mf::BufferStreamId id(next_error_id(lock).as_value());
375+ default_stream = std::make_shared<mcl::ErrorStream>(
376+ std::string{error.what()}, this, id, nullptr);
377 }
378 }
379
380@@ -812,30 +842,24 @@
381 request = *stream_it;
382 stream_requests.erase(stream_it);
383 }
384+
385 auto& protobuf_bs = request->response;
386-
387- if (!protobuf_bs->has_id())
388- {
389- if (!protobuf_bs->has_error())
390- protobuf_bs->set_error("no ID in response (disconnected?)");
391- }
392-
393- if (protobuf_bs->has_error())
394- {
395- for (int i = 0; i < protobuf_bs->buffer().fd_size(); i++)
396- ::close(protobuf_bs->buffer().fd(i));
397- stream_error(
398- std::string{"Error processing buffer stream response: "} + protobuf_bs->error(),
399- request);
400+ if (!validate_buffer_stream(*protobuf_bs))
401+ {
402+ stream_error(std::string{"Error processing buffer stream response: "} + protobuf_bs->error(), request);
403 return;
404 }
405
406 try
407 {
408+ auto pf = static_cast<MirPixelFormat>(request->parameters.pixel_format());
409+ auto usage = static_cast<MirBufferUsage>(request->parameters.buffer_usage());
410+ auto size = mir::geometry::Size{request->parameters.width(), request->parameters.height()};
411+ auto id = mir::frontend::BufferStreamId{protobuf_bs->id().value()};
412 auto stream = std::make_shared<mcl::BufferStream>(
413- this, request->rs, request->wh, server, platform, surface_map, buffer_factory,
414- *protobuf_bs, make_perf_report(logger), std::string{},
415- mir::geometry::Size{request->parameters.width(), request->parameters.height()}, nbuffers);
416+ this, id, request->wh, server, platform, surface_map, buffer_factory,
417+ make_perf_report(logger), std::string{},
418+ size, pf, usage, nbuffers);
419 surface_map->insert(mf::BufferStreamId(protobuf_bs->id().value()), stream);
420
421 if (request->mbs_callback)
422@@ -846,8 +870,7 @@
423 catch (std::exception const& error)
424 {
425 stream_error(
426- std::string{"Error processing buffer stream creating response:"} + boost::diagnostic_information(error),
427- request);
428+ std::string{"Error processing buffer stream creating response:"} + boost::diagnostic_information(error), request);
429 }
430 }
431
432@@ -855,7 +878,6 @@
433 int width, int height,
434 MirPixelFormat format,
435 MirBufferUsage buffer_usage,
436- MirRenderSurface* render_surface,
437 mir_buffer_stream_callback mbs_callback,
438 void *context)
439 {
440@@ -865,10 +887,7 @@
441 params.set_pixel_format(format);
442 params.set_buffer_usage(buffer_usage);
443
444- auto request = std::make_shared<StreamCreationRequest>(render_surface,
445- mbs_callback,
446- context,
447- params);
448+ auto request = std::make_shared<StreamCreationRequest>(mbs_callback, context, params);
449 request->wh->expect_result();
450
451 {
452@@ -890,16 +909,13 @@
453 }
454
455 std::shared_ptr<mir::client::BufferStream> MirConnection::create_client_buffer_stream_with_id(
456- int width, int height,
457- MirRenderSurface* render_surface,
458- mir::protobuf::BufferStream const& a_protobuf_bs)
459+ mir::geometry::Size size, MirPixelFormat format, MirBufferUsage usage,
460+ MirRenderSurface* render_surface)
461 {
462- auto stream = std::make_shared<mcl::BufferStream>(
463- this, render_surface, nullptr, server, platform, surface_map, buffer_factory,
464- a_protobuf_bs, make_perf_report(logger), std::string{},
465- mir::geometry::Size{width, height}, nbuffers);
466- surface_map->insert(render_surface->stream_id(), stream);
467- return stream;
468+ return std::make_shared<mcl::BufferStream>(
469+ this, render_surface->stream_id(), nullptr, server, platform, surface_map, buffer_factory,
470+ make_perf_report(logger), std::string{},
471+ size, format, usage, nbuffers);
472 }
473
474 void MirConnection::render_surface_error(std::string const& error_msg, std::shared_ptr<RenderSurfaceCreationRequest> const& request)
475
476=== modified file 'src/client/mir_connection.h'
477--- src/client/mir_connection.h 2016-12-02 05:05:06 +0000
478+++ src/client/mir_connection.h 2016-12-02 14:27:14 +0000
479@@ -154,13 +154,13 @@
480 int width, int height,
481 MirPixelFormat format,
482 MirBufferUsage buffer_usage,
483- MirRenderSurface* render_surface,
484 mir_buffer_stream_callback mbs_callback,
485 void *context);
486+
487 std::shared_ptr<mir::client::BufferStream> create_client_buffer_stream_with_id(
488- int width, int height,
489- MirRenderSurface* render_surface,
490- mir::protobuf::BufferStream const& a_protobuf_bs);
491+ mir::geometry::Size size, MirPixelFormat format, MirBufferUsage usage,
492+ MirRenderSurface* render_surface);
493+
494 MirWaitHandle* release_buffer_stream(
495 MirBufferStream*,
496 mir_buffer_stream_callback callback,
497@@ -246,19 +246,16 @@
498 struct StreamCreationRequest
499 {
500 StreamCreationRequest(
501- MirRenderSurface* rs,
502 mir_buffer_stream_callback mbs_cb,
503 void* context,
504 mir::protobuf::BufferStreamParameters const& params)
505- : rs(rs),
506- mbs_callback(mbs_cb),
507+ : mbs_callback(mbs_cb),
508 context(context),
509 parameters(params),
510 response(std::make_shared<mir::protobuf::BufferStream>()),
511 wh(std::make_shared<MirWaitHandle>())
512 {
513 }
514- MirRenderSurface* rs;
515 mir_buffer_stream_callback mbs_callback;
516 void* context;
517 mir::protobuf::BufferStreamParameters const parameters;
518
519=== modified file 'src/client/render_surface.cpp'
520--- src/client/render_surface.cpp 2016-12-02 05:05:06 +0000
521+++ src/client/render_surface.cpp 2016-12-02 14:27:14 +0000
522@@ -65,10 +65,9 @@
523 {
524 protobuf_bs->set_pixel_format(format);
525 protobuf_bs->set_buffer_usage(buffer_usage);
526- stream_from_id = connection_->create_client_buffer_stream_with_id(width,
527- height,
528- this,
529- *protobuf_bs);
530+ stream_from_id = connection_->create_client_buffer_stream_with_id(
531+ geom::Size{width, height}, format, buffer_usage, this);
532+
533 if (buffer_usage == mir_buffer_usage_hardware)
534 {
535 platform->use_egl_native_window(
536
537=== modified file 'src/client/screencast_stream.cpp'
538--- src/client/screencast_stream.cpp 2016-11-30 08:13:49 +0000
539+++ src/client/screencast_stream.cpp 2016-12-02 14:27:14 +0000
540@@ -244,11 +244,6 @@
541 return connection_;
542 }
543
544-MirRenderSurface* mcl::ScreencastStream::render_surface() const
545-{
546- return nullptr;
547-}
548-
549 void mcl::ScreencastStream::set_buffer_cache_size(unsigned int)
550 {
551 BOOST_THROW_EXCEPTION(std::logic_error("Attempt to set cache size on screencast is invalid"));
552
553=== modified file 'src/client/screencast_stream.h'
554--- src/client/screencast_stream.h 2016-12-02 05:05:06 +0000
555+++ src/client/screencast_stream.h 2016-12-02 14:27:14 +0000
556@@ -98,7 +98,6 @@
557 MirWaitHandle* set_scale(float scale) override;
558 char const* get_error_message() const override;
559 MirConnection* connection() const override;
560- MirRenderSurface* render_surface() const override;
561
562 private:
563 void process_buffer(protobuf::Buffer const& buffer);
564
565=== modified file 'src/include/client/mir/mir_buffer_stream.h'
566--- src/include/client/mir/mir_buffer_stream.h 2016-12-02 05:05:06 +0000
567+++ src/include/client/mir/mir_buffer_stream.h 2016-12-02 14:27:14 +0000
568@@ -99,7 +99,6 @@
569 virtual MirWaitHandle* set_scale(float) = 0;
570 virtual char const* get_error_message() const = 0;
571 virtual MirConnection* connection() const = 0;
572- virtual MirRenderSurface* render_surface() const = 0;
573
574 virtual void buffer_available(mir::protobuf::Buffer const& buffer) = 0;
575 virtual void buffer_unavailable() = 0;
576
577=== modified file 'tests/unit-tests/client/test_client_buffer_stream.cpp'
578--- tests/unit-tests/client/test_client_buffer_stream.cpp 2016-11-30 08:13:49 +0000
579+++ tests/unit-tests/client/test_client_buffer_stream.cpp 2016-12-02 14:27:14 +0000
580@@ -212,15 +212,16 @@
581
582 testing::NiceMock<mtd::MockProtobufServer> mock_protobuf_server;
583
584- MirPixelFormat const default_pixel_format = mir_pixel_format_argb_8888;
585- MirBufferUsage const default_buffer_usage = mir_buffer_usage_hardware;
586+ MirPixelFormat const format = mir_pixel_format_argb_8888;
587+ MirBufferUsage const usage = mir_buffer_usage_hardware;
588
589 std::shared_ptr<mcl::PerfReport> const perf_report = std::make_shared<mcl::NullPerfReport>();
590
591 MirBufferPackage buffer_package = a_buffer_package();
592 geom::Size size{buffer_package.width, buffer_package.height};
593 mp::BufferStream response = a_protobuf_buffer_stream(
594- default_pixel_format, default_buffer_usage);
595+ format, usage);
596+ mir::frontend::BufferStreamId id { 4 };
597 size_t nbuffers{3};
598 };
599
600@@ -255,55 +256,14 @@
601
602 }
603
604-TEST_F(ClientBufferStream, protobuf_requirements)
605-{
606- auto valid_bs = a_protobuf_buffer_stream(default_pixel_format, default_buffer_usage);
607- EXPECT_NO_THROW({
608- mcl::BufferStream bs(
609- nullptr, nullptr, wait_handle, mock_protobuf_server,
610- std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
611- map, factory,
612- valid_bs, perf_report, "", size, nbuffers);
613- });
614- valid_bs.clear_buffer();
615- EXPECT_NO_THROW({
616- mcl::BufferStream bs(
617- nullptr, nullptr, wait_handle, mock_protobuf_server,
618- std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
619- map, factory,
620- valid_bs, perf_report, "", size, nbuffers);
621- });
622-
623- auto error_bs = valid_bs;
624- error_bs.set_error("An error");
625- EXPECT_THROW({
626- mcl::BufferStream bs(
627- nullptr, nullptr, wait_handle, mock_protobuf_server,
628- std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
629- map, factory,
630- error_bs, perf_report, "", size, nbuffers);
631- }, std::runtime_error);
632-
633- auto no_id_bs = valid_bs;
634- no_id_bs.clear_id();
635- EXPECT_THROW({
636- mcl::BufferStream bs(
637- nullptr, nullptr, wait_handle, mock_protobuf_server,
638- std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
639- map, factory,
640- no_id_bs, perf_report, "", size, nbuffers);
641- }, std::runtime_error);
642-}
643-
644 TEST_F(ClientBufferStream, uses_buffer_message_from_server)
645 {
646 EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),_,_))
647 .WillOnce(Return(std::make_shared<mtd::NullClientBuffer>()));
648 mcl::BufferStream bs(
649- nullptr, nullptr, wait_handle, mock_protobuf_server,
650+ nullptr, id, wait_handle, mock_protobuf_server,
651 std::make_shared<StubClientPlatform>(mt::fake_shared(mock_factory)),
652- map, factory,
653- response, perf_report, "", size, nbuffers);
654+ map, factory, perf_report, "", size, format, usage, nbuffers);
655 service_requests_for(1);
656 }
657
658@@ -311,11 +271,10 @@
659 {
660 EXPECT_CALL(mock_protobuf_server, submit_buffer(_,_,_))
661 .WillOnce(mtd::RunProtobufClosure());
662- mcl::BufferStream bs{
663- nullptr, nullptr, wait_handle, mock_protobuf_server,
664+ mcl::BufferStream bs(
665+ nullptr, id, wait_handle, mock_protobuf_server,
666 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
667- map, factory,
668- response, perf_report, "", size, nbuffers};
669+ map, factory, perf_report, "", size, format, usage, nbuffers);
670 service_requests_for(mock_protobuf_server.alloc_count);
671
672 bs.swap_buffers([]{});
673@@ -324,11 +283,10 @@
674 TEST_F(ClientBufferStream, invokes_callback_on_swap_buffers)
675 {
676 mp::Buffer buffer;
677- mcl::BufferStream bs{
678- nullptr, nullptr, wait_handle, mock_protobuf_server,
679+ mcl::BufferStream bs(
680+ nullptr, id, wait_handle, mock_protobuf_server,
681 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
682- map, factory,
683- response, perf_report, "", size, nbuffers};
684+ map, factory, perf_report, "", size, format, usage, nbuffers);
685 service_requests_for(mock_protobuf_server.alloc_count);
686 ON_CALL(mock_protobuf_server, submit_buffer(_,_,_))
687 .WillByDefault(DoAll(
688@@ -347,17 +305,16 @@
689 size = { width, height };
690
691 mcl::BufferStream bs(
692- nullptr, nullptr, wait_handle, mock_protobuf_server,
693+ nullptr, id, wait_handle, mock_protobuf_server,
694 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
695- map, factory,
696- response, perf_report, "", size, nbuffers);
697+ map, factory, perf_report, "", size, format, usage, nbuffers);
698 auto params = bs.get_parameters();
699
700 EXPECT_STREQ("", params.name);
701 EXPECT_EQ(width, params.width);
702 EXPECT_EQ(height, params.height);
703- EXPECT_EQ(default_pixel_format, params.pixel_format);
704- EXPECT_EQ(default_buffer_usage, params.buffer_usage);
705+ EXPECT_EQ(format, params.pixel_format);
706+ EXPECT_EQ(usage, params.buffer_usage);
707 }
708
709 TEST_F(ClientBufferStream, returns_current_client_buffer)
710@@ -371,7 +328,7 @@
711 mp::Buffer protobuf_buffer_2;
712 fill_protobuf_buffer_from_package(&protobuf_buffer_1, buffer_package_1);
713 fill_protobuf_buffer_from_package(&protobuf_buffer_2, buffer_package_2);
714- auto protobuf_bs = a_protobuf_buffer_stream(default_pixel_format, default_buffer_usage);
715+ auto protobuf_bs = a_protobuf_buffer_stream(format, usage);
716
717 Sequence seq;
718 EXPECT_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package_1),_,_))
719@@ -382,10 +339,9 @@
720 .WillOnce(Return(client_buffer_2));
721
722 mcl::BufferStream bs(
723- nullptr, nullptr, wait_handle, mock_protobuf_server,
724+ nullptr, id, wait_handle, mock_protobuf_server,
725 std::make_shared<StubClientPlatform>(mt::fake_shared(mock_factory)),
726- map, factory,
727- protobuf_bs, perf_report, "", size, nbuffers);
728+ map, factory, perf_report, "", size, format, usage, nbuffers);
729 service_requests_for(1);
730 EXPECT_EQ(client_buffer_1, bs.get_current_buffer());
731
732@@ -400,7 +356,7 @@
733 auto const client_buffer_2 = std::make_shared<mtd::NullClientBuffer>(size);
734 auto buffer_package_1 = a_buffer_package();
735 auto buffer_package_2 = a_buffer_package();
736- auto protobuf_bs = a_protobuf_buffer_stream(default_pixel_format, default_buffer_usage);
737+ auto protobuf_bs = a_protobuf_buffer_stream(format, usage);
738 mp::Buffer protobuf_buffer_2;
739 fill_protobuf_buffer_from_package(&protobuf_buffer_2, buffer_package_2);
740 auto expected_size = geom::Size{buffer_package_1.width, buffer_package_1.height};
741@@ -414,10 +370,9 @@
742 .WillOnce(Return(client_buffer_2));
743
744 mcl::BufferStream bs(
745- nullptr, nullptr, wait_handle, mock_protobuf_server,
746+ nullptr, id, wait_handle, mock_protobuf_server,
747 std::make_shared<StubClientPlatform>(mt::fake_shared(mock_factory)),
748- map, factory,
749- protobuf_bs, perf_report, "", size, nbuffers);
750+ map, factory, perf_report, "", size, format, usage, nbuffers);
751 service_requests_for(1);
752 EXPECT_EQ(client_buffer_1, bs.get_current_buffer());
753 async_buffer_arrives(protobuf_buffer_2);
754@@ -427,11 +382,10 @@
755
756 TEST_F(ClientBufferStream, gets_egl_native_window)
757 {
758- mcl::BufferStream bs{
759- nullptr, nullptr, wait_handle, mock_protobuf_server,
760+ mcl::BufferStream bs(
761+ nullptr, id, wait_handle, mock_protobuf_server,
762 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
763- map, factory,
764- response, perf_report, "", size, nbuffers};
765+ map, factory, perf_report, "", size, format, usage, nbuffers);
766 EXPECT_EQ(StubClientPlatform::egl_native_window, bs.egl_native_window());
767 }
768
769@@ -444,10 +398,9 @@
770 .WillOnce(Return(mt::fake_shared(mock_client_buffer)));
771
772 mcl::BufferStream bs(
773- nullptr, nullptr, wait_handle, mock_protobuf_server,
774+ nullptr, id, wait_handle, mock_protobuf_server,
775 std::make_shared<StubClientPlatform>(mt::fake_shared(mock_factory)),
776- map, factory,
777- response, perf_report, "", size, nbuffers);
778+ map, factory, perf_report, "", size, format, usage, nbuffers);
779 service_requests_for(1);
780
781 mcl::MemoryRegion expected_memory_region;
782@@ -465,10 +418,9 @@
783 ON_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),_,_))
784 .WillByDefault(Return(mt::fake_shared(mock_client_buffer)));
785 mcl::BufferStream bs(
786- nullptr, nullptr, wait_handle, mock_protobuf_server,
787+ nullptr, id, wait_handle, mock_protobuf_server,
788 std::make_shared<StubClientPlatform>(mt::fake_shared(mock_factory)),
789- map, factory,
790- response, perf_report, "", size, nbuffers);
791+ map, factory, perf_report, "", size, format, usage, nbuffers);
792 service_requests_for(2);
793
794 mcl::MemoryRegion first_expected_memory_region;
795@@ -493,10 +445,9 @@
796 std::string const name = "a_unique_surface_name";
797 EXPECT_CALL(mock_perf_report, name_surface(StrEq(name)));
798 mcl::BufferStream bs(
799- nullptr, nullptr, wait_handle, mock_protobuf_server,
800+ nullptr, id, wait_handle, mock_protobuf_server,
801 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
802- map, factory,
803- response, mt::fake_shared(mock_perf_report), name, size, nbuffers);
804+ map, factory, mt::fake_shared(mock_perf_report), name, size, format, usage, nbuffers);
805 }
806
807 TEST_F(ClientBufferStream, perf_report_starts_frame_at_get_current_buffer)
808@@ -506,10 +457,9 @@
809 EXPECT_CALL(mock_perf_report, end_frame(_)).Times(0);
810
811 mcl::BufferStream bs(
812- nullptr, nullptr, wait_handle, mock_protobuf_server,
813+ nullptr, id, wait_handle, mock_protobuf_server,
814 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
815- map, factory,
816- response, mt::fake_shared(mock_perf_report), "Foo", size, nbuffers);
817+ map, factory, mt::fake_shared(mock_perf_report), "Foo", size, format, usage, nbuffers);
818
819 service_requests_for(1);
820
821@@ -523,10 +473,9 @@
822 EXPECT_CALL(mock_perf_report, end_frame(_)).Times(0);
823
824 mcl::BufferStream bs(
825- nullptr, nullptr, wait_handle, mock_protobuf_server,
826+ nullptr, id, wait_handle, mock_protobuf_server,
827 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
828- map, factory,
829- response, mt::fake_shared(mock_perf_report), "Foo", size, nbuffers);
830+ map, factory, mt::fake_shared(mock_perf_report), "Foo", size, format, usage, nbuffers);
831
832 service_requests_for(1);
833
834@@ -540,10 +489,9 @@
835 EXPECT_CALL(mock_perf_report, end_frame(_)).Times(1);
836
837 mcl::BufferStream bs(
838- nullptr, nullptr, wait_handle, mock_protobuf_server,
839+ nullptr, id, wait_handle, mock_protobuf_server,
840 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
841- map, factory,
842- response, mt::fake_shared(mock_perf_report), "Foo", size, nbuffers);
843+ map, factory, mt::fake_shared(mock_perf_report), "Foo", size, format, usage, nbuffers);
844
845 service_requests_for(2);
846
847@@ -564,10 +512,9 @@
848 .WillOnce(Return(mt::fake_shared(mock_client_buffer)));
849
850 mcl::BufferStream bs(
851- nullptr, nullptr, wait_handle, mock_protobuf_server,
852+ nullptr, ClientBufferStream::id, wait_handle, mock_protobuf_server,
853 std::make_shared<StubClientPlatform>(mt::fake_shared(mock_factory)),
854- map, factory,
855- response, perf_report, "", size, nbuffers);
856+ map, factory, perf_report, "", size, format, usage, nbuffers);
857 service_requests_for(1);
858
859 mir::protobuf::Buffer another_buffer_package;
860@@ -601,10 +548,9 @@
861 bool started{false};
862
863 mcl::BufferStream bs(
864- nullptr, nullptr, wait_handle, mock_protobuf_server,
865+ nullptr, id, wait_handle, mock_protobuf_server,
866 std::make_shared<StubClientPlatform>(mt::fake_shared(mock_factory)),
867- map, factory,
868- response, perf_report, "", size, nbuffers);
869+ map, factory, perf_report, "", size, format, usage, nbuffers);
870 service_requests_for(mock_protobuf_server.alloc_count);
871
872 auto never_serviced_request = std::async(std::launch::async,[&] {
873@@ -633,11 +579,10 @@
874 MirWaitHandle* wh{nullptr};
875 bool wait_handle_has_result_in_callback = false;
876
877- mcl::BufferStream bs{
878- nullptr, nullptr, wait_handle, mock_protobuf_server,
879+ mcl::BufferStream bs(
880+ nullptr, id, wait_handle, mock_protobuf_server,
881 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
882- map, factory,
883- response, perf_report, "", size, nbuffers};
884+ map, factory, perf_report, "", size, format, usage, nbuffers);
885 service_requests_for(mock_protobuf_server.alloc_count);
886
887 wh = bs.swap_buffers(
888@@ -655,11 +600,10 @@
889 MirWaitHandle* wh{nullptr};
890 bool wait_handle_has_result_in_callback = false;
891
892- mcl::BufferStream bs{
893- nullptr, nullptr, wait_handle, mock_protobuf_server,
894+ mcl::BufferStream bs(
895+ nullptr, id, wait_handle, mock_protobuf_server,
896 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
897- map, factory,
898- response, perf_report, "", size, nbuffers};
899+ map, factory, perf_report, "", size, format, usage, nbuffers);
900 service_requests_for(mock_protobuf_server.alloc_count);
901
902 wh = bs.swap_buffers(
903@@ -675,11 +619,10 @@
904
905 TEST_F(ClientBufferStream, configures_swap_interval)
906 {
907- mcl::BufferStream bs{
908- nullptr, nullptr, wait_handle, mock_protobuf_server,
909+ mcl::BufferStream bs(
910+ nullptr, id, wait_handle, mock_protobuf_server,
911 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
912- map, factory,
913- response, perf_report, "", size, nbuffers};
914+ map, factory, perf_report, "", size, format, usage, nbuffers);
915 service_requests_for(mock_protobuf_server.alloc_count);
916
917 EXPECT_CALL(mock_protobuf_server, configure_buffer_stream(_,_,_));
918@@ -688,11 +631,10 @@
919
920 TEST_F(ClientBufferStream, sets_swap_interval_requested)
921 {
922- mcl::BufferStream bs{
923- nullptr, nullptr, wait_handle, mock_protobuf_server,
924+ mcl::BufferStream bs(
925+ nullptr, id, wait_handle, mock_protobuf_server,
926 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
927- map, factory,
928- response, perf_report, "", size, nbuffers};
929+ map, factory, perf_report, "", size, format, usage, nbuffers);
930 service_requests_for(mock_protobuf_server.alloc_count);
931
932 bs.set_swap_interval(1);
933@@ -705,11 +647,10 @@
934 TEST_F(ClientBufferStream, environment_overrides_requested_swap_interval)
935 {
936 setenv("MIR_CLIENT_FORCE_SWAP_INTERVAL", "0", 1);
937- mcl::BufferStream bs{
938- nullptr, nullptr, wait_handle, mock_protobuf_server,
939+ mcl::BufferStream bs(
940+ nullptr, id, wait_handle, mock_protobuf_server,
941 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
942- map, factory,
943- response, perf_report, "", size, nbuffers};
944+ map, factory, perf_report, "", size, format, usage, nbuffers);
945 service_requests_for(mock_protobuf_server.alloc_count);
946
947 bs.set_swap_interval(1);
948@@ -736,10 +677,9 @@
949 EXPECT_CALL(mock_factory, create_buffer(_,_,format))
950 .WillRepeatedly(Return(std::make_shared<mtd::NullClientBuffer>()));
951 mcl::BufferStream bs(
952- nullptr, nullptr, wait_handle, mock_protobuf_server,
953+ nullptr, id, wait_handle, mock_protobuf_server,
954 std::make_shared<StubClientPlatform>(mt::fake_shared(mock_factory)),
955- map, factory,
956- response, perf_report, "", size, nbuffers);
957+ map, factory, perf_report, "", size, format, usage, nbuffers);
958 service_requests_for(1);
959 auto params = bs.get_parameters();
960 EXPECT_THAT(params.pixel_format, Eq(format));
961@@ -750,10 +690,9 @@
962 ON_CALL(mock_factory, create_buffer(_,_,_))
963 .WillByDefault(Return(std::make_shared<mtd::NullClientBuffer>(size)));
964 mcl::BufferStream stream(
965- nullptr, nullptr, wait_handle, mock_protobuf_server,
966+ nullptr, id, wait_handle, mock_protobuf_server,
967 std::make_shared<StubClientPlatform>(mt::fake_shared(mock_factory)),
968- map, factory,
969- response, perf_report, "", size, nbuffers);
970+ map, factory, perf_report, "", size, format, usage, nbuffers);
971 for(auto i = 0u; i < 2; i++)
972 {
973 mp::Buffer buffer;
974@@ -772,11 +711,10 @@
975 {
976 ON_CALL(mock_protobuf_server, submit_buffer(_,_,_))
977 .WillByDefault(mtd::RunProtobufClosure());
978- mcl::BufferStream bs{
979- nullptr, nullptr, wait_handle, mock_protobuf_server,
980+ mcl::BufferStream bs(
981+ nullptr, id, wait_handle, mock_protobuf_server,
982 std::make_shared<StubClientPlatform>(mt::fake_shared(stub_factory)),
983- map, factory,
984- response, perf_report, "", size, nbuffers};
985+ map, factory, perf_report, "", size, format, usage, nbuffers);
986 service_requests_for(mock_protobuf_server.alloc_count);
987
988 auto count = 0;
989
990=== modified file 'tests/unit-tests/client/test_mir_connection.cpp'
991--- tests/unit-tests/client/test_mir_connection.cpp 2016-12-02 05:05:06 +0000
992+++ tests/unit-tests/client/test_mir_connection.cpp 2016-12-02 14:27:14 +0000
993@@ -651,7 +651,7 @@
994 EXPECT_CALL(*mock_channel, on_buffer_stream_create(_,_))
995 .WillOnce(Invoke([](mp::BufferStream& bs, google::protobuf::Closure*){ bs.set_error("danger will robertson"); }));
996 EXPECT_FALSE(connection->create_client_buffer_stream(
997- 2, 2, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware, nullptr, nullptr, nullptr)->is_pending());
998+ 2, 2, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware, nullptr, nullptr)->is_pending());
999 }
1000
1001 TEST_F(MirConnectionTest, wait_handle_is_signalled_during_creation_exception)
1002@@ -661,7 +661,7 @@
1003 Invoke([](mp::BufferStream&, google::protobuf::Closure* c){ c->Run(); }),
1004 Throw(std::runtime_error("pay no attention to the man behind the curtain"))));
1005 auto wh = connection->create_client_buffer_stream(
1006- 2, 2, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware, nullptr, nullptr, nullptr);
1007+ 2, 2, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware, nullptr, nullptr);
1008 ASSERT_THAT(wh, Ne(nullptr));
1009 EXPECT_FALSE(wh->is_pending());
1010 }
1011@@ -678,7 +678,7 @@
1012
1013 connection->create_client_buffer_stream(
1014 2, 2, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware,
1015- nullptr, &BufferStreamCallback::created, &callback);
1016+ &BufferStreamCallback::created, &callback);
1017 EXPECT_TRUE(callback.invoked);
1018 ASSERT_TRUE(callback.resulting_stream);
1019 EXPECT_THAT(mir_buffer_stream_get_error_message(callback.resulting_stream),
1020@@ -694,9 +694,29 @@
1021 Invoke([](mp::BufferStream&, google::protobuf::Closure* c){ c->Run(); }),
1022 Throw(std::runtime_error("pay no attention to the man behind the curtain"))));
1023 connection->create_client_buffer_stream(
1024- 2, 2, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware, nullptr,
1025- &BufferStreamCallback::created, &callback);
1026-
1027+ 2, 2, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware,
1028+ &BufferStreamCallback::created, &callback);
1029+
1030+ EXPECT_TRUE(callback.invoked);
1031+ ASSERT_TRUE(callback.resulting_stream);
1032+ EXPECT_THAT(mir_buffer_stream_get_error_message(callback.resulting_stream),
1033+ StrEq("Error processing buffer stream response: no ID in response (disconnected?)"));
1034+}
1035+
1036+TEST_F(MirConnectionTest, creates_error_stream_when_not_given_stream_id)
1037+{
1038+ using namespace testing;
1039+ BufferStreamCallback callback;
1040+ EXPECT_CALL(*mock_channel, on_buffer_stream_create(_,_))
1041+ .WillOnce(Invoke([&](mp::BufferStream& bs, google::protobuf::Closure*)
1042+ {
1043+ bs.clear_id();
1044+ bs.clear_error();
1045+ }));
1046+
1047+ connection->create_client_buffer_stream(
1048+ 2, 2, mir_pixel_format_abgr_8888, mir_buffer_usage_hardware,
1049+ &BufferStreamCallback::created, &callback);
1050 EXPECT_TRUE(callback.invoked);
1051 ASSERT_TRUE(callback.resulting_stream);
1052 EXPECT_THAT(mir_buffer_stream_get_error_message(callback.resulting_stream),

Subscribers

People subscribed via source and target branches