Merge lp:~alan-griffiths/mir/fix-1663130 into lp:mir
- fix-1663130
- Merge into development-branch
Proposed by
Alan Griffiths
Status: | Merged |
---|---|
Approved by: | Chris Halse Rogers |
Approved revision: | no longer in the source branch. |
Merged at revision: | 4205 |
Proposed branch: | lp:~alan-griffiths/mir/fix-1663130 |
Merge into: | lp:mir |
Diff against target: |
623 lines (+0/-599) 3 files modified
examples/CMakeLists.txt (+0/-23) examples/render_surfaces.cpp (+0/-468) examples/render_to_fb.cpp (+0/-108) |
To merge this branch: | bzr merge lp:~alan-griffiths/mir/fix-1663130 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Halse Rogers | Approve | ||
Mir CI Bot | continuous-integration | Approve | |
Review via email: mp+327420@code.launchpad.net |
Commit message
Remove obsolete & broken example code
Description of the change
To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote : | # |
review:
Approve
(continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote : | # |
Yup, that's not code we want to support.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'examples/CMakeLists.txt' |
2 | --- examples/CMakeLists.txt 2017-06-06 16:26:18 +0000 |
3 | +++ examples/CMakeLists.txt 2017-07-14 11:41:27 +0000 |
4 | @@ -1,15 +1,3 @@ |
5 | -mir_add_wrapped_executable(mir_demo_standalone_render_surfaces |
6 | - render_surfaces.cpp |
7 | - buffer_render_target.cpp |
8 | - image_renderer.cpp |
9 | -) |
10 | - |
11 | -target_link_libraries(mir_demo_standalone_render_surfaces |
12 | - mirserver |
13 | - exampleserverconfig |
14 | - ${Boost_LIBRARIES} |
15 | -) |
16 | - |
17 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -fno-strict-aliasing -Wextra") |
18 | |
19 | add_library(eglapp STATIC |
20 | @@ -192,17 +180,6 @@ |
21 | ${GL_INCLUDE_DIRS} |
22 | ) |
23 | |
24 | -mir_add_wrapped_executable(mir_demo_standalone_render_to_fb |
25 | - render_to_fb.cpp |
26 | -) |
27 | - |
28 | -target_link_libraries(mir_demo_standalone_render_to_fb |
29 | - mirserver |
30 | - mirdraw |
31 | - ${GL_LIBRARIES} |
32 | - ${Boost_LIBRARIES} |
33 | -) |
34 | - |
35 | add_library(mir_demo_server_loadable MODULE |
36 | server_example.cpp |
37 | glog_logger.cpp |
38 | |
39 | === removed file 'examples/render_surfaces.cpp' |
40 | --- examples/render_surfaces.cpp 2017-05-08 03:04:26 +0000 |
41 | +++ examples/render_surfaces.cpp 1970-01-01 00:00:00 +0000 |
42 | @@ -1,468 +0,0 @@ |
43 | -/* |
44 | - * Copyright © 2012-2014 Canonical Ltd. |
45 | - * |
46 | - * This program is free software: you can redistribute it and/or modify |
47 | - * it under the terms of the GNU General Public License version 3 as |
48 | - * published by the Free Software Foundation. |
49 | - * |
50 | - * This program is distributed in the hope that it will be useful, |
51 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
52 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
53 | - * GNU General Public License for more details. |
54 | - * |
55 | - * You should have received a copy of the GNU General Public License |
56 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
57 | - * |
58 | - * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
59 | - */ |
60 | - |
61 | -#include "server_example_input_event_filter.h" |
62 | -#include "server_example_display_configuration_policy.h" |
63 | -#include "mir/server_status_listener.h" |
64 | -#include "mir/compositor/display_buffer_compositor.h" |
65 | -#include "mir/compositor/display_buffer_compositor_factory.h" |
66 | -#include "mir/scene/surface_creation_parameters.h" |
67 | -#include "mir/geometry/size.h" |
68 | -#include "mir/geometry/rectangles.h" |
69 | -#include "mir/graphics/display.h" |
70 | -#include "mir/graphics/display_buffer.h" |
71 | -#include "mir/graphics/platform.h" |
72 | -#include "mir/graphics/graphic_buffer_allocator.h" |
73 | -#include "mir/options/option.h" |
74 | -#include "mir/scene/surface.h" |
75 | -#include "mir/scene/buffer_stream_factory.h" |
76 | -#include "mir/scene/surface_factory.h" |
77 | -#include "mir/shell/surface_stack.h" |
78 | -#include "mir/frontend/buffer_sink.h" |
79 | -#include "mir/frontend/client_buffers.h" |
80 | -#include "mir/server.h" |
81 | -#include "mir/report_exception.h" |
82 | -#include "mir/renderer/gl/context.h" |
83 | -#include "mir/renderer/gl/context_source.h" |
84 | - |
85 | -#include "mir_image.h" |
86 | -#include "buffer_render_target.h" |
87 | -#include "image_renderer.h" |
88 | - |
89 | -#define GLM_FORCE_RADIANS |
90 | -#include <glm/gtc/matrix_transform.hpp> |
91 | - |
92 | -#include <thread> |
93 | -#include <atomic> |
94 | -#include <chrono> |
95 | -#include <csignal> |
96 | -#include <iostream> |
97 | -#include <sstream> |
98 | -#include <vector> |
99 | - |
100 | -namespace mg = mir::graphics; |
101 | -namespace mc = mir::compositor; |
102 | -namespace ms = mir::scene; |
103 | -namespace mf = mir::frontend; |
104 | -namespace mo = mir::options; |
105 | -namespace msh = mir::shell; |
106 | -namespace mi = mir::input; |
107 | -namespace geom = mir::geometry; |
108 | -namespace mt = mir::tools; |
109 | -namespace me = mir::examples; |
110 | - |
111 | - |
112 | -///\page render_surfaces-example render_surfaces.cpp: A simple program using the mir library. |
113 | -///\tableofcontents |
114 | -///render_surfaces shows the use of mir to render some moving surfaces |
115 | -///\section main main() |
116 | -/// The main() function uses a RenderSurfacesServerConfiguration to initialize and run mir. |
117 | -/// \snippet render_surfaces.cpp main_tag |
118 | -///\section RenderSurfacesServerConfiguration RenderSurfacesServerConfiguration |
119 | -/// The configuration stubs out client connectivity and input. |
120 | -/// \snippet render_surfaces.cpp RenderSurfacesServerConfiguration_stubs_tag |
121 | -/// it also provides a bespoke display buffer compositor |
122 | -/// \snippet render_surfaces.cpp RenderSurfacesDisplayBufferCompositor_tag |
123 | -///\section Utilities Utility classes |
124 | -/// For smooth animation we need to track time and move surfaces accordingly |
125 | -///\subsection StopWatch StopWatch |
126 | -/// \snippet render_surfaces.cpp StopWatch_tag |
127 | -///\subsection Moveable Moveable |
128 | -/// \snippet render_surfaces.cpp Moveable_tag |
129 | - |
130 | -///\example render_surfaces.cpp A simple program using the mir library. |
131 | - |
132 | -namespace |
133 | -{ |
134 | -std::atomic<bool> created{false}; |
135 | - |
136 | -static const float min_alpha = 0.3f; |
137 | - |
138 | -char const* const surfaces_to_render = "surfaces-to-render"; |
139 | - |
140 | -auto as_context_source(mg::Display* display) |
141 | -{ |
142 | - auto ctx = dynamic_cast<mir::renderer::gl::ContextSource*>(display->native_display()); |
143 | - if (!ctx) |
144 | - BOOST_THROW_EXCEPTION(std::logic_error("Display does not support GL rendering")); |
145 | - return ctx; |
146 | -} |
147 | - |
148 | -///\internal [StopWatch_tag] |
149 | -// tracks elapsed time - for animation. |
150 | -class StopWatch |
151 | -{ |
152 | -public: |
153 | - StopWatch() : start(std::chrono::high_resolution_clock::now()), |
154 | - last(start), |
155 | - now(last) |
156 | - { |
157 | - } |
158 | - |
159 | - void stop() |
160 | - { |
161 | - now = std::chrono::high_resolution_clock::now(); |
162 | - } |
163 | - |
164 | - double elapsed_seconds_since_start() |
165 | - { |
166 | - auto elapsed = now - start; |
167 | - float elapsed_sec = std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count() / 1000000.0f; |
168 | - return elapsed_sec; |
169 | - } |
170 | - |
171 | - double elapsed_seconds_since_last_restart() |
172 | - { |
173 | - auto elapsed = now - last; |
174 | - float elapsed_sec = std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count() / 1000000.0f; |
175 | - return elapsed_sec; |
176 | - } |
177 | - |
178 | - void restart() |
179 | - { |
180 | - std::swap(last, now); |
181 | - } |
182 | - |
183 | -private: |
184 | - std::chrono::high_resolution_clock::time_point start; |
185 | - std::chrono::high_resolution_clock::time_point last; |
186 | - std::chrono::high_resolution_clock::time_point now; |
187 | -}; |
188 | -///\internal [StopWatch_tag] |
189 | - |
190 | -///\internal [Moveable_tag] |
191 | -// Adapter to support movement of surfaces. |
192 | -class Moveable |
193 | -{ |
194 | -public: |
195 | - Moveable() {} |
196 | - Moveable(std::shared_ptr<ms::Surface> const& s, const geom::Size& display_size, |
197 | - float dx, float dy, const glm::vec3& rotation_axis, float alpha_offset) |
198 | - : surface(s), display_size(display_size), |
199 | - x(s->top_left().x.as_int()), |
200 | - y(s->top_left().y.as_int()), |
201 | - w(s->size().width.as_int()), |
202 | - h(s->size().height.as_int()), |
203 | - dx{dx}, |
204 | - dy{dy}, |
205 | - rotation_axis(rotation_axis), |
206 | - alpha_offset{alpha_offset} |
207 | - { |
208 | - } |
209 | - |
210 | - void step() |
211 | - { |
212 | - stop_watch.stop(); |
213 | - float elapsed_sec = stop_watch.elapsed_seconds_since_last_restart(); |
214 | - float total_elapsed_sec = stop_watch.elapsed_seconds_since_start(); |
215 | - stop_watch.restart(); |
216 | - |
217 | - bool should_update = true; |
218 | - float new_x = x + elapsed_sec * dx; |
219 | - float new_y = y + elapsed_sec * dy; |
220 | - if (new_x < 0.0 || new_x + w > display_size.width.as_uint32_t()) |
221 | - { |
222 | - dx = -dx; |
223 | - should_update = false; |
224 | - } |
225 | - |
226 | - if (new_y < 0.0 || new_y + h > display_size.height.as_uint32_t()) |
227 | - { |
228 | - dy = -dy; |
229 | - should_update = false; |
230 | - } |
231 | - |
232 | - if (should_update) |
233 | - { |
234 | - surface->move_to({new_x, new_y}); |
235 | - x = new_x; |
236 | - y = new_y; |
237 | - } |
238 | - |
239 | - glm::mat4 trans = glm::rotate(glm::mat4(1.0f), |
240 | - glm::radians(total_elapsed_sec * 120.0f), |
241 | - rotation_axis); |
242 | - surface->set_transformation(trans); |
243 | - |
244 | - float const alpha_amplitude = (1.0f - min_alpha) / 2.0f; |
245 | - surface->set_alpha(min_alpha + alpha_amplitude + |
246 | - alpha_amplitude * |
247 | - sin(alpha_offset + 2 * M_PI * total_elapsed_sec / |
248 | - 3.0)); |
249 | - } |
250 | - |
251 | -private: |
252 | - std::shared_ptr<ms::Surface> surface; |
253 | - geom::Size display_size; |
254 | - float x; |
255 | - float y; |
256 | - float w; |
257 | - float h; |
258 | - float dx; |
259 | - float dy; |
260 | - StopWatch stop_watch; |
261 | - glm::vec3 rotation_axis; |
262 | - float alpha_offset; |
263 | -}; |
264 | -///\internal [Moveable_tag] |
265 | - |
266 | -void callback_when_started(mir::Server& server, std::function<void()> callback) |
267 | -{ |
268 | - struct ServerStatusListener : mir::ServerStatusListener |
269 | - { |
270 | - ServerStatusListener(std::function<void()> callback) : |
271 | - callback(callback) {} |
272 | - |
273 | - virtual void paused() override {} |
274 | - virtual void resumed() override {} |
275 | - virtual void started() override {callback(); callback = []{}; } |
276 | - virtual void ready_for_user_input() override {} |
277 | - virtual void stop_receiving_input() override {} |
278 | - |
279 | - std::function<void()> callback; |
280 | - }; |
281 | - |
282 | - server.override_the_server_status_listener([callback] |
283 | - { |
284 | - return std::make_shared<ServerStatusListener>(callback); |
285 | - }); |
286 | -} |
287 | - |
288 | -///\internal [RenderSurfacesServerConfiguration_stubs_tag] |
289 | -class RenderSurfacesDisplayBufferCompositor : public mc::DisplayBufferCompositor |
290 | -{ |
291 | -public: |
292 | - RenderSurfacesDisplayBufferCompositor( |
293 | - std::unique_ptr<DisplayBufferCompositor> db_compositor, |
294 | - std::vector<Moveable>& moveables) |
295 | - : db_compositor{std::move(db_compositor)}, |
296 | - moveables(moveables), |
297 | - frames{0} |
298 | - { |
299 | - } |
300 | - |
301 | - void composite(mc::SceneElementSequence&& scene_sequence) override |
302 | - { |
303 | - while (!created) std::this_thread::yield(); |
304 | - stop_watch.stop(); |
305 | - if (stop_watch.elapsed_seconds_since_last_restart() >= 1) |
306 | - { |
307 | - std::cout << "FPS: " << frames << " Frame Time: " << 1.0 / frames << std::endl; |
308 | - frames = 0; |
309 | - stop_watch.restart(); |
310 | - } |
311 | - |
312 | - db_compositor->composite(std::move(scene_sequence)); |
313 | - |
314 | - for (auto& m : moveables) |
315 | - m.step(); |
316 | - |
317 | - frames++; |
318 | - } |
319 | - |
320 | -private: |
321 | - std::unique_ptr<DisplayBufferCompositor> const db_compositor; |
322 | - StopWatch stop_watch; |
323 | - std::vector<Moveable>& moveables; |
324 | - uint32_t frames; |
325 | -}; |
326 | -///\internal [RenderSurfacesServerConfiguration_stubs_tag] |
327 | - |
328 | -class RenderSurfacesDisplayBufferCompositorFactory : public mc::DisplayBufferCompositorFactory |
329 | -{ |
330 | -public: |
331 | - RenderSurfacesDisplayBufferCompositorFactory( |
332 | - std::shared_ptr<mc::DisplayBufferCompositorFactory> const& factory, |
333 | - std::vector<Moveable>& moveables) |
334 | - : factory{factory}, |
335 | - moveables(moveables) |
336 | - { |
337 | - } |
338 | - |
339 | - std::unique_ptr<mc::DisplayBufferCompositor> create_compositor_for(mg::DisplayBuffer& display_buffer) |
340 | - { |
341 | - auto compositor = factory->create_compositor_for(display_buffer); |
342 | - auto raw = new RenderSurfacesDisplayBufferCompositor( |
343 | - std::move(compositor), moveables); |
344 | - return std::unique_ptr<RenderSurfacesDisplayBufferCompositor>(raw); |
345 | - } |
346 | - |
347 | -private: |
348 | - std::shared_ptr<mc::DisplayBufferCompositorFactory> const factory; |
349 | - std::vector<Moveable>& moveables; |
350 | -}; |
351 | - |
352 | -///\internal [RenderSurfacesServer_tag] |
353 | -// Extend the default configuration to manage moveables. |
354 | -class RenderSurfacesServer : private mir::Server |
355 | -{ |
356 | - std::shared_ptr<mir::input::EventFilter> const quit_filter{me::make_quit_filter_for(*this)}; |
357 | -public: |
358 | - RenderSurfacesServer(int argc, char const** argv) |
359 | - { |
360 | - me::add_display_configuration_options_to(*this); |
361 | - |
362 | - ///\internal [RenderSurfacesDisplayBufferCompositor_tag] |
363 | - // Decorate the DefaultDisplayBufferCompositor in order to move surfaces. |
364 | - wrap_display_buffer_compositor_factory([this](std::shared_ptr<mc::DisplayBufferCompositorFactory> const& wrapped) |
365 | - { |
366 | - return std::make_shared<RenderSurfacesDisplayBufferCompositorFactory>( |
367 | - wrapped, |
368 | - moveables); |
369 | - }); |
370 | - ///\internal [RenderSurfacesDisplayBufferCompositor_tag] |
371 | - |
372 | - add_configuration_option(surfaces_to_render, "Number of surfaces to render", 5); |
373 | - |
374 | - // Provide the command line and run the *this |
375 | - set_command_line(argc, argv); |
376 | - setenv("MIR_SERVER_NO_FILE", "", 1); |
377 | - |
378 | - // If there's a server available, try connecting to it |
379 | - if (auto const socket = getenv("MIR_SOCKET")) |
380 | - setenv("MIR_SERVER_HOST_SOCKET", socket, 0); |
381 | - |
382 | - // Unless the compositor starts before we create the surfaces it won't respond to |
383 | - // the change notification that causes. |
384 | - callback_when_started(*this, [this] { create_surfaces(); }); |
385 | - |
386 | - apply_settings(); |
387 | - } |
388 | - |
389 | - using mir::Server::run; |
390 | - using mir::Server::exited_normally; |
391 | - |
392 | - // New function to initialize moveables with surfaces |
393 | - void create_surfaces() |
394 | - try |
395 | - { |
396 | - moveables.resize(get_options()->get<int>(surfaces_to_render)); |
397 | - std::cout << "Rendering " << moveables.size() << " surfaces" << std::endl; |
398 | - |
399 | - auto const display = the_display(); |
400 | - auto const buffer_stream_factory = the_buffer_stream_factory(); |
401 | - auto const gralloc = the_graphics_platform()->create_buffer_allocator(); |
402 | - auto const surface_factory = the_surface_factory(); |
403 | - auto const surface_stack = the_surface_stack(); |
404 | - auto const gl_context = as_context_source(the_display().get())->create_gl_context(); |
405 | - |
406 | - /* TODO: Get proper configuration */ |
407 | - geom::Rectangles view_area; |
408 | - display->for_each_display_sync_group([&](mg::DisplaySyncGroup& group) |
409 | - { |
410 | - group.for_each_display_buffer([&](mg::DisplayBuffer& db) |
411 | - { |
412 | - view_area.add(db.view_area()); |
413 | - }); |
414 | - }); |
415 | - geom::Size const display_size{view_area.bounding_rectangle().size}; |
416 | - uint32_t const surface_side{300}; |
417 | - geom::Size const surface_size{surface_side, surface_side}; |
418 | - |
419 | - float const angular_step = 2.0 * M_PI / moveables.size(); |
420 | - float const w = display_size.width.as_uint32_t(); |
421 | - float const h = display_size.height.as_uint32_t(); |
422 | - auto const surface_pf = supported_pixel_formats()[0]; |
423 | - |
424 | - int i = 0; |
425 | - for (auto& m : moveables) |
426 | - { |
427 | - auto params = ms::a_surface() |
428 | - .of_size(surface_size) |
429 | - .of_pixel_format(surface_pf) |
430 | - .of_buffer_usage(mg::BufferUsage::hardware); |
431 | - mg::BufferProperties properties{params.size, params.pixel_format, params.buffer_usage}; |
432 | - struct NullBufferSink : mf::BufferSink |
433 | - { |
434 | - void send_buffer(mf::BufferStreamId, mg::Buffer&, mg::BufferIpcMsgType) override {} |
435 | - void add_buffer(mg::Buffer&) override {} |
436 | - void remove_buffer(mg::Buffer&) override {} |
437 | - void update_buffer(mg::Buffer&) override {} |
438 | - void error_buffer(geom::Size, MirPixelFormat, std::string const&) override {} |
439 | - }; |
440 | - |
441 | - auto buffers = buffer_stream_factory->create_buffer_map(std::make_shared<NullBufferSink>()); |
442 | - auto const stream = buffer_stream_factory->create_buffer_stream({}, buffers, properties); |
443 | - auto const surface = surface_factory->create_surface( |
444 | - {ms::StreamInfo{stream, {}, {}}}, params); |
445 | - surface_stack->add_surface(surface, params.input_mode); |
446 | - |
447 | - { |
448 | - auto buffer = gralloc->alloc_buffer(properties); |
449 | - |
450 | - { |
451 | - gl_context->make_current(); |
452 | - |
453 | - mt::ImageRenderer img_renderer{mir_image.pixel_data, |
454 | - geom::Size{mir_image.width, mir_image.height}, |
455 | - mir_image.bytes_per_pixel}; |
456 | - mt::BufferRenderTarget brt{*buffer}; |
457 | - brt.make_current(); |
458 | - img_renderer.render(); |
459 | - |
460 | - gl_context->release_current(); |
461 | - } |
462 | - surface->primary_buffer_stream()->submit_buffer(buffer); |
463 | - } |
464 | - |
465 | - /* |
466 | - * Place each surface at a different starting location and give it a |
467 | - * different speed, rotation and alpha offset. |
468 | - */ |
469 | - uint32_t const x = w * (0.5 + 0.25 * cos(i * angular_step)) - surface_side / 2.0; |
470 | - uint32_t const y = h * (0.5 + 0.25 * sin(i * angular_step)) - surface_side / 2.0; |
471 | - |
472 | - surface->move_to({x, y}); |
473 | - m = Moveable(surface, display_size, |
474 | - cos(0.1f + i * M_PI / 6.0f) * w / 3.0f, |
475 | - sin(0.1f + i * M_PI / 6.0f) * h / 3.0f, |
476 | - glm::vec3{(i % 3 == 0) * 1.0f, (i % 3 == 1) * 1.0f, (i % 3 == 2) * 1.0f}, |
477 | - 2.0f * M_PI * cos(i)); |
478 | - ++i; |
479 | - } |
480 | - |
481 | - created = true; |
482 | - } |
483 | - catch (...) |
484 | - { |
485 | - mir::report_exception(); |
486 | - exit(EXIT_FAILURE); |
487 | - } |
488 | - |
489 | -private: |
490 | - std::vector<Moveable> moveables; |
491 | -}; |
492 | -///\internal [RenderSurfacesServer_tag] |
493 | -} |
494 | - |
495 | -int main(int argc, char const** argv) |
496 | -try |
497 | -{ |
498 | - ///\internal [main_tag] |
499 | - RenderSurfacesServer render_surfaces{argc, argv}; |
500 | - |
501 | - render_surfaces.run(); |
502 | - |
503 | - return render_surfaces.exited_normally() ? EXIT_SUCCESS : EXIT_FAILURE; |
504 | - ///\internal [main_tag] |
505 | -} |
506 | -catch (...) |
507 | -{ |
508 | - mir::report_exception(); |
509 | - return EXIT_FAILURE; |
510 | -} |
511 | |
512 | === removed file 'examples/render_to_fb.cpp' |
513 | --- examples/render_to_fb.cpp 2017-05-08 03:04:26 +0000 |
514 | +++ examples/render_to_fb.cpp 1970-01-01 00:00:00 +0000 |
515 | @@ -1,108 +0,0 @@ |
516 | -/* |
517 | - * Copyright © 2012-2014 Canonical Ltd. |
518 | - * |
519 | - * This program is free software: you can redistribute it and/or modify |
520 | - * it under the terms of the GNU General Public License version 3 as |
521 | - * published by the Free Software Foundation. |
522 | - * |
523 | - * This program is distributed in the hope that it will be useful, |
524 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
525 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
526 | - * GNU General Public License for more details. |
527 | - * |
528 | - * You should have received a copy of the GNU General Public License |
529 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
530 | - * |
531 | - * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
532 | - */ |
533 | - |
534 | -#include "graphics.h" |
535 | -#include "as_render_target.h" |
536 | - |
537 | -#include "mir/server.h" |
538 | -#include "mir/report_exception.h" |
539 | -#include "mir/graphics/display.h" |
540 | -#include "mir/graphics/display_buffer.h" |
541 | -#include "mir/renderer/gl/render_target.h" |
542 | - |
543 | -#include <csignal> |
544 | - |
545 | -namespace mg=mir::graphics; |
546 | -namespace mo=mir::options; |
547 | -namespace me=mir::examples; |
548 | - |
549 | -namespace |
550 | -{ |
551 | -volatile std::sig_atomic_t running = true; |
552 | - |
553 | -void signal_handler(int /*signum*/) |
554 | -{ |
555 | - running = false; |
556 | -} |
557 | -} |
558 | - |
559 | -void render_loop(mir::Server& server) |
560 | -{ |
561 | - /* Set up graceful exit on SIGINT and SIGTERM */ |
562 | - struct sigaction sa; |
563 | - sa.sa_handler = signal_handler; |
564 | - sa.sa_flags = 0; |
565 | - sigemptyset(&sa.sa_mask); |
566 | - |
567 | - sigaction(SIGINT, &sa, NULL); |
568 | - sigaction(SIGTERM, &sa, NULL); |
569 | - |
570 | - auto display = server.the_display(); |
571 | - |
572 | - mir::draw::glAnimationBasic gl_animation; |
573 | - |
574 | - display->for_each_display_sync_group([&](mg::DisplaySyncGroup& group) |
575 | - { |
576 | - group.for_each_display_buffer([&](mg::DisplayBuffer& buffer) |
577 | - { |
578 | - me::as_render_target(buffer)->make_current(); |
579 | - gl_animation.init_gl(); |
580 | - }); |
581 | - }); |
582 | - |
583 | - while (running) |
584 | - { |
585 | - display->for_each_display_sync_group([&](mg::DisplaySyncGroup& group) |
586 | - { |
587 | - group.for_each_display_buffer([&](mg::DisplayBuffer& buffer) |
588 | - { |
589 | - auto const render_target = me::as_render_target(buffer); |
590 | - render_target->make_current(); |
591 | - gl_animation.render_gl(); |
592 | - render_target->swap_buffers(); |
593 | - }); |
594 | - group.post(); |
595 | - }); |
596 | - |
597 | - gl_animation.step(); |
598 | - } |
599 | -} |
600 | - |
601 | -int main(int argc, char const** argv) |
602 | -try |
603 | -{ |
604 | - // We don't want to act as a server by providing an endpoint |
605 | - setenv("MIR_SERVER_NO_FILE", "", 1); |
606 | - |
607 | - // If there's a server available, try connecting to it |
608 | - if (auto const socket = getenv("MIR_SOCKET")) |
609 | - setenv("MIR_SERVER_HOST_SOCKET", socket, 0); |
610 | - |
611 | - mir::Server server; |
612 | - server.set_command_line(argc, argv); |
613 | - server.apply_settings(); |
614 | - |
615 | - render_loop(server); |
616 | - |
617 | - return EXIT_SUCCESS; |
618 | -} |
619 | -catch (...) |
620 | -{ |
621 | - mir::report_exception(); |
622 | - return EXIT_FAILURE; |
623 | -} |
PASSED: Continuous integration, rev:4205 /mir-jenkins. ubuntu. com/job/ mir-ci/ 3485/ /mir-jenkins. ubuntu. com/job/ build-mir/ 4760 /mir-jenkins. ubuntu. com/job/ build-0- fetch/4926 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= artful/ 4915 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial/ 4915 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= zesty/4915 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= artful/ 4797 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= artful/ 4797/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= zesty/4797 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= zesty/4797/ artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= artful/ 4797 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= artful/ 4797/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial/ 4797 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial/ 4797/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= zesty/4797 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= zesty/4797/ artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= mesa,release= artful/ 4797 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= mesa,release= artful/ 4797/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= mesa,release= zesty/4797 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= mesa,release= zesty/4797/ artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial/ 4797 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial/ 4797/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /mir-jenkins. ubuntu. com/job/ mir-ci/ 3485/rebuild
https:/