Merge lp:~phablet-team/trust-store/test-tp-take-2 into lp:trust-store
- test-tp-take-2
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | Cemil Azizoglu |
Proposed branch: | lp:~phablet-team/trust-store/test-tp-take-2 |
Merge into: | lp:trust-store |
Diff against target: |
677 lines (+600/-2) 5 files modified
CMakeLists.txt (+2/-0) src/CMakeLists.txt (+6/-0) src/core/trust/mir/eglapp.c (+488/-0) src/core/trust/mir/eglapp.h (+43/-0) src/core/trust/mir/prompt_main.cpp (+61/-2) |
To merge this branch: | bzr merge lp:~phablet-team/trust-store/test-tp-take-2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Needs Fixing | |
Cemil Azizoglu (community) | Disapprove | ||
Review via email: mp+290060@code.launchpad.net |
Commit message
DO NOT LAND. Test for debugging lp:1551811.
Description of the change
DO NOT LAND. Test for debugging lp:1551811.
- 151. By Cemil Azizoglu
-
Make socket_file NULL.
- 152. By Cemil Azizoglu
-
Use /run/user/
32011/mir_ socket_ trusted - 153. By Cemil Azizoglu
-
Add some debug info
- 154. By Cemil Azizoglu
-
Pass NULL
- 155. By Cemil Azizoglu
-
GL app for TPP
- 156. By Cemil Azizoglu
-
- Fix package name
- No args needed - 157. By Cemil Azizoglu
-
correct package name
- 158. By Cemil Azizoglu
-
C-style headers
- 159. By Cemil Azizoglu
-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99)
- 160. By Cemil Azizoglu
-
remove sleep()s
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:160
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Unmerged revisions
- 160. By Cemil Azizoglu
-
remove sleep()s
- 159. By Cemil Azizoglu
-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99)
- 158. By Cemil Azizoglu
-
C-style headers
- 157. By Cemil Azizoglu
-
correct package name
- 156. By Cemil Azizoglu
-
- Fix package name
- No args needed - 155. By Cemil Azizoglu
-
GL app for TPP
- 154. By Cemil Azizoglu
-
Pass NULL
- 153. By Cemil Azizoglu
-
Add some debug info
- 152. By Cemil Azizoglu
-
Use /run/user/
32011/mir_ socket_ trusted - 151. By Cemil Azizoglu
-
Make socket_file NULL.
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2016-01-11 20:35:30 +0000 |
3 | +++ CMakeLists.txt 2016-03-30 00:50:42 +0000 |
4 | @@ -70,6 +70,8 @@ |
5 | |
6 | if (TRUST_STORE_MIR_AGENT_ENABLED) |
7 | pkg_check_modules(MIR_CLIENT mirclient REQUIRED) |
8 | + pkg_check_modules(EGL egl REQUIRED) |
9 | + pkg_check_modules(GLESv2 glesv2 REQUIRED) |
10 | |
11 | include_directories( |
12 | ${MIR_CLIENT_INCLUDE_DIRS} |
13 | |
14 | === modified file 'src/CMakeLists.txt' |
15 | --- src/CMakeLists.txt 2016-01-11 09:51:51 +0000 |
16 | +++ src/CMakeLists.txt 2016-03-30 00:50:42 +0000 |
17 | @@ -25,6 +25,8 @@ |
18 | pkg_check_modules(LIBAPPARMOR libapparmor REQUIRED) |
19 | pkg_check_modules(SQLITE3 sqlite3 REQUIRED) |
20 | |
21 | +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") |
22 | + |
23 | set(CMAKE_INCLUDE_CURRENT_DIR ON) |
24 | |
25 | include_directories( |
26 | @@ -103,6 +105,7 @@ |
27 | core/trust/i18n.cpp |
28 | |
29 | core/trust/mir/prompt_main.cpp |
30 | + core/trust/mir/eglapp.c |
31 | ) |
32 | |
33 | qt5_use_modules(trust-prompt Core Gui Qml Quick) |
34 | @@ -111,7 +114,10 @@ |
35 | trust-prompt |
36 | |
37 | ${Boost_LIBRARIES} |
38 | + ${MIR_CLIENT_LDFLAGS} |
39 | ${PROCESS_CPP_LDFLAGS} |
40 | + ${EGL_LDFLAGS} |
41 | + ${GLESv2_LDFLAGS} |
42 | ) |
43 | |
44 | install( |
45 | |
46 | === added file 'src/core/trust/mir/eglapp.c' |
47 | --- src/core/trust/mir/eglapp.c 1970-01-01 00:00:00 +0000 |
48 | +++ src/core/trust/mir/eglapp.c 2016-03-30 00:50:42 +0000 |
49 | @@ -0,0 +1,488 @@ |
50 | +/* |
51 | + * Copyright © 2013 Canonical Ltd. |
52 | + * |
53 | + * This program is free software: you can redistribute it and/or modify |
54 | + * it under the terms of the GNU General Public License version 3 as |
55 | + * published by the Free Software Foundation. |
56 | + * |
57 | + * This program is distributed in the hope that it will be useful, |
58 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
59 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
60 | + * GNU General Public License for more details. |
61 | + * |
62 | + * You should have received a copy of the GNU General Public License |
63 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
64 | + * |
65 | + * Author: Daniel van Vugt <daniel.van.vugt@canonical.com> |
66 | + */ |
67 | + |
68 | +#include "eglapp.h" |
69 | +#include "mir_toolkit/mir_client_library.h" |
70 | +#include "mir_toolkit/mir_prompt_session.h" |
71 | +#include <assert.h> |
72 | +#include <string.h> |
73 | +#include <stdio.h> |
74 | +#include <stdlib.h> |
75 | +#include <getopt.h> |
76 | +#include <unistd.h> |
77 | +#include <errno.h> |
78 | +#include <sys/wait.h> |
79 | +#include <sys/types.h> |
80 | +#include <signal.h> |
81 | +#include <time.h> |
82 | +#include <EGL/egl.h> |
83 | +#include <GLES2/gl2.h> |
84 | + |
85 | +#include <xkbcommon/xkbcommon-keysyms.h> |
86 | + |
87 | +float mir_eglapp_background_opacity = 1.0f; |
88 | + |
89 | +static const char* appname = "egldemo"; |
90 | + |
91 | +static MirConnection *connection; |
92 | +static MirSurface *surface; |
93 | +static EGLDisplay egldisplay; |
94 | +static EGLSurface eglsurface; |
95 | +static volatile sig_atomic_t running = 0; |
96 | + |
97 | +#define CHECK(_cond, _err) \ |
98 | + if (!(_cond)) \ |
99 | + { \ |
100 | + printf("%s\n", (_err)); \ |
101 | + return 0; \ |
102 | + } |
103 | + |
104 | +void mir_eglapp_shutdown(void) |
105 | +{ |
106 | + eglMakeCurrent(egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
107 | + eglTerminate(egldisplay); |
108 | + mir_surface_release_sync(surface); |
109 | + surface = NULL; |
110 | + mir_connection_release(connection); |
111 | + connection = NULL; |
112 | +} |
113 | + |
114 | +static void shutdown(int signum) |
115 | +{ |
116 | + if (running) |
117 | + { |
118 | + running = 0; |
119 | + printf("Signal %d received. Good night.\n", signum); |
120 | + } |
121 | +} |
122 | + |
123 | +mir_eglapp_bool mir_eglapp_running(void) |
124 | +{ |
125 | + return running; |
126 | +} |
127 | + |
128 | +void mir_eglapp_swap_buffers(void) |
129 | +{ |
130 | + EGLint width, height; |
131 | + |
132 | + if (!running) |
133 | + return; |
134 | + |
135 | + eglSwapBuffers(egldisplay, eglsurface); |
136 | + |
137 | + /* |
138 | + * Querying the surface (actually the current buffer) dimensions here is |
139 | + * the only truly safe way to be sure that the dimensions we think we |
140 | + * have are those of the buffer being rendered to. But this should be |
141 | + * improved in future; https://bugs.launchpad.net/mir/+bug/1194384 |
142 | + */ |
143 | + if (eglQuerySurface(egldisplay, eglsurface, EGL_WIDTH, &width) && |
144 | + eglQuerySurface(egldisplay, eglsurface, EGL_HEIGHT, &height)) |
145 | + { |
146 | + glViewport(0, 0, width, height); |
147 | + } |
148 | +} |
149 | + |
150 | +static void mir_eglapp_handle_input_event(MirInputEvent const* event) |
151 | +{ |
152 | + if (mir_input_event_get_type(event) != mir_input_event_type_key) |
153 | + return; |
154 | + MirKeyboardEvent const* kev = mir_input_event_get_keyboard_event(event); |
155 | + if (mir_keyboard_event_action(kev) != mir_keyboard_action_up) |
156 | + return; |
157 | + if (mir_keyboard_event_key_code(kev) != XKB_KEY_q) |
158 | + return; |
159 | + |
160 | + running = 0; |
161 | +} |
162 | + |
163 | +static void mir_eglapp_handle_surface_event(MirSurfaceEvent const* sev) |
164 | +{ |
165 | + MirSurfaceAttrib attrib = mir_surface_event_get_attribute(sev); |
166 | + if (attrib != mir_surface_attrib_visibility) |
167 | + return; |
168 | + switch (mir_surface_event_get_attribute_value(sev)) |
169 | + { |
170 | + case mir_surface_visibility_exposed: |
171 | + printf("Surface exposed\n"); |
172 | + break; |
173 | + case mir_surface_visibility_occluded: |
174 | + printf("Surface occluded\n"); |
175 | + break; |
176 | + default: |
177 | + break; |
178 | + } |
179 | +} |
180 | + |
181 | +static void mir_eglapp_handle_event(MirSurface* surface, MirEvent const* ev, void* context) |
182 | +{ |
183 | + (void) surface; |
184 | + (void) context; |
185 | + |
186 | + switch (mir_event_get_type(ev)) |
187 | + { |
188 | + case mir_event_type_input: |
189 | + mir_eglapp_handle_input_event(mir_event_get_input_event(ev)); |
190 | + break; |
191 | + case mir_event_type_surface: |
192 | + mir_eglapp_handle_surface_event(mir_event_get_surface_event(ev)); |
193 | + break; |
194 | + case mir_event_type_resize: |
195 | + /* |
196 | + * FIXME: https://bugs.launchpad.net/mir/+bug/1194384 |
197 | + * It is unsafe to set the width and height here because we're in a |
198 | + * different thread to that doing the rendering. So we either need |
199 | + * support for event queuing (directing them to another thread) or |
200 | + * full single-threaded callbacks. (LP: #1194384). |
201 | + */ |
202 | + { |
203 | + MirResizeEvent const* resize = mir_event_get_resize_event(ev); |
204 | + printf("Resized to %dx%d\n", |
205 | + mir_resize_event_get_width(resize), |
206 | + mir_resize_event_get_height(resize)); |
207 | + } |
208 | + break; |
209 | + case mir_event_type_close_surface: |
210 | + printf("Received close event from server.\n"); |
211 | + running = 0; |
212 | + break; |
213 | + default: |
214 | + break; |
215 | + } |
216 | +} |
217 | + |
218 | +static const MirDisplayOutput *find_active_output( |
219 | + const MirDisplayConfiguration *conf) |
220 | +{ |
221 | + const MirDisplayOutput *output = NULL; |
222 | + int d; |
223 | + |
224 | + for (d = 0; d < (int)conf->num_outputs; d++) |
225 | + { |
226 | + const MirDisplayOutput *out = conf->outputs + d; |
227 | + |
228 | + if (out->used && |
229 | + out->connected && |
230 | + out->num_modes && |
231 | + out->current_mode < out->num_modes) |
232 | + { |
233 | + output = out; |
234 | + break; |
235 | + } |
236 | + } |
237 | + |
238 | + return output; |
239 | +} |
240 | + |
241 | +mir_eglapp_bool mir_eglapp_init(unsigned int *width, unsigned int *height) |
242 | +{ |
243 | + EGLint ctxattribs[] = |
244 | + { |
245 | + EGL_CONTEXT_CLIENT_VERSION, 2, |
246 | + EGL_NONE |
247 | + }; |
248 | + EGLConfig eglconfig; |
249 | + EGLint neglconfigs; |
250 | + EGLContext eglctx; |
251 | + EGLBoolean ok; |
252 | + EGLint swapinterval = 1; |
253 | + unsigned int output_id = mir_display_output_id_invalid; |
254 | + char *mir_socket = NULL; |
255 | + char const* cursor_name = mir_default_cursor_name; |
256 | + unsigned int rgb_bits = 8; |
257 | +#if 0 |
258 | + if (argc > 1) |
259 | + { |
260 | + int i; |
261 | + for (i = 1; i < argc; i++) |
262 | + { |
263 | + mir_eglapp_bool help = 0; |
264 | + const char *arg = argv[i]; |
265 | + |
266 | + if (arg[0] == '-') |
267 | + { |
268 | + if (arg[1] == '-' && arg[2] == '\0') |
269 | + break; |
270 | + |
271 | + switch (arg[1]) |
272 | + { |
273 | + case 'a': |
274 | + appname = argv[++i]; |
275 | + break; |
276 | + case 'b': |
277 | + { |
278 | + float alpha = 1.0f; |
279 | + arg += 2; |
280 | + if (!arg[0] && i < argc-1) |
281 | + { |
282 | + i++; |
283 | + arg = argv[i]; |
284 | + } |
285 | + if (sscanf(arg, "%f", &alpha) == 1) |
286 | + { |
287 | + mir_eglapp_background_opacity = alpha; |
288 | + } |
289 | + else |
290 | + { |
291 | + printf("Invalid opacity value: %s\n", arg); |
292 | + help = 1; |
293 | + } |
294 | + } |
295 | + break; |
296 | + case 'e': |
297 | + { |
298 | + arg += 2; |
299 | + if (!arg[0] && i < argc-1) |
300 | + { |
301 | + ++i; |
302 | + arg = argv[i]; |
303 | + } |
304 | + if (sscanf(arg, "%u", &rgb_bits) != 1) |
305 | + { |
306 | + printf("Invalid colour channel depth: %s\n", arg); |
307 | + help = 1; |
308 | + } |
309 | + } |
310 | + break; |
311 | + case 'n': |
312 | + swapinterval = 0; |
313 | + break; |
314 | + case 'o': |
315 | + { |
316 | + unsigned int the_id = 0; |
317 | + arg += 2; |
318 | + if (!arg[0] && i < argc-1) |
319 | + { |
320 | + i++; |
321 | + arg = argv[i]; |
322 | + } |
323 | + if (sscanf(arg, "%u", &the_id) == 1) |
324 | + { |
325 | + output_id = the_id; |
326 | + } |
327 | + else |
328 | + { |
329 | + printf("Invalid output ID: %s\n", arg); |
330 | + help = 1; |
331 | + } |
332 | + } |
333 | + break; |
334 | + case 'f': |
335 | + *width = 0; |
336 | + *height = 0; |
337 | + break; |
338 | + case 's': |
339 | + { |
340 | + unsigned int w, h; |
341 | + arg += 2; |
342 | + if (!arg[0] && i < argc-1) |
343 | + { |
344 | + i++; |
345 | + arg = argv[i]; |
346 | + } |
347 | + if (sscanf(arg, "%ux%u", &w, &h) == 2) |
348 | + { |
349 | + *width = w; |
350 | + *height = h; |
351 | + } |
352 | + else |
353 | + { |
354 | + printf("Invalid size: %s\n", arg); |
355 | + help = 1; |
356 | + } |
357 | + } |
358 | + break; |
359 | + case 'm': |
360 | + mir_socket = argv[++i]; |
361 | + printf("Mir socket = '%s'\n", mir_socket); |
362 | + break; |
363 | + case 'c': |
364 | + cursor_name = argv[++i]; |
365 | + break; |
366 | + case 'q': |
367 | + { |
368 | + FILE *unused = freopen("/dev/null", "a", stdout); |
369 | + (void)unused; |
370 | + break; |
371 | + } |
372 | + case 'h': |
373 | + default: |
374 | + help = 1; |
375 | + break; |
376 | + } |
377 | + } |
378 | + else |
379 | + { |
380 | + help = 1; |
381 | + } |
382 | + |
383 | + if (help) |
384 | + { |
385 | + printf("Usage: %s [<options>]\n" |
386 | + " -a name Set application name\n" |
387 | + " -b Background opacity (0.0 - 1.0)\n" |
388 | + " -e EGL colour channel size in bits\n" |
389 | + " -h Show this help text\n" |
390 | + " -f Force full screen\n" |
391 | + " -o ID Force placement on output monitor ID\n" |
392 | + " -n Don't sync to vblank\n" |
393 | + " -m socket Mir server socket\n" |
394 | + " -s WIDTHxHEIGHT Force surface size\n" |
395 | + " -c name Request cursor image by name\n" |
396 | + " -q Quiet mode (no messages output)\n" |
397 | + " -- Ignore all arguments that follow\n" |
398 | + , argv[0]); |
399 | + return 0; |
400 | + } |
401 | + } |
402 | + } |
403 | +#endif |
404 | + |
405 | + connection = mir_connect_sync(mir_socket, appname); |
406 | + CHECK(mir_connection_is_valid(connection), "Can't get connection"); |
407 | + |
408 | + egldisplay = eglGetDisplay( |
409 | + mir_connection_get_egl_native_display(connection)); |
410 | + CHECK(egldisplay != EGL_NO_DISPLAY, "Can't eglGetDisplay"); |
411 | + |
412 | + ok = eglInitialize(egldisplay, NULL, NULL); |
413 | + CHECK(ok, "Can't eglInitialize"); |
414 | + |
415 | + EGLint alpha_bits = mir_eglapp_background_opacity == 1.0f ? 0 : rgb_bits; |
416 | + const EGLint attribs[] = |
417 | + { |
418 | + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
419 | + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
420 | + EGL_RED_SIZE, rgb_bits, |
421 | + EGL_GREEN_SIZE, rgb_bits, |
422 | + EGL_BLUE_SIZE, rgb_bits, |
423 | + EGL_ALPHA_SIZE, alpha_bits, |
424 | + EGL_NONE |
425 | + }; |
426 | + |
427 | + ok = eglChooseConfig(egldisplay, attribs, &eglconfig, 1, &neglconfigs); |
428 | + CHECK(ok, "Could not eglChooseConfig"); |
429 | + CHECK(neglconfigs > 0, "No EGL config available"); |
430 | + |
431 | + MirPixelFormat pixel_format = |
432 | + mir_connection_get_egl_pixel_format(connection, egldisplay, eglconfig); |
433 | + |
434 | + printf("Mir chose pixel format %d.\n", pixel_format); |
435 | + if (alpha_bits == 0) |
436 | + { |
437 | + /* |
438 | + * If we are opaque then it's OK to switch pixel format slightly, |
439 | + * to enable bypass/overlays to work. Otherwise the presence of an |
440 | + * alpha channel would prevent them from being used. |
441 | + * It would be really nice if Mesa just gave us the right answer in |
442 | + * the first place though. (LP: #1480755) |
443 | + */ |
444 | + if (pixel_format == mir_pixel_format_abgr_8888) |
445 | + pixel_format = mir_pixel_format_xbgr_8888; |
446 | + else if (pixel_format == mir_pixel_format_argb_8888) |
447 | + pixel_format = mir_pixel_format_xrgb_8888; |
448 | + } |
449 | + printf("Using pixel format %d.\n", pixel_format); |
450 | + |
451 | + /* eglapps are interested in the screen size, so |
452 | + use mir_connection_create_display_config */ |
453 | + MirDisplayConfiguration* display_config = |
454 | + mir_connection_create_display_config(connection); |
455 | + |
456 | + const MirDisplayOutput *output = find_active_output(display_config); |
457 | + |
458 | + if (output == NULL) |
459 | + { |
460 | + printf("No active outputs found.\n"); |
461 | + return 0; |
462 | + } |
463 | + |
464 | + const MirDisplayMode *mode = &output->modes[output->current_mode]; |
465 | + |
466 | + printf("Current active output is %dx%d %+d%+d\n", |
467 | + mode->horizontal_resolution, mode->vertical_resolution, |
468 | + output->position_x, output->position_y); |
469 | + |
470 | + if (*width == 0) |
471 | + *width = mode->horizontal_resolution; |
472 | + if (*height == 0) |
473 | + *height = mode->vertical_resolution; |
474 | + |
475 | + mir_display_config_destroy(display_config); |
476 | + |
477 | + MirSurfaceSpec *spec = |
478 | + mir_connection_create_spec_for_normal_surface(connection, *width, *height, pixel_format); |
479 | + |
480 | + CHECK(spec != NULL, "Can't create a surface spec"); |
481 | +#if 0 |
482 | + char const* name = argv[0]; |
483 | + for (char const* p = name; *p; p++) |
484 | + { |
485 | + if (*p == '/') |
486 | + name = p + 1; |
487 | + } |
488 | +#endif |
489 | + mir_surface_spec_set_name(spec, "JustAtest"); |
490 | + |
491 | + if (output_id != mir_display_output_id_invalid) |
492 | + mir_surface_spec_set_fullscreen_on_output(spec, output_id); |
493 | + |
494 | + surface = mir_surface_create_sync(spec); |
495 | + mir_surface_spec_release(spec); |
496 | + |
497 | + CHECK(mir_surface_is_valid(surface), "Can't create a surface"); |
498 | + |
499 | + mir_surface_set_event_handler(surface, mir_eglapp_handle_event, NULL); |
500 | + |
501 | + MirCursorConfiguration *conf = mir_cursor_configuration_from_name(cursor_name); |
502 | + mir_surface_configure_cursor(surface, conf); |
503 | + mir_cursor_configuration_destroy(conf); |
504 | + |
505 | + eglsurface = eglCreateWindowSurface(egldisplay, eglconfig, |
506 | + (EGLNativeWindowType)mir_buffer_stream_get_egl_native_window(mir_surface_get_buffer_stream(surface)), NULL); |
507 | + |
508 | + CHECK(eglsurface != EGL_NO_SURFACE, "eglCreateWindowSurface failed"); |
509 | + |
510 | + eglctx = eglCreateContext(egldisplay, eglconfig, EGL_NO_CONTEXT, |
511 | + ctxattribs); |
512 | + CHECK(eglctx != EGL_NO_CONTEXT, "eglCreateContext failed"); |
513 | + |
514 | + ok = eglMakeCurrent(egldisplay, eglsurface, eglsurface, eglctx); |
515 | + CHECK(ok, "Can't eglMakeCurrent"); |
516 | + |
517 | + signal(SIGINT, shutdown); |
518 | + signal(SIGTERM, shutdown); |
519 | + signal(SIGHUP, shutdown); |
520 | + |
521 | + printf("Surface %d DPI\n", mir_surface_get_dpi(surface)); |
522 | + eglSwapInterval(egldisplay, swapinterval); |
523 | + |
524 | + running = 1; |
525 | + |
526 | + return 1; |
527 | +} |
528 | + |
529 | +struct MirConnection* mir_eglapp_native_connection() |
530 | +{ |
531 | + return connection; |
532 | +} |
533 | + |
534 | +struct MirSurface* mir_eglapp_native_surface() |
535 | +{ |
536 | + return surface; |
537 | +} |
538 | |
539 | === added file 'src/core/trust/mir/eglapp.h' |
540 | --- src/core/trust/mir/eglapp.h 1970-01-01 00:00:00 +0000 |
541 | +++ src/core/trust/mir/eglapp.h 2016-03-30 00:50:42 +0000 |
542 | @@ -0,0 +1,43 @@ |
543 | +/* |
544 | + * Copyright © 2013 Canonical Ltd. |
545 | + * |
546 | + * This program is free software: you can redistribute it and/or modify |
547 | + * it under the terms of the GNU General Public License version 3 as |
548 | + * published by the Free Software Foundation. |
549 | + * |
550 | + * This program is distributed in the hope that it will be useful, |
551 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
552 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
553 | + * GNU General Public License for more details. |
554 | + * |
555 | + * You should have received a copy of the GNU General Public License |
556 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
557 | + * |
558 | + * Author: Daniel van Vugt <daniel.van.vugt@canonical.com> |
559 | + */ |
560 | + |
561 | +#ifndef __EGLAPP_H__ |
562 | +#define __EGLAPP_H__ |
563 | + |
564 | +#ifdef __cplusplus |
565 | +extern "C" { |
566 | +#endif |
567 | + |
568 | +typedef int mir_eglapp_bool; |
569 | +struct MirConnection; |
570 | +struct MirSurface; |
571 | + |
572 | +extern float mir_eglapp_background_opacity; |
573 | + |
574 | +mir_eglapp_bool mir_eglapp_init(unsigned int *width, unsigned int *height); |
575 | +void mir_eglapp_swap_buffers(void); |
576 | +mir_eglapp_bool mir_eglapp_running(void); |
577 | +void mir_eglapp_shutdown(void); |
578 | + |
579 | +struct MirConnection* mir_eglapp_native_connection(); |
580 | +struct MirSurface* mir_eglapp_native_surface(); |
581 | +#ifdef __cplusplus |
582 | +} |
583 | +#endif |
584 | + |
585 | +#endif |
586 | |
587 | === modified file 'src/core/trust/mir/prompt_main.cpp' |
588 | --- src/core/trust/mir/prompt_main.cpp 2015-11-26 15:25:34 +0000 |
589 | +++ src/core/trust/mir/prompt_main.cpp 2016-03-30 00:50:42 +0000 |
590 | @@ -36,10 +36,16 @@ |
591 | |
592 | #include <core/posix/this_process.h> |
593 | |
594 | +#include <mirclient/mir_toolkit/mir_client_library.h> |
595 | + |
596 | #include "prompt_config.h" |
597 | #include "prompt_main.h" |
598 | |
599 | #include <iostream> |
600 | +extern "C" |
601 | +{ |
602 | +#include "eglapp.h" |
603 | +} |
604 | |
605 | namespace cli = core::trust::mir::cli; |
606 | namespace env = core::trust::mir::env; |
607 | @@ -176,7 +182,60 @@ |
608 | } |
609 | }); |
610 | |
611 | - // We already parsed the command line arguments and do not parse them |
612 | +#if 0 |
613 | + auto connection = mir_connect_sync(/* "/run/user/32011/mir_socket" */ NULL, "ThisIsJustATest"); |
614 | + |
615 | + if (not mir_connection_is_valid(connection)) |
616 | + { |
617 | + std::cerr << "Connection not valid" << std::endl; |
618 | + return EXIT_FAILURE; |
619 | + } |
620 | + std::cout << "Succesful connection" << std::endl; |
621 | + |
622 | + mir_connection_release(connection); |
623 | + std::cout << "Releasing connection" << std::endl; |
624 | + return EXIT_SUCCESS; |
625 | +#else |
626 | + unsigned int width = 0, height = 0; |
627 | + |
628 | + if (!mir_eglapp_init(&width, &height)) |
629 | + { |
630 | + std::cerr << "Cannot init egl app" << std::endl; |
631 | + return EXIT_FAILURE; |
632 | + } |
633 | + std::cout << "Succesfully inited egl app" << std::endl; |
634 | + |
635 | + typedef struct Color |
636 | + { |
637 | + GLfloat r, g, b, a; |
638 | + } Color; |
639 | + |
640 | + |
641 | + float const opacity = mir_eglapp_background_opacity; |
642 | + Color red = {opacity, 0.0f, 0.0f, opacity}; |
643 | + Color green = {0.0f, opacity, 0.0f, opacity}; |
644 | + Color blue = {0.0f, 0.0f, opacity, opacity}; |
645 | + |
646 | + for (unsigned i=0; i<20; i++) |
647 | + { |
648 | + glClearColor(red.r, red.g, red.b, red.a); |
649 | + glClear(GL_COLOR_BUFFER_BIT); |
650 | + mir_eglapp_swap_buffers(); |
651 | + |
652 | + glClearColor(green.r, green.g, green.b, green.a); |
653 | + glClear(GL_COLOR_BUFFER_BIT); |
654 | + mir_eglapp_swap_buffers(); |
655 | + |
656 | + glClearColor(blue.r, blue.g, blue.b, blue.a); |
657 | + glClear(GL_COLOR_BUFFER_BIT); |
658 | + mir_eglapp_swap_buffers(); |
659 | + } |
660 | + |
661 | + mir_eglapp_shutdown(); |
662 | + return EXIT_SUCCESS; |
663 | +#endif |
664 | + |
665 | + /*// We already parsed the command line arguments and do not parse them |
666 | // to the application. |
667 | QGuiApplication app{argc, argv}; |
668 | |
669 | @@ -227,7 +286,7 @@ |
670 | &signal_trap, |
671 | SLOT(quit(int))); |
672 | |
673 | - return app.exec(); |
674 | + return app.exec();*/ |
675 | } |
676 | |
677 | #include "prompt_main.moc" |
Test for debugging lp:1551811. Not meant for landing.