Merge lp:~albaguirre/mir/ci-debug-1499229 into lp:mir
- ci-debug-1499229
- Merge into development-branch
Status: | Rejected |
---|---|
Rejected by: | Alberto Aguirre |
Proposed branch: | lp:~albaguirre/mir/ci-debug-1499229 |
Merge into: | lp:mir |
Diff against target: |
1707 lines (+564/-181) 40 files modified
include/client/mir_toolkit/mir_screencast.h (+18/-0) include/renderers/gl/mir/renderer/gl/render_target.h (+5/-1) src/client/mir_connection.cpp (+1/-1) src/client/mir_connection.h (+1/-1) src/client/mir_screencast.cpp (+3/-1) src/client/mir_screencast.h (+3/-0) src/client/mir_screencast_api.cpp (+10/-0) src/client/symbols.map (+2/-0) src/include/server/mir/frontend/screencast.h (+3/-1) src/platforms/android/server/display_buffer.cpp (+4/-0) src/platforms/android/server/display_buffer.h (+1/-0) src/platforms/mesa/server/kms/display_buffer.cpp (+4/-0) src/platforms/mesa/server/kms/display_buffer.h (+1/-0) src/platforms/mesa/server/x11/graphics/display_buffer.cpp (+4/-0) src/platforms/mesa/server/x11/graphics/display_buffer.h (+1/-0) src/protobuf/mir_protobuf.proto (+2/-0) src/renderers/gl/renderer.cpp (+7/-1) src/renderers/gl/renderer.h (+1/-0) src/server/compositor/compositing_screencast.cpp (+52/-57) src/server/compositor/compositing_screencast.h (+8/-4) src/server/compositor/screencast_display_buffer.cpp (+79/-18) src/server/compositor/screencast_display_buffer.h (+52/-10) src/server/frontend/session_mediator.cpp (+10/-2) src/server/frontend/unauthorized_screencast.cpp (+3/-3) src/server/frontend/unauthorized_screencast.h (+5/-3) src/server/graphics/nested/display_buffer.cpp (+4/-0) src/server/graphics/nested/display_buffer.h (+1/-0) src/server/graphics/offscreen/display_buffer.cpp (+4/-0) src/server/graphics/offscreen/display_buffer.h (+1/-0) tests/include/mir/test/doubles/mock_gl_display_buffer.h (+1/-0) tests/include/mir/test/doubles/mock_screencast.h (+4/-2) tests/include/mir/test/doubles/null_screencast.h (+3/-1) tests/include/mir/test/doubles/stub_gl_display_buffer.h (+1/-0) tests/integration-tests/test_client_screencast.cpp (+10/-5) tests/mir_test/test_dispatchable.cpp (+15/-1) tests/unit-tests/compositor/test_compositing_screencast.cpp (+98/-21) tests/unit-tests/compositor/test_screencast_display_buffer.cpp (+84/-38) tests/unit-tests/dispatch/test_threaded_dispatcher.cpp (+55/-8) tests/unit-tests/frontend/test_session_mediator.cpp (+2/-2) tests/unit-tests/graphics/offscreen/test_offscreen_display.cpp (+1/-0) |
To merge this branch: | bzr merge lp:~albaguirre/mir/ci-debug-1499229 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir CI Bot | continuous-integration | Needs Fixing | |
Mir development team | Pending | ||
Review via email: mp+292418@code.launchpad.net |
Commit message
DO NOT MERGE,
just debugging lp:1499229
Description of the change
Mir CI Bot (mir-ci-bot) wrote : | # |
- 3471. By Alberto Aguirre
-
more debug
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3471
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unmerged revisions
- 3471. By Alberto Aguirre
-
more debug
- 3470. By Alberto Aguirre
-
Add some diagnostics to ThreadedDispatc
herTest
Preview Diff
1 | === modified file 'include/client/mir_toolkit/mir_screencast.h' |
2 | --- include/client/mir_toolkit/mir_screencast.h 2016-03-23 22:04:19 +0000 |
3 | +++ include/client/mir_toolkit/mir_screencast.h 2016-04-20 18:34:35 +0000 |
4 | @@ -78,6 +78,24 @@ |
5 | void mir_screencast_spec_set_capture_region(MirScreencastSpec* spec, MirRectangle const* region); |
6 | |
7 | /** |
8 | + * Set the requested mirror mode. |
9 | + * |
10 | + * \param [in] spec Specification to mutate |
11 | + * \param [in] mode The mirroring mode to apply when screencasting |
12 | + * |
13 | + */ |
14 | +void mir_screencast_spec_set_mirror_mode(MirScreencastSpec* spec, MirMirrorMode mode); |
15 | + |
16 | +/** |
17 | + * Set the requested number of buffers to use. |
18 | + * |
19 | + * \param [in] spec Specification to mutate |
20 | + * \param [in] nbuffers The number of buffers to allocate for screencasting |
21 | + * |
22 | + */ |
23 | +void mir_screencast_spec_set_number_of_buffers(MirScreencastSpec* spec, int nbuffers); |
24 | + |
25 | +/** |
26 | * Release the resources held by a MirScreencastSpec. |
27 | * |
28 | * \param [in] spec Specification to release |
29 | |
30 | === modified file 'include/renderers/gl/mir/renderer/gl/render_target.h' |
31 | --- include/renderers/gl/mir/renderer/gl/render_target.h 2015-10-01 08:58:30 +0000 |
32 | +++ include/renderers/gl/mir/renderer/gl/render_target.h 2016-04-20 18:34:35 +0000 |
33 | @@ -31,7 +31,7 @@ |
34 | public: |
35 | virtual ~RenderTarget() = default; |
36 | |
37 | - /** Makes the the current GL render target. */ |
38 | + /** Makes GL render target current to calling thread */ |
39 | virtual void make_current() = 0; |
40 | /** Releases the current GL render target. */ |
41 | virtual void release_current() = 0; |
42 | @@ -41,6 +41,10 @@ |
43 | * free GL-related resources such as textures and buffers. |
44 | */ |
45 | virtual void swap_buffers() = 0; |
46 | + /** Binds any necessary resources (fbos, textures if any) |
47 | + * in preparation for drawing. |
48 | + */ |
49 | + virtual void bind() = 0; |
50 | |
51 | protected: |
52 | RenderTarget() = default; |
53 | |
54 | === modified file 'src/client/mir_connection.cpp' |
55 | --- src/client/mir_connection.cpp 2016-04-14 05:37:22 +0000 |
56 | +++ src/client/mir_connection.cpp 2016-04-20 18:34:35 +0000 |
57 | @@ -896,7 +896,7 @@ |
58 | } |
59 | |
60 | std::shared_ptr<mir::client::ClientBufferStream> MirConnection::make_consumer_stream( |
61 | - mp::BufferStream const& protobuf_bs, mir::geometry::Size) |
62 | + mp::BufferStream const& protobuf_bs) |
63 | { |
64 | return std::make_shared<mcl::ScreencastStream>( |
65 | this, server, platform, protobuf_bs); |
66 | |
67 | === modified file 'src/client/mir_connection.h' |
68 | --- src/client/mir_connection.h 2016-03-30 01:12:38 +0000 |
69 | +++ src/client/mir_connection.h 2016-04-20 18:34:35 +0000 |
70 | @@ -145,7 +145,7 @@ |
71 | unsigned int formats_size, unsigned int& valid_formats); |
72 | |
73 | std::shared_ptr<mir::client::ClientBufferStream> make_consumer_stream( |
74 | - mir::protobuf::BufferStream const& protobuf_bs, mir::geometry::Size); |
75 | + mir::protobuf::BufferStream const& protobuf_bs); |
76 | |
77 | MirWaitHandle* create_client_buffer_stream( |
78 | int width, int height, |
79 | |
80 | === modified file 'src/client/mir_screencast.cpp' |
81 | --- src/client/mir_screencast.cpp 2016-03-28 17:37:35 +0000 |
82 | +++ src/client/mir_screencast.cpp 2016-04-20 18:34:35 +0000 |
83 | @@ -43,6 +43,8 @@ |
84 | SERIALIZE_OPTION_IF_SET(width); |
85 | SERIALIZE_OPTION_IF_SET(height); |
86 | SERIALIZE_OPTION_IF_SET(pixel_format); |
87 | + SERIALIZE_OPTION_IF_SET(mirror_mode); |
88 | + SERIALIZE_OPTION_IF_SET(num_buffers); |
89 | |
90 | if (spec.capture_region.is_set()) |
91 | { |
92 | @@ -182,7 +184,7 @@ |
93 | { |
94 | std::lock_guard<decltype(mutex)> lock(mutex); |
95 | buffer_stream = connection->make_consumer_stream( |
96 | - protobuf_screencast->buffer_stream(), {}); |
97 | + protobuf_screencast->buffer_stream()); |
98 | } |
99 | |
100 | callback(this, context); |
101 | |
102 | === modified file 'src/client/mir_screencast.h' |
103 | --- src/client/mir_screencast.h 2016-03-25 20:24:48 +0000 |
104 | +++ src/client/mir_screencast.h 2016-04-20 18:34:35 +0000 |
105 | @@ -61,6 +61,9 @@ |
106 | mir::optional_value<unsigned int> height; |
107 | mir::optional_value<MirPixelFormat> pixel_format; |
108 | mir::optional_value<MirRectangle> capture_region; |
109 | + |
110 | + mir::optional_value<MirMirrorMode> mirror_mode; |
111 | + mir::optional_value<int> num_buffers; |
112 | }; |
113 | |
114 | struct MirScreencast |
115 | |
116 | === modified file 'src/client/mir_screencast_api.cpp' |
117 | --- src/client/mir_screencast_api.cpp 2016-03-23 22:04:19 +0000 |
118 | +++ src/client/mir_screencast_api.cpp 2016-04-20 18:34:35 +0000 |
119 | @@ -69,6 +69,16 @@ |
120 | spec->capture_region = *region; |
121 | } |
122 | |
123 | +void mir_screencast_spec_set_mirror_mode(MirScreencastSpec* spec, MirMirrorMode mode) |
124 | +{ |
125 | + spec->mirror_mode = mode; |
126 | +} |
127 | + |
128 | +void mir_screencast_spec_set_number_of_buffers(MirScreencastSpec* spec, int nbuffers) |
129 | +{ |
130 | + spec->num_buffers = nbuffers; |
131 | +} |
132 | + |
133 | void mir_screencast_spec_release(MirScreencastSpec* spec) |
134 | { |
135 | delete spec; |
136 | |
137 | === modified file 'src/client/symbols.map' |
138 | --- src/client/symbols.map 2016-04-13 01:34:20 +0000 |
139 | +++ src/client/symbols.map 2016-04-20 18:34:35 +0000 |
140 | @@ -290,6 +290,8 @@ |
141 | mir_screencast_spec_release; |
142 | mir_screencast_spec_set_capture_region; |
143 | mir_screencast_spec_set_height; |
144 | + mir_screencast_spec_set_mirror_mode; |
145 | + mir_screencast_spec_set_number_of_buffers; |
146 | mir_screencast_spec_set_pixel_format; |
147 | mir_screencast_spec_set_width; |
148 | } MIR_CLIENT_0.21; |
149 | |
150 | === modified file 'src/include/server/mir/frontend/screencast.h' |
151 | --- src/include/server/mir/frontend/screencast.h 2015-02-22 07:46:25 +0000 |
152 | +++ src/include/server/mir/frontend/screencast.h 2016-04-20 18:34:35 +0000 |
153 | @@ -41,7 +41,9 @@ |
154 | virtual ScreencastSessionId create_session( |
155 | mir::geometry::Rectangle const& region, |
156 | mir::geometry::Size const& size, |
157 | - MirPixelFormat pixel_format) = 0; |
158 | + MirPixelFormat pixel_format, |
159 | + int nbuffers, |
160 | + MirMirrorMode mirror_mode) = 0; |
161 | virtual void destroy_session(ScreencastSessionId id) = 0; |
162 | virtual std::shared_ptr<graphics::Buffer> capture(ScreencastSessionId id) = 0; |
163 | |
164 | |
165 | === modified file 'src/platforms/android/server/display_buffer.cpp' |
166 | --- src/platforms/android/server/display_buffer.cpp 2016-03-28 23:15:00 +0000 |
167 | +++ src/platforms/android/server/display_buffer.cpp 2016-04-20 18:34:35 +0000 |
168 | @@ -103,6 +103,10 @@ |
169 | gl_context.swap_buffers(); |
170 | } |
171 | |
172 | +void mga::DisplayBuffer::bind() |
173 | +{ |
174 | +} |
175 | + |
176 | MirOrientation mga::DisplayBuffer::orientation() const |
177 | { |
178 | /* |
179 | |
180 | === modified file 'src/platforms/android/server/display_buffer.h' |
181 | --- src/platforms/android/server/display_buffer.h 2016-03-28 23:15:00 +0000 |
182 | +++ src/platforms/android/server/display_buffer.h 2016-04-20 18:34:35 +0000 |
183 | @@ -64,6 +64,7 @@ |
184 | void release_current() override; |
185 | void swap_buffers() override; |
186 | bool post_renderables_if_optimizable(RenderableList const& renderlist) override; |
187 | + void bind() override; |
188 | |
189 | MirOrientation orientation() const override; |
190 | MirMirrorMode mirror_mode() const override; |
191 | |
192 | === modified file 'src/platforms/mesa/server/kms/display_buffer.cpp' |
193 | --- src/platforms/mesa/server/kms/display_buffer.cpp 2016-03-28 23:15:00 +0000 |
194 | +++ src/platforms/mesa/server/kms/display_buffer.cpp 2016-04-20 18:34:35 +0000 |
195 | @@ -456,6 +456,10 @@ |
196 | } |
197 | } |
198 | |
199 | +void mgm::DisplayBuffer::bind() |
200 | +{ |
201 | +} |
202 | + |
203 | void mgm::DisplayBuffer::release_current() |
204 | { |
205 | egl.release_current(); |
206 | |
207 | === modified file 'src/platforms/mesa/server/kms/display_buffer.h' |
208 | --- src/platforms/mesa/server/kms/display_buffer.h 2016-03-28 23:15:00 +0000 |
209 | +++ src/platforms/mesa/server/kms/display_buffer.h 2016-04-20 18:34:35 +0000 |
210 | @@ -67,6 +67,7 @@ |
211 | void release_current() override; |
212 | void swap_buffers() override; |
213 | bool post_renderables_if_optimizable(RenderableList const& renderlist) override; |
214 | + void bind() override; |
215 | |
216 | void for_each_display_buffer( |
217 | std::function<void(graphics::DisplayBuffer&)> const& f) override; |
218 | |
219 | === modified file 'src/platforms/mesa/server/x11/graphics/display_buffer.cpp' |
220 | --- src/platforms/mesa/server/x11/graphics/display_buffer.cpp 2016-03-28 23:15:00 +0000 |
221 | +++ src/platforms/mesa/server/x11/graphics/display_buffer.cpp 2016-04-20 18:34:35 +0000 |
222 | @@ -67,6 +67,10 @@ |
223 | BOOST_THROW_EXCEPTION(mg::egl_error("Cannot swap")); |
224 | } |
225 | |
226 | +void mgx::DisplayBuffer::bind() |
227 | +{ |
228 | +} |
229 | + |
230 | MirOrientation mgx::DisplayBuffer::orientation() const |
231 | { |
232 | return orientation_; |
233 | |
234 | === modified file 'src/platforms/mesa/server/x11/graphics/display_buffer.h' |
235 | --- src/platforms/mesa/server/x11/graphics/display_buffer.h 2016-03-28 23:15:00 +0000 |
236 | +++ src/platforms/mesa/server/x11/graphics/display_buffer.h 2016-04-20 18:34:35 +0000 |
237 | @@ -49,6 +49,7 @@ |
238 | void make_current() override; |
239 | void release_current() override; |
240 | void swap_buffers() override; |
241 | + void bind() override; |
242 | bool post_renderables_if_optimizable(RenderableList const& renderlist) override; |
243 | void set_orientation(MirOrientation const new_orientation); |
244 | |
245 | |
246 | === modified file 'src/protobuf/mir_protobuf.proto' |
247 | --- src/protobuf/mir_protobuf.proto 2016-04-14 05:37:22 +0000 |
248 | +++ src/protobuf/mir_protobuf.proto 2016-04-20 18:34:35 +0000 |
249 | @@ -313,6 +313,8 @@ |
250 | required uint32 width = 2; |
251 | required uint32 height = 3; |
252 | required int32 pixel_format = 4; |
253 | + optional uint32 num_buffers = 5; |
254 | + optional int32 mirror_mode = 6; |
255 | } |
256 | |
257 | message ScreencastId { |
258 | |
259 | === modified file 'src/renderers/gl/renderer.cpp' |
260 | --- src/renderers/gl/renderer.cpp 2016-03-29 17:48:07 +0000 |
261 | +++ src/renderers/gl/renderer.cpp 2016-04-20 18:34:35 +0000 |
262 | @@ -97,6 +97,12 @@ |
263 | render_target->make_current(); |
264 | } |
265 | |
266 | +void mrg::CurrentRenderTarget::bind() |
267 | +{ |
268 | + ensure_current(); |
269 | + render_target->bind(); |
270 | +} |
271 | + |
272 | void mrg::CurrentRenderTarget::swap_buffers() |
273 | { |
274 | render_target->swap_buffers(); |
275 | @@ -228,7 +234,7 @@ |
276 | |
277 | void mrg::Renderer::render(mg::RenderableList const& renderables) const |
278 | { |
279 | - render_target.ensure_current(); |
280 | + render_target.bind(); |
281 | |
282 | glClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]); |
283 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
284 | |
285 | === modified file 'src/renderers/gl/renderer.h' |
286 | --- src/renderers/gl/renderer.h 2016-03-28 23:15:00 +0000 |
287 | +++ src/renderers/gl/renderer.h 2016-04-20 18:34:35 +0000 |
288 | @@ -49,6 +49,7 @@ |
289 | ~CurrentRenderTarget(); |
290 | |
291 | void ensure_current(); |
292 | + void bind(); |
293 | void swap_buffers(); |
294 | |
295 | private: |
296 | |
297 | === modified file 'src/server/compositor/compositing_screencast.cpp' |
298 | --- src/server/compositor/compositing_screencast.cpp 2016-01-27 16:32:36 +0000 |
299 | +++ src/server/compositor/compositing_screencast.cpp 2016-04-20 18:34:35 +0000 |
300 | @@ -18,6 +18,7 @@ |
301 | |
302 | #include "compositing_screencast.h" |
303 | #include "screencast_display_buffer.h" |
304 | +#include "queueing_schedule.h" |
305 | #include "mir/graphics/buffer.h" |
306 | #include "mir/graphics/buffer_properties.h" |
307 | #include "mir/graphics/display.h" |
308 | @@ -65,22 +66,28 @@ |
309 | } |
310 | } |
311 | |
312 | -struct mc::detail::ScreencastSessionContext |
313 | +class mc::detail::ScreencastSessionContext |
314 | { |
315 | +public: |
316 | ScreencastSessionContext( |
317 | std::shared_ptr<Scene> const& scene, |
318 | - std::shared_ptr<graphics::Buffer> const& buffer, |
319 | - std::unique_ptr<graphics::GLContext> gl_context, |
320 | - std::unique_ptr<graphics::DisplayBuffer> display_buffer, |
321 | - std::unique_ptr<compositor::DisplayBufferCompositor> display_buffer_compositor, |
322 | - std::unique_ptr<graphics::VirtualOutput> a_virtual_output) : |
323 | - scene{scene}, |
324 | - buffer{buffer}, |
325 | - gl_context{std::move(gl_context)}, |
326 | - display_buffer{std::move(display_buffer)}, |
327 | - display_buffer_compositor{std::move(display_buffer_compositor)}, |
328 | - virtual_output{std::move(a_virtual_output)} |
329 | + mg::Display& display, |
330 | + mg::GraphicBufferAllocator& buffer_allocator, |
331 | + DisplayBufferCompositorFactory& db_compositor_factory, |
332 | + geom::Rectangle const& capture_region, |
333 | + geom::Size const& capture_size, |
334 | + MirPixelFormat pixel_format, |
335 | + int nbuffers, |
336 | + MirMirrorMode mirror_mode) |
337 | + : scene{scene}, |
338 | + display_buffer{std::make_unique<ScreencastDisplayBuffer>(capture_region, capture_size, mirror_mode, free_queue, ready_queue, display)}, |
339 | + display_buffer_compositor{db_compositor_factory.create_compositor_for(*display_buffer)}, |
340 | + virtual_output{make_virtual_output(display, capture_region)} |
341 | { |
342 | + mg::BufferProperties const buffer_properties{capture_size, pixel_format, mg::BufferUsage::hardware}; |
343 | + for (int i = 0; i < nbuffers; i++) |
344 | + free_queue.schedule(buffer_allocator.alloc_buffer(buffer_properties)); |
345 | + |
346 | scene->register_compositor(this); |
347 | if (virtual_output) |
348 | virtual_output->enable(); |
349 | @@ -90,12 +97,28 @@ |
350 | scene->unregister_compositor(this); |
351 | } |
352 | |
353 | + std::shared_ptr<mg::Buffer> capture() |
354 | + { |
355 | + //FIXME:: the client needs a better way to express it is no longer |
356 | + //using the last captured buffer |
357 | + if (last_captured_buffer) |
358 | + free_queue.schedule(last_captured_buffer); |
359 | + |
360 | + display_buffer_compositor->composite(scene->scene_elements_for(this)); |
361 | + |
362 | + last_captured_buffer = ready_queue.next_buffer(); |
363 | + return last_captured_buffer; |
364 | + } |
365 | + |
366 | +private: |
367 | std::shared_ptr<Scene> const scene; |
368 | - std::shared_ptr<graphics::Buffer> buffer; |
369 | - std::unique_ptr<graphics::GLContext> gl_context; |
370 | - std::unique_ptr<graphics::DisplayBuffer> display_buffer; |
371 | + QueueingSchedule free_queue; |
372 | + QueueingSchedule ready_queue; |
373 | + std::unique_ptr<ScreencastDisplayBuffer> display_buffer; |
374 | + |
375 | std::unique_ptr<compositor::DisplayBufferCompositor> display_buffer_compositor; |
376 | std::unique_ptr<graphics::VirtualOutput> virtual_output; |
377 | + std::shared_ptr<mg::Buffer> last_captured_buffer; |
378 | }; |
379 | |
380 | |
381 | @@ -114,19 +137,22 @@ |
382 | mf::ScreencastSessionId mc::CompositingScreencast::create_session( |
383 | geom::Rectangle const& region, |
384 | geom::Size const& size, |
385 | - MirPixelFormat const pixel_format) |
386 | + MirPixelFormat const pixel_format, |
387 | + int nbuffers, |
388 | + MirMirrorMode mirror_mode) |
389 | { |
390 | if (size.width.as_int() == 0 || |
391 | size.height.as_int() == 0 || |
392 | region.size.width.as_int() == 0 || |
393 | region.size.height.as_int() == 0 || |
394 | - pixel_format == mir_pixel_format_invalid) |
395 | + pixel_format == mir_pixel_format_invalid || |
396 | + nbuffers < 1) |
397 | { |
398 | BOOST_THROW_EXCEPTION(std::runtime_error("Invalid parameters")); |
399 | } |
400 | std::lock_guard<decltype(session_mutex)> lock{session_mutex}; |
401 | auto const id = next_available_session_id(); |
402 | - session_contexts[id] = create_session_context(region, size, pixel_format); |
403 | + session_contexts[id] = create_session_context(region, size, pixel_format, nbuffers, mirror_mode); |
404 | |
405 | return id; |
406 | } |
407 | @@ -134,12 +160,6 @@ |
408 | void mc::CompositingScreencast::destroy_session(mf::ScreencastSessionId id) |
409 | { |
410 | std::lock_guard<decltype(session_mutex)> lock{session_mutex}; |
411 | - auto gl_context = std::move(session_contexts.at(id)->gl_context); |
412 | - |
413 | - auto using_gl_context = mir::raii::paired_calls( |
414 | - [&] { gl_context->make_current(); }, |
415 | - [&] { gl_context->release_current(); }); |
416 | - |
417 | session_contexts.erase(id); |
418 | } |
419 | |
420 | @@ -152,14 +172,7 @@ |
421 | session_context = session_contexts.at(id); |
422 | } |
423 | |
424 | - auto using_gl_context = mir::raii::paired_calls( |
425 | - [&] { session_context->gl_context->make_current(); }, |
426 | - [&] { session_context->gl_context->release_current(); }); |
427 | - |
428 | - session_context->display_buffer_compositor->composite( |
429 | - session_context->scene->scene_elements_for(session_context.get())); |
430 | - |
431 | - return session_context->buffer; |
432 | + return session_context->capture(); |
433 | } |
434 | |
435 | mf::ScreencastSessionId mc::CompositingScreencast::next_available_session_id() |
436 | @@ -178,30 +191,12 @@ |
437 | mc::CompositingScreencast::create_session_context( |
438 | geometry::Rectangle const& rect, |
439 | geometry::Size const& size, |
440 | - MirPixelFormat pixel_format) |
441 | + MirPixelFormat pixel_format, |
442 | + int nbuffers, |
443 | + MirMirrorMode mirror_mode) |
444 | { |
445 | - mg::BufferProperties buffer_properties{ |
446 | - size, |
447 | - pixel_format, |
448 | - mg::BufferUsage::hardware}; |
449 | - |
450 | - auto gl_context = display->create_gl_context(); |
451 | - auto gl_context_raw = gl_context.get(); |
452 | - |
453 | - auto using_gl_context = mir::raii::paired_calls( |
454 | - [&] { gl_context_raw->make_current(); }, |
455 | - [&] { gl_context_raw->release_current(); }); |
456 | - |
457 | - auto buffer = buffer_allocator->alloc_buffer(buffer_properties); |
458 | - auto display_buffer = std::make_unique<ScreencastDisplayBuffer>(rect, *buffer); |
459 | - auto db_compositor = db_compositor_factory->create_compositor_for(*display_buffer); |
460 | - auto virtual_output = make_virtual_output(*display, rect); |
461 | - return std::shared_ptr<detail::ScreencastSessionContext>( |
462 | - new detail::ScreencastSessionContext{ |
463 | - scene, |
464 | - buffer, |
465 | - std::move(gl_context), |
466 | - std::move(display_buffer), |
467 | - std::move(db_compositor), |
468 | - std::move(virtual_output)}); |
469 | + |
470 | + return std::make_shared<detail::ScreencastSessionContext>( |
471 | + scene, *display, *buffer_allocator, *db_compositor_factory, |
472 | + rect, size, pixel_format, nbuffers, mirror_mode); |
473 | } |
474 | |
475 | === modified file 'src/server/compositor/compositing_screencast.h' |
476 | --- src/server/compositor/compositing_screencast.h 2014-10-17 18:03:54 +0000 |
477 | +++ src/server/compositor/compositing_screencast.h 2016-04-20 18:34:35 +0000 |
478 | @@ -52,16 +52,20 @@ |
479 | frontend::ScreencastSessionId create_session( |
480 | geometry::Rectangle const& region, |
481 | geometry::Size const& size, |
482 | - MirPixelFormat pixel_format); |
483 | - void destroy_session(frontend::ScreencastSessionId id); |
484 | - std::shared_ptr<graphics::Buffer> capture(frontend::ScreencastSessionId id); |
485 | + MirPixelFormat pixel_format, |
486 | + int nbuffers, |
487 | + MirMirrorMode mirror_mode) override; |
488 | + void destroy_session(frontend::ScreencastSessionId id) override; |
489 | + std::shared_ptr<graphics::Buffer> capture(frontend::ScreencastSessionId id) override; |
490 | |
491 | private: |
492 | frontend::ScreencastSessionId next_available_session_id(); |
493 | std::shared_ptr<detail::ScreencastSessionContext> |
494 | create_session_context(geometry::Rectangle const& rect, |
495 | geometry::Size const& size, |
496 | - MirPixelFormat pixel_format); |
497 | + MirPixelFormat pixel_format, |
498 | + int nbuffers, |
499 | + MirMirrorMode mirror_mode); |
500 | |
501 | std::mutex session_mutex; |
502 | std::shared_ptr<Scene> const scene; |
503 | |
504 | === modified file 'src/server/compositor/screencast_display_buffer.cpp' |
505 | --- src/server/compositor/screencast_display_buffer.cpp 2016-03-28 23:15:00 +0000 |
506 | +++ src/server/compositor/screencast_display_buffer.cpp 2016-04-20 18:34:35 +0000 |
507 | @@ -17,53 +17,94 @@ |
508 | */ |
509 | |
510 | #include "screencast_display_buffer.h" |
511 | +#include "schedule.h" |
512 | + |
513 | #include "mir/graphics/buffer.h" |
514 | +#include "mir/graphics/display.h" |
515 | +#include "mir/graphics/gl_context.h" |
516 | #include "mir/renderer/gl/texture_source.h" |
517 | +#include "mir/raii.h" |
518 | |
519 | #include <boost/throw_exception.hpp> |
520 | |
521 | namespace mc = mir::compositor; |
522 | namespace mg = mir::graphics; |
523 | +namespace mrgl = mir::renderer::gl; |
524 | namespace geom = mir::geometry; |
525 | |
526 | +namespace |
527 | +{ |
528 | +auto as_texture_source(mg::Buffer* buffer) |
529 | +{ |
530 | + auto tex = dynamic_cast<mrgl::TextureSource*>(buffer->native_buffer_base()); |
531 | + if (!tex) |
532 | + BOOST_THROW_EXCEPTION(std::logic_error("Buffer does not support GL rendering")); |
533 | + return tex; |
534 | +} |
535 | + |
536 | +template <void (*Generate)(GLsizei,GLuint*), void (*Delete)(GLsizei,GLuint const*)> |
537 | +mc::detail::GLResource<Delete> allocate_gl_resource() |
538 | +{ |
539 | + GLuint resource; |
540 | + Generate(1, &resource); |
541 | + return mc::detail::GLResource<Delete>{resource}; |
542 | +} |
543 | +} |
544 | + |
545 | mc::ScreencastDisplayBuffer::ScreencastDisplayBuffer( |
546 | geom::Rectangle const& rect, |
547 | - mg::Buffer& buffer) |
548 | - : rect(rect), buffer(buffer), |
549 | - texture_source( |
550 | - dynamic_cast<mir::renderer::gl::TextureSource*>( |
551 | - buffer.native_buffer_base())), |
552 | + geom::Size const& size, |
553 | + MirMirrorMode mirror_mode, |
554 | + Schedule& free_queue, |
555 | + Schedule& ready_queue, |
556 | + mg::Display& display) |
557 | + : gl_context(display.create_gl_context()), |
558 | + rect(rect), mirror_mode_(mirror_mode), |
559 | + free_queue(free_queue), ready_queue(ready_queue), |
560 | old_fbo(), old_viewport() |
561 | { |
562 | - if (!texture_source) |
563 | - BOOST_THROW_EXCEPTION(std::logic_error("Buffer does not support GL rendering")); |
564 | + auto const gl_context_raii = mir::raii::paired_calls( |
565 | + [this] { gl_context->make_current(); }, |
566 | + [this] { gl_context->release_current(); }); |
567 | + |
568 | glGetIntegerv(GL_VIEWPORT, old_viewport); |
569 | glGetIntegerv(GL_FRAMEBUFFER_BINDING, &old_fbo); |
570 | |
571 | - glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
572 | + auto texture = allocate_gl_resource<glGenTextures, glDeleteTextures>(); |
573 | + auto depth_buffer = allocate_gl_resource<glGenRenderbuffers, glDeleteRenderbuffers>(); |
574 | + auto framebuffer = allocate_gl_resource<glGenFramebuffers, glDeleteFramebuffers>(); |
575 | + |
576 | + glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
577 | |
578 | /* Set up the color buffer... */ |
579 | - glBindTexture(GL_TEXTURE_2D, color_tex); |
580 | + glBindTexture(GL_TEXTURE_2D, texture); |
581 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
582 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
583 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
584 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
585 | |
586 | /* and the depth buffer */ |
587 | - auto const buf_size = buffer.size(); |
588 | - glBindRenderbuffer(GL_RENDERBUFFER, depth_rbo); |
589 | + glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer); |
590 | glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, |
591 | - buf_size.width.as_uint32_t(), |
592 | - buf_size.height.as_uint32_t()); |
593 | + size.width.as_uint32_t(), |
594 | + size.height.as_uint32_t()); |
595 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, |
596 | - GL_RENDERBUFFER, depth_rbo); |
597 | + GL_RENDERBUFFER, depth_buffer); |
598 | |
599 | if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) |
600 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to create FBO for buffer")); |
601 | + |
602 | + color_tex = std::move(texture); |
603 | + depth_rbo = std::move(depth_buffer); |
604 | + fbo = std::move(framebuffer); |
605 | } |
606 | |
607 | mc::ScreencastDisplayBuffer::~ScreencastDisplayBuffer() |
608 | { |
609 | + make_current(); |
610 | + color_tex.reset(); |
611 | + depth_rbo.reset(); |
612 | + fbo.reset(); |
613 | release_current(); |
614 | } |
615 | |
616 | @@ -74,12 +115,21 @@ |
617 | |
618 | void mc::ScreencastDisplayBuffer::make_current() |
619 | { |
620 | + gl_context->make_current(); |
621 | +} |
622 | + |
623 | +void mc::ScreencastDisplayBuffer::bind() |
624 | +{ |
625 | + if (!current_buffer) |
626 | + current_buffer = free_queue.next_buffer(); |
627 | + |
628 | + auto texture_source = as_texture_source(current_buffer.get()); |
629 | glBindTexture(GL_TEXTURE_2D, color_tex); |
630 | - texture_source->gl_bind_to_texture(); |
631 | + texture_source->bind(); |
632 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
633 | GL_TEXTURE_2D, color_tex, 0); |
634 | |
635 | - auto const buf_size = buffer.size(); |
636 | + auto const buf_size = current_buffer->size(); |
637 | |
638 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
639 | glViewport(0, 0, buf_size.width.as_uint32_t(), buf_size.height.as_uint32_t()); |
640 | @@ -90,6 +140,8 @@ |
641 | glBindFramebuffer(GL_FRAMEBUFFER, old_fbo); |
642 | glViewport(old_viewport[0], old_viewport[1], |
643 | old_viewport[2], old_viewport[3]); |
644 | + |
645 | + gl_context->release_current(); |
646 | } |
647 | |
648 | bool mc::ScreencastDisplayBuffer::post_renderables_if_optimizable(mg::RenderableList const&) |
649 | @@ -99,7 +151,16 @@ |
650 | |
651 | void mc::ScreencastDisplayBuffer::swap_buffers() |
652 | { |
653 | - glFinish(); |
654 | + if (current_buffer) |
655 | + { |
656 | + |
657 | + //TODO: replace this with a fence which the client could use |
658 | + //to wait for rendering completion |
659 | + glFinish(); |
660 | + |
661 | + ready_queue.schedule(current_buffer); |
662 | + current_buffer = nullptr; |
663 | + } |
664 | } |
665 | |
666 | MirOrientation mc::ScreencastDisplayBuffer::orientation() const |
667 | @@ -109,7 +170,7 @@ |
668 | |
669 | MirMirrorMode mc::ScreencastDisplayBuffer::mirror_mode() const |
670 | { |
671 | - return mir_mirror_mode_none; |
672 | + return mirror_mode_; |
673 | } |
674 | |
675 | mg::NativeDisplayBuffer* mc::ScreencastDisplayBuffer::native_display_buffer() |
676 | |
677 | === modified file 'src/server/compositor/screencast_display_buffer.h' |
678 | --- src/server/compositor/screencast_display_buffer.h 2016-03-28 23:15:00 +0000 |
679 | +++ src/server/compositor/screencast_display_buffer.h 2016-04-20 18:34:35 +0000 |
680 | @@ -26,27 +26,57 @@ |
681 | |
682 | namespace mir |
683 | { |
684 | +namespace graphics |
685 | +{ |
686 | +class Display; |
687 | +class GLContext; |
688 | +} |
689 | namespace renderer { namespace gl { class TextureSource; }} |
690 | namespace compositor |
691 | { |
692 | + |
693 | namespace detail |
694 | { |
695 | |
696 | -template <void (*Generate)(GLsizei,GLuint*), void (*Delete)(GLsizei,GLuint const*)> |
697 | +template <void (*Delete)(GLsizei,GLuint const*)> |
698 | class GLResource |
699 | { |
700 | public: |
701 | - GLResource() { Generate(1, &resource); } |
702 | - ~GLResource() { Delete(1, &resource); } |
703 | + GLResource() {} |
704 | + GLResource(GLuint resource) : resource{resource} {} |
705 | + ~GLResource() { reset(); } |
706 | + |
707 | operator GLuint() const { return resource; } |
708 | |
709 | + void reset() |
710 | + { |
711 | + if (resource) |
712 | + { |
713 | + Delete(1, &resource); |
714 | + resource = 0; |
715 | + } |
716 | + } |
717 | + |
718 | + GLResource(GLResource&& other) : resource {other.resource} |
719 | + { |
720 | + other.resource = 0; |
721 | + } |
722 | + |
723 | + GLResource& operator=(GLResource&& other) |
724 | + { |
725 | + resource = other.resource; |
726 | + other.resource = 0; |
727 | + return *this; |
728 | + } |
729 | + |
730 | private: |
731 | GLResource(GLResource const&) = delete; |
732 | GLResource& operator=(GLResource const&) = delete; |
733 | - GLuint resource = 0; |
734 | + GLuint resource{0}; |
735 | }; |
736 | } |
737 | |
738 | +class Schedule; |
739 | class ScreencastDisplayBuffer : public graphics::DisplayBuffer, |
740 | public graphics::NativeDisplayBuffer, |
741 | public renderer::gl::RenderTarget |
742 | @@ -54,13 +84,19 @@ |
743 | public: |
744 | ScreencastDisplayBuffer( |
745 | geometry::Rectangle const& rect, |
746 | - graphics::Buffer& buffer); |
747 | + geometry::Size const& size, |
748 | + MirMirrorMode mirror_mode, |
749 | + Schedule& free_queue, |
750 | + Schedule& ready_queue, |
751 | + graphics::Display& display); |
752 | ~ScreencastDisplayBuffer(); |
753 | |
754 | geometry::Rectangle view_area() const override; |
755 | |
756 | void make_current() override; |
757 | |
758 | + void bind() override; |
759 | + |
760 | void release_current() override; |
761 | |
762 | bool post_renderables_if_optimizable(graphics::RenderableList const&) override; |
763 | @@ -74,14 +110,20 @@ |
764 | NativeDisplayBuffer* native_display_buffer() override; |
765 | |
766 | private: |
767 | + std::unique_ptr<graphics::GLContext> gl_context; |
768 | geometry::Rectangle const rect; |
769 | - graphics::Buffer& buffer; |
770 | - renderer::gl::TextureSource* texture_source; |
771 | + MirMirrorMode const mirror_mode_; |
772 | + |
773 | + Schedule& free_queue; |
774 | + Schedule& ready_queue; |
775 | + std::shared_ptr<graphics::Buffer> current_buffer; |
776 | + |
777 | GLint old_fbo; |
778 | GLint old_viewport[4]; |
779 | - detail::GLResource<glGenTextures,glDeleteTextures> const color_tex; |
780 | - detail::GLResource<glGenRenderbuffers,glDeleteRenderbuffers> const depth_rbo; |
781 | - detail::GLResource<glGenFramebuffers,glDeleteFramebuffers> const fbo; |
782 | + |
783 | + detail::GLResource<glDeleteTextures> color_tex; |
784 | + detail::GLResource<glDeleteRenderbuffers> depth_rbo; |
785 | + detail::GLResource<glDeleteFramebuffers> fbo; |
786 | }; |
787 | |
788 | } |
789 | |
790 | === modified file 'src/server/frontend/session_mediator.cpp' |
791 | --- src/server/frontend/session_mediator.cpp 2016-04-15 03:41:28 +0000 |
792 | +++ src/server/frontend/session_mediator.cpp 2016-04-20 18:34:35 +0000 |
793 | @@ -755,7 +755,15 @@ |
794 | geom::Size const size{parameters->width(), parameters->height()}; |
795 | MirPixelFormat const pixel_format = static_cast<MirPixelFormat>(parameters->pixel_format()); |
796 | |
797 | - auto screencast_session_id = screencast->create_session(region, size, pixel_format); |
798 | + int nbuffers = 1; |
799 | + if (parameters->has_num_buffers()) |
800 | + nbuffers = parameters->num_buffers(); |
801 | + |
802 | + MirMirrorMode mirror_mode = mir_mirror_mode_none; |
803 | + if (parameters->has_mirror_mode()) |
804 | + mirror_mode = static_cast<MirMirrorMode>(parameters->mirror_mode()); |
805 | + |
806 | + auto screencast_session_id = screencast->create_session(region, size, pixel_format, nbuffers, mirror_mode); |
807 | auto buffer = screencast->capture(screencast_session_id); |
808 | |
809 | protobuf_screencast->mutable_screencast_id()->set_value( |
810 | @@ -786,7 +794,7 @@ |
811 | mir::protobuf::Buffer* protobuf_buffer, |
812 | google::protobuf::Closure* done) |
813 | { |
814 | - static auto const msg_type = mg::BufferIpcMsgType::update_msg; |
815 | + static auto const msg_type = mg::BufferIpcMsgType::full_msg; |
816 | ScreencastSessionId const screencast_session_id{ |
817 | protobuf_screencast_id->value()}; |
818 | |
819 | |
820 | === modified file 'src/server/frontend/unauthorized_screencast.cpp' |
821 | --- src/server/frontend/unauthorized_screencast.cpp 2014-03-20 09:36:44 +0000 |
822 | +++ src/server/frontend/unauthorized_screencast.cpp 2016-04-20 18:34:35 +0000 |
823 | @@ -24,9 +24,9 @@ |
824 | namespace mf = mir::frontend; |
825 | |
826 | mf::ScreencastSessionId mf::UnauthorizedScreencast::create_session( |
827 | - geometry::Rectangle const&, |
828 | - geometry::Size const&, |
829 | - MirPixelFormat) |
830 | + mir::geometry::Rectangle const&, |
831 | + mir::geometry::Size const&, |
832 | + MirPixelFormat, int, MirMirrorMode) |
833 | { |
834 | BOOST_THROW_EXCEPTION( |
835 | std::runtime_error("Process is not authorized to capture screencasts")); |
836 | |
837 | === modified file 'src/server/frontend/unauthorized_screencast.h' |
838 | --- src/server/frontend/unauthorized_screencast.h 2014-03-20 09:36:44 +0000 |
839 | +++ src/server/frontend/unauthorized_screencast.h 2016-04-20 18:34:35 +0000 |
840 | @@ -30,9 +30,11 @@ |
841 | { |
842 | public: |
843 | ScreencastSessionId create_session( |
844 | - geometry::Rectangle const& region, |
845 | - geometry::Size const& size, |
846 | - MirPixelFormat pixel_format) override; |
847 | + mir::geometry::Rectangle const& region, |
848 | + mir::geometry::Size const& size, |
849 | + MirPixelFormat pixel_format, |
850 | + int nbuffers, |
851 | + MirMirrorMode mirror_mode) override; |
852 | void destroy_session(frontend::ScreencastSessionId id) override; |
853 | std::shared_ptr<graphics::Buffer> capture(frontend::ScreencastSessionId id) override; |
854 | }; |
855 | |
856 | === modified file 'src/server/graphics/nested/display_buffer.cpp' |
857 | --- src/server/graphics/nested/display_buffer.cpp 2016-04-04 03:30:04 +0000 |
858 | +++ src/server/graphics/nested/display_buffer.cpp 2016-04-20 18:34:35 +0000 |
859 | @@ -73,6 +73,10 @@ |
860 | eglSwapBuffers(egl_display, egl_surface); |
861 | } |
862 | |
863 | +void mgn::detail::DisplayBuffer::bind() |
864 | +{ |
865 | +} |
866 | + |
867 | bool mgn::detail::DisplayBuffer::post_renderables_if_optimizable(RenderableList const&) |
868 | { |
869 | return false; |
870 | |
871 | === modified file 'src/server/graphics/nested/display_buffer.h' |
872 | --- src/server/graphics/nested/display_buffer.h 2016-03-28 23:15:00 +0000 |
873 | +++ src/server/graphics/nested/display_buffer.h 2016-04-20 18:34:35 +0000 |
874 | @@ -60,6 +60,7 @@ |
875 | void make_current() override; |
876 | void release_current() override; |
877 | void swap_buffers() override; |
878 | + void bind() override; |
879 | MirOrientation orientation() const override; |
880 | MirMirrorMode mirror_mode() const override; |
881 | |
882 | |
883 | === modified file 'src/server/graphics/offscreen/display_buffer.cpp' |
884 | --- src/server/graphics/offscreen/display_buffer.cpp 2016-03-28 23:15:00 +0000 |
885 | +++ src/server/graphics/offscreen/display_buffer.cpp 2016-04-20 18:34:35 +0000 |
886 | @@ -130,6 +130,10 @@ |
887 | void mgo::DisplayBuffer::make_current() |
888 | { |
889 | egl_context.make_current(); |
890 | +} |
891 | + |
892 | +void mgo::DisplayBuffer::bind() |
893 | +{ |
894 | fbo.bind(); |
895 | } |
896 | |
897 | |
898 | === modified file 'src/server/graphics/offscreen/display_buffer.h' |
899 | --- src/server/graphics/offscreen/display_buffer.h 2016-03-28 23:15:00 +0000 |
900 | +++ src/server/graphics/offscreen/display_buffer.h 2016-04-20 18:34:35 +0000 |
901 | @@ -67,6 +67,7 @@ |
902 | |
903 | geometry::Rectangle view_area() const override; |
904 | void make_current() override; |
905 | + void bind() override; |
906 | void release_current() override; |
907 | void swap_buffers() override; |
908 | |
909 | |
910 | === modified file 'tests/include/mir/test/doubles/mock_gl_display_buffer.h' |
911 | --- tests/include/mir/test/doubles/mock_gl_display_buffer.h 2015-10-01 08:58:30 +0000 |
912 | +++ tests/include/mir/test/doubles/mock_gl_display_buffer.h 2016-04-20 18:34:35 +0000 |
913 | @@ -36,6 +36,7 @@ |
914 | MOCK_METHOD0(make_current, void()); |
915 | MOCK_METHOD0(release_current, void()); |
916 | MOCK_METHOD0(swap_buffers, void()); |
917 | + MOCK_METHOD0(bind, void()); |
918 | }; |
919 | |
920 | } |
921 | |
922 | === modified file 'tests/include/mir/test/doubles/mock_screencast.h' |
923 | --- tests/include/mir/test/doubles/mock_screencast.h 2014-03-05 21:12:05 +0000 |
924 | +++ tests/include/mir/test/doubles/mock_screencast.h 2016-04-20 18:34:35 +0000 |
925 | @@ -33,11 +33,13 @@ |
926 | class MockScreencast : public frontend::Screencast |
927 | { |
928 | public: |
929 | - MOCK_METHOD3(create_session, |
930 | + MOCK_METHOD5(create_session, |
931 | frontend::ScreencastSessionId( |
932 | geometry::Rectangle const&, |
933 | geometry::Size const&, |
934 | - MirPixelFormat)); |
935 | + MirPixelFormat, |
936 | + int, |
937 | + MirMirrorMode)); |
938 | MOCK_METHOD1(destroy_session, void(frontend::ScreencastSessionId)); |
939 | MOCK_METHOD1(capture, |
940 | std::shared_ptr<graphics::Buffer>( |
941 | |
942 | === modified file 'tests/include/mir/test/doubles/null_screencast.h' |
943 | --- tests/include/mir/test/doubles/null_screencast.h 2014-03-05 21:12:05 +0000 |
944 | +++ tests/include/mir/test/doubles/null_screencast.h 2016-04-20 18:34:35 +0000 |
945 | @@ -34,7 +34,9 @@ |
946 | frontend::ScreencastSessionId create_session( |
947 | geometry::Rectangle const&, |
948 | geometry::Size const&, |
949 | - MirPixelFormat) |
950 | + MirPixelFormat, |
951 | + int, |
952 | + MirMirrorMode) |
953 | { |
954 | return frontend::ScreencastSessionId{1}; |
955 | } |
956 | |
957 | === modified file 'tests/include/mir/test/doubles/stub_gl_display_buffer.h' |
958 | --- tests/include/mir/test/doubles/stub_gl_display_buffer.h 2015-10-01 08:58:30 +0000 |
959 | +++ tests/include/mir/test/doubles/stub_gl_display_buffer.h 2016-04-20 18:34:35 +0000 |
960 | @@ -38,6 +38,7 @@ |
961 | void make_current() override {} |
962 | void release_current() override {} |
963 | void swap_buffers() override {} |
964 | + void bind() override {} |
965 | }; |
966 | |
967 | } |
968 | |
969 | === modified file 'tests/integration-tests/test_client_screencast.cpp' |
970 | --- tests/integration-tests/test_client_screencast.cpp 2016-03-25 20:24:48 +0000 |
971 | +++ tests/integration-tests/test_client_screencast.cpp 2016-04-20 18:34:35 +0000 |
972 | @@ -107,7 +107,7 @@ |
973 | InSequence seq; |
974 | |
975 | EXPECT_CALL(mock_screencast(), |
976 | - create_session(_, _, _)) |
977 | + create_session(_, _, _, _, _)) |
978 | .WillOnce(Return(screencast_session_id)); |
979 | |
980 | EXPECT_CALL(mock_screencast(), capture(screencast_session_id)) |
981 | @@ -137,7 +137,7 @@ |
982 | InSequence seq; |
983 | |
984 | EXPECT_CALL(mock_screencast(), |
985 | - create_session(region, size, pixel_format)) |
986 | + create_session(region, size, pixel_format,_,_)) |
987 | .WillOnce(Return(screencast_session_id)); |
988 | |
989 | EXPECT_CALL(mock_screencast(), capture(_)) |
990 | @@ -159,7 +159,7 @@ |
991 | mf::ScreencastSessionId const screencast_session_id{99}; |
992 | |
993 | InSequence seq; |
994 | - EXPECT_CALL(mock_screencast(), create_session(_, _, _)) |
995 | + EXPECT_CALL(mock_screencast(), create_session(_, _, _, _, _)) |
996 | .WillOnce(Return(screencast_session_id)); |
997 | EXPECT_CALL(mock_screencast(), capture(_)) |
998 | .WillOnce(Return(std::make_shared<mtd::StubBuffer>())); |
999 | @@ -180,7 +180,7 @@ |
1000 | { |
1001 | using namespace testing; |
1002 | std::string const an_error_message{"boring error message"}; |
1003 | - EXPECT_CALL(mock_screencast(), create_session(_, _, _)) |
1004 | + EXPECT_CALL(mock_screencast(), create_session(_, _, _, _, _)) |
1005 | .WillOnce(Throw(std::runtime_error(an_error_message))); |
1006 | |
1007 | auto screencast = mir_connection_create_screencast_sync(connection, &default_screencast_params); |
1008 | @@ -202,11 +202,13 @@ |
1009 | {default_screencast_params.region.left, default_screencast_params.region.top}, |
1010 | {default_screencast_params.region.width, default_screencast_params.region.height}}; |
1011 | MirPixelFormat const pixel_format {default_screencast_params.pixel_format}; |
1012 | + int const num_buffers{3}; |
1013 | + MirMirrorMode const mirror_mode{mir_mirror_mode_vertical}; |
1014 | |
1015 | InSequence seq; |
1016 | |
1017 | EXPECT_CALL(mock_screencast(), |
1018 | - create_session(region, size, pixel_format)) |
1019 | + create_session(region, size, pixel_format, num_buffers, mirror_mode)) |
1020 | .WillOnce(Return(screencast_session_id)); |
1021 | |
1022 | EXPECT_CALL(mock_screencast(), capture(_)) |
1023 | @@ -222,6 +224,9 @@ |
1024 | MirRectangle const capture_region = as_mir_rect(region); |
1025 | mir_screencast_spec_set_capture_region(spec, &capture_region); |
1026 | |
1027 | + mir_screencast_spec_set_number_of_buffers(spec, num_buffers); |
1028 | + mir_screencast_spec_set_mirror_mode(spec, mirror_mode); |
1029 | + |
1030 | auto screencast = mir_screencast_create_sync(spec); |
1031 | ASSERT_NE(nullptr, screencast); |
1032 | ASSERT_TRUE(mir_screencast_is_valid(screencast)); |
1033 | |
1034 | === modified file 'tests/mir_test/test_dispatchable.cpp' |
1035 | --- tests/mir_test/test_dispatchable.cpp 2015-06-25 03:00:08 +0000 |
1036 | +++ tests/mir_test/test_dispatchable.cpp 2016-04-20 18:34:35 +0000 |
1037 | @@ -24,6 +24,8 @@ |
1038 | #include <gtest/gtest.h> |
1039 | #include <gmock/gmock.h> |
1040 | |
1041 | +#include <system_error> |
1042 | + |
1043 | namespace mt = mir::test; |
1044 | namespace md = mir::dispatch; |
1045 | |
1046 | @@ -72,9 +74,21 @@ |
1047 | |
1048 | void mt::TestDispatchable::trigger() |
1049 | { |
1050 | + std::cerr << "mt::TestDispatchable::trigger " << std::endl; |
1051 | using namespace testing; |
1052 | char dummy{0}; |
1053 | - EXPECT_THAT(::write(write_fd, &dummy, sizeof(dummy)), Eq(sizeof(dummy))); |
1054 | + auto expected_size = sizeof(dummy); |
1055 | + auto written_size = ::write(write_fd, &dummy, expected_size); |
1056 | + if (written_size < 0) |
1057 | + { |
1058 | + std::system_error e{errno, std::system_category()}; |
1059 | + std::cerr << "Failed to write dummy data: " << e.what() << std::endl; |
1060 | + } |
1061 | + else if (written_size != sizeof(dummy)) |
1062 | + { |
1063 | + std::cerr << "Failed to write dummy data" << std::endl; |
1064 | + } |
1065 | + EXPECT_THAT(written_size, Eq(expected_size)); |
1066 | } |
1067 | |
1068 | void mt::TestDispatchable::untrigger() |
1069 | |
1070 | === modified file 'tests/unit-tests/compositor/test_compositing_screencast.cpp' |
1071 | --- tests/unit-tests/compositor/test_compositing_screencast.cpp 2016-02-01 22:53:06 +0000 |
1072 | +++ tests/unit-tests/compositor/test_compositing_screencast.cpp 2016-04-20 18:34:35 +0000 |
1073 | @@ -24,6 +24,7 @@ |
1074 | #include "mir/graphics/graphic_buffer_allocator.h" |
1075 | #include "mir/geometry/rectangle.h" |
1076 | #include "mir/geometry/rectangles.h" |
1077 | +#include "mir/renderer/gl/render_target.h" |
1078 | |
1079 | #include "mir/test/doubles/null_display.h" |
1080 | #include "mir/test/doubles/null_display_buffer_compositor_factory.h" |
1081 | @@ -35,6 +36,7 @@ |
1082 | #include "mir/test/doubles/stub_scene_element.h" |
1083 | #include "mir/test/doubles/mock_scene.h" |
1084 | |
1085 | +#include "mir/test/as_render_target.h" |
1086 | #include "mir/test/fake_shared.h" |
1087 | |
1088 | #include <boost/throw_exception.hpp> |
1089 | @@ -49,6 +51,7 @@ |
1090 | namespace mf = mir::frontend; |
1091 | namespace mtd = mir::test::doubles; |
1092 | namespace mt = mir::test; |
1093 | +namespace mrgl = mir::renderer::gl; |
1094 | namespace geom = mir::geometry; |
1095 | |
1096 | namespace |
1097 | @@ -129,21 +132,27 @@ |
1098 | class WrappingDisplayBufferCompositor : public mc::DisplayBufferCompositor |
1099 | { |
1100 | public: |
1101 | - WrappingDisplayBufferCompositor(mc::DisplayBufferCompositor& comp) |
1102 | - : comp(comp) |
1103 | + WrappingDisplayBufferCompositor(mc::DisplayBufferCompositor& comp, mg::DisplayBuffer& db) |
1104 | + : comp(comp), |
1105 | + render_target(mt::as_render_target(db)) |
1106 | { |
1107 | + //TODO: we shouldn't need to care if the display buffer is GL capable |
1108 | + if (!render_target) |
1109 | + BOOST_THROW_EXCEPTION(std::logic_error("Display Buffer does not support GL rendering")); |
1110 | } |
1111 | |
1112 | void composite(mc::SceneElementSequence&& elements) |
1113 | { |
1114 | + render_target->bind(); |
1115 | comp.composite(std::move(elements)); |
1116 | + render_target->swap_buffers(); |
1117 | } |
1118 | |
1119 | private: |
1120 | mc::DisplayBufferCompositor& comp; |
1121 | + mrgl::RenderTarget* render_target; |
1122 | }; |
1123 | |
1124 | - |
1125 | struct MockBufferAllocator : mg::GraphicBufferAllocator |
1126 | { |
1127 | MOCK_METHOD1(alloc_buffer, |
1128 | @@ -154,11 +163,10 @@ |
1129 | |
1130 | struct MockDisplayBufferCompositorFactory : mc::DisplayBufferCompositorFactory |
1131 | { |
1132 | - std::unique_ptr<mc::DisplayBufferCompositor> create_compositor_for(mg::DisplayBuffer& db) |
1133 | + std::unique_ptr<mc::DisplayBufferCompositor> create_compositor_for(mg::DisplayBuffer& db) override |
1134 | { |
1135 | create_compositor_mock(db); |
1136 | - return std::unique_ptr<WrappingDisplayBufferCompositor>( |
1137 | - new WrappingDisplayBufferCompositor{mock_db_compositor}); |
1138 | + return std::make_unique<WrappingDisplayBufferCompositor>(mock_db_compositor, db); |
1139 | } |
1140 | |
1141 | MockDisplayBufferCompositor mock_db_compositor; |
1142 | @@ -166,6 +174,20 @@ |
1143 | MOCK_METHOD1(create_compositor_mock, void(mg::DisplayBuffer&)); |
1144 | }; |
1145 | |
1146 | +struct StubDisplayBufferCompositor : mc::DisplayBufferCompositor |
1147 | +{ |
1148 | + void composite(mc::SceneElementSequence&&) override {} |
1149 | +}; |
1150 | + |
1151 | +struct StubDisplayBufferCompositorFactory : mc::DisplayBufferCompositorFactory |
1152 | +{ |
1153 | + std::unique_ptr<mc::DisplayBufferCompositor> create_compositor_for(mg::DisplayBuffer& db) override |
1154 | + { |
1155 | + return std::make_unique<WrappingDisplayBufferCompositor>(stub_db_compositor, db); |
1156 | + } |
1157 | + StubDisplayBufferCompositor stub_db_compositor; |
1158 | +}; |
1159 | + |
1160 | MATCHER_P(DisplayBufferCoversArea, output_extents, "") |
1161 | { |
1162 | return arg.view_area() == output_extents; |
1163 | @@ -193,11 +215,13 @@ |
1164 | mtd::StubScene stub_scene; |
1165 | StubDisplay stub_display; |
1166 | mtd::StubGLBufferAllocator stub_buffer_allocator; |
1167 | - mtd::NullDisplayBufferCompositorFactory stub_db_compositor_factory; |
1168 | + StubDisplayBufferCompositorFactory stub_db_compositor_factory; |
1169 | mc::CompositingScreencast screencast; |
1170 | geom::Size const default_size; |
1171 | geom::Rectangle const default_region; |
1172 | - MirPixelFormat default_pixel_format; |
1173 | + MirPixelFormat const default_pixel_format; |
1174 | + int const default_num_buffers{2}; |
1175 | + MirMirrorMode const default_mirror_mode{mir_mirror_mode_vertical}; |
1176 | }; |
1177 | |
1178 | } |
1179 | @@ -208,7 +232,9 @@ |
1180 | |
1181 | for (int i = 0; i != 10; ++i) |
1182 | { |
1183 | - auto session_id = screencast.create_session(default_region, default_size, default_pixel_format); |
1184 | + auto session_id = screencast.create_session( |
1185 | + default_region, default_size, default_pixel_format, |
1186 | + default_num_buffers, default_mirror_mode); |
1187 | ASSERT_TRUE(session_ids.find(session_id) == session_ids.end()) |
1188 | << "session_id: " << session_id << " iter: " << i; |
1189 | session_ids.insert(session_id); |
1190 | @@ -221,9 +247,10 @@ |
1191 | geom::Size invalid_size{0, 0}; |
1192 | geom::Rectangle invalid_region{{0, 0}, {0, 0}}; |
1193 | |
1194 | - EXPECT_THROW(screencast.create_session(invalid_region, default_size, default_pixel_format), std::runtime_error); |
1195 | - EXPECT_THROW(screencast.create_session(default_region, invalid_size, default_pixel_format), std::runtime_error); |
1196 | - EXPECT_THROW(screencast.create_session(default_region, default_size, mir_pixel_format_invalid), std::runtime_error); |
1197 | + EXPECT_THROW(screencast.create_session(invalid_region, default_size, default_pixel_format, default_num_buffers, default_mirror_mode), std::runtime_error); |
1198 | + EXPECT_THROW(screencast.create_session(default_region, invalid_size, default_pixel_format, default_num_buffers, default_mirror_mode), std::runtime_error); |
1199 | + EXPECT_THROW(screencast.create_session(default_region, default_size, mir_pixel_format_invalid, default_num_buffers, default_mirror_mode), std::runtime_error); |
1200 | + EXPECT_THROW(screencast.create_session(default_region, default_size, mir_pixel_format_invalid, 0, default_mirror_mode), std::runtime_error); |
1201 | } |
1202 | |
1203 | TEST_F(CompositingScreencastTest, throws_on_capture_with_invalid_session_id) |
1204 | @@ -234,7 +261,9 @@ |
1205 | |
1206 | TEST_F(CompositingScreencastTest, throws_on_capture_with_destroyed_session_id) |
1207 | { |
1208 | - auto session_id = screencast.create_session(default_region, default_size, default_pixel_format); |
1209 | + auto session_id = screencast.create_session( |
1210 | + default_region, default_size, default_pixel_format, |
1211 | + default_num_buffers, default_mirror_mode); |
1212 | screencast.destroy_session(session_id); |
1213 | EXPECT_THROW(screencast.capture(session_id), std::logic_error); |
1214 | } |
1215 | @@ -262,7 +291,9 @@ |
1216 | mt::fake_shared(stub_buffer_allocator), |
1217 | mt::fake_shared(mock_db_compositor_factory)}; |
1218 | |
1219 | - auto session_id = screencast_local.create_session(default_region, default_size, default_pixel_format); |
1220 | + auto session_id = screencast_local.create_session( |
1221 | + default_region, default_size, default_pixel_format, |
1222 | + default_num_buffers, default_mirror_mode); |
1223 | |
1224 | screencast_local.capture(session_id); |
1225 | } |
1226 | @@ -285,13 +316,15 @@ |
1227 | mt::fake_shared(mock_buffer_allocator), |
1228 | mt::fake_shared(stub_db_compositor_factory)}; |
1229 | |
1230 | - auto session_id = screencast_local.create_session(default_region, default_size, default_pixel_format); |
1231 | + auto session_id = screencast_local.create_session( |
1232 | + default_region, default_size, default_pixel_format, |
1233 | + 1, default_mirror_mode); |
1234 | |
1235 | auto buffer = screencast_local.capture(session_id); |
1236 | ASSERT_EQ(&stub_buffer, buffer.get()); |
1237 | } |
1238 | |
1239 | -TEST_F(CompositingScreencastTest, uses_one_buffer_per_session) |
1240 | +TEST_F(CompositingScreencastTest, allocates_different_buffers_per_session) |
1241 | { |
1242 | using namespace testing; |
1243 | |
1244 | @@ -309,13 +342,17 @@ |
1245 | mt::fake_shared(mock_buffer_allocator), |
1246 | mt::fake_shared(stub_db_compositor_factory)}; |
1247 | |
1248 | - auto session_id1 = screencast_local.create_session(default_region, default_size, default_pixel_format); |
1249 | + auto session_id1 = screencast_local.create_session( |
1250 | + default_region, default_size, default_pixel_format, |
1251 | + 1, default_mirror_mode); |
1252 | auto buffer1 = screencast_local.capture(session_id1); |
1253 | ASSERT_EQ(&stub_buffer1, buffer1.get()); |
1254 | buffer1 = screencast_local.capture(session_id1); |
1255 | ASSERT_EQ(&stub_buffer1, buffer1.get()); |
1256 | |
1257 | - auto session_id2 = screencast_local.create_session(default_region, default_size, default_pixel_format); |
1258 | + auto session_id2 = screencast_local.create_session( |
1259 | + default_region, default_size, default_pixel_format, |
1260 | + 1, default_mirror_mode); |
1261 | auto buffer2 = screencast_local.capture(session_id2); |
1262 | ASSERT_EQ(&stub_buffer2, buffer2.get()); |
1263 | buffer2 = screencast_local.capture(session_id2); |
1264 | @@ -327,6 +364,7 @@ |
1265 | using namespace testing; |
1266 | NiceMock<mtd::MockScene> mock_scene; |
1267 | NiceMock<MockBufferAllocator> mock_buffer_allocator; |
1268 | + |
1269 | ON_CALL(mock_buffer_allocator, alloc_buffer(_)) |
1270 | .WillByDefault(Return(std::make_shared<mtd::StubGLBuffer>())); |
1271 | |
1272 | @@ -341,7 +379,9 @@ |
1273 | mt::fake_shared(mock_buffer_allocator), |
1274 | mt::fake_shared(stub_db_compositor_factory)}; |
1275 | |
1276 | - auto session_id = screencast_local.create_session(default_region, default_size, default_pixel_format); |
1277 | + auto session_id = screencast_local.create_session( |
1278 | + default_region, default_size, default_pixel_format, |
1279 | + default_num_buffers, default_mirror_mode); |
1280 | screencast_local.destroy_session(session_id); |
1281 | } |
1282 | |
1283 | @@ -357,7 +397,9 @@ |
1284 | mt::fake_shared(stub_buffer_allocator), |
1285 | mt::fake_shared(stub_db_compositor_factory)}; |
1286 | |
1287 | - auto session_id = screencast_local.create_session(region_outside_display, default_size, default_pixel_format); |
1288 | + auto session_id = screencast_local.create_session( |
1289 | + region_outside_display, default_size, default_pixel_format, |
1290 | + default_num_buffers, default_mirror_mode); |
1291 | screencast_local.destroy_session(session_id); |
1292 | |
1293 | EXPECT_TRUE(stub_display.virtual_output_created); |
1294 | @@ -376,7 +418,9 @@ |
1295 | mt::fake_shared(stub_buffer_allocator), |
1296 | mt::fake_shared(stub_db_compositor_factory)}; |
1297 | |
1298 | - auto session_id = screencast_local.create_session(region_inside_display, default_size, default_pixel_format); |
1299 | + auto session_id = screencast_local.create_session( |
1300 | + region_inside_display, default_size, default_pixel_format, |
1301 | + default_num_buffers, default_mirror_mode); |
1302 | screencast_local.destroy_session(session_id); |
1303 | |
1304 | EXPECT_FALSE(stub_display.virtual_output_created); |
1305 | @@ -384,3 +428,36 @@ |
1306 | } |
1307 | |
1308 | |
1309 | +TEST_F(CompositingScreencastTest, uses_requested_number_of_buffers) |
1310 | +{ |
1311 | + using namespace testing; |
1312 | + |
1313 | + MockBufferAllocator mock_buffer_allocator; |
1314 | + int const expected_num_buffers = 4; |
1315 | + std::vector<mtd::StubGLBuffer> buffers(expected_num_buffers); |
1316 | + |
1317 | + |
1318 | + EXPECT_CALL(mock_buffer_allocator, alloc_buffer(_)) |
1319 | + .WillOnce(Return(mt::fake_shared(buffers[0]))) |
1320 | + .WillOnce(Return(mt::fake_shared(buffers[1]))) |
1321 | + .WillOnce(Return(mt::fake_shared(buffers[2]))) |
1322 | + .WillOnce(Return(mt::fake_shared(buffers[3]))); |
1323 | + |
1324 | + mc::CompositingScreencast screencast_local{ |
1325 | + mt::fake_shared(stub_scene), |
1326 | + mt::fake_shared(stub_display), |
1327 | + mt::fake_shared(mock_buffer_allocator), |
1328 | + mt::fake_shared(stub_db_compositor_factory)}; |
1329 | + |
1330 | + auto session_id = screencast_local.create_session( |
1331 | + default_region, default_size, default_pixel_format, |
1332 | + expected_num_buffers, default_mirror_mode); |
1333 | + |
1334 | + for (int i = 0; i < expected_num_buffers; i++) |
1335 | + { |
1336 | + auto buffer = screencast_local.capture(session_id); |
1337 | + ASSERT_EQ(&buffers[i], buffer.get()); |
1338 | + } |
1339 | +} |
1340 | + |
1341 | + |
1342 | |
1343 | === modified file 'tests/unit-tests/compositor/test_screencast_display_buffer.cpp' |
1344 | --- tests/unit-tests/compositor/test_screencast_display_buffer.cpp 2016-01-29 08:18:22 +0000 |
1345 | +++ tests/unit-tests/compositor/test_screencast_display_buffer.cpp 2016-04-20 18:34:35 +0000 |
1346 | @@ -17,33 +17,50 @@ |
1347 | */ |
1348 | |
1349 | #include "src/server/compositor/screencast_display_buffer.h" |
1350 | +#include "src/server/compositor/queueing_schedule.h" |
1351 | |
1352 | +#include "mir/test/fake_shared.h" |
1353 | #include "mir/test/doubles/mock_gl_buffer.h" |
1354 | #include "mir/test/doubles/stub_gl_buffer.h" |
1355 | #include "mir/test/doubles/mock_gl.h" |
1356 | #include "mir/test/doubles/stub_renderable.h" |
1357 | +#include "mir/test/doubles/stub_display.h" |
1358 | |
1359 | #include <gtest/gtest.h> |
1360 | #include <gmock/gmock.h> |
1361 | |
1362 | namespace mc = mir::compositor; |
1363 | +namespace mt = mir::test; |
1364 | namespace mtd = mir::test::doubles; |
1365 | namespace geom = mir::geometry; |
1366 | namespace mg = mir::graphics; |
1367 | |
1368 | +using namespace testing; |
1369 | + |
1370 | namespace |
1371 | { |
1372 | |
1373 | struct ScreencastDisplayBufferTest : testing::Test |
1374 | { |
1375 | + void SetUp() override |
1376 | + { |
1377 | + free_queue.schedule(mt::fake_shared(stub_buffer)); |
1378 | + } |
1379 | + |
1380 | testing::NiceMock<mtd::MockGL> mock_gl; |
1381 | + mc::QueueingSchedule free_queue; |
1382 | + mc::QueueingSchedule ready_queue; |
1383 | + mtd::StubGLBuffer stub_buffer; |
1384 | + mtd::StubDisplay stub_display{1}; |
1385 | + geom::Size const default_size{300,400}; |
1386 | + geom::Rectangle const default_rect{{100,100}, {800,600}}; |
1387 | + MirMirrorMode const default_mirror_mode{mir_mirror_mode_vertical}; |
1388 | }; |
1389 | |
1390 | } |
1391 | |
1392 | TEST_F(ScreencastDisplayBufferTest, cleans_up_gl_resources) |
1393 | { |
1394 | - using namespace testing; |
1395 | GLuint const texture{11}; |
1396 | GLuint const renderbuffer{12}; |
1397 | GLuint const framebuffer{13}; |
1398 | @@ -59,15 +76,13 @@ |
1399 | EXPECT_CALL(mock_gl, glDeleteRenderbuffers(1,Pointee(renderbuffer))); |
1400 | EXPECT_CALL(mock_gl, glDeleteFramebuffers(1,Pointee(framebuffer))); |
1401 | |
1402 | - geom::Rectangle const rect{{100,100}, {800,600}}; |
1403 | - mtd::StubGLBuffer stub_buffer; |
1404 | - |
1405 | - mc::ScreencastDisplayBuffer db{rect, stub_buffer}; |
1406 | + mc::ScreencastDisplayBuffer db{default_rect, default_size, |
1407 | + default_mirror_mode, free_queue, |
1408 | + ready_queue, stub_display}; |
1409 | } |
1410 | |
1411 | TEST_F(ScreencastDisplayBufferTest, cleans_up_gl_resources_on_construction_failure) |
1412 | { |
1413 | - using namespace testing; |
1414 | GLuint const texture{11}; |
1415 | GLuint const renderbuffer{12}; |
1416 | GLuint const framebuffer{13}; |
1417 | @@ -86,42 +101,37 @@ |
1418 | EXPECT_CALL(mock_gl, glDeleteRenderbuffers(1,Pointee(renderbuffer))); |
1419 | EXPECT_CALL(mock_gl, glDeleteFramebuffers(1,Pointee(framebuffer))); |
1420 | |
1421 | - geom::Rectangle const rect{{100,100}, {800,600}}; |
1422 | - mtd::StubGLBuffer stub_buffer; |
1423 | - |
1424 | EXPECT_THROW({ |
1425 | - mc::ScreencastDisplayBuffer db(rect, stub_buffer); |
1426 | + mc::ScreencastDisplayBuffer db(default_rect, default_size, |
1427 | + default_mirror_mode, free_queue, |
1428 | + ready_queue, stub_display); |
1429 | }, std::runtime_error); |
1430 | } |
1431 | |
1432 | -TEST_F(ScreencastDisplayBufferTest, sets_render_buffer_size_to_supplied_buffer_size) |
1433 | +TEST_F(ScreencastDisplayBufferTest, sets_render_buffer_size_to_supplied_size) |
1434 | { |
1435 | - using namespace testing; |
1436 | - |
1437 | - geom::Rectangle const rect{{100,100}, {800,600}}; |
1438 | - testing::NiceMock<mtd::MockGLBuffer> mock_buffer{ |
1439 | - rect.size, geom::Stride{100}, mir_pixel_format_xbgr_8888}; |
1440 | - |
1441 | /* Set the buffer as rendering target */ |
1442 | EXPECT_CALL(mock_gl, |
1443 | - glRenderbufferStorage(_, _, |
1444 | - mock_buffer.size().width.as_int(), |
1445 | - mock_buffer.size().height.as_int())); |
1446 | + glRenderbufferStorage(_, _, |
1447 | + default_size.width.as_int(), |
1448 | + default_size.height.as_int())); |
1449 | |
1450 | - mc::ScreencastDisplayBuffer db{rect, mock_buffer}; |
1451 | + mc::ScreencastDisplayBuffer db{default_rect, default_size, |
1452 | + default_mirror_mode, free_queue, |
1453 | + ready_queue, stub_display}; |
1454 | } |
1455 | |
1456 | TEST_F(ScreencastDisplayBufferTest, renders_to_supplied_buffer) |
1457 | { |
1458 | - using namespace testing; |
1459 | - |
1460 | - geom::Rectangle const rect{{100,100}, {800,600}}; |
1461 | testing::NiceMock<mtd::MockGLBuffer> mock_buffer{ |
1462 | - rect.size, geom::Stride{100}, mir_pixel_format_xbgr_8888}; |
1463 | + default_rect.size, geom::Stride{100}, mir_pixel_format_xbgr_8888}; |
1464 | + |
1465 | + mc::QueueingSchedule free_queue; |
1466 | + free_queue.schedule(mt::fake_shared(mock_buffer)); |
1467 | |
1468 | InSequence s; |
1469 | /* Set the buffer as rendering target */ |
1470 | - EXPECT_CALL(mock_buffer, gl_bind_to_texture()); |
1471 | + EXPECT_CALL(mock_buffer, bind()); |
1472 | EXPECT_CALL(mock_gl, |
1473 | glViewport(0, 0, |
1474 | mock_buffer.size().width.as_int(), |
1475 | @@ -129,37 +139,73 @@ |
1476 | /* Restore previous viewport on exit */ |
1477 | EXPECT_CALL(mock_gl, glViewport(0, 0, 0, 0)); |
1478 | |
1479 | - mc::ScreencastDisplayBuffer db{rect, mock_buffer}; |
1480 | - db.make_current(); |
1481 | + mc::ScreencastDisplayBuffer db{default_rect, default_size, |
1482 | + default_mirror_mode, free_queue, |
1483 | + ready_queue, stub_display}; |
1484 | + db.bind(); |
1485 | } |
1486 | |
1487 | TEST_F(ScreencastDisplayBufferTest, forces_rendering_to_complete_on_swap) |
1488 | { |
1489 | - using namespace testing; |
1490 | - |
1491 | - geom::Rectangle const rect{{100,100}, {800,600}}; |
1492 | - mtd::StubGLBuffer stub_buffer; |
1493 | - |
1494 | - mc::ScreencastDisplayBuffer db{rect, stub_buffer}; |
1495 | + mc::ScreencastDisplayBuffer db{default_rect, default_size, |
1496 | + default_mirror_mode, free_queue, |
1497 | + ready_queue, stub_display}; |
1498 | |
1499 | Mock::VerifyAndClearExpectations(&mock_gl); |
1500 | EXPECT_CALL(mock_gl, glFinish()); |
1501 | |
1502 | + db.bind(); |
1503 | db.swap_buffers(); |
1504 | } |
1505 | |
1506 | TEST_F(ScreencastDisplayBufferTest, rejects_attempt_to_optimize) |
1507 | { |
1508 | - geom::Rectangle const rect{{100,100}, {800,600}}; |
1509 | - mtd::StubGLBuffer stub_buffer; |
1510 | - |
1511 | mg::RenderableList renderables{ |
1512 | std::make_shared<mtd::StubRenderable>(), |
1513 | std::make_shared<mtd::StubRenderable>(), |
1514 | std::make_shared<mtd::StubRenderable>()}; |
1515 | |
1516 | - mc::ScreencastDisplayBuffer db{rect, stub_buffer}; |
1517 | + mc::ScreencastDisplayBuffer db{default_rect, default_size, |
1518 | + default_mirror_mode, free_queue, |
1519 | + ready_queue, stub_display}; |
1520 | |
1521 | EXPECT_FALSE(db.post_renderables_if_optimizable(renderables)); |
1522 | } |
1523 | |
1524 | +TEST_F(ScreencastDisplayBufferTest, does_not_throw_on_multiple_make_current_calls) |
1525 | +{ |
1526 | + mc::ScreencastDisplayBuffer db{default_rect, default_size, |
1527 | + default_mirror_mode, free_queue, |
1528 | + ready_queue, stub_display}; |
1529 | + |
1530 | + EXPECT_NO_THROW(db.make_current()); |
1531 | + EXPECT_NO_THROW(db.make_current()); |
1532 | +} |
1533 | + |
1534 | +TEST_F(ScreencastDisplayBufferTest, schedules_onto_ready_queue) |
1535 | +{ |
1536 | + mc::ScreencastDisplayBuffer db{default_rect, default_size, |
1537 | + default_mirror_mode, free_queue, |
1538 | + ready_queue, stub_display}; |
1539 | + |
1540 | + db.bind(); |
1541 | + db.swap_buffers(); |
1542 | + |
1543 | + ASSERT_THAT(ready_queue.num_scheduled(), Gt(0)); |
1544 | + |
1545 | + auto ready_buffer = ready_queue.next_buffer(); |
1546 | + auto const expected_buffer = mt::fake_shared(stub_buffer); |
1547 | + |
1548 | + EXPECT_THAT(ready_buffer, Eq(expected_buffer)); |
1549 | +} |
1550 | + |
1551 | +TEST_F(ScreencastDisplayBufferTest, uses_requested_mirror_mode) |
1552 | +{ |
1553 | + MirMirrorMode const expected_mirror_mode{mir_mirror_mode_horizontal}; |
1554 | + mc::ScreencastDisplayBuffer db{default_rect, default_size, |
1555 | + expected_mirror_mode, free_queue, |
1556 | + ready_queue, stub_display}; |
1557 | + |
1558 | + EXPECT_THAT(db.mirror_mode(), Eq(expected_mirror_mode)); |
1559 | +} |
1560 | + |
1561 | |
1562 | === modified file 'tests/unit-tests/dispatch/test_threaded_dispatcher.cpp' |
1563 | --- tests/unit-tests/dispatch/test_threaded_dispatcher.cpp 2016-03-23 06:39:56 +0000 |
1564 | +++ tests/unit-tests/dispatch/test_threaded_dispatcher.cpp 2016-04-20 18:34:35 +0000 |
1565 | @@ -36,9 +36,37 @@ |
1566 | |
1567 | namespace md = mir::dispatch; |
1568 | namespace mt = mir::test; |
1569 | +namespace mtf = mir_test_framework; |
1570 | |
1571 | namespace |
1572 | { |
1573 | + |
1574 | +std::ostream& operator << (std::ostream& os, mtf::TerminationReason const& reason) |
1575 | +{ |
1576 | + switch(reason) |
1577 | + { |
1578 | + case mtf::TerminationReason::unknown: |
1579 | + os << "unknown"; |
1580 | + break; |
1581 | + case mtf::TerminationReason::child_terminated_normally: |
1582 | + os << "child_terminated_normally"; |
1583 | + break; |
1584 | + case mtf::TerminationReason::child_terminated_by_signal: |
1585 | + os << "child_terminated_by_signal"; |
1586 | + break; |
1587 | + case mtf::TerminationReason::child_terminated_with_core_dump: |
1588 | + os << "child_terminated_with_core_dump"; |
1589 | + break; |
1590 | + case mtf::TerminationReason::child_stopped_by_signal: |
1591 | + os << "child_stopped_by_signal"; |
1592 | + break; |
1593 | + case mtf::TerminationReason::child_resumed_by_signal: |
1594 | + os << "child_resumed_by_signal"; |
1595 | + break; |
1596 | + } |
1597 | + return os; |
1598 | +} |
1599 | + |
1600 | class ThreadedDispatcherTest : public ::testing::Test |
1601 | { |
1602 | public: |
1603 | @@ -331,10 +359,19 @@ |
1604 | [&] |
1605 | { |
1606 | { |
1607 | - auto dispatched = std::make_shared<mt::Signal>(); |
1608 | + auto dispatched_signal = std::make_shared<mt::Signal>(); |
1609 | auto dispatchable = std::make_shared<mt::TestDispatchable>( |
1610 | - [dispatched]() { dispatched->raise(); }); |
1611 | - |
1612 | + [dispatched_signal]() { dispatched_signal->raise(); }); |
1613 | + auto exception_handler = [] { |
1614 | + try |
1615 | + { |
1616 | + throw; |
1617 | + } |
1618 | + catch(std::exception const& e) |
1619 | + { |
1620 | + std::cerr << "error: " << e.what() << std::endl; |
1621 | + } |
1622 | + }; |
1623 | /* When there's no SIGCONT handler installed a SIGSTOP/SIGCONT |
1624 | * pair POSIX mandates that a SIGSTOP/SIGCONT pair will *not* |
1625 | * result in blocked syscalls returning EINTR. |
1626 | @@ -348,17 +385,23 @@ |
1627 | */ |
1628 | signal(SIGCONT, &sigcont_handler); |
1629 | |
1630 | - md::ThreadedDispatcher dispatcher{"Test thread", dispatchable}; |
1631 | + md::ThreadedDispatcher dispatcher{"Test thread", dispatchable, exception_handler}; |
1632 | // Ensure the dispatcher has started |
1633 | dispatchable->trigger(); |
1634 | - EXPECT_TRUE(dispatched->wait_for(1s)); |
1635 | + bool dispatched = dispatched_signal->wait_for(1s); |
1636 | + if (!dispatched) |
1637 | + std::cerr << "Timed out waiting for dispatcher to start" << std::endl; |
1638 | + EXPECT_TRUE(dispatched); |
1639 | |
1640 | stop_and_restart_process(); |
1641 | |
1642 | - dispatched->reset(); |
1643 | + dispatched_signal->reset(); |
1644 | // The dispatcher shouldn't have been affected by the signal |
1645 | dispatchable->trigger(); |
1646 | - EXPECT_TRUE(dispatched->wait_for(5s)); |
1647 | + dispatched = dispatched_signal->wait_for(5s); |
1648 | + if (!dispatched) |
1649 | + std::cerr << "Timed out waiting for dispatch" << std::endl; |
1650 | + EXPECT_TRUE(dispatched); |
1651 | |
1652 | // Because we terminate this process with an explicit call to |
1653 | // exit(), objects on the stack are not destroyed. |
1654 | @@ -367,7 +410,9 @@ |
1655 | stop_and_restart_process.~CrossProcessAction(); |
1656 | } |
1657 | |
1658 | - exit(HasFailure() ? EXIT_FAILURE : EXIT_SUCCESS); |
1659 | + auto exit_code = HasFailure() ? EXIT_FAILURE : EXIT_SUCCESS; |
1660 | + std::cerr << "exiting child process with code: " << exit_code << std::endl; |
1661 | + exit(exit_code); |
1662 | }, |
1663 | []{ return 1; }); |
1664 | |
1665 | @@ -383,6 +428,8 @@ |
1666 | }); |
1667 | |
1668 | auto const result = child->wait_for_termination(30s); |
1669 | + std::cerr << "child exit - reason: " << result.reason; |
1670 | + std::cerr << " - exit code: " << result.exit_code << std::endl; |
1671 | EXPECT_TRUE(result.succeeded()); |
1672 | } |
1673 | |
1674 | |
1675 | === modified file 'tests/unit-tests/frontend/test_session_mediator.cpp' |
1676 | --- tests/unit-tests/frontend/test_session_mediator.cpp 2016-04-15 03:41:28 +0000 |
1677 | +++ tests/unit-tests/frontend/test_session_mediator.cpp 2016-04-20 18:34:35 +0000 |
1678 | @@ -599,7 +599,7 @@ |
1679 | EXPECT_EQ(stub_buffer.id().as_value(), screencast.buffer_stream().buffer().buffer_id()); |
1680 | } |
1681 | |
1682 | -TEST_F(SessionMediator, partially_packs_buffer_for_screencast_buffer) |
1683 | +TEST_F(SessionMediator, fully_packs_screencast_buffer) |
1684 | { |
1685 | using namespace testing; |
1686 | |
1687 | @@ -608,7 +608,7 @@ |
1688 | auto const& stub_buffer = stub_screencast->stub_buffer; |
1689 | |
1690 | EXPECT_CALL(mock_ipc_operations, |
1691 | - pack_buffer(_, Ref(stub_buffer), mg::BufferIpcMsgType::update_msg)) |
1692 | + pack_buffer(_, Ref(stub_buffer), mg::BufferIpcMsgType::full_msg)) |
1693 | .Times(1); |
1694 | |
1695 | mediator.screencast_buffer(&screencast_id, |
1696 | |
1697 | === modified file 'tests/unit-tests/graphics/offscreen/test_offscreen_display.cpp' |
1698 | --- tests/unit-tests/graphics/offscreen/test_offscreen_display.cpp 2016-01-29 08:18:22 +0000 |
1699 | +++ tests/unit-tests/graphics/offscreen/test_offscreen_display.cpp 2016-04-20 18:34:35 +0000 |
1700 | @@ -132,6 +132,7 @@ |
1701 | EXPECT_CALL(mock_gl, glBindFramebuffer(_,Ne(0))); |
1702 | |
1703 | mt::as_render_target(db)->make_current(); |
1704 | + mt::as_render_target(db)->bind(); |
1705 | |
1706 | Mock::VerifyAndClearExpectations(&mock_egl); |
1707 | Mock::VerifyAndClearExpectations(&mock_gl); |
FAILED: Continuous integration, rev:3470 /mir-jenkins. ubuntu. com/job/ mir-ci/ 873/ /mir-jenkins. ubuntu. com/job/ build-mir/ 894/console /mir-jenkins. ubuntu. com/job/ build-0- fetch/931 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= vivid+overlay/ 922 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial/ 922 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= vivid+overlay/ 904/console /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial/ 904/console /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= android, release= vivid+overlay/ 904/console /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= android, release= vivid+overlay/ 904/console /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial/ 904/console
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /mir-jenkins. ubuntu. com/job/ mir-ci/ 873/rebuild
https:/