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