Mir

Merge lp:~kdub/mir/plumb-resizing into lp:mir

Proposed by Kevin DuBois on 2015-08-25
Status: Merged
Approved by: Kevin DuBois on 2015-09-08
Approved revision: 2862
Merged at revision: 2908
Proposed branch: lp:~kdub/mir/plumb-resizing
Merge into: lp:mir
Prerequisite: lp:~kdub/mir/buffer-stream-use-vault
Diff against target: 252 lines (+109/-1)
7 files modified
src/client/buffer_stream.cpp (+15/-0)
src/client/buffer_stream.h (+1/-1)
src/client/client_buffer_stream.h (+2/-0)
src/client/mir_surface.cpp (+12/-0)
src/client/mir_surface.h (+1/-0)
tests/include/mir/test/doubles/mock_client_buffer_stream.h (+1/-0)
tests/unit-tests/client/test_client_mir_surface.cpp (+77/-0)
To merge this branch: bzr merge lp:~kdub/mir/plumb-resizing
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-09-08
Alexandros Frantzis (community) 2015-08-25 Approve on 2015-09-03
Review via email: mp+269093@code.launchpad.net

Commit Message

client: plumb together bits for resizing in the new semantics. Previous behavior was to start handing out buffers, and notify the client. Since the client is in charge of allocations now, this branch works by receiving the notification, and then arranging the size transition. User-specified streams are not resized; this sizing bit of user-specified stream arrangement still needs to be worked out in the client api.

Description of the Change

client: plumb together bits for resizing in the new semantics. Previous behavior was to start handing out buffers, and notify the client. Since the client is in charge of allocations now, this branch works by receiving the notification, and then arranging the size transition. User-specified streams are not resized; this sizing bit of user-specified stream arrangement still needs to be worked out in the client api.

To post a comment you must log in.
Alexandros Frantzis (afrantzis) wrote :

Looks related to this, or perhaps the parent branch?

13: [ RUN ] BufferSemanticsMode/ClientBufferStream.producer_streams_call_submit_buffer_on_next_buffer/0
Build timed out (after 240 minutes). Marking the build as failed.

review: Needs Fixing
Kevin DuBois (kdub) wrote :

parent branch, should be fixed

Kevin DuBois (kdub) wrote :

> parent branch, should be fixed
For the curious, the unit test didn't have the buffer stub sizes matching, which caused a hang waiting for a correct-sized buffer.

Kevin DuBois (kdub) wrote :

9: [ FAILED ] ThreadedDispatcherSignalTest.keeps_dispatching_after_signal_interruption (2650 ms)
doesnt look related to the branch, maybe https://bugs.launchpad.net/mir/+bug/1441620 ?

Kevin DuBois (kdub) wrote :

the tests for ClientBufferStream are indicating that these objects need a bit of refactoring...

Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve
Francis Ginther (fginther) wrote :

FAILURE: http://jenkins.qa.ubuntu.com/job/mir-wily-amd64-autolanding/387/console

^ Failed because the slave ran out of disk space. The slave has been taken offline and will be fixed. I mentioned re-approving this to kdub, but since there are other failures, I'll leave this for him to look at more closely.

