Merge lp:~cemil-azizoglu/mir/x11-better-display-handling into lp:mir
- x11-better-display-handling
- Merge into development-branch
Status: | Merged |
---|---|
Merged at revision: | 3732 |
Proposed branch: | lp:~cemil-azizoglu/mir/x11-better-display-handling |
Merge into: | lp:mir |
Diff against target: |
1158 lines (+397/-414) 15 files modified
src/platforms/mesa/server/kms/display_buffer.cpp (+1/-1) src/platforms/mesa/server/x11/graphics/CMakeLists.txt (+1/-2) src/platforms/mesa/server/x11/graphics/display.cpp (+60/-127) src/platforms/mesa/server/x11/graphics/display.h (+11/-48) src/platforms/mesa/server/x11/graphics/display_buffer.cpp (+36/-18) src/platforms/mesa/server/x11/graphics/display_buffer.h (+18/-9) src/platforms/mesa/server/x11/graphics/display_group.cpp (+0/-47) src/platforms/mesa/server/x11/graphics/display_group.h (+0/-52) src/platforms/mesa/server/x11/graphics/egl_helper.cpp (+184/-0) src/platforms/mesa/server/x11/graphics/egl_helper.h (+78/-0) src/platforms/mesa/server/x11/graphics/gl_context.cpp (+0/-45) src/platforms/mesa/server/x11/graphics/gl_context.h (+0/-52) src/platforms/mesa/server/x11/graphics/platform.cpp (+1/-1) tests/unit-tests/graphics/test_platform_prober.cpp (+3/-1) tests/unit-tests/platforms/mesa/x11/test_display.cpp (+4/-11) |
To merge this branch: | bzr merge lp:~cemil-azizoglu/mir/x11-better-display-handling |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir CI Bot | continuous-integration | Needs Fixing | |
Alan Griffiths | Approve | ||
Daniel van Vugt | Abstain | ||
Alexandros Frantzis (community) | Approve | ||
Review via email: mp+306681@code.launchpad.net |
Commit message
Overhauled mgx::Display and mgx::DisplayBuffer implementations to bring it more inline with mesa-kms.
Description of the change
Overhauled mgx::Display and mgx::DisplayBuffer implementations.
- Previously, mgx::Display created a window *and* set up the egl window surface. With this branch it only creates the window as that's the "display", but leaves the egl window creation/management to mgx::DisplayBuffer much like its kms counterpart.
- Created an EGL helper, much like the mgmh::EGLHelper, though too bad it can't reuse the same code as mesa-kms uses gbm while mesa-x11 uses x11 objects in the headers.
- Fixed the bug where mir_demo_
- Similar to mesa-kms, made mgx::DisplayBuffer inherit from DisplaySyncGroup, which simplifies the code.
Mir CI Bot (mir-ci-bot) wrote : | # |
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3716
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:/
Click here to trigger a rebuild:
https:/
Daniel van Vugt (vanvugt) wrote : | # |
Please have a look at this before we have major conflicts:
https:/
Alexandros Frantzis (afrantzis) wrote : | # |
Looks good.
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
> Please have a look at this before we have major conflicts:
> https:/
We will definitely conflict. It'd be good if you could rebase to this MP as the Display/
Daniel van Vugt (vanvugt) wrote : | # |
Well I've had that code written in some form for months. It would be nice if I didn't have to rewrite parts due to this branch.
Daniel van Vugt (vanvugt) : | # |
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
> Well I've had that code written in some form for months. It would be nice if I
> didn't have to rewrite parts due to this branch.
Understood. I guess this is part of the game. No worries. If this one lands before yours I can help you rebase it.
Daniel van Vugt (vanvugt) wrote : | # |
Also, please check this list in case you're fixing more bugs than you know(!)
Alan Griffiths (alan-griffiths) wrote : | # |
Well, the code looks no worse than before ;)
And it does seem to fix Mir-on-X11 mode for mir_demo_
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Daniel van Vugt (vanvugt) wrote : | # |
^^^
Archive sync problems are new today. Also bug 1628828 is happening.
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Preview Diff
1 | === modified file 'src/platforms/mesa/server/kms/display_buffer.cpp' |
2 | --- src/platforms/mesa/server/kms/display_buffer.cpp 2016-09-19 06:09:48 +0000 |
3 | +++ src/platforms/mesa/server/kms/display_buffer.cpp 2016-09-26 01:54:42 +0000 |
4 | @@ -152,7 +152,7 @@ |
5 | |
6 | set_crtc(scheduled_composite_frame); |
7 | |
8 | - egl.release_current(); |
9 | + release_current(); |
10 | |
11 | listener->report_successful_drm_mode_set_crtc_on_construction(); |
12 | listener->report_successful_display_construction(); |
13 | |
14 | === modified file 'src/platforms/mesa/server/x11/graphics/CMakeLists.txt' |
15 | --- src/platforms/mesa/server/x11/graphics/CMakeLists.txt 2016-07-28 03:39:52 +0000 |
16 | +++ src/platforms/mesa/server/x11/graphics/CMakeLists.txt 2016-09-26 01:54:42 +0000 |
17 | @@ -19,9 +19,8 @@ |
18 | guest_platform.cpp |
19 | display.cpp |
20 | display_configuration.cpp |
21 | - gl_context.cpp |
22 | - display_group.cpp |
23 | display_buffer.cpp |
24 | + egl_helper.cpp |
25 | ) |
26 | |
27 | add_library( |
28 | |
29 | === modified file 'src/platforms/mesa/server/x11/graphics/display.cpp' |
30 | --- src/platforms/mesa/server/x11/graphics/display.cpp 2016-09-15 00:57:28 +0000 |
31 | +++ src/platforms/mesa/server/x11/graphics/display.cpp 2016-09-26 01:54:42 +0000 |
32 | @@ -18,24 +18,25 @@ |
33 | |
34 | #include "mir/graphics/platform.h" |
35 | #include "mir/graphics/display_report.h" |
36 | -#include "mir/graphics/egl_resources.h" |
37 | #include "mir/graphics/egl_error.h" |
38 | #include "mir/graphics/virtual_output.h" |
39 | +#include "mir/renderer/gl/context.h" |
40 | #include "mir/graphics/gl_config.h" |
41 | #include "display_configuration.h" |
42 | #include "display.h" |
43 | #include "display_buffer.h" |
44 | -#include "gl_context.h" |
45 | |
46 | #include <boost/throw_exception.hpp> |
47 | -#include <fcntl.h> |
48 | -#include <mutex> |
49 | |
50 | #include <X11/Xatom.h> |
51 | |
52 | #define MIR_LOG_COMPONENT "x11-display" |
53 | #include "mir/log.h" |
54 | |
55 | +namespace mg=mir::graphics; |
56 | +namespace mgx=mg::X; |
57 | +namespace geom=mir::geometry; |
58 | + |
59 | namespace |
60 | { |
61 | auto get_pixel_width(Display *dpy) |
62 | @@ -50,66 +51,45 @@ |
63 | |
64 | return float(screen->mheight) / screen->height; |
65 | } |
66 | -} |
67 | - |
68 | -namespace mg=mir::graphics; |
69 | -namespace mgx=mg::X; |
70 | -namespace geom=mir::geometry; |
71 | - |
72 | -mgx::X11EGLDisplay::X11EGLDisplay(::Display* x_dpy) |
73 | - : egl_dpy{eglGetDisplay(x_dpy)} |
74 | -{ |
75 | - if (!egl_dpy) |
76 | - BOOST_THROW_EXCEPTION(mg::egl_error("Cannot get an egl display")); |
77 | - |
78 | - EGLint egl_major, egl_minor; |
79 | - if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) |
80 | - BOOST_THROW_EXCEPTION(mg::egl_error("eglInitialize failed")); |
81 | - |
82 | - mir::log_info("EGL Version %d.%d", egl_major, egl_minor); |
83 | -} |
84 | - |
85 | -mgx::X11EGLDisplay::~X11EGLDisplay() |
86 | -{ |
87 | - eglTerminate(egl_dpy); |
88 | -} |
89 | - |
90 | -mgx::X11EGLDisplay::operator EGLDisplay() const |
91 | -{ |
92 | - return egl_dpy; |
93 | + |
94 | +class XGLContext : public mir::renderer::gl::Context |
95 | +{ |
96 | +public: |
97 | + XGLContext(::Display* const x_dpy, |
98 | + std::shared_ptr<mg::GLConfig> const& gl_config, |
99 | + EGLContext const shared_ctx) |
100 | + : egl{*gl_config} |
101 | + { |
102 | + egl.setup(x_dpy, shared_ctx); |
103 | + } |
104 | + |
105 | + ~XGLContext() = default; |
106 | + |
107 | + void make_current() const override |
108 | + { |
109 | + egl.make_current(); |
110 | + } |
111 | + |
112 | + void release_current() const override |
113 | + { |
114 | + egl.release_current(); |
115 | + } |
116 | + |
117 | +private: |
118 | + mgx::helpers::EGLHelper egl; |
119 | +}; |
120 | } |
121 | |
122 | mgx::X11Window::X11Window(::Display* x_dpy, |
123 | EGLDisplay egl_dpy, |
124 | geom::Size const size, |
125 | - GLConfig const& gl_config) |
126 | + EGLConfig const egl_cfg) |
127 | : x_dpy{x_dpy} |
128 | { |
129 | - EGLint const att[] = { |
130 | - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
131 | - EGL_RED_SIZE, 8, |
132 | - EGL_GREEN_SIZE, 8, |
133 | - EGL_BLUE_SIZE, 8, |
134 | - EGL_ALPHA_SIZE, 8, |
135 | - EGL_DEPTH_SIZE, gl_config.depth_buffer_bits(), |
136 | - EGL_STENCIL_SIZE, gl_config.stencil_buffer_bits(), |
137 | - EGL_RENDERABLE_TYPE, MIR_SERVER_EGL_OPENGL_BIT, |
138 | - EGL_NONE |
139 | - }; |
140 | - |
141 | auto root = XDefaultRootWindow(x_dpy); |
142 | |
143 | - EGLint num_configs; |
144 | - if (!eglChooseConfig(egl_dpy, att, &config, 1, &num_configs)) |
145 | - BOOST_THROW_EXCEPTION(mg::egl_error("Cannot get an EGL config")); |
146 | - |
147 | - mir::log_info("%d config(s) found", num_configs); |
148 | - |
149 | - if (num_configs <= 0) |
150 | - BOOST_THROW_EXCEPTION(mg::egl_error("Cannot get an EGL config")); |
151 | - |
152 | EGLint vid; |
153 | - if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) |
154 | + if (!eglGetConfigAttrib(egl_dpy, egl_cfg, EGL_NATIVE_VISUAL_ID, &vid)) |
155 | BOOST_THROW_EXCEPTION(mg::egl_error("Cannot get config attrib")); |
156 | |
157 | XVisualInfo visTemplate; |
158 | @@ -214,103 +194,56 @@ |
159 | return win; |
160 | } |
161 | |
162 | -EGLConfig mgx::X11Window::egl_config() const |
163 | -{ |
164 | - return config; |
165 | -} |
166 | - |
167 | unsigned long mgx::X11Window::red_mask() const |
168 | { |
169 | return r_mask; |
170 | } |
171 | |
172 | -mgx::X11EGLContext::X11EGLContext(EGLDisplay egl_dpy, EGLConfig config) |
173 | - : egl_dpy{egl_dpy} |
174 | -{ |
175 | - eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
176 | - |
177 | - static const EGLint ctx_attribs[] = { |
178 | -#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT |
179 | - EGL_CONTEXT_CLIENT_VERSION, 2, |
180 | -#endif |
181 | - EGL_NONE }; |
182 | - |
183 | - egl_ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs); |
184 | - if (!egl_ctx) |
185 | - BOOST_THROW_EXCEPTION(mg::egl_error("eglCreateContext failed")); |
186 | -} |
187 | - |
188 | -mgx::X11EGLContext::~X11EGLContext() |
189 | -{ |
190 | - eglDestroyContext(egl_dpy, egl_ctx); |
191 | -} |
192 | - |
193 | -mgx::X11EGLContext::operator EGLContext() const |
194 | -{ |
195 | - return egl_ctx; |
196 | -} |
197 | - |
198 | -mgx::X11EGLSurface::X11EGLSurface(EGLDisplay egl_dpy, EGLConfig config, Window win) |
199 | - : egl_dpy{egl_dpy}, egl_surf{eglCreateWindowSurface(egl_dpy, config, win, NULL)} |
200 | -{ |
201 | - if (!egl_surf) |
202 | - BOOST_THROW_EXCEPTION(mg::egl_error("eglCreateWindowSurface failed")); |
203 | -} |
204 | - |
205 | -mgx::X11EGLSurface::~X11EGLSurface() |
206 | -{ |
207 | - eglDestroySurface(egl_dpy, egl_surf); |
208 | -} |
209 | - |
210 | -mgx::X11EGLSurface::operator EGLSurface() const |
211 | -{ |
212 | - return egl_surf; |
213 | -} |
214 | - |
215 | mgx::Display::Display(::Display* x_dpy, |
216 | geom::Size const size, |
217 | - GLConfig const& gl_config, |
218 | + std::shared_ptr<GLConfig> const& gl_config, |
219 | std::shared_ptr<DisplayReport> const& report) |
220 | - : egl_display{X11EGLDisplay(x_dpy)}, |
221 | + : shared_egl{*gl_config}, |
222 | + x_dpy{x_dpy}, |
223 | size{size}, |
224 | + gl_config{gl_config}, |
225 | pixel_width{get_pixel_width(x_dpy)}, |
226 | pixel_height{get_pixel_height(x_dpy)}, |
227 | - win{X11Window(x_dpy, |
228 | - egl_display, |
229 | - size, |
230 | - gl_config)}, |
231 | - egl_context{X11EGLContext(egl_display, |
232 | - win.egl_config())}, |
233 | - egl_surface{X11EGLSurface(egl_display, |
234 | - win.egl_config(), |
235 | - win)}, |
236 | report{report}, |
237 | orientation{mir_orientation_normal} |
238 | { |
239 | - auto red_mask = win.red_mask(); |
240 | + shared_egl.setup(x_dpy); |
241 | + |
242 | + win = std::make_unique<X11Window>(x_dpy, |
243 | + shared_egl.display(), |
244 | + size, |
245 | + shared_egl.config()); |
246 | + |
247 | + auto red_mask = win->red_mask(); |
248 | pf = (red_mask == 0xFF0000 ? mir_pixel_format_argb_8888 |
249 | : mir_pixel_format_abgr_8888); |
250 | |
251 | - display_group = std::make_unique<mgx::DisplayGroup>( |
252 | - std::make_unique<mgx::DisplayBuffer>(size, |
253 | - egl_display, |
254 | - egl_surface, |
255 | - egl_context, |
256 | - report, |
257 | - orientation)); |
258 | - |
259 | - report->report_egl_configuration(egl_display, win.egl_config()); |
260 | + display_buffer = std::make_unique<mgx::DisplayBuffer>( |
261 | + x_dpy, |
262 | + *win, |
263 | + size, |
264 | + shared_egl.context(), |
265 | + report, |
266 | + orientation, |
267 | + *gl_config); |
268 | + |
269 | + shared_egl.make_current(); |
270 | + |
271 | report->report_successful_display_construction(); |
272 | } |
273 | |
274 | mgx::Display::~Display() noexcept |
275 | { |
276 | - eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
277 | } |
278 | |
279 | void mgx::Display::for_each_display_sync_group(std::function<void(mg::DisplaySyncGroup&)> const& f) |
280 | { |
281 | - f(*display_group); |
282 | + f(*display_buffer); |
283 | } |
284 | |
285 | std::unique_ptr<mg::DisplayConfiguration> mgx::Display::configuration() const |
286 | @@ -335,7 +268,7 @@ |
287 | }); |
288 | |
289 | orientation = o; |
290 | - display_group->set_orientation(orientation); |
291 | + display_buffer->set_orientation(orientation); |
292 | } |
293 | |
294 | void mgx::Display::register_configuration_change_handler( |
295 | @@ -378,7 +311,7 @@ |
296 | |
297 | std::unique_ptr<mir::renderer::gl::Context> mgx::Display::create_gl_context() |
298 | { |
299 | - return std::make_unique<mgx::XGLContext>(egl_display, egl_surface, egl_context); |
300 | + return std::make_unique<XGLContext>(x_dpy, gl_config, shared_egl.context()); |
301 | } |
302 | |
303 | bool mgx::Display::apply_if_configuration_preserves_display_buffers( |
304 | |
305 | === modified file 'src/platforms/mesa/server/x11/graphics/display.h' |
306 | --- src/platforms/mesa/server/x11/graphics/display.h 2016-09-15 00:57:28 +0000 |
307 | +++ src/platforms/mesa/server/x11/graphics/display.h 2016-09-26 01:54:42 +0000 |
308 | @@ -20,10 +20,10 @@ |
309 | #define MIR_GRAPHICS_X_DISPLAY_H_ |
310 | |
311 | #include "mir/graphics/display.h" |
312 | +#include "mir/geometry/size.h" |
313 | #include "mir/renderer/gl/context_source.h" |
314 | #include "mir_toolkit/common.h" |
315 | -#include "display_group.h" |
316 | -#include "mir/geometry/size.h" |
317 | +#include "egl_helper.h" |
318 | |
319 | #include <X11/Xlib.h> |
320 | #include <X11/Xutil.h> |
321 | @@ -35,21 +35,12 @@ |
322 | { |
323 | |
324 | class GLConfig; |
325 | +class DisplayReport; |
326 | |
327 | namespace X |
328 | { |
329 | |
330 | -class X11EGLDisplay |
331 | -{ |
332 | -public: |
333 | - X11EGLDisplay(::Display* x_dpy); |
334 | - ~X11EGLDisplay(); |
335 | - |
336 | - operator EGLDisplay() const; |
337 | - |
338 | -private: |
339 | - EGLDisplay const egl_dpy; |
340 | -}; |
341 | +class DisplayBuffer; |
342 | |
343 | class X11Window |
344 | { |
345 | @@ -57,46 +48,18 @@ |
346 | X11Window(::Display* const x_dpy, |
347 | EGLDisplay egl_dpy, |
348 | geometry::Size const size, |
349 | - GLConfig const& gl_config); |
350 | + EGLConfig const egl_cfg); |
351 | ~X11Window(); |
352 | |
353 | operator Window() const; |
354 | - EGLConfig egl_config() const; |
355 | unsigned long red_mask() const; |
356 | |
357 | private: |
358 | ::Display* const x_dpy; |
359 | Window win; |
360 | - EGLConfig config; |
361 | unsigned long r_mask; |
362 | }; |
363 | |
364 | -class X11EGLContext |
365 | -{ |
366 | -public: |
367 | - X11EGLContext(EGLDisplay egl_dpy, EGLConfig config); |
368 | - ~X11EGLContext(); |
369 | - |
370 | - operator EGLContext() const; |
371 | - |
372 | -private: |
373 | - EGLContext egl_ctx; |
374 | - EGLDisplay const egl_dpy; |
375 | -}; |
376 | - |
377 | -class X11EGLSurface |
378 | -{ |
379 | -public: |
380 | - X11EGLSurface(EGLDisplay egl_dpy, EGLConfig config, Window win); |
381 | - ~X11EGLSurface(); |
382 | - |
383 | - operator EGLSurface() const; |
384 | - |
385 | -private: |
386 | - EGLDisplay const egl_dpy; |
387 | - EGLSurface const egl_surf; |
388 | -}; |
389 | - |
390 | class Display : public graphics::Display, |
391 | public graphics::NativeDisplay, |
392 | public renderer::gl::ContextSource |
393 | @@ -104,7 +67,7 @@ |
394 | public: |
395 | explicit Display(::Display* x_dpy, |
396 | geometry::Size const size, |
397 | - GLConfig const& gl_config, |
398 | + std::shared_ptr<GLConfig> const& gl_config, |
399 | std::shared_ptr<DisplayReport> const& report); |
400 | ~Display() noexcept; |
401 | |
402 | @@ -136,17 +99,17 @@ |
403 | std::unique_ptr<renderer::gl::Context> create_gl_context() override; |
404 | |
405 | private: |
406 | - X11EGLDisplay const egl_display; |
407 | + helpers::EGLHelper shared_egl; |
408 | + ::Display* const x_dpy; |
409 | mir::geometry::Size const size; |
410 | + std::shared_ptr<GLConfig> const gl_config; |
411 | float pixel_width; |
412 | float pixel_height; |
413 | - X11Window const win; |
414 | - X11EGLContext egl_context; |
415 | - X11EGLSurface egl_surface; |
416 | + std::unique_ptr<X11Window> win; |
417 | MirPixelFormat pf; |
418 | - std::unique_ptr<DisplayGroup> display_group; |
419 | std::shared_ptr<DisplayReport> const report; |
420 | MirOrientation orientation; //TODO: keep entire current display configuration |
421 | + std::unique_ptr<DisplayBuffer> display_buffer; |
422 | }; |
423 | |
424 | } |
425 | |
426 | === modified file 'src/platforms/mesa/server/x11/graphics/display_buffer.cpp' |
427 | --- src/platforms/mesa/server/x11/graphics/display_buffer.cpp 2016-09-19 06:09:48 +0000 |
428 | +++ src/platforms/mesa/server/x11/graphics/display_buffer.cpp 2016-09-26 01:54:42 +0000 |
429 | @@ -17,29 +17,33 @@ |
430 | * |
431 | */ |
432 | |
433 | -#include "mir/graphics/egl_error.h" |
434 | +#include "mir/fatal.h" |
435 | #include "display_buffer.h" |
436 | #include "display_configuration.h" |
437 | - |
438 | -#include <boost/throw_exception.hpp> |
439 | +#include "mir/graphics/display_report.h" |
440 | |
441 | namespace mg=mir::graphics; |
442 | namespace mgx=mg::X; |
443 | namespace geom=mir::geometry; |
444 | |
445 | -mgx::DisplayBuffer::DisplayBuffer(geom::Size const sz, |
446 | - EGLDisplay const d, |
447 | - EGLSurface const s, |
448 | - EGLContext const c, |
449 | +mgx::DisplayBuffer::DisplayBuffer(::Display* const x_dpy, |
450 | + Window const win, |
451 | + geom::Size const sz, |
452 | + EGLContext const shared_context, |
453 | std::shared_ptr<DisplayReport> const& r, |
454 | - MirOrientation const o) |
455 | + MirOrientation const o, |
456 | + GLConfig const& gl_config) |
457 | : size{sz}, |
458 | - egl_dpy{d}, |
459 | - egl_surf{s}, |
460 | - egl_ctx{c}, |
461 | report{r}, |
462 | - orientation_{o} |
463 | + orientation_{o}, |
464 | + egl{gl_config} |
465 | { |
466 | + egl.setup(x_dpy, win, shared_context); |
467 | + egl.report_egl_configuration( |
468 | + [&r] (EGLDisplay disp, EGLConfig cfg) |
469 | + { |
470 | + r->report_egl_configuration(disp, cfg); |
471 | + }); |
472 | } |
473 | |
474 | geom::Rectangle mgx::DisplayBuffer::view_area() const |
475 | @@ -56,14 +60,13 @@ |
476 | |
477 | void mgx::DisplayBuffer::make_current() |
478 | { |
479 | - if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) |
480 | - BOOST_THROW_EXCEPTION(mg::egl_error("Cannot make current")); |
481 | + if (!egl.make_current()) |
482 | + fatal_error("Failed to make EGL surface current"); |
483 | } |
484 | |
485 | void mgx::DisplayBuffer::release_current() |
486 | { |
487 | - if (!eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) |
488 | - BOOST_THROW_EXCEPTION(mg::egl_error("Cannot make uncurrent")); |
489 | + egl.release_current(); |
490 | } |
491 | |
492 | bool mgx::DisplayBuffer::overlay(RenderableList const& /*renderlist*/) |
493 | @@ -73,8 +76,8 @@ |
494 | |
495 | void mgx::DisplayBuffer::swap_buffers() |
496 | { |
497 | - if (!eglSwapBuffers(egl_dpy, egl_surf)) |
498 | - BOOST_THROW_EXCEPTION(mg::egl_error("Cannot swap")); |
499 | + if (!egl.swap_buffers()) |
500 | + fatal_error("Failed to perform buffer swap"); |
501 | |
502 | /* |
503 | * Admittedly we are not a real display and will miss some real vsyncs |
504 | @@ -107,3 +110,18 @@ |
505 | { |
506 | return this; |
507 | } |
508 | + |
509 | +void mgx::DisplayBuffer::for_each_display_buffer( |
510 | + std::function<void(graphics::DisplayBuffer&)> const& f) |
511 | +{ |
512 | + f(*this); |
513 | +} |
514 | + |
515 | +void mgx::DisplayBuffer::post() |
516 | +{ |
517 | +} |
518 | + |
519 | +std::chrono::milliseconds mgx::DisplayBuffer::recommended_sleep() const |
520 | +{ |
521 | + return std::chrono::milliseconds::zero(); |
522 | +} |
523 | |
524 | === modified file 'src/platforms/mesa/server/x11/graphics/display_buffer.h' |
525 | --- src/platforms/mesa/server/x11/graphics/display_buffer.h 2016-09-19 06:09:48 +0000 |
526 | +++ src/platforms/mesa/server/x11/graphics/display_buffer.h 2016-09-26 01:54:42 +0000 |
527 | @@ -20,10 +20,10 @@ |
528 | #ifndef MIR_GRAPHICS_X_DISPLAY_BUFFER_H_ |
529 | #define MIR_GRAPHICS_X_DISPLAY_BUFFER_H_ |
530 | |
531 | -#include "mir/graphics/display_report.h" |
532 | #include "mir/graphics/display_buffer.h" |
533 | +#include "mir/graphics/display.h" |
534 | #include "mir/renderer/gl/render_target.h" |
535 | -#include "gl_context.h" |
536 | +#include "egl_helper.h" |
537 | |
538 | #include <EGL/egl.h> |
539 | #include <memory> |
540 | @@ -32,21 +32,27 @@ |
541 | { |
542 | namespace graphics |
543 | { |
544 | + |
545 | +class GLConfig; |
546 | +class DisplayReport; |
547 | + |
548 | namespace X |
549 | { |
550 | |
551 | class DisplayBuffer : public graphics::DisplayBuffer, |
552 | + public graphics::DisplaySyncGroup, |
553 | public graphics::NativeDisplayBuffer, |
554 | public renderer::gl::RenderTarget |
555 | { |
556 | public: |
557 | DisplayBuffer( |
558 | + ::Display* const x_dpy, |
559 | + Window const win, |
560 | geometry::Size const sz, |
561 | - EGLDisplay const d, |
562 | - EGLSurface const s, |
563 | - EGLContext const c, |
564 | + EGLContext const shared_context, |
565 | std::shared_ptr<DisplayReport> const& r, |
566 | - MirOrientation const o); |
567 | + MirOrientation const o, |
568 | + GLConfig const& gl_config); |
569 | |
570 | geometry::Rectangle view_area() const override; |
571 | void make_current() override; |
572 | @@ -56,17 +62,20 @@ |
573 | bool overlay(RenderableList const& renderlist) override; |
574 | void set_orientation(MirOrientation const new_orientation); |
575 | |
576 | + void for_each_display_buffer( |
577 | + std::function<void(graphics::DisplayBuffer&)> const& f) override; |
578 | + void post() override; |
579 | + std::chrono::milliseconds recommended_sleep() const override; |
580 | + |
581 | MirOrientation orientation() const override; |
582 | MirMirrorMode mirror_mode() const override; |
583 | NativeDisplayBuffer* native_display_buffer() override; |
584 | |
585 | private: |
586 | geometry::Size const size; |
587 | - EGLDisplay const egl_dpy; |
588 | - EGLSurface const egl_surf; |
589 | - EGLContext const egl_ctx; |
590 | std::shared_ptr<DisplayReport> const report; |
591 | MirOrientation orientation_; |
592 | + helpers::EGLHelper egl; |
593 | }; |
594 | |
595 | } |
596 | |
597 | === removed file 'src/platforms/mesa/server/x11/graphics/display_group.cpp' |
598 | --- src/platforms/mesa/server/x11/graphics/display_group.cpp 2016-01-29 08:18:22 +0000 |
599 | +++ src/platforms/mesa/server/x11/graphics/display_group.cpp 1970-01-01 00:00:00 +0000 |
600 | @@ -1,47 +0,0 @@ |
601 | -/* |
602 | - * Copyright © 2015 Canonical Ltd. |
603 | - * |
604 | - * This program is free software: you can redistribute it and/or modify it |
605 | - * under the terms of the GNU Lesser General Public License version 3, |
606 | - * as published by the Free Software Foundation. |
607 | - * |
608 | - * This program is distributed in the hope that it will be useful, |
609 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
610 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
611 | - * GNU Lesser General Public License for more details. |
612 | - * |
613 | - * You should have received a copy of the GNU Lesser General Public License |
614 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
615 | - * |
616 | - * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com> |
617 | - * |
618 | - */ |
619 | - |
620 | -#include "display_group.h" |
621 | - |
622 | -namespace mg = mir::graphics; |
623 | -namespace mgx = mg::X; |
624 | - |
625 | -mgx::DisplayGroup::DisplayGroup(std::unique_ptr<mgx::DisplayBuffer> primary_buffer) |
626 | -{ |
627 | - display_buffer = std::move(primary_buffer); |
628 | -} |
629 | - |
630 | -void mgx::DisplayGroup::for_each_display_buffer(std::function<void(mg::DisplayBuffer&)> const& f) |
631 | -{ |
632 | - f(*display_buffer); |
633 | -} |
634 | - |
635 | -void mgx::DisplayGroup::post() |
636 | -{ |
637 | -} |
638 | - |
639 | -std::chrono::milliseconds mgx::DisplayGroup::recommended_sleep() const |
640 | -{ |
641 | - return std::chrono::milliseconds::zero(); |
642 | -} |
643 | - |
644 | -void mgx::DisplayGroup::set_orientation(MirOrientation orientation) |
645 | -{ |
646 | - display_buffer->set_orientation(orientation); |
647 | -} |
648 | |
649 | === removed file 'src/platforms/mesa/server/x11/graphics/display_group.h' |
650 | --- src/platforms/mesa/server/x11/graphics/display_group.h 2016-01-29 08:18:22 +0000 |
651 | +++ src/platforms/mesa/server/x11/graphics/display_group.h 1970-01-01 00:00:00 +0000 |
652 | @@ -1,52 +0,0 @@ |
653 | -/* |
654 | - * Copyright © 2015 Canonical Ltd. |
655 | - * |
656 | - * This program is free software: you can redistribute it and/or modify it |
657 | - * under the terms of the GNU Lesser General Public License version 3, |
658 | - * as published by the Free Software Foundation. |
659 | - * |
660 | - * This program is distributed in the hope that it will be useful, |
661 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
662 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
663 | - * GNU Lesser General Public License for more details. |
664 | - * |
665 | - * You should have received a copy of the GNU Lesser General Public License |
666 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
667 | - * |
668 | - * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com> |
669 | - * |
670 | - */ |
671 | - |
672 | -#ifndef MIR_GRAPHICS_X_DISPLAY_GROUP_H_ |
673 | -#define MIR_GRAPHICS_X_DISPLAY_GROUP_H_ |
674 | - |
675 | -#include "mir_toolkit/common.h" |
676 | -#include "mir/graphics/display.h" |
677 | -#include "display_buffer.h" |
678 | - |
679 | -namespace mir |
680 | -{ |
681 | -namespace graphics |
682 | -{ |
683 | -namespace X |
684 | -{ |
685 | - |
686 | -class DisplayGroup : public graphics::DisplaySyncGroup |
687 | -{ |
688 | -public: |
689 | - DisplayGroup(std::unique_ptr<DisplayBuffer> primary_buffer); |
690 | - |
691 | - void for_each_display_buffer(std::function<void(graphics::DisplayBuffer&)> const& f) override; |
692 | - void post() override; |
693 | - std::chrono::milliseconds recommended_sleep() const override; |
694 | - void set_orientation(MirOrientation orientation); |
695 | - |
696 | -private: |
697 | - std::unique_ptr<DisplayBuffer> display_buffer; |
698 | -}; |
699 | - |
700 | -} |
701 | -} |
702 | -} |
703 | - |
704 | -#endif /* MIR_GRAPHICS_X_DISPLAY_GROUP_H_ */ |
705 | |
706 | === added file 'src/platforms/mesa/server/x11/graphics/egl_helper.cpp' |
707 | --- src/platforms/mesa/server/x11/graphics/egl_helper.cpp 1970-01-01 00:00:00 +0000 |
708 | +++ src/platforms/mesa/server/x11/graphics/egl_helper.cpp 2016-09-26 01:54:42 +0000 |
709 | @@ -0,0 +1,184 @@ |
710 | +/* |
711 | + * Copyright © 2016 Canonical Ltd. |
712 | + * |
713 | + * This program is free software: you can redistribute it and/or modify it |
714 | + * under the terms of the GNU Lesser General Public License version 3, |
715 | + * as published by the Free Software Foundation. |
716 | + * |
717 | + * This program is distributed in the hope that it will be useful, |
718 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
719 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
720 | + * GNU Lesser General Public License for more details. |
721 | + * |
722 | + * You should have received a copy of the GNU Lesser General Public License |
723 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
724 | + * |
725 | + * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com> |
726 | + */ |
727 | + |
728 | +#include "egl_helper.h" |
729 | + |
730 | +#include "mir/graphics/gl_config.h" |
731 | +#include "mir/graphics/egl_error.h" |
732 | + |
733 | +#include <boost/throw_exception.hpp> |
734 | + |
735 | +namespace mg = mir::graphics; |
736 | +namespace mgx = mg::X; |
737 | +namespace mgxh = mgx::helpers; |
738 | + |
739 | +mgxh::EGLHelper::EGLHelper(GLConfig const& gl_config) |
740 | + : depth_buffer_bits{gl_config.depth_buffer_bits()}, |
741 | + stencil_buffer_bits{gl_config.stencil_buffer_bits()}, |
742 | + egl_display{EGL_NO_DISPLAY}, egl_config{0}, |
743 | + egl_context{EGL_NO_CONTEXT}, egl_surface{EGL_NO_SURFACE}, |
744 | + should_terminate_egl{false} |
745 | +{ |
746 | +} |
747 | + |
748 | +void mgxh::EGLHelper::setup(::Display* const x_dpy) |
749 | +{ |
750 | + eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
751 | + |
752 | + static const EGLint context_attr[] = { |
753 | +#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT |
754 | + EGL_CONTEXT_CLIENT_VERSION, 2, |
755 | +#endif |
756 | + EGL_NONE |
757 | + }; |
758 | + |
759 | + setup_internal(x_dpy, true); |
760 | + |
761 | + egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, context_attr); |
762 | + if (egl_context == EGL_NO_CONTEXT) |
763 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL context")); |
764 | +} |
765 | + |
766 | +void mgxh::EGLHelper::setup(::Display* const x_dpy, EGLContext shared_context) |
767 | +{ |
768 | + eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
769 | + |
770 | + static const EGLint context_attr[] = { |
771 | +#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT |
772 | + EGL_CONTEXT_CLIENT_VERSION, 2, |
773 | +#endif |
774 | + EGL_NONE |
775 | + }; |
776 | + |
777 | + setup_internal(x_dpy, false); |
778 | + |
779 | + egl_context = eglCreateContext(egl_display, egl_config, shared_context, context_attr); |
780 | + if (egl_context == EGL_NO_CONTEXT) |
781 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL context")); |
782 | +} |
783 | + |
784 | +void mgxh::EGLHelper::setup(::Display* const x_dpy, Window win, |
785 | + EGLContext shared_context) |
786 | +{ |
787 | + eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
788 | + |
789 | + static const EGLint context_attr[] = { |
790 | +#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT |
791 | + EGL_CONTEXT_CLIENT_VERSION, 2, |
792 | +#endif |
793 | + EGL_NONE |
794 | + }; |
795 | + |
796 | + setup_internal(x_dpy, false); |
797 | + |
798 | + egl_surface = eglCreateWindowSurface(egl_display, egl_config, win, nullptr); |
799 | + if(egl_surface == EGL_NO_SURFACE) |
800 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL window surface")); |
801 | + |
802 | + egl_context = eglCreateContext(egl_display, egl_config, shared_context, context_attr); |
803 | + if (egl_context == EGL_NO_CONTEXT) |
804 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL context")); |
805 | +} |
806 | + |
807 | +mgxh::EGLHelper::~EGLHelper() noexcept |
808 | +{ |
809 | + if (egl_display != EGL_NO_DISPLAY) { |
810 | + if (egl_context != EGL_NO_CONTEXT) |
811 | + { |
812 | + eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
813 | + if (eglGetCurrentContext() == egl_context) |
814 | + eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
815 | + eglDestroyContext(egl_display, egl_context); |
816 | + } |
817 | + if (egl_surface != EGL_NO_SURFACE) |
818 | + eglDestroySurface(egl_display, egl_surface); |
819 | + if (should_terminate_egl) |
820 | + eglTerminate(egl_display); |
821 | + } |
822 | +} |
823 | + |
824 | +bool mgxh::EGLHelper::swap_buffers() |
825 | +{ |
826 | + auto ret = eglSwapBuffers(egl_display, egl_surface); |
827 | + return (ret == EGL_TRUE); |
828 | +} |
829 | + |
830 | +bool mgxh::EGLHelper::make_current() const |
831 | +{ |
832 | + auto ret = eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context); |
833 | + eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
834 | + return (ret == EGL_TRUE); |
835 | +} |
836 | + |
837 | +bool mgxh::EGLHelper::release_current() const |
838 | +{ |
839 | + auto ret = eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
840 | + return (ret == EGL_TRUE); |
841 | +} |
842 | + |
843 | +void mgxh::EGLHelper::setup_internal(::Display* const x_dpy, bool initialize) |
844 | +{ |
845 | + EGLint const config_attr[] = { |
846 | + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
847 | + EGL_RED_SIZE, 8, |
848 | + EGL_GREEN_SIZE, 8, |
849 | + EGL_BLUE_SIZE, 8, |
850 | + EGL_ALPHA_SIZE, 8, |
851 | + EGL_DEPTH_SIZE, depth_buffer_bits, |
852 | + EGL_STENCIL_SIZE, stencil_buffer_bits, |
853 | + EGL_RENDERABLE_TYPE, MIR_SERVER_EGL_OPENGL_BIT, |
854 | + EGL_NONE |
855 | + }; |
856 | + |
857 | + static const EGLint required_egl_version_major = 1; |
858 | + static const EGLint required_egl_version_minor = 4; |
859 | + |
860 | + EGLint num_egl_configs; |
861 | + |
862 | + egl_display = eglGetDisplay(static_cast<EGLNativeDisplayType>(x_dpy)); |
863 | + if (egl_display == EGL_NO_DISPLAY) |
864 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to get EGL display")); |
865 | + |
866 | + if (initialize) |
867 | + { |
868 | + EGLint major, minor; |
869 | + |
870 | + if (eglInitialize(egl_display, &major, &minor) == EGL_FALSE) |
871 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to initialize EGL display")); |
872 | + |
873 | + if ((major != required_egl_version_major) || (minor != required_egl_version_minor)) |
874 | + { |
875 | + BOOST_THROW_EXCEPTION( |
876 | + boost::enable_error_info(std::runtime_error("Incompatible EGL version"))); |
877 | + // TODO: Insert egl version major and minor into exception |
878 | + } |
879 | + |
880 | + should_terminate_egl = true; |
881 | + } |
882 | + |
883 | + if (eglChooseConfig(egl_display, config_attr, &egl_config, 1, &num_egl_configs) == EGL_FALSE || |
884 | + num_egl_configs != 1) |
885 | + { |
886 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to choose ARGB EGL config")); |
887 | + } |
888 | +} |
889 | + |
890 | +void mgxh::EGLHelper::report_egl_configuration(std::function<void(EGLDisplay, EGLConfig)> f) |
891 | +{ |
892 | + f(egl_display, egl_config); |
893 | +} |
894 | |
895 | === added file 'src/platforms/mesa/server/x11/graphics/egl_helper.h' |
896 | --- src/platforms/mesa/server/x11/graphics/egl_helper.h 1970-01-01 00:00:00 +0000 |
897 | +++ src/platforms/mesa/server/x11/graphics/egl_helper.h 2016-09-26 01:54:42 +0000 |
898 | @@ -0,0 +1,78 @@ |
899 | +/* |
900 | + * Copyright © 2016 Canonical Ltd. |
901 | + * |
902 | + * This program is free software: you can redistribute it and/or modify it |
903 | + * under the terms of the GNU Lesser General Public License version 3, |
904 | + * as published by the Free Software Foundation. |
905 | + * |
906 | + * This program is distributed in the hope that it will be useful, |
907 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
908 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
909 | + * GNU Lesser General Public License for more details. |
910 | + * |
911 | + * You should have received a copy of the GNU Lesser General Public License |
912 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
913 | + * |
914 | + * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com> |
915 | + */ |
916 | + |
917 | +#ifndef MIR_GRAPHICS_X11_EGL_HELPER_H_ |
918 | +#define MIR_GRAPHICS_X11_EGL_HELPER_H_ |
919 | + |
920 | +#include <memory> |
921 | + |
922 | +#include <X11/Xlib.h> |
923 | +#include <EGL/egl.h> |
924 | + |
925 | +namespace mir |
926 | +{ |
927 | +namespace graphics |
928 | +{ |
929 | +class GLConfig; |
930 | + |
931 | +namespace X |
932 | +{ |
933 | + |
934 | +namespace helpers |
935 | +{ |
936 | + |
937 | +class EGLHelper |
938 | +{ |
939 | +public: |
940 | + EGLHelper(GLConfig const& gl_config); |
941 | + ~EGLHelper() noexcept; |
942 | + |
943 | + EGLHelper(const EGLHelper&) = delete; |
944 | + EGLHelper& operator=(const EGLHelper&) = delete; |
945 | + |
946 | + void setup(::Display* const x_dpy); |
947 | + void setup(::Display* const x_dpy, EGLContext shared_context); |
948 | + void setup(::Display* const x_dpy, Window win, |
949 | + EGLContext shared_context); |
950 | + |
951 | + bool swap_buffers(); |
952 | + bool make_current() const; |
953 | + bool release_current() const; |
954 | + |
955 | + EGLContext context() { return egl_context; } |
956 | + EGLDisplay display() { return egl_display; } |
957 | + EGLConfig config() { return egl_config; } |
958 | + |
959 | + void report_egl_configuration(std::function<void(EGLDisplay, EGLConfig)>); |
960 | +private: |
961 | + void setup_internal(::Display* const x_dpy, bool initialize); |
962 | + |
963 | + EGLint const depth_buffer_bits; |
964 | + EGLint const stencil_buffer_bits; |
965 | + EGLDisplay egl_display; |
966 | + EGLConfig egl_config; |
967 | + EGLContext egl_context; |
968 | + EGLSurface egl_surface; |
969 | + bool should_terminate_egl; |
970 | +}; |
971 | + |
972 | +} |
973 | +} |
974 | +} |
975 | +} |
976 | +#endif /* MIR_GRAPHICS_X11_EGL_HELPER_H_ */ |
977 | |
978 | === removed file 'src/platforms/mesa/server/x11/graphics/gl_context.cpp' |
979 | --- src/platforms/mesa/server/x11/graphics/gl_context.cpp 2016-01-29 08:18:22 +0000 |
980 | +++ src/platforms/mesa/server/x11/graphics/gl_context.cpp 1970-01-01 00:00:00 +0000 |
981 | @@ -1,45 +0,0 @@ |
982 | -/* |
983 | - * Copyright © 2015 Canonical Ltd. |
984 | - * |
985 | - * This program is free software: you can redistribute it and/or modify it |
986 | - * under the terms of the GNU Lesser General Public License version 3, |
987 | - * as published by the Free Software Foundation. |
988 | - * |
989 | - * This program is distributed in the hope that it will be useful, |
990 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
991 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
992 | - * GNU Lesser General Public License for more details. |
993 | - * |
994 | - * You should have received a copy of the GNU Lesser General Public License |
995 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
996 | - * |
997 | - * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com> |
998 | - * |
999 | - */ |
1000 | - |
1001 | -#include "mir/graphics/egl_error.h" |
1002 | -#include "gl_context.h" |
1003 | -#include <boost/throw_exception.hpp> |
1004 | -#include <stdexcept> |
1005 | - |
1006 | -namespace mg=mir::graphics; |
1007 | -namespace mgx=mg::X; |
1008 | - |
1009 | -mgx::XGLContext::XGLContext(EGLDisplay const d, EGLSurface const s, EGLContext const c) |
1010 | - : egl_dpy{d}, |
1011 | - egl_surf{s}, |
1012 | - egl_ctx{c} |
1013 | -{ |
1014 | -} |
1015 | - |
1016 | -void mgx::XGLContext::make_current() const |
1017 | -{ |
1018 | - if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) |
1019 | - BOOST_THROW_EXCEPTION(mg::egl_error("Cannot make current")); |
1020 | -} |
1021 | - |
1022 | -void mgx::XGLContext::release_current() const |
1023 | -{ |
1024 | - if (!eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) |
1025 | - BOOST_THROW_EXCEPTION(mg::egl_error("Cannot make uncurrent")); |
1026 | -} |
1027 | |
1028 | === removed file 'src/platforms/mesa/server/x11/graphics/gl_context.h' |
1029 | --- src/platforms/mesa/server/x11/graphics/gl_context.h 2016-07-28 09:10:43 +0000 |
1030 | +++ src/platforms/mesa/server/x11/graphics/gl_context.h 1970-01-01 00:00:00 +0000 |
1031 | @@ -1,52 +0,0 @@ |
1032 | -/* |
1033 | - * Copyright © 2015 Canonical Ltd. |
1034 | - * |
1035 | - * This program is free software: you can redistribute it and/or modify it |
1036 | - * under the terms of the GNU Lesser General Public License version 3, |
1037 | - * as published by the Free Software Foundation. |
1038 | - * |
1039 | - * This program is distributed in the hope that it will be useful, |
1040 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1041 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1042 | - * GNU Lesser General Public License for more details. |
1043 | - * |
1044 | - * You should have received a copy of the GNU Lesser General Public License |
1045 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1046 | - * |
1047 | - * Authored by: Cemil Azizoglu <cemil.azizoglu@canonical.com> |
1048 | - * |
1049 | - */ |
1050 | - |
1051 | -#ifndef MIR_GRAPHICS_X_GL_CONTEXT_H_ |
1052 | -#define MIR_GRAPHICS_X_GL_CONTEXT_H_ |
1053 | - |
1054 | -#include "mir/renderer/gl/context.h" |
1055 | - |
1056 | -#include <EGL/egl.h> |
1057 | - |
1058 | -namespace mir |
1059 | -{ |
1060 | -namespace graphics |
1061 | -{ |
1062 | -namespace X |
1063 | -{ |
1064 | - |
1065 | -class XGLContext : public renderer::gl::Context |
1066 | -{ |
1067 | -public: |
1068 | - XGLContext(EGLDisplay const d, EGLSurface const s, EGLContext const c); |
1069 | - ~XGLContext() = default; |
1070 | - void make_current() const override; |
1071 | - void release_current() const override; |
1072 | - |
1073 | -private: |
1074 | - EGLDisplay const egl_dpy; |
1075 | - EGLSurface const egl_surf; |
1076 | - EGLContext const egl_ctx; |
1077 | -}; |
1078 | - |
1079 | -} |
1080 | -} |
1081 | -} |
1082 | - |
1083 | -#endif /* MIR_GRAPHICS_X_GL_CONTEXT_H_ */ |
1084 | |
1085 | === modified file 'src/platforms/mesa/server/x11/graphics/platform.cpp' |
1086 | --- src/platforms/mesa/server/x11/graphics/platform.cpp 2016-09-07 03:37:03 +0000 |
1087 | +++ src/platforms/mesa/server/x11/graphics/platform.cpp 2016-09-26 01:54:42 +0000 |
1088 | @@ -51,7 +51,7 @@ |
1089 | std::shared_ptr<DisplayConfigurationPolicy> const& /*initial_conf_policy*/, |
1090 | std::shared_ptr<GLConfig> const& gl_config) |
1091 | { |
1092 | - return make_module_ptr<mgx::Display>(x11_connection.get(), size, *gl_config, |
1093 | + return make_module_ptr<mgx::Display>(x11_connection.get(), size, gl_config, |
1094 | report); |
1095 | } |
1096 | |
1097 | |
1098 | === modified file 'tests/unit-tests/graphics/test_platform_prober.cpp' |
1099 | --- tests/unit-tests/graphics/test_platform_prober.cpp 2016-06-23 17:53:10 +0000 |
1100 | +++ tests/unit-tests/graphics/test_platform_prober.cpp 2016-09-26 01:54:42 +0000 |
1101 | @@ -25,8 +25,10 @@ |
1102 | #include "mir/raii.h" |
1103 | |
1104 | #include "mir/test/doubles/mock_egl.h" |
1105 | -#ifdef MIR_BUILD_PLATFORM_MESA_KMS |
1106 | +#if defined(MIR_BUILD_PLATFORM_MESA_KMS) || defined(MIR_BUILD_PLATFORM_MESA_X11) |
1107 | #include "mir/test/doubles/mock_drm.h" |
1108 | +#endif |
1109 | +#ifdef MIR_BUILD_PLATFORM_MESA_KMS |
1110 | #include "mir/test/doubles/mock_gbm.h" |
1111 | #endif |
1112 | |
1113 | |
1114 | === modified file 'tests/unit-tests/platforms/mesa/x11/test_display.cpp' |
1115 | --- tests/unit-tests/platforms/mesa/x11/test_display.cpp 2016-09-07 04:45:58 +0000 |
1116 | +++ tests/unit-tests/platforms/mesa/x11/test_display.cpp 2016-09-26 01:54:42 +0000 |
1117 | @@ -27,11 +27,13 @@ |
1118 | #include "mir/test/doubles/mock_egl.h" |
1119 | #include "mir/test/doubles/mock_x11.h" |
1120 | #include "mir/test/doubles/mock_gl_config.h" |
1121 | +#include "mir/test/fake_shared.h" |
1122 | |
1123 | |
1124 | namespace mg=mir::graphics; |
1125 | namespace mgx=mg::X; |
1126 | -namespace mtd=mir::test::doubles; |
1127 | +namespace mt=mir::test; |
1128 | +namespace mtd=mt::doubles; |
1129 | namespace geom=mir::geometry; |
1130 | using namespace testing; |
1131 | |
1132 | @@ -97,7 +99,7 @@ |
1133 | return std::make_shared<mgx::Display>( |
1134 | mock_x11.fake_x11.display, |
1135 | size, |
1136 | - mock_gl_config, |
1137 | + mt::fake_shared(mock_gl_config), |
1138 | std::make_shared<mir::report::null::DisplayReport>()); |
1139 | } |
1140 | |
1141 | @@ -112,18 +114,9 @@ |
1142 | { |
1143 | using namespace testing; |
1144 | |
1145 | - EXPECT_CALL(mock_egl, eglGetDisplay(mock_x11.fake_x11.display)) |
1146 | - .Times(Exactly(1)); |
1147 | - |
1148 | EXPECT_CALL(mock_x11, XCreateWindow_wrapper(mock_x11.fake_x11.display,_, size.width.as_int(), size.height.as_int(),_,_,_,_,_,_)) |
1149 | .Times(Exactly(1)); |
1150 | |
1151 | - EXPECT_CALL(mock_egl, eglCreateContext(mock_egl.fake_egl_display,_, EGL_NO_CONTEXT,_)) |
1152 | - .Times(Exactly(1)); |
1153 | - |
1154 | - EXPECT_CALL(mock_egl, eglCreateWindowSurface(mock_egl.fake_egl_display,_, reinterpret_cast<mtd::MockEGL::AnyNativeType>(mock_x11.fake_x11.window), nullptr)) |
1155 | - .Times(Exactly(1)); |
1156 | - |
1157 | EXPECT_CALL(mock_x11, XNextEvent(mock_x11.fake_x11.display,_)) |
1158 | .Times(AtLeast(1)); |
1159 |
FAILED: Continuous integration, rev:3715 /mir-jenkins. ubuntu. com/job/ mir-ci/ 1809/ /mir-jenkins. ubuntu. com/job/ build-mir/ 2260/console /mir-jenkins. ubuntu. com/job/ build-0- fetch/2323 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= vivid+overlay/ 2314 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial+ overlay/ 2314 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= yakkety/ 2314 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= yakkety/ 2288/console /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial+ overlay/ 2288 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial+ overlay/ 2288/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= yakkety/ 2288 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= yakkety/ 2288/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= android, release= vivid+overlay/ 2288 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= android, release= vivid+overlay/ 2288/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial+ overlay/ 2288 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial+ overlay/ 2288/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: 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/ 1809/rebuild
https:/