Merge lp:~kdub/mir/egl-connection-for-offscreen into lp:mir
- egl-connection-for-offscreen
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Daniel van Vugt |
Approved revision: | no longer in the source branch. |
Merged at revision: | 4090 |
Proposed branch: | lp:~kdub/mir/egl-connection-for-offscreen |
Merge into: | lp:mir |
Prerequisite: | lp:~kdub/mir/resurrect-offscreen |
Diff against target: |
1141 lines (+450/-251) 29 files modified
include/platform/mir/graphics/platform.h (+13/-2) include/renderers/gl/mir/renderer/gl/egl_platform.h (+47/-0) include/test/mir/test/doubles/null_platform.h (+2/-2) src/platforms/android/server/platform.cpp (+5/-0) src/platforms/android/server/platform.h (+6/-1) src/platforms/eglstream-kms/server/platform.cpp (+5/-0) src/platforms/eglstream-kms/server/platform.h (+5/-1) src/platforms/mesa/server/display_helpers.cpp (+0/-188) src/platforms/mesa/server/display_helpers.h (+0/-42) src/platforms/mesa/server/kms/CMakeLists.txt (+2/-0) src/platforms/mesa/server/kms/display.h (+1/-0) src/platforms/mesa/server/kms/display_buffer.h (+1/-0) src/platforms/mesa/server/kms/egl_helper.cpp (+209/-0) src/platforms/mesa/server/kms/egl_helper.h (+77/-0) src/platforms/mesa/server/kms/guest_platform.cpp (+5/-0) src/platforms/mesa/server/kms/guest_platform.h (+6/-1) src/platforms/mesa/server/kms/platform.cpp (+5/-0) src/platforms/mesa/server/kms/platform.h (+5/-1) src/platforms/mesa/server/x11/graphics/guest_platform.cpp (+5/-0) src/platforms/mesa/server/x11/graphics/guest_platform.h (+7/-1) src/platforms/mesa/server/x11/graphics/platform.cpp (+5/-0) src/platforms/mesa/server/x11/graphics/platform.h (+5/-1) src/server/graphics/default_configuration.cpp (+14/-4) src/server/graphics/nested/platform.cpp (+9/-1) src/server/graphics/nested/platform.h (+5/-1) tests/integration-tests/graphics/mesa/test_buffer_integration.cpp (+1/-0) tests/integration-tests/test_submit_buffer.cpp (+1/-1) tests/mir_test_framework/platform_graphics_throw.cpp (+2/-2) tests/mir_test_framework/stubbed_graphics_platform.cpp (+2/-2) |
To merge this branch: | bzr merge lp:~kdub/mir/egl-connection-for-offscreen |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel van Vugt | Approve | ||
Mir CI Bot | continuous-integration | Approve | |
Cemil Azizoglu (community) | Approve | ||
Alexandros Frantzis (community) | Approve | ||
Review via email: mp+319679@code.launchpad.net |
Commit message
Adding back offscreen needed to add back a function in mg::Platform by which the EGLNativeDispla
Description of the change
Adding back offscreen needed to add back a function in mg::Platform by which the EGLNativeDispla
Mir CI Bot (mir-ci-bot) wrote : | # |
Alexandros Frantzis (afrantzis) wrote : | # |
I think the name NativeRenderAccess used to access native platform functionality is too tied to our current use case. If we need to add non-rendering native functionality to platform, accessing it through NativeRenderAccess would be unintuitive, so I would vote for a more generic name (e.g., NativePlatform) like we have done for Display and Buffer.
Looks good otherwise.
Needs discussion.
Kevin DuBois (kdub) wrote : | # |
I'm alright with NativePlatform, will change
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:4092
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Alexandros Frantzis (afrantzis) wrote : | # |
Looks good.
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:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
Ok lgtm.
Daniel van Vugt (vanvugt) wrote : | # |
17:07:37 ../../.
17:07:37 ../../.
17:07:37 lto1: all warnings being treated as errors
Daniel van Vugt (vanvugt) wrote : | # |
(1) Build failure per above.
(2) "EGLAccess" feels like a poor choice of words. Looking at where it is used (https:/
Daniel van Vugt (vanvugt) wrote : | # |
(3) Why is it necessary to change the current architecture here? AFAIK you're aiming to solve bug 1118903 which should be just one new graphics driver...?
Kevin DuBois (kdub) wrote : | # |
renamed.
the goal in this MP is more to clean up the way the offscreen platform creates a SurfacelessEGLC
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:4095
https:/
Executed test runs:
Click here to trigger a rebuild:
https:/
Kevin DuBois (kdub) wrote : | # |
The fix for the ODR violation was abit more involved. EGL was included in display_helpers.h, shared by kms/ and x11/. Because display_helpers.h also had gbm helpers in there, __GBM__ was set, which would set the eglplatform.h to be the gbm platform wherever display_helpers.h was included. The correct fix is to move mgmh::EGLHelper into kms/ so that x11 can set its own platform types, while still using display_helpers.h
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:4096
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Daniel van Vugt (vanvugt) wrote : | # |
native_platform() sounds like maybe a const method, but worry about that later.
Preview Diff
1 | === modified file 'include/platform/mir/graphics/platform.h' |
2 | --- include/platform/mir/graphics/platform.h 2017-03-09 12:52:48 +0000 |
3 | +++ include/platform/mir/graphics/platform.h 2017-03-15 13:54:31 +0000 |
4 | @@ -21,7 +21,6 @@ |
5 | #define MIR_GRAPHICS_PLATFORM_H_ |
6 | |
7 | #include <boost/program_options/options_description.hpp> |
8 | -#include <EGL/egl.h> |
9 | |
10 | #include "mir/module_properties.h" |
11 | #include "mir/module_deleter.h" |
12 | @@ -54,6 +53,14 @@ |
13 | class GLConfig; |
14 | class PlatformIpcOperations; |
15 | class NestedContext; |
16 | +class NativePlatform |
17 | +{ |
18 | +protected: |
19 | + NativePlatform() = default; |
20 | + virtual ~NativePlatform() = default; |
21 | + NativePlatform(NativePlatform const&) = delete; |
22 | + NativePlatform& operator=(NativePlatform const&) = delete; |
23 | +}; |
24 | |
25 | /** |
26 | * \defgroup platform_enablement Mir platform enablement |
27 | @@ -92,7 +99,11 @@ |
28 | */ |
29 | virtual UniqueModulePtr<PlatformIpcOperations> make_ipc_operations() const = 0; |
30 | |
31 | - virtual EGLNativeDisplayType egl_native_display() const = 0; |
32 | + /** |
33 | + * Access the native resource[s] used to connect to the rendering backend |
34 | + * for this platform |
35 | + */ |
36 | + virtual NativePlatform* native_platform() = 0; |
37 | }; |
38 | |
39 | /** |
40 | |
41 | === added file 'include/renderers/gl/mir/renderer/gl/egl_platform.h' |
42 | --- include/renderers/gl/mir/renderer/gl/egl_platform.h 1970-01-01 00:00:00 +0000 |
43 | +++ include/renderers/gl/mir/renderer/gl/egl_platform.h 2017-03-15 13:54:31 +0000 |
44 | @@ -0,0 +1,47 @@ |
45 | +/* |
46 | + * Copyright © 2017 Canonical Ltd. |
47 | + * |
48 | + * This program is free software: you can redistribute it and/or modify it |
49 | + * under the terms of the GNU Lesser General Public License version 3, |
50 | + * as published by the Free Software Foundation. |
51 | + * |
52 | + * This program is distributed in the hope that it will be useful, |
53 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
54 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
55 | + * GNU Lesser General Public License for more details. |
56 | + * |
57 | + * You should have received a copy of the GNU Lesser General Public License |
58 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
59 | + * |
60 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
61 | + */ |
62 | + |
63 | +#ifndef MIR_RENDERER_GL_EGL_PLATFORM_H_ |
64 | +#define MIR_RENDERER_GL_EGL_PLATFORM_H_ |
65 | + |
66 | +#include <EGL/egl.h> |
67 | + |
68 | +namespace mir |
69 | +{ |
70 | +namespace renderer |
71 | +{ |
72 | +namespace gl |
73 | +{ |
74 | + |
75 | +class EGLPlatform |
76 | +{ |
77 | +public: |
78 | + virtual ~EGLPlatform() = default; |
79 | + virtual EGLNativeDisplayType egl_native_display() const = 0; |
80 | + |
81 | +protected: |
82 | + EGLPlatform() = default; |
83 | + EGLPlatform(EGLPlatform const&) = delete; |
84 | + EGLPlatform& operator=(EGLPlatform const&) = delete; |
85 | +}; |
86 | + |
87 | +} |
88 | +} |
89 | +} |
90 | + |
91 | +#endif /* MIR_RENDERER_GL_EGL_PLATFORM_H_ */ |
92 | |
93 | === modified file 'include/test/mir/test/doubles/null_platform.h' |
94 | --- include/test/mir/test/doubles/null_platform.h 2017-03-09 12:52:48 +0000 |
95 | +++ include/test/mir/test/doubles/null_platform.h 2017-03-15 13:54:31 +0000 |
96 | @@ -51,9 +51,9 @@ |
97 | return mir::make_module_ptr<NullPlatformIpcOperations>(); |
98 | } |
99 | |
100 | - EGLNativeDisplayType egl_native_display() const override |
101 | + graphics::NativePlatform* native_platform() override |
102 | { |
103 | - return EGLNativeDisplayType(); |
104 | + return nullptr; |
105 | } |
106 | }; |
107 | } |
108 | |
109 | === modified file 'src/platforms/android/server/platform.cpp' |
110 | --- src/platforms/android/server/platform.cpp 2017-03-14 05:30:56 +0000 |
111 | +++ src/platforms/android/server/platform.cpp 2017-03-15 13:54:31 +0000 |
112 | @@ -162,6 +162,11 @@ |
113 | return mir::make_module_ptr<mga::IpcOperations>(); |
114 | } |
115 | |
116 | +mg::NativePlatform* mga::Platform::native_platform() |
117 | +{ |
118 | + return this; |
119 | +} |
120 | + |
121 | EGLNativeDisplayType mga::Platform::egl_native_display() const |
122 | { |
123 | return EGL_DEFAULT_DISPLAY; |
124 | |
125 | === modified file 'src/platforms/android/server/platform.h' |
126 | --- src/platforms/android/server/platform.h 2017-03-09 12:52:48 +0000 |
127 | +++ src/platforms/android/server/platform.h 2017-03-15 13:54:31 +0000 |
128 | @@ -22,6 +22,8 @@ |
129 | #include "mir/graphics/platform.h" |
130 | #include "device_quirks.h" |
131 | #include "overlay_optimization.h" |
132 | +#include "mir/graphics/display.h" |
133 | +#include "mir/renderer/gl/egl_platform.h" |
134 | |
135 | namespace mir |
136 | { |
137 | @@ -36,7 +38,9 @@ |
138 | class CommandStreamSyncFactory; |
139 | class NativeWindowReport; |
140 | |
141 | -class Platform : public graphics::Platform |
142 | +class Platform : public graphics::Platform, |
143 | + public graphics::NativePlatform, |
144 | + public mir::renderer::gl::EGLPlatform |
145 | { |
146 | public: |
147 | Platform( |
148 | @@ -53,6 +57,7 @@ |
149 | std::shared_ptr<graphics::DisplayConfigurationPolicy> const&, |
150 | std::shared_ptr<graphics::GLConfig> const& /*gl_config*/) override; |
151 | UniqueModulePtr<PlatformIpcOperations> make_ipc_operations() const override; |
152 | + NativePlatform* native_platform() override; |
153 | EGLNativeDisplayType egl_native_display() const override; |
154 | |
155 | private: |
156 | |
157 | === modified file 'src/platforms/eglstream-kms/server/platform.cpp' |
158 | --- src/platforms/eglstream-kms/server/platform.cpp 2017-03-09 12:52:48 +0000 |
159 | +++ src/platforms/eglstream-kms/server/platform.cpp 2017-03-15 13:54:31 +0000 |
160 | @@ -161,6 +161,11 @@ |
161 | return mir::make_module_ptr<NoIPCOperations>(); |
162 | } |
163 | |
164 | +mg::NativePlatform* mge::Platform::native_platform() |
165 | +{ |
166 | + return this; |
167 | +} |
168 | + |
169 | EGLNativeDisplayType mge::Platform::egl_native_display() const |
170 | { |
171 | return display; |
172 | |
173 | === modified file 'src/platforms/eglstream-kms/server/platform.h' |
174 | --- src/platforms/eglstream-kms/server/platform.h 2017-03-09 12:52:48 +0000 |
175 | +++ src/platforms/eglstream-kms/server/platform.h 2017-03-15 13:54:31 +0000 |
176 | @@ -25,6 +25,7 @@ |
177 | #include "mir/graphics/display.h" |
178 | #include "mir/graphics/platform_ipc_operations.h" |
179 | #include "mir/fd.h" |
180 | +#include "mir/renderer/gl/egl_platform.h" |
181 | |
182 | #include <EGL/egl.h> |
183 | #include <EGL/eglext.h> |
184 | @@ -35,7 +36,9 @@ |
185 | { |
186 | namespace eglstream |
187 | { |
188 | -class Platform : public mir::graphics::Platform |
189 | +class Platform : public graphics::Platform, |
190 | + public graphics::NativePlatform, |
191 | + public mir::renderer::gl::EGLPlatform |
192 | { |
193 | public: |
194 | Platform( |
195 | @@ -52,6 +55,7 @@ |
196 | |
197 | UniqueModulePtr<PlatformIpcOperations> make_ipc_operations() const override; |
198 | |
199 | + NativePlatform* native_platform() override; |
200 | EGLNativeDisplayType egl_native_display() const override; |
201 | |
202 | private: |
203 | |
204 | === modified file 'src/platforms/mesa/server/display_helpers.cpp' |
205 | --- src/platforms/mesa/server/display_helpers.cpp 2017-03-13 08:12:52 +0000 |
206 | +++ src/platforms/mesa/server/display_helpers.cpp 2017-03-15 13:54:31 +0000 |
207 | @@ -21,8 +21,6 @@ |
208 | |
209 | #include "kms-utils/drm_mode_resources.h" |
210 | |
211 | -#include "mir/graphics/gl_config.h" |
212 | -#include "mir/graphics/egl_error.h" |
213 | #include "mir/udev/wrapper.h" |
214 | |
215 | #include <boost/exception/errinfo_errno.hpp> |
216 | @@ -307,189 +305,3 @@ |
217 | if (device) |
218 | gbm_device_destroy(device); |
219 | } |
220 | - |
221 | -/************* |
222 | - * EGLHelper * |
223 | - *************/ |
224 | - |
225 | -mgmh::EGLHelper::EGLHelper(GLConfig const& gl_config) |
226 | - : depth_buffer_bits{gl_config.depth_buffer_bits()}, |
227 | - stencil_buffer_bits{gl_config.stencil_buffer_bits()}, |
228 | - egl_display{EGL_NO_DISPLAY}, egl_config{0}, |
229 | - egl_context{EGL_NO_CONTEXT}, egl_surface{EGL_NO_SURFACE}, |
230 | - should_terminate_egl{false} |
231 | -{ |
232 | -} |
233 | - |
234 | -mgmh::EGLHelper::EGLHelper( |
235 | - GLConfig const& gl_config, |
236 | - GBMHelper const& gbm, |
237 | - gbm_surface* surface, |
238 | - EGLContext shared_context) |
239 | - : EGLHelper(gl_config) |
240 | -{ |
241 | - setup(gbm, surface, shared_context); |
242 | -} |
243 | - |
244 | -mgmh::EGLHelper::EGLHelper(EGLHelper&& from) |
245 | - : depth_buffer_bits{from.depth_buffer_bits}, |
246 | - stencil_buffer_bits{from.stencil_buffer_bits}, |
247 | - egl_display{from.egl_display}, |
248 | - egl_config{from.egl_config}, |
249 | - egl_context{from.egl_context}, |
250 | - egl_surface{from.egl_surface}, |
251 | - should_terminate_egl{from.should_terminate_egl} |
252 | -{ |
253 | - from.should_terminate_egl = false; |
254 | - from.egl_display = EGL_NO_DISPLAY; |
255 | - from.egl_context = EGL_NO_CONTEXT; |
256 | - from.egl_surface = EGL_NO_SURFACE; |
257 | -} |
258 | - |
259 | -void mgmh::EGLHelper::setup(GBMHelper const& gbm) |
260 | -{ |
261 | - eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
262 | - |
263 | - static const EGLint context_attr[] = { |
264 | -#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT |
265 | - EGL_CONTEXT_CLIENT_VERSION, 2, |
266 | -#endif |
267 | - EGL_NONE |
268 | - }; |
269 | - |
270 | - setup_internal(gbm, true); |
271 | - |
272 | - egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, context_attr); |
273 | - if (egl_context == EGL_NO_CONTEXT) |
274 | - BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL context")); |
275 | -} |
276 | - |
277 | -void mgmh::EGLHelper::setup(GBMHelper const& gbm, EGLContext shared_context) |
278 | -{ |
279 | - eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
280 | - |
281 | - static const EGLint context_attr[] = { |
282 | -#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT |
283 | - EGL_CONTEXT_CLIENT_VERSION, 2, |
284 | -#endif |
285 | - EGL_NONE |
286 | - }; |
287 | - |
288 | - setup_internal(gbm, false); |
289 | - |
290 | - egl_context = eglCreateContext(egl_display, egl_config, shared_context, context_attr); |
291 | - if (egl_context == EGL_NO_CONTEXT) |
292 | - BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL context")); |
293 | -} |
294 | - |
295 | -void mgmh::EGLHelper::setup(GBMHelper const& gbm, gbm_surface* surface_gbm, |
296 | - EGLContext shared_context) |
297 | -{ |
298 | - eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
299 | - |
300 | - static const EGLint context_attr[] = { |
301 | -#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT |
302 | - EGL_CONTEXT_CLIENT_VERSION, 2, |
303 | -#endif |
304 | - EGL_NONE |
305 | - }; |
306 | - |
307 | - setup_internal(gbm, false); |
308 | - |
309 | - egl_surface = eglCreateWindowSurface(egl_display, egl_config, surface_gbm, nullptr); |
310 | - if(egl_surface == EGL_NO_SURFACE) |
311 | - BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL window surface")); |
312 | - |
313 | - egl_context = eglCreateContext(egl_display, egl_config, shared_context, context_attr); |
314 | - if (egl_context == EGL_NO_CONTEXT) |
315 | - BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL context")); |
316 | -} |
317 | - |
318 | -mgmh::EGLHelper::~EGLHelper() noexcept |
319 | -{ |
320 | - if (egl_display != EGL_NO_DISPLAY) { |
321 | - if (egl_context != EGL_NO_CONTEXT) |
322 | - { |
323 | - eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
324 | - if (eglGetCurrentContext() == egl_context) |
325 | - eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
326 | - eglDestroyContext(egl_display, egl_context); |
327 | - } |
328 | - if (egl_surface != EGL_NO_SURFACE) |
329 | - eglDestroySurface(egl_display, egl_surface); |
330 | - if (should_terminate_egl) |
331 | - eglTerminate(egl_display); |
332 | - } |
333 | -} |
334 | - |
335 | -bool mgmh::EGLHelper::swap_buffers() |
336 | -{ |
337 | - auto ret = eglSwapBuffers(egl_display, egl_surface); |
338 | - return (ret == EGL_TRUE); |
339 | -} |
340 | - |
341 | -bool mgmh::EGLHelper::make_current() const |
342 | -{ |
343 | - auto ret = eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context); |
344 | - eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
345 | - return (ret == EGL_TRUE); |
346 | -} |
347 | - |
348 | -bool mgmh::EGLHelper::release_current() const |
349 | -{ |
350 | - auto ret = eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
351 | - return (ret == EGL_TRUE); |
352 | -} |
353 | - |
354 | -void mgmh::EGLHelper::setup_internal(GBMHelper const& gbm, bool initialize) |
355 | -{ |
356 | - EGLint const config_attr[] = { |
357 | - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
358 | - EGL_RED_SIZE, 5, |
359 | - EGL_GREEN_SIZE, 5, |
360 | - EGL_BLUE_SIZE, 5, |
361 | - EGL_ALPHA_SIZE, 0, |
362 | - EGL_DEPTH_SIZE, depth_buffer_bits, |
363 | - EGL_STENCIL_SIZE, stencil_buffer_bits, |
364 | - EGL_RENDERABLE_TYPE, MIR_SERVER_EGL_OPENGL_BIT, |
365 | - EGL_NONE |
366 | - }; |
367 | - |
368 | - static const EGLint required_egl_version_major = 1; |
369 | - static const EGLint required_egl_version_minor = 4; |
370 | - |
371 | - EGLint num_egl_configs; |
372 | - |
373 | - egl_display = eglGetDisplay(static_cast<EGLNativeDisplayType>(gbm.device)); |
374 | - if (egl_display == EGL_NO_DISPLAY) |
375 | - BOOST_THROW_EXCEPTION(mg::egl_error("Failed to get EGL display")); |
376 | - |
377 | - if (initialize) |
378 | - { |
379 | - EGLint major, minor; |
380 | - |
381 | - if (eglInitialize(egl_display, &major, &minor) == EGL_FALSE) |
382 | - BOOST_THROW_EXCEPTION(mg::egl_error("Failed to initialize EGL display")); |
383 | - |
384 | - if ((major < required_egl_version_major) || |
385 | - (major == required_egl_version_major && minor < required_egl_version_minor)) |
386 | - { |
387 | - BOOST_THROW_EXCEPTION( |
388 | - boost::enable_error_info(std::runtime_error("Incompatible EGL version"))); |
389 | - // TODO: Insert egl version major and minor into exception |
390 | - } |
391 | - |
392 | - should_terminate_egl = true; |
393 | - } |
394 | - |
395 | - if (eglChooseConfig(egl_display, config_attr, &egl_config, 1, &num_egl_configs) == EGL_FALSE || |
396 | - num_egl_configs != 1) |
397 | - { |
398 | - BOOST_THROW_EXCEPTION(mg::egl_error("Failed to choose ARGB EGL config")); |
399 | - } |
400 | -} |
401 | - |
402 | -void mgmh::EGLHelper::report_egl_configuration(std::function<void(EGLDisplay, EGLConfig)> f) |
403 | -{ |
404 | - f(egl_display, egl_config); |
405 | -} |
406 | |
407 | === modified file 'src/platforms/mesa/server/display_helpers.h' |
408 | --- src/platforms/mesa/server/display_helpers.h 2017-03-13 08:12:52 +0000 |
409 | +++ src/platforms/mesa/server/display_helpers.h 2017-03-15 13:54:31 +0000 |
410 | @@ -30,15 +30,12 @@ |
411 | #include <gbm.h> |
412 | #pragma GCC diagnostic pop |
413 | |
414 | -#include <EGL/egl.h> |
415 | #include <xf86drmMode.h> |
416 | |
417 | namespace mir |
418 | { |
419 | namespace graphics |
420 | { |
421 | -class GLConfig; |
422 | - |
423 | namespace mesa |
424 | { |
425 | |
426 | @@ -98,45 +95,6 @@ |
427 | gbm_device* device; |
428 | }; |
429 | |
430 | -class EGLHelper |
431 | -{ |
432 | -public: |
433 | - EGLHelper(GLConfig const& gl_config); |
434 | - EGLHelper( |
435 | - GLConfig const& gl_config, |
436 | - GBMHelper const& gbm, |
437 | - gbm_surface* surface, |
438 | - EGLContext shared_context); |
439 | - ~EGLHelper() noexcept; |
440 | - EGLHelper(EGLHelper&& from); |
441 | - |
442 | - EGLHelper(const EGLHelper&) = delete; |
443 | - EGLHelper& operator=(const EGLHelper&) = delete; |
444 | - |
445 | - void setup(GBMHelper const& gbm); |
446 | - void setup(GBMHelper const& gbm, EGLContext shared_context); |
447 | - void setup(GBMHelper const& gbm, gbm_surface* surface_gbm, |
448 | - EGLContext shared_context); |
449 | - |
450 | - bool swap_buffers(); |
451 | - bool make_current() const; |
452 | - bool release_current() const; |
453 | - |
454 | - EGLContext context() { return egl_context; } |
455 | - |
456 | - void report_egl_configuration(std::function<void(EGLDisplay, EGLConfig)>); |
457 | -private: |
458 | - void setup_internal(GBMHelper const& gbm, bool initialize); |
459 | - |
460 | - EGLint const depth_buffer_bits; |
461 | - EGLint const stencil_buffer_bits; |
462 | - EGLDisplay egl_display; |
463 | - EGLConfig egl_config; |
464 | - EGLContext egl_context; |
465 | - EGLSurface egl_surface; |
466 | - bool should_terminate_egl; |
467 | -}; |
468 | - |
469 | } |
470 | } |
471 | } |
472 | |
473 | === modified file 'src/platforms/mesa/server/kms/CMakeLists.txt' |
474 | --- src/platforms/mesa/server/kms/CMakeLists.txt 2017-03-13 08:12:52 +0000 |
475 | +++ src/platforms/mesa/server/kms/CMakeLists.txt 2017-03-15 13:54:31 +0000 |
476 | @@ -41,6 +41,8 @@ |
477 | real_kms_output.cpp |
478 | kms_output_container.h |
479 | real_kms_output_container.cpp |
480 | + egl_helper.h |
481 | + egl_helper.cpp |
482 | ) |
483 | |
484 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/symbols.map.in |
485 | |
486 | === modified file 'src/platforms/mesa/server/kms/display.h' |
487 | --- src/platforms/mesa/server/kms/display.h 2017-02-15 07:38:33 +0000 |
488 | +++ src/platforms/mesa/server/kms/display.h 2017-03-15 13:54:31 +0000 |
489 | @@ -24,6 +24,7 @@ |
490 | #include "real_kms_output_container.h" |
491 | #include "real_kms_display_configuration.h" |
492 | #include "display_helpers.h" |
493 | +#include "egl_helper.h" |
494 | #include "platform_common.h" |
495 | |
496 | #include <atomic> |
497 | |
498 | === modified file 'src/platforms/mesa/server/kms/display_buffer.h' |
499 | --- src/platforms/mesa/server/kms/display_buffer.h 2017-03-13 08:12:52 +0000 |
500 | +++ src/platforms/mesa/server/kms/display_buffer.h 2017-03-15 13:54:31 +0000 |
501 | @@ -23,6 +23,7 @@ |
502 | #include "mir/graphics/display.h" |
503 | #include "mir/renderer/gl/render_target.h" |
504 | #include "display_helpers.h" |
505 | +#include "egl_helper.h" |
506 | #include "platform_common.h" |
507 | |
508 | #include <vector> |
509 | |
510 | === added file 'src/platforms/mesa/server/kms/egl_helper.cpp' |
511 | --- src/platforms/mesa/server/kms/egl_helper.cpp 1970-01-01 00:00:00 +0000 |
512 | +++ src/platforms/mesa/server/kms/egl_helper.cpp 2017-03-15 13:54:31 +0000 |
513 | @@ -0,0 +1,209 @@ |
514 | +/* |
515 | + * Copyright © 2017 Canonical Ltd. |
516 | + * |
517 | + * This program is free software: you can redistribute it and/or modify it |
518 | + * under the terms of the GNU Lesser General Public License version 3, |
519 | + * as published by the Free Software Foundation. |
520 | + * |
521 | + * This program is distributed in the hope that it will be useful, |
522 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
523 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
524 | + * GNU Lesser General Public License for more details. |
525 | + * |
526 | + * You should have received a copy of the GNU Lesser General Public License |
527 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
528 | + * |
529 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
530 | + */ |
531 | + |
532 | +#include "egl_helper.h" |
533 | +#include "mir/graphics/gl_config.h" |
534 | +#include "mir/graphics/egl_error.h" |
535 | +#include <boost/exception/errinfo_errno.hpp> |
536 | +#include <boost/throw_exception.hpp> |
537 | + |
538 | +namespace mg = mir::graphics; |
539 | +namespace mgm = mir::graphics::mesa; |
540 | +namespace mgmh = mir::graphics::mesa::helpers; |
541 | + |
542 | +mgmh::EGLHelper::EGLHelper(GLConfig const& gl_config) |
543 | + : depth_buffer_bits{gl_config.depth_buffer_bits()}, |
544 | + stencil_buffer_bits{gl_config.stencil_buffer_bits()}, |
545 | + egl_display{EGL_NO_DISPLAY}, egl_config{0}, |
546 | + egl_context{EGL_NO_CONTEXT}, egl_surface{EGL_NO_SURFACE}, |
547 | + should_terminate_egl{false} |
548 | +{ |
549 | +} |
550 | + |
551 | +mgmh::EGLHelper::EGLHelper( |
552 | + GLConfig const& gl_config, |
553 | + GBMHelper const& gbm, |
554 | + gbm_surface* surface, |
555 | + EGLContext shared_context) |
556 | + : EGLHelper(gl_config) |
557 | +{ |
558 | + setup(gbm, surface, shared_context); |
559 | +} |
560 | + |
561 | +mgmh::EGLHelper::EGLHelper(EGLHelper&& from) |
562 | + : depth_buffer_bits{from.depth_buffer_bits}, |
563 | + stencil_buffer_bits{from.stencil_buffer_bits}, |
564 | + egl_display{from.egl_display}, |
565 | + egl_config{from.egl_config}, |
566 | + egl_context{from.egl_context}, |
567 | + egl_surface{from.egl_surface}, |
568 | + should_terminate_egl{from.should_terminate_egl} |
569 | +{ |
570 | + from.should_terminate_egl = false; |
571 | + from.egl_display = EGL_NO_DISPLAY; |
572 | + from.egl_context = EGL_NO_CONTEXT; |
573 | + from.egl_surface = EGL_NO_SURFACE; |
574 | +} |
575 | + |
576 | +void mgmh::EGLHelper::setup(GBMHelper const& gbm) |
577 | +{ |
578 | + eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
579 | + |
580 | + static const EGLint context_attr[] = { |
581 | +#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT |
582 | + EGL_CONTEXT_CLIENT_VERSION, 2, |
583 | +#endif |
584 | + EGL_NONE |
585 | + }; |
586 | + |
587 | + setup_internal(gbm, true); |
588 | + |
589 | + egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, context_attr); |
590 | + if (egl_context == EGL_NO_CONTEXT) |
591 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL context")); |
592 | +} |
593 | + |
594 | +void mgmh::EGLHelper::setup(GBMHelper const& gbm, EGLContext shared_context) |
595 | +{ |
596 | + eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
597 | + |
598 | + static const EGLint context_attr[] = { |
599 | +#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT |
600 | + EGL_CONTEXT_CLIENT_VERSION, 2, |
601 | +#endif |
602 | + EGL_NONE |
603 | + }; |
604 | + |
605 | + setup_internal(gbm, false); |
606 | + |
607 | + egl_context = eglCreateContext(egl_display, egl_config, shared_context, context_attr); |
608 | + if (egl_context == EGL_NO_CONTEXT) |
609 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL context")); |
610 | +} |
611 | + |
612 | +void mgmh::EGLHelper::setup(GBMHelper const& gbm, gbm_surface* surface_gbm, |
613 | + EGLContext shared_context) |
614 | +{ |
615 | + eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
616 | + |
617 | + static const EGLint context_attr[] = { |
618 | +#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT |
619 | + EGL_CONTEXT_CLIENT_VERSION, 2, |
620 | +#endif |
621 | + EGL_NONE |
622 | + }; |
623 | + |
624 | + setup_internal(gbm, false); |
625 | + |
626 | + egl_surface = eglCreateWindowSurface(egl_display, egl_config, surface_gbm, nullptr); |
627 | + if(egl_surface == EGL_NO_SURFACE) |
628 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL window surface")); |
629 | + |
630 | + egl_context = eglCreateContext(egl_display, egl_config, shared_context, context_attr); |
631 | + if (egl_context == EGL_NO_CONTEXT) |
632 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create EGL context")); |
633 | +} |
634 | + |
635 | +mgmh::EGLHelper::~EGLHelper() noexcept |
636 | +{ |
637 | + if (egl_display != EGL_NO_DISPLAY) { |
638 | + if (egl_context != EGL_NO_CONTEXT) |
639 | + { |
640 | + eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
641 | + if (eglGetCurrentContext() == egl_context) |
642 | + eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
643 | + eglDestroyContext(egl_display, egl_context); |
644 | + } |
645 | + if (egl_surface != EGL_NO_SURFACE) |
646 | + eglDestroySurface(egl_display, egl_surface); |
647 | + if (should_terminate_egl) |
648 | + eglTerminate(egl_display); |
649 | + } |
650 | +} |
651 | + |
652 | +bool mgmh::EGLHelper::swap_buffers() |
653 | +{ |
654 | + auto ret = eglSwapBuffers(egl_display, egl_surface); |
655 | + return (ret == EGL_TRUE); |
656 | +} |
657 | + |
658 | +bool mgmh::EGLHelper::make_current() const |
659 | +{ |
660 | + auto ret = eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context); |
661 | + eglBindAPI(MIR_SERVER_EGL_OPENGL_API); |
662 | + return (ret == EGL_TRUE); |
663 | +} |
664 | + |
665 | +bool mgmh::EGLHelper::release_current() const |
666 | +{ |
667 | + auto ret = eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
668 | + return (ret == EGL_TRUE); |
669 | +} |
670 | + |
671 | +void mgmh::EGLHelper::setup_internal(GBMHelper const& gbm, bool initialize) |
672 | +{ |
673 | + EGLint const config_attr[] = { |
674 | + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
675 | + EGL_RED_SIZE, 5, |
676 | + EGL_GREEN_SIZE, 5, |
677 | + EGL_BLUE_SIZE, 5, |
678 | + EGL_ALPHA_SIZE, 0, |
679 | + EGL_DEPTH_SIZE, depth_buffer_bits, |
680 | + EGL_STENCIL_SIZE, stencil_buffer_bits, |
681 | + EGL_RENDERABLE_TYPE, MIR_SERVER_EGL_OPENGL_BIT, |
682 | + EGL_NONE |
683 | + }; |
684 | + |
685 | + static const EGLint required_egl_version_major = 1; |
686 | + static const EGLint required_egl_version_minor = 4; |
687 | + |
688 | + EGLint num_egl_configs; |
689 | + |
690 | + egl_display = eglGetDisplay(static_cast<EGLNativeDisplayType>(gbm.device)); |
691 | + if (egl_display == EGL_NO_DISPLAY) |
692 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to get EGL display")); |
693 | + |
694 | + if (initialize) |
695 | + { |
696 | + EGLint major, minor; |
697 | + |
698 | + if (eglInitialize(egl_display, &major, &minor) == EGL_FALSE) |
699 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to initialize EGL display")); |
700 | + |
701 | + if ((major < required_egl_version_major) || |
702 | + (major == required_egl_version_major && minor < required_egl_version_minor)) |
703 | + { |
704 | + BOOST_THROW_EXCEPTION( |
705 | + boost::enable_error_info(std::runtime_error("Incompatible EGL version"))); |
706 | + // TODO: Insert egl version major and minor into exception |
707 | + } |
708 | + |
709 | + should_terminate_egl = true; |
710 | + } |
711 | + |
712 | + if (eglChooseConfig(egl_display, config_attr, &egl_config, 1, &num_egl_configs) == EGL_FALSE || |
713 | + num_egl_configs != 1) |
714 | + { |
715 | + BOOST_THROW_EXCEPTION(mg::egl_error("Failed to choose ARGB EGL config")); |
716 | + } |
717 | +} |
718 | + |
719 | +void mgmh::EGLHelper::report_egl_configuration(std::function<void(EGLDisplay, EGLConfig)> f) |
720 | +{ |
721 | + f(egl_display, egl_config); |
722 | +} |
723 | |
724 | === added file 'src/platforms/mesa/server/kms/egl_helper.h' |
725 | --- src/platforms/mesa/server/kms/egl_helper.h 1970-01-01 00:00:00 +0000 |
726 | +++ src/platforms/mesa/server/kms/egl_helper.h 2017-03-15 13:54:31 +0000 |
727 | @@ -0,0 +1,77 @@ |
728 | +/* |
729 | + * Copyright © 2017 Canonical Ltd. |
730 | + * |
731 | + * This program is free software: you can redistribute it and/or modify it |
732 | + * under the terms of the GNU Lesser General Public License version 3, |
733 | + * as published by the Free Software Foundation. |
734 | + * |
735 | + * This program is distributed in the hope that it will be useful, |
736 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
737 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
738 | + * GNU Lesser General Public License for more details. |
739 | + * |
740 | + * You should have received a copy of the GNU Lesser General Public License |
741 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
742 | + * |
743 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
744 | + */ |
745 | + |
746 | +#ifndef MIR_GRAPHICS_MESA_EGL_HELPER_H_ |
747 | +#define MIR_GRAPHICS_MESA_EGL_HELPER_H_ |
748 | + |
749 | +#include "display_helpers.h" |
750 | +#include <EGL/egl.h> |
751 | + |
752 | +namespace mir |
753 | +{ |
754 | +namespace graphics |
755 | +{ |
756 | +class GLConfig; |
757 | +namespace mesa |
758 | +{ |
759 | +namespace helpers |
760 | +{ |
761 | +class EGLHelper |
762 | +{ |
763 | +public: |
764 | + EGLHelper(GLConfig const& gl_config); |
765 | + EGLHelper( |
766 | + GLConfig const& gl_config, |
767 | + GBMHelper const& gbm, |
768 | + gbm_surface* surface, |
769 | + EGLContext shared_context); |
770 | + ~EGLHelper() noexcept; |
771 | + EGLHelper(EGLHelper&& from); |
772 | + |
773 | + EGLHelper(const EGLHelper&) = delete; |
774 | + EGLHelper& operator=(const EGLHelper&) = delete; |
775 | + |
776 | + void setup(GBMHelper const& gbm); |
777 | + void setup(GBMHelper const& gbm, EGLContext shared_context); |
778 | + void setup(GBMHelper const& gbm, gbm_surface* surface_gbm, |
779 | + EGLContext shared_context); |
780 | + |
781 | + bool swap_buffers(); |
782 | + bool make_current() const; |
783 | + bool release_current() const; |
784 | + |
785 | + EGLContext context() { return egl_context; } |
786 | + |
787 | + void report_egl_configuration(std::function<void(EGLDisplay, EGLConfig)>); |
788 | +private: |
789 | + void setup_internal(GBMHelper const& gbm, bool initialize); |
790 | + |
791 | + EGLint const depth_buffer_bits; |
792 | + EGLint const stencil_buffer_bits; |
793 | + EGLDisplay egl_display; |
794 | + EGLConfig egl_config; |
795 | + EGLContext egl_context; |
796 | + EGLSurface egl_surface; |
797 | + bool should_terminate_egl; |
798 | +}; |
799 | +} |
800 | +} |
801 | +} |
802 | +} |
803 | + |
804 | +#endif /* MIR_GRAPHICS_MESA_EGL_HELPER_H_ */ |
805 | |
806 | === modified file 'src/platforms/mesa/server/kms/guest_platform.cpp' |
807 | --- src/platforms/mesa/server/kms/guest_platform.cpp 2017-03-09 12:52:48 +0000 |
808 | +++ src/platforms/mesa/server/kms/guest_platform.cpp 2017-03-15 13:54:31 +0000 |
809 | @@ -83,6 +83,11 @@ |
810 | BOOST_THROW_EXCEPTION(std::runtime_error("mgm::GuestPlatform cannot create display\n")); |
811 | } |
812 | |
813 | +mg::NativePlatform* mgm::GuestPlatform::native_platform() |
814 | +{ |
815 | + return this; |
816 | +} |
817 | + |
818 | EGLNativeDisplayType mgm::GuestPlatform::egl_native_display() const |
819 | { |
820 | return gbm.device; |
821 | |
822 | === modified file 'src/platforms/mesa/server/kms/guest_platform.h' |
823 | --- src/platforms/mesa/server/kms/guest_platform.h 2017-03-09 12:52:48 +0000 |
824 | +++ src/platforms/mesa/server/kms/guest_platform.h 2017-03-15 13:54:31 +0000 |
825 | @@ -23,6 +23,7 @@ |
826 | |
827 | #include "mir/graphics/platform.h" |
828 | #include "mir/graphics/platform_ipc_package.h" |
829 | +#include "mir/renderer/gl/egl_platform.h" |
830 | #include "display_helpers.h" |
831 | |
832 | namespace mir |
833 | @@ -33,7 +34,9 @@ |
834 | { |
835 | class InternalNativeDisplay; |
836 | |
837 | -class GuestPlatform : public graphics::Platform |
838 | +class GuestPlatform : public graphics::Platform, |
839 | + public graphics::NativePlatform, |
840 | + public mir::renderer::gl::EGLPlatform |
841 | { |
842 | public: |
843 | GuestPlatform(std::shared_ptr<NestedContext> const& nested_context_arg); |
844 | @@ -44,6 +47,8 @@ |
845 | UniqueModulePtr<Display> create_display( |
846 | std::shared_ptr<graphics::DisplayConfigurationPolicy> const&, |
847 | std::shared_ptr<graphics::GLConfig> const& /*gl_config*/) override; |
848 | + |
849 | + NativePlatform* native_platform() override; |
850 | EGLNativeDisplayType egl_native_display() const override; |
851 | |
852 | private: |
853 | |
854 | === modified file 'src/platforms/mesa/server/kms/platform.cpp' |
855 | --- src/platforms/mesa/server/kms/platform.cpp 2017-03-09 12:52:48 +0000 |
856 | +++ src/platforms/mesa/server/kms/platform.cpp 2017-03-15 13:54:31 +0000 |
857 | @@ -79,6 +79,11 @@ |
858 | return make_module_ptr<mgm::IpcOperations>(drm); |
859 | } |
860 | |
861 | +mg::NativePlatform* mgm::Platform::native_platform() |
862 | +{ |
863 | + return this; |
864 | +} |
865 | + |
866 | EGLNativeDisplayType mgm::Platform::egl_native_display() const |
867 | { |
868 | return gbm->device; |
869 | |
870 | === modified file 'src/platforms/mesa/server/kms/platform.h' |
871 | --- src/platforms/mesa/server/kms/platform.h 2017-03-09 12:52:48 +0000 |
872 | +++ src/platforms/mesa/server/kms/platform.h 2017-03-15 13:54:31 +0000 |
873 | @@ -20,6 +20,7 @@ |
874 | #define MIR_GRAPHICS_MESA_PLATFORM_H_ |
875 | |
876 | #include "mir/graphics/platform.h" |
877 | +#include "mir/renderer/gl/egl_platform.h" |
878 | #include "platform_common.h" |
879 | #include "display_helpers.h" |
880 | |
881 | @@ -33,7 +34,9 @@ |
882 | |
883 | class VirtualTerminal; |
884 | class InternalNativeDisplay; |
885 | -class Platform : public graphics::Platform |
886 | +class Platform : public graphics::Platform, |
887 | + public graphics::NativePlatform, |
888 | + public mir::renderer::gl::EGLPlatform |
889 | { |
890 | public: |
891 | explicit Platform(std::shared_ptr<DisplayReport> const& reporter, |
892 | @@ -49,6 +52,7 @@ |
893 | |
894 | UniqueModulePtr<PlatformIpcOperations> make_ipc_operations() const override; |
895 | |
896 | + NativePlatform* native_platform() override; |
897 | EGLNativeDisplayType egl_native_display() const override; |
898 | |
899 | std::shared_ptr<mir::udev::Context> udev; |
900 | |
901 | === modified file 'src/platforms/mesa/server/x11/graphics/guest_platform.cpp' |
902 | --- src/platforms/mesa/server/x11/graphics/guest_platform.cpp 2017-03-09 12:52:48 +0000 |
903 | +++ src/platforms/mesa/server/x11/graphics/guest_platform.cpp 2017-03-15 13:54:31 +0000 |
904 | @@ -59,6 +59,11 @@ |
905 | BOOST_THROW_EXCEPTION(std::runtime_error("Guest platform cannot create display\n")); |
906 | } |
907 | |
908 | +mg::NativePlatform* mgx::GuestPlatform::native_platform() |
909 | +{ |
910 | + return this; |
911 | +} |
912 | + |
913 | EGLNativeDisplayType mgx::GuestPlatform::egl_native_display() const |
914 | { |
915 | return gbm.device; |
916 | |
917 | === modified file 'src/platforms/mesa/server/x11/graphics/guest_platform.h' |
918 | --- src/platforms/mesa/server/x11/graphics/guest_platform.h 2017-03-09 12:52:48 +0000 |
919 | +++ src/platforms/mesa/server/x11/graphics/guest_platform.h 2017-03-15 13:54:31 +0000 |
920 | @@ -22,6 +22,8 @@ |
921 | |
922 | #include "mir/graphics/platform.h" |
923 | #include "display_helpers.h" |
924 | +#undef __GBM__ //display_helpers.h sets __GBM__ platform, here need X11 egl platform defs, and gbm utilities |
925 | +#include "mir/renderer/gl/egl_platform.h" |
926 | |
927 | namespace mir |
928 | { |
929 | @@ -30,7 +32,9 @@ |
930 | namespace X |
931 | { |
932 | |
933 | -class GuestPlatform : public graphics::Platform |
934 | +class GuestPlatform : public graphics::Platform, |
935 | + public graphics::NativePlatform, |
936 | + public mir::renderer::gl::EGLPlatform |
937 | { |
938 | public: |
939 | GuestPlatform(std::shared_ptr<NestedContext> const& /*nested_context*/); |
940 | @@ -41,6 +45,8 @@ |
941 | UniqueModulePtr<Display> create_display( |
942 | std::shared_ptr<graphics::DisplayConfigurationPolicy> const&, |
943 | std::shared_ptr<graphics::GLConfig> const&) override; |
944 | + |
945 | + NativePlatform* native_platform() override; |
946 | EGLNativeDisplayType egl_native_display() const override; |
947 | |
948 | private: |
949 | |
950 | === modified file 'src/platforms/mesa/server/x11/graphics/platform.cpp' |
951 | --- src/platforms/mesa/server/x11/graphics/platform.cpp 2017-03-09 12:52:48 +0000 |
952 | +++ src/platforms/mesa/server/x11/graphics/platform.cpp 2017-03-15 13:54:31 +0000 |
953 | @@ -60,6 +60,11 @@ |
954 | return make_module_ptr<mg::mesa::IpcOperations>(drm); |
955 | } |
956 | |
957 | +mg::NativePlatform* mgx::Platform::native_platform() |
958 | +{ |
959 | + return this; |
960 | +} |
961 | + |
962 | EGLNativeDisplayType mgx::Platform::egl_native_display() const |
963 | { |
964 | return eglGetDisplay(x11_connection.get()); |
965 | |
966 | === modified file 'src/platforms/mesa/server/x11/graphics/platform.h' |
967 | --- src/platforms/mesa/server/x11/graphics/platform.h 2017-03-09 12:52:48 +0000 |
968 | +++ src/platforms/mesa/server/x11/graphics/platform.h 2017-03-15 13:54:31 +0000 |
969 | @@ -23,6 +23,7 @@ |
970 | #include "mir/graphics/platform.h" |
971 | #include "display_helpers.h" |
972 | #include "mir/geometry/size.h" |
973 | +#include "mir/renderer/gl/egl_platform.h" |
974 | |
975 | #include <X11/Xlib.h> |
976 | #include <X11/Xutil.h> |
977 | @@ -34,7 +35,9 @@ |
978 | namespace X |
979 | { |
980 | |
981 | -class Platform : public graphics::Platform |
982 | +class Platform : public graphics::Platform, |
983 | + public graphics::NativePlatform, |
984 | + public mir::renderer::gl::EGLPlatform |
985 | { |
986 | public: |
987 | explicit Platform(std::shared_ptr<::Display> const& conn, |
988 | @@ -51,6 +54,7 @@ |
989 | |
990 | UniqueModulePtr<PlatformIpcOperations> make_ipc_operations() const override; |
991 | |
992 | + NativePlatform* native_platform() override; |
993 | EGLNativeDisplayType egl_native_display() const override; |
994 | private: |
995 | std::shared_ptr<::Display> const x11_connection; |
996 | |
997 | === modified file 'src/server/graphics/default_configuration.cpp' |
998 | --- src/server/graphics/default_configuration.cpp 2017-03-09 13:00:13 +0000 |
999 | +++ src/server/graphics/default_configuration.cpp 2017-03-15 13:54:31 +0000 |
1000 | @@ -153,10 +153,20 @@ |
1001 | { |
1002 | if (the_options()->is_set(options::offscreen_opt)) |
1003 | { |
1004 | - return std::make_shared<mg::offscreen::Display>( |
1005 | - the_graphics_platform()->egl_native_display(), |
1006 | - the_display_configuration_policy(), |
1007 | - the_display_report()); |
1008 | + if (auto egl_access = dynamic_cast<mir::renderer::gl::EGLPlatform*>( |
1009 | + the_graphics_platform()->native_platform())) |
1010 | + { |
1011 | + return std::make_shared<mg::offscreen::Display>( |
1012 | + egl_access->egl_native_display(), |
1013 | + the_display_configuration_policy(), |
1014 | + the_display_report()); |
1015 | + } |
1016 | + else |
1017 | + { |
1018 | + BOOST_THROW_EXCEPTION(std::runtime_error( |
1019 | + "underlying rendering platform does not support EGL access."\ |
1020 | + " Could not create offscreen display")); |
1021 | + } |
1022 | } |
1023 | |
1024 | return the_graphics_platform()->create_display( |
1025 | |
1026 | === modified file 'src/server/graphics/nested/platform.cpp' |
1027 | --- src/server/graphics/nested/platform.cpp 2017-03-14 05:30:56 +0000 |
1028 | +++ src/server/graphics/nested/platform.cpp 2017-03-15 13:54:31 +0000 |
1029 | @@ -31,6 +31,7 @@ |
1030 | #include "mir/graphics/buffer_ipc_message.h" |
1031 | #include "mir/graphics/platform_ipc_operations.h" |
1032 | #include "mir/graphics/platform_operation_message.h" |
1033 | +#include "mir/renderer/gl/egl_platform.h" |
1034 | |
1035 | namespace mg = mir::graphics; |
1036 | namespace mgn = mir::graphics::nested; |
1037 | @@ -144,5 +145,12 @@ |
1038 | |
1039 | EGLNativeDisplayType mgn::Platform::egl_native_display() const |
1040 | { |
1041 | - return guest_platform->egl_native_display(); |
1042 | + if (auto a = dynamic_cast<mir::renderer::gl::EGLPlatform*>(guest_platform->native_platform())) |
1043 | + return a->egl_native_display(); |
1044 | + return EGL_NO_DISPLAY; |
1045 | +} |
1046 | + |
1047 | +mg::NativePlatform* mgn::Platform::native_platform() |
1048 | +{ |
1049 | + return this; |
1050 | } |
1051 | |
1052 | === modified file 'src/server/graphics/nested/platform.h' |
1053 | --- src/server/graphics/nested/platform.h 2017-03-09 13:00:13 +0000 |
1054 | +++ src/server/graphics/nested/platform.h 2017-03-15 13:54:31 +0000 |
1055 | @@ -20,6 +20,7 @@ |
1056 | #define MIR_GRAPHICS_NESTED_PLATFORM_H_ |
1057 | |
1058 | #include "mir/graphics/platform.h" |
1059 | +#include "mir/renderer/gl/egl_platform.h" |
1060 | #include "passthrough_option.h" |
1061 | #include <memory> |
1062 | |
1063 | @@ -35,7 +36,9 @@ |
1064 | namespace nested |
1065 | { |
1066 | class HostConnection; |
1067 | -class Platform : public graphics::Platform |
1068 | +class Platform : public graphics::Platform, |
1069 | + public graphics::NativePlatform, |
1070 | + public mir::renderer::gl::EGLPlatform |
1071 | { |
1072 | public: |
1073 | Platform( |
1074 | @@ -49,6 +52,7 @@ |
1075 | std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy, |
1076 | std::shared_ptr<GLConfig> const& gl_config) override; |
1077 | UniqueModulePtr<PlatformIpcOperations> make_ipc_operations() const override; |
1078 | + NativePlatform* native_platform() override; |
1079 | EGLNativeDisplayType egl_native_display() const override; |
1080 | private: |
1081 | std::shared_ptr<mir::SharedLibrary> const library; |
1082 | |
1083 | === modified file 'tests/integration-tests/graphics/mesa/test_buffer_integration.cpp' |
1084 | --- tests/integration-tests/graphics/mesa/test_buffer_integration.cpp 2017-03-09 12:52:48 +0000 |
1085 | +++ tests/integration-tests/graphics/mesa/test_buffer_integration.cpp 2017-03-15 13:54:31 +0000 |
1086 | @@ -33,6 +33,7 @@ |
1087 | |
1088 | #include "mir_test_framework/testing_server_configuration.h" |
1089 | |
1090 | +#include <EGL/egl.h> |
1091 | #include <thread> |
1092 | #include <gtest/gtest.h> |
1093 | #include <stdexcept> |
1094 | |
1095 | === modified file 'tests/integration-tests/test_submit_buffer.cpp' |
1096 | --- tests/integration-tests/test_submit_buffer.cpp 2017-03-14 05:30:56 +0000 |
1097 | +++ tests/integration-tests/test_submit_buffer.cpp 2017-03-15 13:54:31 +0000 |
1098 | @@ -233,7 +233,7 @@ |
1099 | return underlying_platform->create_display(policy, config); |
1100 | } |
1101 | |
1102 | - EGLNativeDisplayType egl_native_display() const override { return EGL_DEFAULT_DISPLAY; } |
1103 | + mg::NativePlatform* native_platform() override { return nullptr; } |
1104 | |
1105 | std::shared_ptr<mir::Fd> const last_fd; |
1106 | std::shared_ptr<mg::Platform> const underlying_platform; |
1107 | |
1108 | === modified file 'tests/mir_test_framework/platform_graphics_throw.cpp' |
1109 | --- tests/mir_test_framework/platform_graphics_throw.cpp 2017-03-09 12:52:48 +0000 |
1110 | +++ tests/mir_test_framework/platform_graphics_throw.cpp 2017-03-15 13:54:31 +0000 |
1111 | @@ -84,12 +84,12 @@ |
1112 | return stub_platform->make_ipc_operations(); |
1113 | } |
1114 | |
1115 | - EGLNativeDisplayType egl_native_display() const override |
1116 | + mg::NativePlatform* native_platform() override |
1117 | { |
1118 | if (should_throw.at(ExceptionLocation::at_egl_native_display)) |
1119 | BOOST_THROW_EXCEPTION(std::runtime_error("Exception during egl_native_display")); |
1120 | |
1121 | - return stub_platform->egl_native_display(); |
1122 | + return stub_platform->native_platform(); |
1123 | } |
1124 | |
1125 | private: |
1126 | |
1127 | === modified file 'tests/mir_test_framework/stubbed_graphics_platform.cpp' |
1128 | --- tests/mir_test_framework/stubbed_graphics_platform.cpp 2017-03-14 05:30:56 +0000 |
1129 | +++ tests/mir_test_framework/stubbed_graphics_platform.cpp 2017-03-15 13:54:31 +0000 |
1130 | @@ -304,9 +304,9 @@ |
1131 | return adaptee->create_display(initial_conf_policy, gl_config); |
1132 | } |
1133 | |
1134 | - EGLNativeDisplayType egl_native_display() const override |
1135 | + mg::NativePlatform* native_platform() override |
1136 | { |
1137 | - return adaptee->egl_native_display(); |
1138 | + return adaptee->native_platform(); |
1139 | } |
1140 | |
1141 | std::shared_ptr<mg::NestedContext> const context; |
PASSED: Continuous integration, rev:4091 /mir-jenkins. ubuntu. com/job/ mir-ci/ 3137/ /mir-jenkins. ubuntu. com/job/ build-mir/ 4211 /mir-jenkins. ubuntu. com/job/ build-0- fetch/4298 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= vivid+overlay/ 4288 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial+ overlay/ 4288 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= zesty/4288 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= zesty/4238 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= zesty/4238/ artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial+ overlay/ 4238 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial+ overlay/ 4238/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= zesty/4238 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= zesty/4238/ artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= android, release= vivid+overlay/ 4238 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= android, release= vivid+overlay/ 4238/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= android, release= vivid+overlay/ 4238 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= android, release= vivid+overlay/ 4238/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial+ overlay/ 4238 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial+ overlay/ 4238/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /mir-jenkins. ubuntu. com/job/ mir-ci/ 3137/rebuild
https:/