review: Approve (continuous-integration)

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 2015-09-01 02:03:02 +0000
3+++ src/client/buffer_stream.cpp 2015-09-01 15:20:55 +0000
4@@ -61,6 +61,7 @@
5 virtual uint32_t current_buffer_id() = 0;
6 virtual MirWaitHandle* submit(std::function<void()> const&, geometry::Size sz, MirPixelFormat, int stream_id) = 0;
7 virtual void lost_connection() = 0;
8+ virtual void set_size(geom::Size) = 0;
9 virtual ~ServerBufferSemantics() = default;
10 ServerBufferSemantics() = default;
11 ServerBufferSemantics(ServerBufferSemantics const&) = delete;
12@@ -207,6 +208,10 @@
13 next_buffer_wait_handle.result_received();
14 }
15
16+ void set_size(geom::Size) override
17+ {
18+ }
19+
20 std::mutex mutex;
21 mcl::ClientBufferDepository wrapped;
22 mir::protobuf::DisplayServer& display_server;
23@@ -308,6 +313,11 @@
24 return &next_buffer_wait_handle;
25 }
26
27+ void set_size(geom::Size size) override
28+ {
29+ vault.set_size(size);
30+ }
31+
32 void lost_connection() override
33 {
34 }
35@@ -648,3 +658,8 @@
36 std::unique_lock<decltype(mutex)> lock(mutex);
37 buffer_depository->lost_connection();
38 }
39+
40+void mcl::BufferStream::set_size(geom::Size sz)
41+{
42+ buffer_depository->set_size(sz);
43+}
44
45=== modified file 'src/client/buffer_stream.h'
46--- src/client/buffer_stream.h 2015-09-01 02:03:02 +0000
47+++ src/client/buffer_stream.h 2015-09-01 15:20:55 +0000
48@@ -119,7 +119,7 @@
49
50 void buffer_available(mir::protobuf::Buffer const& buffer) override;
51 void buffer_unavailable() override;
52-
53+ void set_size(geometry::Size) override;
54 protected:
55 BufferStream(BufferStream const&) = delete;
56 BufferStream& operator=(BufferStream const&) = delete;
57
58=== modified file 'src/client/client_buffer_stream.h'
59--- src/client/client_buffer_stream.h 2015-08-07 05:46:34 +0000
60+++ src/client/client_buffer_stream.h 2015-09-01 15:20:55 +0000
61@@ -20,6 +20,7 @@
62 #define MIR_CLIENT_CLIENT_BUFFER_STREAM_H_
63
64 #include "mir/frontend/buffer_stream_id.h"
65+#include "mir/geometry/size.h"
66
67 #include "mir_toolkit/client_types.h"
68 #include "mir_toolkit/mir_native_buffer.h"
69@@ -69,6 +70,7 @@
70 virtual bool valid() const = 0;
71 virtual void buffer_available(mir::protobuf::Buffer const& buffer) = 0;
72 virtual void buffer_unavailable() = 0;
73+ virtual void set_size(geometry::Size) = 0;
74
75 protected:
76 ClientBufferStream() = default;
77
78=== modified file 'src/client/mir_surface.cpp'
79--- src/client/mir_surface.cpp 2015-08-12 06:37:54 +0000
80+++ src/client/mir_surface.cpp 2015-09-01 15:20:55 +0000
81@@ -577,6 +577,17 @@
82 keymapper->set_rules(names);
83 break;
84 }
85+ case mir_event_type_resize:
86+ {
87+ if (auto_resize_stream)
88+ {
89+ auto resize_event = mir_event_get_resize_event(&e);
90+ buffer_stream->set_size(geom::Size{
91+ mir_resize_event_get_width(resize_event),
92+ mir_resize_event_get_height(resize_event)});
93+ }
94+ break;
95+ }
96 default:
97 break;
98 };
99@@ -703,6 +714,7 @@
100
101 if (spec.streams.is_set())
102 {
103+ auto_resize_stream = false;
104 for(auto const& stream : spec.streams.value())
105 {
106 auto const new_stream = surface_specification->add_stream();
107
108=== modified file 'src/client/mir_surface.h'
109--- src/client/mir_surface.h 2015-08-07 05:46:34 +0000
110+++ src/client/mir_surface.h 2015-09-01 15:20:55 +0000
111@@ -223,6 +223,7 @@
112
113 std::function<void(MirEvent const*)> handle_event_callback;
114 std::shared_ptr<mir::dispatch::ThreadedDispatcher> input_thread;
115+ bool auto_resize_stream{true};
116 };
117
118 #endif /* MIR_CLIENT_PRIVATE_MIR_WAIT_HANDLE_H_ */
119
120=== modified file 'tests/include/mir/test/doubles/mock_client_buffer_stream.h'
121--- tests/include/mir/test/doubles/mock_client_buffer_stream.h 2015-07-16 07:03:19 +0000
122+++ tests/include/mir/test/doubles/mock_client_buffer_stream.h 2015-09-01 15:20:55 +0000
123@@ -47,6 +47,7 @@
124 MOCK_CONST_METHOD0(valid, bool(void));
125 MOCK_METHOD1(buffer_available, void(mir::protobuf::Buffer const&));
126 MOCK_METHOD0(buffer_unavailable, void());
127+ MOCK_METHOD1(set_size, void(geometry::Size));
128 };
129
130 }
131
132=== modified file 'tests/unit-tests/client/test_client_mir_surface.cpp'
133--- tests/unit-tests/client/test_client_mir_surface.cpp 2015-08-14 16:37:34 +0000
134+++ tests/unit-tests/client/test_client_mir_surface.cpp 2015-09-01 15:20:55 +0000
135@@ -32,8 +32,10 @@
136 #include "src/client/rpc/null_rpc_report.h"
137 #include "src/client/rpc/mir_display_server.h"
138 #include "src/client/rpc/mir_basic_rpc_channel.h"
139+#include "src/client/connection_surface_map.h"
140 #include "mir/dispatch/dispatchable.h"
141 #include "mir/dispatch/threaded_dispatcher.h"
142+#include "mir/events/event_builders.h"
143
144 #include "mir/frontend/connector.h"
145 #include "mir/input/input_platform.h"
146@@ -100,6 +102,14 @@
147 done->Run();
148 }
149
150+ void release_surface(
151+ const mir::protobuf::SurfaceId*,
152+ mir::protobuf::Void*,
153+ google::protobuf::Closure* done)
154+ {
155+ done->Run();
156+ }
157+
158 void exchange_buffer(
159 mir::protobuf::BufferRequest const* /*request*/,
160 mir::protobuf::Buffer* response,
161@@ -109,6 +119,14 @@
162 done->Run();
163 }
164
165+ void modify_surface(
166+ const mir::protobuf::SurfaceModifications*,
167+ mir::protobuf::Void*,
168+ google::protobuf::Closure* done)
169+ {
170+ done->Run();
171+ }
172+
173 MirBufferPackage server_package;
174 int width_sent;
175 int height_sent;
176@@ -297,6 +315,7 @@
177 connect_parameters.set_application_name("test");
178
179 TestConnectionConfiguration conf;
180+ surface_map = conf.the_surface_map();
181 connection = std::make_shared<MirConnection>(conf);
182 MirWaitHandle* wait_handle = connection->connect("MirClientSurfaceTest",
183 null_connected_callback, 0);
184@@ -359,6 +378,7 @@
185 std::shared_ptr<MockServerPackageGenerator> const mock_server_tool =
186 std::make_shared<MockServerPackageGenerator>();
187
188+ std::shared_ptr<mcl::ConnectionSurfaceMap> surface_map;
189 std::shared_ptr<mt::TestProtobufServer> test_server;
190 std::shared_ptr<mclr::DisplayServer> client_comm_channel;
191
192@@ -502,3 +522,60 @@
193
194 EXPECT_GE(std::chrono::steady_clock::now(), expected_end);
195 }
196+
197+TEST_F(MirClientSurfaceTest, resizes_streams_and_calls_callback_if_no_customized_streams)
198+{
199+ using namespace testing;
200+ auto mock_stream = std::make_shared<mtd::MockClientBufferStream>();
201+ auto mock_stream_factory = std::make_shared<NiceMock<mtd::MockClientBufferStreamFactory>>();
202+ auto mock_input_platform = std::make_shared<NiceMock<MockClientInputPlatform>>();
203+ ON_CALL(*mock_stream_factory, make_producer_stream(_,_,_,_,An<void*>()))
204+ .WillByDefault(Return(mock_stream.get()));
205+ ON_CALL(*mock_stream_factory, make_producer_stream(_,_,_,_,An<geom::Size>()))
206+ .WillByDefault(Return(mock_stream));
207+ ON_CALL(*mock_input_platform, create_input_receiver(_,_,_))
208+ .WillByDefault(Return(std::make_shared<mt::TestDispatchable>([]{})));
209+ ON_CALL(*mock_stream, rpc_id()).WillByDefault(Return(mir::frontend::BufferStreamId(2)));
210+
211+ geom::Size size(120, 124);
212+ EXPECT_CALL(*mock_stream, set_size(size));
213+ auto ev = mir::events::make_event(mir::frontend::SurfaceId(2), size);
214+
215+ //FIXME: difficult construction
216+ MirSurface surface{connection.get(), *client_comm_channel, nullptr,
217+ mock_stream_factory, mock_input_platform, spec, &null_surface_callback, nullptr};
218+ auto wait_handle = surface.get_create_wait_handle();
219+ wait_handle->wait_for_all();
220+ surface.handle_event(*ev);
221+ surface_map->erase(mir::frontend::BufferStreamId(2));
222+}
223+
224+TEST_F(MirClientSurfaceTest, resizes_streams_and_calls_callback_if_customized_streams)
225+{
226+ using namespace testing;
227+ auto mock_stream = std::make_shared<NiceMock<mtd::MockClientBufferStream>>();
228+ auto mock_stream_factory = std::make_shared<NiceMock<mtd::MockClientBufferStreamFactory>>();
229+ auto mock_input_platform = std::make_shared<NiceMock<MockClientInputPlatform>>();
230+ ON_CALL(*mock_stream, rpc_id()).WillByDefault(Return(mir::frontend::BufferStreamId(2)));
231+ ON_CALL(*mock_stream_factory, make_producer_stream(_,_,_,_,An<void*>()))
232+ .WillByDefault(Return(mock_stream.get()));
233+ ON_CALL(*mock_stream_factory, make_producer_stream(_,_,_,_,An<geom::Size>()))
234+ .WillByDefault(Return(mock_stream));
235+ ON_CALL(*mock_input_platform, create_input_receiver(_,_,_))
236+ .WillByDefault(Return(std::make_shared<mt::TestDispatchable>([]{})));
237+
238+ geom::Size size(120, 124);
239+ EXPECT_CALL(*mock_stream, set_size(size)).Times(0);
240+ auto ev = mir::events::make_event(mir::frontend::SurfaceId(2), size);
241+ MirSurface surface{connection.get(), *client_comm_channel, nullptr,
242+ mock_stream_factory, mock_input_platform, spec, &null_surface_callback, nullptr};
243+ surface.get_create_wait_handle()->wait_for_all();
244+
245+ MirSurfaceSpec spec;
246+ std::vector<MirBufferStreamInfo> info =
247+ {{reinterpret_cast<MirBufferStream*>(surface.get_buffer_stream()), 0, 1 }};
248+ spec.streams = info;
249+ surface.modify(spec)->wait_for_all();
250+ surface.handle_event(*ev);
251+ surface_map->erase(mir::frontend::BufferStreamId(2));
252+}

Subscribers

People subscribed via source and target branches