Merge lp:~gerboland/qtmir/refactor-opengl into lp:qtmir
- refactor-opengl
- Merge into trunk
Status: | Needs review |
---|---|
Proposed branch: | lp:~gerboland/qtmir/refactor-opengl |
Merge into: | lp:qtmir |
Prerequisite: | lp:~alan-griffiths/qtmir/untangle-libmirserver-from-QOBJECTs |
Diff against target: |
777 lines (+317/-201) 15 files modified
src/platforms/mirserver/CMakeLists.txt (+4/-3) src/platforms/mirserver/egl.h (+34/-0) src/platforms/mirserver/eglimpl.cpp (+92/-0) src/platforms/mirserver/eglimpl.h (+41/-0) src/platforms/mirserver/glconfiguration.cpp (+61/-0) src/platforms/mirserver/glconfiguration.h (+59/-0) src/platforms/mirserver/miropenglcontext.cpp (+5/-67) src/platforms/mirserver/miropenglcontext.h (+4/-9) src/platforms/mirserver/mirserverintegration.cpp (+1/-5) src/platforms/mirserver/openglcontextfactory.cpp (+0/-51) src/platforms/mirserver/openglcontextfactory.h (+0/-47) src/platforms/mirserver/qmirserver.cpp (+2/-2) src/platforms/mirserver/qmirserver.h (+5/-5) src/platforms/mirserver/qmirserver_p.cpp (+3/-6) src/platforms/mirserver/qmirserver_p.h (+6/-6) |
To merge this branch: | bzr merge lp:~gerboland/qtmir/refactor-opengl |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alan Griffiths | Needs Fixing | ||
Unity8 CI Bot (community) | continuous-integration | Approve | |
Review via email: mp+322023@code.launchpad.net |
This proposal supersedes a proposal from 2017-04-05.
Commit message
Refactor GL context management
- isolate EGL state (Config & Display) into separate class
- isolate GLConfiguration into a separate class
- share the EGL state with MirOpenGLContext to allow it to create its Surface itself.
Then can remove the OpenGLContextFa
The EGL and GLConfiguration classes will be handy to expose in a later C++ api.
Description of the change
- 643. By Gerry Boland
-
It works, comment removed
- 644. By Gerry Boland
-
Fix GL/EGL debugging
- 645. By Gerry Boland
-
Fix header file ifndefs
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:645
https:/
Executed test runs:
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:/
Alan Griffiths (alan-griffiths) wrote : | # |
class GLConfiguration ...
I'm not sure of the design intent here.
The only reason for virtual functions appears to be supplying two ints. Inlining virtual functions is an unlikely design. And the implementations just supply constants. Note that copying (with slicing) is allowed.
How about a handle class:
class GLConfiguration
{
public:
GLConfigura
~GLConfigur
int depth_buffer_bits() const;
int stencil_
void operator(
private:
struct Self;
std:
};
Alan Griffiths (alan-griffiths) wrote : | # |
+class EGL
+{
+public:
+ virtual EGLConfig config() const = 0;
+ virtual EGLDisplay display() const = 0;
+};
It is a good idea to disable CopyAssign in an interface.
Alan Griffiths (alan-griffiths) wrote : | # |
Other than the above nits, this looks like good progress.
Unmerged revisions
- 645. By Gerry Boland
-
Fix header file ifndefs
- 644. By Gerry Boland
-
Fix GL/EGL debugging
- 643. By Gerry Boland
-
It works, comment removed
- 642. By Gerry Boland
-
Refactor GL context management
- isolate EGL state (Config & Display) into separate class
- isolate GLConfiguration into a separate class
- share the EGL state with MirOpenGLContext to allow it to create its Surface itself.
Then can remove the OpenGLContextFactory and remove mir dependencies in QMirServerPrivate and some QPA internals from QMirServer. The EGL and GLConfiguration classes will be handy to expose in a later C++ api.
- 641. By Alan Griffiths
-
Apply Gerry's patch to CMakeLists.txt
- 640. By Alan Griffiths
-
windowmanagemen
tpolicy. cpp doesn't use libmirserver - 639. By Alan Griffiths
-
cleanup the mirserver platform compile flags
- 638. By Alan Griffiths
-
Avoid dependency on libmirserver-dev in qtcompositor.h
- 637. By Alan Griffiths
-
Avoid dependency on libmirserver-dev in inputdeviceobse
rver.h - 636. By Alan Griffiths
-
Avoid dependency on libmirserver-dev in screensmodel.h
Preview Diff
1 | === modified file 'src/platforms/mirserver/CMakeLists.txt' |
2 | --- src/platforms/mirserver/CMakeLists.txt 2017-04-05 16:31:55 +0000 |
3 | +++ src/platforms/mirserver/CMakeLists.txt 2017-04-05 16:31:55 +0000 |
4 | @@ -52,17 +52,16 @@ |
5 | |
6 | # Files the depend on mirserver-dev |
7 | set(MIRSERVER_DEPENDANTS |
8 | + eglimpl.cpp |
9 | eventbuilder.cpp |
10 | eventdispatch.cpp |
11 | + glconfiguration.cpp |
12 | inputdeviceobserver.cpp |
13 | mircursorimages.cpp |
14 | mirdisplayconfigurationpolicy.cpp |
15 | miropenglcontext.cpp |
16 | mirserverhooks.cpp |
17 | - mirserverintegration.cpp |
18 | - openglcontextfactory.cpp |
19 | promptsessionmanager.cpp |
20 | - qmirserver.cpp |
21 | qmirserver_p.cpp |
22 | qteventfeeder.cpp |
23 | screen.cpp |
24 | @@ -79,11 +78,13 @@ |
25 | initialsurfacesizes.cpp |
26 | inputdeviceobserver.cpp |
27 | logging.cpp |
28 | + mirserverintegration.cpp |
29 | mirsingleton.cpp |
30 | nativeinterface.cpp |
31 | offscreensurface.cpp |
32 | plugin.cpp |
33 | promptsessionlistener.cpp |
34 | + qmirserver.cpp |
35 | qtcompositor.cpp |
36 | services.cpp |
37 | sessionauthorizer.cpp |
38 | |
39 | === added file 'src/platforms/mirserver/egl.h' |
40 | --- src/platforms/mirserver/egl.h 1970-01-01 00:00:00 +0000 |
41 | +++ src/platforms/mirserver/egl.h 2017-04-05 16:31:55 +0000 |
42 | @@ -0,0 +1,34 @@ |
43 | +/* |
44 | + * Copyright (C) 2017 Canonical, Ltd. |
45 | + * |
46 | + * This program is free software: you can redistribute it and/or modify it under |
47 | + * the terms of the GNU Lesser General Public License version 3, as published by |
48 | + * the Free Software Foundation. |
49 | + * |
50 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
51 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
52 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
53 | + * Lesser General Public License for more details. |
54 | + * |
55 | + * You should have received a copy of the GNU Lesser General Public License |
56 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
57 | + */ |
58 | + |
59 | +#ifndef QTMIR_EGL_H |
60 | +#define QTMIR_EGL_H |
61 | + |
62 | +#define MESA_EGL_NO_X11_HEADERS |
63 | +#include <EGL/egl.h> |
64 | + |
65 | +namespace qtmir { |
66 | + |
67 | +class EGL |
68 | +{ |
69 | +public: |
70 | + virtual EGLConfig config() const = 0; |
71 | + virtual EGLDisplay display() const = 0; |
72 | +}; |
73 | + |
74 | +} // namespace qtmir |
75 | + |
76 | +#endif // QTMIR_EGL_H |
77 | |
78 | === added file 'src/platforms/mirserver/eglimpl.cpp' |
79 | --- src/platforms/mirserver/eglimpl.cpp 1970-01-01 00:00:00 +0000 |
80 | +++ src/platforms/mirserver/eglimpl.cpp 2017-04-05 16:31:55 +0000 |
81 | @@ -0,0 +1,92 @@ |
82 | +/* |
83 | + * Copyright (C) 2017 Canonical, Ltd. |
84 | + * |
85 | + * This program is free software: you can redistribute it and/or modify it under |
86 | + * the terms of the GNU Lesser General Public License version 3, as published by |
87 | + * the Free Software Foundation. |
88 | + * |
89 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
90 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
91 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
92 | + * Lesser General Public License for more details. |
93 | + * |
94 | + * You should have received a copy of the GNU Lesser General Public License |
95 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
96 | + */ |
97 | + |
98 | +#include "eglimpl.h" |
99 | + |
100 | +// Mir |
101 | +#include <mir/graphics/display.h> |
102 | +#include <mir/renderer/gl/context.h> |
103 | +#include <mir/renderer/gl/context_source.h> |
104 | + |
105 | +// Qt |
106 | +#include <QDebug> |
107 | +#include <QtGui/private/qopenglcontext_p.h> |
108 | +#include <QtPlatformSupport/private/qeglconvenience_p.h> |
109 | + |
110 | +using namespace qtmir; |
111 | +namespace mrg = mir::renderer::gl; |
112 | + |
113 | +EGLImpl::EGLImpl(mir::graphics::Display &display) |
114 | + : m_eglConfig(0) |
115 | + , m_eglDisplay(0) |
116 | +{ |
117 | + // create a temporary GL context to fetch the EGL display and config, so Qt can determine the surface format |
118 | + std::unique_ptr<mrg::Context> mirContext = dynamic_cast<mrg::ContextSource*>( |
119 | + display.native_display())->create_gl_context(); |
120 | + mirContext->make_current(); |
121 | + |
122 | + m_eglDisplay = eglGetCurrentDisplay(); |
123 | + if (m_eglDisplay == EGL_NO_DISPLAY) { |
124 | + qFatal("Unable to determine current EGL Display"); |
125 | + } |
126 | + |
127 | + EGLContext eglContext = eglGetCurrentContext(); |
128 | + if (eglContext == EGL_NO_CONTEXT) { |
129 | + qFatal("Unable to determine current EGL Context"); |
130 | + } |
131 | + EGLint eglConfigId = -1; |
132 | + EGLBoolean result; |
133 | + result = eglQueryContext(m_eglDisplay, eglContext, EGL_CONFIG_ID, &eglConfigId); |
134 | + if (result != EGL_TRUE || eglConfigId < 0) { |
135 | + qFatal("Unable to determine current EGL Config ID"); |
136 | + } |
137 | + |
138 | + EGLint matchingEglConfigCount; |
139 | + EGLint const attribList[] = { |
140 | + EGL_CONFIG_ID, eglConfigId, |
141 | + EGL_NONE |
142 | + }; |
143 | + result = eglChooseConfig(m_eglDisplay, attribList, &m_eglConfig, 1, &matchingEglConfigCount); |
144 | + if (result != EGL_TRUE || m_eglConfig == nullptr || matchingEglConfigCount < 1) { |
145 | + qFatal("Unable to select EGL Config with the supposed current config ID"); |
146 | + } |
147 | + |
148 | +#ifdef QGL_DEBUG |
149 | + const char* string = (const char*) glGetString(GL_VENDOR); |
150 | + qDebug() << "OpenGL ES vendor: " << qPrintable(string); |
151 | + string = (const char*) glGetString(GL_RENDERER); |
152 | + qDebug() << "OpenGL ES renderer" << qPrintable(string); |
153 | + string = (const char*) glGetString(GL_VERSION); |
154 | + qDebug() << "OpenGL ES version" << qPrintable(string); |
155 | + string = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION); |
156 | + qDebug() << "OpenGL ES Shading Language version:" << qPrintable(string); |
157 | + string = (const char*) glGetString(GL_EXTENSIONS); |
158 | + qDebug() << "OpenGL ES extensions:" << qPrintable(string); |
159 | + q_printEglConfig(m_eglDisplay, m_eglConfig); |
160 | +#endif |
161 | + |
162 | + mirContext->release_current(); // Need to release as it doesn't happen when GLContext goes out of scope |
163 | +} |
164 | + |
165 | +EGLConfig EGLImpl::config() const |
166 | +{ |
167 | + return m_eglConfig; |
168 | +} |
169 | + |
170 | +EGLDisplay EGLImpl::display() const |
171 | +{ |
172 | + return m_eglDisplay; |
173 | +} |
174 | |
175 | === added file 'src/platforms/mirserver/eglimpl.h' |
176 | --- src/platforms/mirserver/eglimpl.h 1970-01-01 00:00:00 +0000 |
177 | +++ src/platforms/mirserver/eglimpl.h 2017-04-05 16:31:55 +0000 |
178 | @@ -0,0 +1,41 @@ |
179 | +/* |
180 | + * Copyright (C) 2017 Canonical, Ltd. |
181 | + * |
182 | + * This program is free software: you can redistribute it and/or modify it under |
183 | + * the terms of the GNU Lesser General Public License version 3, as published by |
184 | + * the Free Software Foundation. |
185 | + * |
186 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
187 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
188 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
189 | + * Lesser General Public License for more details. |
190 | + * |
191 | + * You should have received a copy of the GNU Lesser General Public License |
192 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
193 | + */ |
194 | + |
195 | +#ifndef QTMIR_EGLIMPL_H |
196 | +#define QTMIR_EGLIMPL_H |
197 | + |
198 | +#include "egl.h" |
199 | + |
200 | +namespace mir { namespace graphics { class Display; }} |
201 | + |
202 | +namespace qtmir { |
203 | + |
204 | +class EGLImpl : public EGL |
205 | +{ |
206 | +public: |
207 | + explicit EGLImpl(mir::graphics::Display &display); |
208 | + |
209 | + EGLConfig config() const override; |
210 | + EGLDisplay display() const override; |
211 | + |
212 | +private: |
213 | + EGLConfig m_eglConfig; |
214 | + EGLDisplay m_eglDisplay; |
215 | +}; |
216 | + |
217 | +} //namespace qtmir |
218 | + |
219 | +#endif // QTMIR_EGLIMPL_H |
220 | |
221 | === added file 'src/platforms/mirserver/glconfiguration.cpp' |
222 | --- src/platforms/mirserver/glconfiguration.cpp 1970-01-01 00:00:00 +0000 |
223 | +++ src/platforms/mirserver/glconfiguration.cpp 2017-04-05 16:31:55 +0000 |
224 | @@ -0,0 +1,61 @@ |
225 | +/* |
226 | + * Copyright (C) 2017 Canonical, Ltd. |
227 | + * |
228 | + * This program is free software: you can redistribute it and/or modify it under |
229 | + * the terms of the GNU Lesser General Public License version 3, as published by |
230 | + * the Free Software Foundation. |
231 | + * |
232 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
233 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
234 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
235 | + * Lesser General Public License for more details. |
236 | + * |
237 | + * You should have received a copy of the GNU Lesser General Public License |
238 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
239 | + */ |
240 | + |
241 | +#include "glconfiguration.h" |
242 | + |
243 | +#include <mir/server.h> |
244 | + |
245 | +#include <mir/graphics/gl_config.h> |
246 | + |
247 | +#include <QSurfaceFormat> |
248 | + |
249 | +using namespace qtmir; |
250 | +namespace mg = mir::graphics; |
251 | + |
252 | +namespace { |
253 | + |
254 | +class GLConfigImpl : public mg::GLConfig |
255 | +{ |
256 | +public: |
257 | + GLConfigImpl(int depth, int stencil) : depthBufferBits(depth), stencilBufferBits(stencil) {} |
258 | + |
259 | + int depth_buffer_bits() const override { return depthBufferBits; } |
260 | + int stencil_buffer_bits() const override { return stencilBufferBits; } |
261 | +private: |
262 | + int depthBufferBits; |
263 | + int stencilBufferBits; |
264 | +}; |
265 | + |
266 | +} // namespace |
267 | + |
268 | + |
269 | +GLConfiguration::GLConfiguration() |
270 | +{ |
271 | + auto defaultFormat = QSurfaceFormat::defaultFormat(); |
272 | + defaultFormat.setDepthBufferSize(depth_buffer_bits()); |
273 | + defaultFormat.setStencilBufferSize(stencil_buffer_bits()); |
274 | + QSurfaceFormat::setDefaultFormat(defaultFormat); |
275 | +} |
276 | + |
277 | +GLConfiguration::~GLConfiguration() = default; |
278 | + |
279 | +void GLConfiguration::operator()(mir::Server& server) const |
280 | +{ |
281 | + server.override_the_gl_config([&] |
282 | + { |
283 | + return std::make_shared<::GLConfigImpl>(depth_buffer_bits(), stencil_buffer_bits()); |
284 | + }); |
285 | +} |
286 | |
287 | === added file 'src/platforms/mirserver/glconfiguration.h' |
288 | --- src/platforms/mirserver/glconfiguration.h 1970-01-01 00:00:00 +0000 |
289 | +++ src/platforms/mirserver/glconfiguration.h 2017-04-05 16:31:55 +0000 |
290 | @@ -0,0 +1,59 @@ |
291 | +/* |
292 | + * Copyright (C) 2017 Canonical, Ltd. |
293 | + * |
294 | + * This program is free software: you can redistribute it and/or modify it under |
295 | + * the terms of the GNU Lesser General Public License version 3, as published by |
296 | + * the Free Software Foundation. |
297 | + * |
298 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
299 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
300 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
301 | + * Lesser General Public License for more details. |
302 | + * |
303 | + * You should have received a copy of the GNU Lesser General Public License |
304 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
305 | + */ |
306 | + |
307 | +#ifndef QTMIR_GLCONFIGURATION_H |
308 | +#define QTMIR_GLCONFIGURATION_H |
309 | + |
310 | +#include <memory> |
311 | + |
312 | +namespace mir { class Server; } |
313 | + |
314 | +namespace qtmir |
315 | +{ |
316 | + |
317 | +class GLConfiguration |
318 | +{ |
319 | +public: |
320 | + GLConfiguration(); |
321 | + virtual ~GLConfiguration(); |
322 | + |
323 | + virtual int depth_buffer_bits() const { return 24; } |
324 | + virtual int stencil_buffer_bits() const { return 8; } |
325 | + |
326 | + void operator()(mir::Server& server) const; |
327 | +}; |
328 | + |
329 | + |
330 | +/* |
331 | + Set the GLConfiguration to allow the server specify aspects of |
332 | + the preferred GL configuration (used by Mir when doing eglChooseConfig) |
333 | + |
334 | + usage: |
335 | + class MyGLConfiguration : public qtmir::GLConfiguration |
336 | + { |
337 | + int depth_buffer_bits() const override { return 0; } |
338 | + int stencil_buffer_bits() const override { return 8; } |
339 | + } |
340 | + |
341 | + MyGLConfiguration glConfig; |
342 | + |
343 | + qtmir::GuiServerApplication app(argc, argv, { glConfig }); |
344 | + */ |
345 | + |
346 | +} // namespace qtmir |
347 | + |
348 | + |
349 | +#endif // QTMIR_GLCONFIGURATION_H |
350 | |
351 | === modified file 'src/platforms/mirserver/miropenglcontext.cpp' |
352 | --- src/platforms/mirserver/miropenglcontext.cpp 2016-12-14 16:59:01 +0000 |
353 | +++ src/platforms/mirserver/miropenglcontext.cpp 2017-04-05 16:31:55 +0000 |
354 | @@ -1,5 +1,5 @@ |
355 | /* |
356 | - * Copyright (C) 2013-2016 Canonical, Ltd. |
357 | + * Copyright (C) 2013-2017 Canonical, Ltd. |
358 | * |
359 | * This program is free software: you can redistribute it and/or modify it under |
360 | * the terms of the GNU Lesser General Public License version 3, as published by |
361 | @@ -14,97 +14,35 @@ |
362 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
363 | */ |
364 | |
365 | +#include <QDebug> |
366 | + |
367 | #include "miropenglcontext.h" |
368 | |
369 | #include "offscreensurface.h" |
370 | #include "mirglconfig.h" |
371 | #include "screenwindow.h" |
372 | |
373 | -#include <QDebug> |
374 | - |
375 | #include <QOpenGLFramebufferObject> |
376 | #include <QSurfaceFormat> |
377 | #include <QtPlatformSupport/private/qeglconvenience_p.h> |
378 | #include <QtGui/private/qopenglcontext_p.h> |
379 | |
380 | -// Mir |
381 | -#include <mir/graphics/display.h> |
382 | -#include <mir/renderer/gl/context.h> |
383 | -#include <mir/renderer/gl/context_source.h> |
384 | - |
385 | // Qt supports one GL context per screen, but also shared contexts. |
386 | // The Mir "Display" generates a shared GL context for all DisplayBuffers |
387 | // (i.e. individual display output buffers) to use as a common base context. |
388 | |
389 | -MirOpenGLContext::MirOpenGLContext( |
390 | - mir::graphics::Display &display, |
391 | - mir::graphics::GLConfig &gl_config, |
392 | - const QSurfaceFormat &format) |
393 | +MirOpenGLContext::MirOpenGLContext(const QSharedPointer<qtmir::EGL> egl, const QSurfaceFormat &format) |
394 | : m_currentWindow(nullptr) |
395 | -#ifdef QGL_DEBUG |
396 | - , m_logger(new QOpenGLDebugLogger(this)) |
397 | -#endif |
398 | { |
399 | - // create a temporary GL context to fetch the EGL display and config, so Qt can determine the surface format |
400 | - std::unique_ptr<mir::renderer::gl::Context> mirContext = dynamic_cast<mir::renderer::gl::ContextSource*>( |
401 | - display.native_display())->create_gl_context(); |
402 | - mirContext->make_current(); |
403 | - |
404 | - EGLDisplay eglDisplay = eglGetCurrentDisplay(); |
405 | - if (eglDisplay == EGL_NO_DISPLAY) { |
406 | - qFatal("Unable to determine current EGL Display"); |
407 | - } |
408 | - EGLContext eglContext = eglGetCurrentContext(); |
409 | - if (eglContext == EGL_NO_CONTEXT) { |
410 | - qFatal("Unable to determine current EGL Context"); |
411 | - } |
412 | - EGLint eglConfigId = -1; |
413 | - EGLBoolean result; |
414 | - result = eglQueryContext(eglDisplay, eglContext, EGL_CONFIG_ID, &eglConfigId); |
415 | - if (result != EGL_TRUE || eglConfigId < 0) { |
416 | - qFatal("Unable to determine current EGL Config ID"); |
417 | - } |
418 | - |
419 | - EGLConfig eglConfig; |
420 | - EGLint matchingEglConfigCount; |
421 | - EGLint const attribList[] = { |
422 | - EGL_CONFIG_ID, eglConfigId, |
423 | - EGL_NONE |
424 | - }; |
425 | - result = eglChooseConfig(eglDisplay, attribList, &eglConfig, 1, &matchingEglConfigCount); |
426 | - if (result != EGL_TRUE || eglConfig == nullptr || matchingEglConfigCount < 1) { |
427 | - qFatal("Unable to select EGL Config with the supposed current config ID"); |
428 | - } |
429 | - |
430 | QSurfaceFormat formatCopy = format; |
431 | formatCopy.setRenderableType(QSurfaceFormat::OpenGLES); |
432 | |
433 | - m_format = q_glFormatFromConfig(eglDisplay, eglConfig, formatCopy); |
434 | - mirContext->release_current(); // Need to release as it doesn't happen when GLContext goes out of scope |
435 | - |
436 | - // FIXME: the temporary gl context created by Mir does not have the attributes we specified |
437 | - // in the GLConfig, so need to set explicitly for now |
438 | - m_format.setDepthBufferSize(gl_config.depth_buffer_bits()); |
439 | - m_format.setStencilBufferSize(gl_config.stencil_buffer_bits()); |
440 | - m_format.setSamples(-1); |
441 | + m_format = q_glFormatFromConfig(egl->display(), egl->config(), formatCopy); |
442 | |
443 | #ifdef QGL_DEBUG |
444 | - const char* string = (const char*) glGetString(GL_VENDOR); |
445 | - qDebug() << "OpenGL ES vendor: " << qPrintable(string); |
446 | - string = (const char*) glGetString(GL_RENDERER); |
447 | - qDebug() << "OpenGL ES renderer" << qPrintable(string); |
448 | - string = (const char*) glGetString(GL_VERSION); |
449 | - qDebug() << "OpenGL ES version" << qPrintable(string); |
450 | - string = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION); |
451 | - qDebug() << "OpenGL ES Shading Language version:" << qPrintable(string); |
452 | - string = (const char*) glGetString(GL_EXTENSIONS); |
453 | - qDebug() << "OpenGL ES extensions:" << qPrintable(string); |
454 | - q_printEglConfig(eglDisplay, eglConfig); |
455 | - |
456 | QObject::connect(m_logger, &QOpenGLDebugLogger::messageLogged, |
457 | this, &MirOpenGLContext::onGlDebugMessageLogged, Qt::DirectConnection); |
458 | #endif // debug |
459 | - mirContext->release_current(); // Need to release as it doesn't happen when GLContext goes out of scope |
460 | } |
461 | |
462 | QSurfaceFormat MirOpenGLContext::format() const |
463 | |
464 | === modified file 'src/platforms/mirserver/miropenglcontext.h' |
465 | --- src/platforms/mirserver/miropenglcontext.h 2016-11-18 12:14:14 +0000 |
466 | +++ src/platforms/mirserver/miropenglcontext.h 2017-04-05 16:31:55 +0000 |
467 | @@ -19,21 +19,19 @@ |
468 | |
469 | #include <qpa/qplatformopenglcontext.h> |
470 | |
471 | +#include "egl.h" |
472 | + |
473 | #ifdef QGL_DEBUG |
474 | #include <QOpenGLDebugLogger> |
475 | #endif |
476 | |
477 | class ScreenWindow; |
478 | -namespace mir { namespace graphics { class Display; class GLConfig; }} |
479 | |
480 | class MirOpenGLContext : public QObject, public QPlatformOpenGLContext |
481 | { |
482 | Q_OBJECT |
483 | public: |
484 | - MirOpenGLContext( |
485 | - mir::graphics::Display &display, |
486 | - mir::graphics::GLConfig &gl_config |
487 | - , const QSurfaceFormat &); |
488 | + explicit MirOpenGLContext(const QSharedPointer<qtmir::EGL> egl, const QSurfaceFormat &); |
489 | ~MirOpenGLContext() = default; |
490 | |
491 | QSurfaceFormat format() const override; |
492 | @@ -50,14 +48,11 @@ |
493 | QFunctionPointer getProcAddress(const char *procName) override; |
494 | #endif |
495 | |
496 | -#ifdef QGL_DEBUG |
497 | - Q_SLOT void onGlDebugMessageLogged(QOpenGLDebugMessage m) { qDebug() << m; } |
498 | -#endif |
499 | - |
500 | private: |
501 | QSurfaceFormat m_format; |
502 | ScreenWindow *m_currentWindow; |
503 | #ifdef QGL_DEBUG |
504 | + Q_SLOT void onGlDebugMessageLogged(QOpenGLDebugMessage m) { qDebug() << m; } |
505 | QOpenGLDebugLogger *m_logger; |
506 | #endif |
507 | }; |
508 | |
509 | === modified file 'src/platforms/mirserver/mirserverintegration.cpp' |
510 | --- src/platforms/mirserver/mirserverintegration.cpp 2017-02-21 18:53:48 +0000 |
511 | +++ src/platforms/mirserver/mirserverintegration.cpp 2017-04-05 16:31:55 +0000 |
512 | @@ -30,10 +30,6 @@ |
513 | #include <QStringList> |
514 | #include <QDebug> |
515 | |
516 | -// Mir |
517 | -#include <mir/graphics/display.h> |
518 | -#include <mir/graphics/display_configuration.h> |
519 | - |
520 | // local |
521 | #include "clipboard.h" |
522 | #include "miropenglcontext.h" |
523 | @@ -125,7 +121,7 @@ |
524 | |
525 | QPlatformOpenGLContext *MirServerIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const |
526 | { |
527 | - return m_mirServer->createPlatformOpenGLContext(context); |
528 | + return new MirOpenGLContext(m_mirServer->eglConfig(), context->format()); |
529 | } |
530 | |
531 | QAbstractEventDispatcher *MirServerIntegration::createEventDispatcher() const |
532 | |
533 | === removed file 'src/platforms/mirserver/openglcontextfactory.cpp' |
534 | --- src/platforms/mirserver/openglcontextfactory.cpp 2016-11-03 20:17:46 +0000 |
535 | +++ src/platforms/mirserver/openglcontextfactory.cpp 1970-01-01 00:00:00 +0000 |
536 | @@ -1,51 +0,0 @@ |
537 | -/* |
538 | - * Copyright © 2016 Canonical Ltd. |
539 | - * |
540 | - * This program is free software: you can redistribute it and/or modify it |
541 | - * under the terms of the GNU General Public License version 3, |
542 | - * as published by the Free Software Foundation. |
543 | - * |
544 | - * This program is distributed in the hope that it will be useful, |
545 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
546 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
547 | - * GNU General Public License for more details. |
548 | - * |
549 | - * You should have received a copy of the GNU General Public License |
550 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
551 | - * |
552 | - * Authored by: Alan Griffiths <alan@octopull.co.uk> |
553 | - */ |
554 | - |
555 | -#include "openglcontextfactory.h" |
556 | - |
557 | -// local |
558 | -#include "mirglconfig.h" |
559 | -#include "miropenglcontext.h" |
560 | - |
561 | -// mir |
562 | -#include <mir/server.h> |
563 | - |
564 | -struct qtmir::OpenGLContextFactory::Self |
565 | -{ |
566 | - std::shared_ptr<MirGLConfig> m_glConfig; |
567 | -}; |
568 | - |
569 | -qtmir::OpenGLContextFactory::OpenGLContextFactory() : |
570 | - self{std::make_shared<Self>()} |
571 | -{ |
572 | -} |
573 | - |
574 | -void qtmir::OpenGLContextFactory::operator()(mir::Server& server) |
575 | -{ |
576 | - server.override_the_gl_config([this] |
577 | - { return self->m_glConfig = std::make_shared<MirGLConfig>(); }); |
578 | -} |
579 | - |
580 | -QPlatformOpenGLContext *qtmir::OpenGLContextFactory::createPlatformOpenGLContext( |
581 | - QSurfaceFormat format, mir::graphics::Display &mirDisplay) const |
582 | -{ |
583 | - if (!self->m_glConfig) |
584 | - throw std::logic_error("No gl config available. Server not running?"); |
585 | - |
586 | - return new MirOpenGLContext(mirDisplay, *self->m_glConfig, format); |
587 | -} |
588 | |
589 | === removed file 'src/platforms/mirserver/openglcontextfactory.h' |
590 | --- src/platforms/mirserver/openglcontextfactory.h 2016-11-03 20:17:46 +0000 |
591 | +++ src/platforms/mirserver/openglcontextfactory.h 1970-01-01 00:00:00 +0000 |
592 | @@ -1,47 +0,0 @@ |
593 | -/* |
594 | - * Copyright © 2016 Canonical Ltd. |
595 | - * |
596 | - * This program is free software: you can redistribute it and/or modify it |
597 | - * under the terms of the GNU General Public License version 3, |
598 | - * as published by the Free Software Foundation. |
599 | - * |
600 | - * This program is distributed in the hope that it will be useful, |
601 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
602 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
603 | - * GNU General Public License for more details. |
604 | - * |
605 | - * You should have received a copy of the GNU General Public License |
606 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
607 | - * |
608 | - * Authored by: Alan Griffiths <alan@octopull.co.uk> |
609 | - */ |
610 | - |
611 | -#ifndef MIRAL_OPENGLCONTEXTFACTORY_H |
612 | -#define MIRAL_OPENGLCONTEXTFACTORY_H |
613 | - |
614 | -#include <memory> |
615 | - |
616 | -namespace mir { namespace graphics { class Display; }} |
617 | -namespace mir { class Server; } |
618 | - |
619 | -class QPlatformOpenGLContext; |
620 | -class QSurfaceFormat; |
621 | - |
622 | -namespace qtmir |
623 | -{ |
624 | -class OpenGLContextFactory |
625 | -{ |
626 | -public: |
627 | - OpenGLContextFactory(); |
628 | - |
629 | - void operator()(mir::Server& server); |
630 | - |
631 | - QPlatformOpenGLContext *createPlatformOpenGLContext(QSurfaceFormat format, mir::graphics::Display &mirDisplay) const; |
632 | - |
633 | -private: |
634 | - struct Self; |
635 | - std::shared_ptr<Self> self; |
636 | -}; |
637 | -} |
638 | - |
639 | -#endif //MIRAL_OPENGLCONTEXTFACTORY_H |
640 | |
641 | === modified file 'src/platforms/mirserver/qmirserver.cpp' |
642 | --- src/platforms/mirserver/qmirserver.cpp 2017-03-14 13:49:38 +0000 |
643 | +++ src/platforms/mirserver/qmirserver.cpp 2017-04-05 16:31:55 +0000 |
644 | @@ -82,10 +82,10 @@ |
645 | return d->screensModel; |
646 | } |
647 | |
648 | -QPlatformOpenGLContext *QMirServer::createPlatformOpenGLContext(QOpenGLContext *context) const |
649 | +QSharedPointer<qtmir::EGL> QMirServer::eglConfig() const |
650 | { |
651 | Q_D(const QMirServer); |
652 | - return d->createPlatformOpenGLContext(context); |
653 | + return d->eglConfig; |
654 | } |
655 | |
656 | void *QMirServer::nativeResourceForIntegration(const QByteArray &resource) const |
657 | |
658 | === modified file 'src/platforms/mirserver/qmirserver.h' |
659 | --- src/platforms/mirserver/qmirserver.h 2017-02-21 18:53:48 +0000 |
660 | +++ src/platforms/mirserver/qmirserver.h 2017-04-05 16:31:55 +0000 |
661 | @@ -24,13 +24,13 @@ |
662 | #include <memory> |
663 | |
664 | // qtmir |
665 | -namespace qtmir { class PromptSessionManager; } |
666 | +namespace qtmir { |
667 | + class EGL; |
668 | + class PromptSessionManager; |
669 | +} |
670 | |
671 | class QMirServerPrivate; |
672 | -class ScreensController; |
673 | class ScreensModel; |
674 | -class QPlatformOpenGLContext; |
675 | -class QOpenGLContext; |
676 | |
677 | class QMirServer: public QObject |
678 | { |
679 | @@ -45,7 +45,7 @@ |
680 | bool isRunning() const; |
681 | |
682 | QSharedPointer<ScreensModel> screensModel() const; |
683 | - QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const; |
684 | + QSharedPointer<qtmir::EGL> eglConfig() const; |
685 | void *nativeResourceForIntegration(const QByteArray &resource) const; |
686 | std::shared_ptr<qtmir::PromptSessionManager> thePromptSessionManager() const; |
687 | |
688 | |
689 | === modified file 'src/platforms/mirserver/qmirserver_p.cpp' |
690 | --- src/platforms/mirserver/qmirserver_p.cpp 2017-03-28 17:13:24 +0000 |
691 | +++ src/platforms/mirserver/qmirserver_p.cpp 2017-04-05 16:31:55 +0000 |
692 | @@ -22,6 +22,7 @@ |
693 | #include "windowmanagementpolicy.h" |
694 | #include "promptsessionmanager.h" |
695 | #include "setqtcompositor.h" |
696 | +#include "eglimpl.h" |
697 | |
698 | // prototyping for later incorporation in miral |
699 | #include <miral/persist_display_config.h> |
700 | @@ -68,11 +69,6 @@ |
701 | return mir_running; |
702 | } |
703 | |
704 | -QPlatformOpenGLContext *QMirServerPrivate::createPlatformOpenGLContext(QOpenGLContext *context) const |
705 | -{ |
706 | - return m_openGLContextFactory.createPlatformOpenGLContext(context->format(), *m_mirServerHooks.theMirDisplay()); |
707 | -} |
708 | - |
709 | std::shared_ptr<qtmir::PromptSessionManager> QMirServerPrivate::promptSessionManager() const |
710 | { |
711 | return std::make_shared<qtmir::PromptSessionManager>(m_mirServerHooks.thePromptSessionManager()); |
712 | @@ -115,6 +111,7 @@ |
713 | |
714 | runner.add_start_callback([&] |
715 | { |
716 | + eglConfig.reset(new qtmir::EGLImpl(*m_mirServerHooks.theMirDisplay())); |
717 | screensModel->update(); |
718 | screensController = m_mirServerHooks.createScreensController(screensModel); |
719 | m_mirServerHooks.createInputDeviceObserver(); |
720 | @@ -130,8 +127,8 @@ |
721 | |
722 | runner.run_with( |
723 | { |
724 | + m_glConfig, |
725 | m_sessionAuthorizer, |
726 | - m_openGLContextFactory, |
727 | m_mirServerHooks, |
728 | miral::set_window_management_policy<WindowManagementPolicy>(m_windowModelNotifier, m_windowController, |
729 | m_appNotifier, screensModel), |
730 | |
731 | === modified file 'src/platforms/mirserver/qmirserver_p.h' |
732 | --- src/platforms/mirserver/qmirserver_p.h 2017-02-21 18:53:48 +0000 |
733 | +++ src/platforms/mirserver/qmirserver_p.h 2017-04-05 16:31:55 +0000 |
734 | @@ -27,12 +27,12 @@ |
735 | |
736 | // local |
737 | #include "appnotifier.h" |
738 | -#include "openglcontextfactory.h" |
739 | +#include "glconfiguration.h" |
740 | +#include "mirserverhooks.h" |
741 | #include "screensmodel.h" |
742 | +#include "sessionauthorizer.h" |
743 | #include "windowcontroller.h" |
744 | #include "windowmodelnotifier.h" |
745 | -#include "sessionauthorizer.h" |
746 | -#include "mirserverhooks.h" |
747 | |
748 | //miral |
749 | #include <miral/application_authorizer.h> |
750 | @@ -44,6 +44,7 @@ |
751 | namespace qtmir |
752 | { |
753 | using SetSessionAuthorizer = miral::SetApplicationAuthorizer<SessionAuthorizer>; |
754 | +class EGL; |
755 | class PromptSessionManager; |
756 | } |
757 | |
758 | @@ -54,8 +55,7 @@ |
759 | const QSharedPointer<ScreensModel> screensModel{new ScreensModel()}; |
760 | QSharedPointer<ScreensController> screensController; |
761 | MirServerThread *serverThread; |
762 | - |
763 | - QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const; |
764 | + QSharedPointer<qtmir::EGL> eglConfig; |
765 | |
766 | void run(const std::function<void()> &startCallback); |
767 | void stop(); |
768 | @@ -76,8 +76,8 @@ |
769 | { return &m_windowController; } |
770 | |
771 | private: |
772 | + qtmir::GLConfiguration m_glConfig; |
773 | qtmir::SetSessionAuthorizer m_sessionAuthorizer; |
774 | - qtmir::OpenGLContextFactory m_openGLContextFactory; |
775 | qtmir::MirServerHooks m_mirServerHooks; |
776 | |
777 | miral::MirRunner runner; |
PASSED: Continuous integration, rev:643 /unity8- jenkins. ubuntu. com/job/ lp-qtmir- ci/670/ /unity8- jenkins. ubuntu. com/job/ build/4908 /unity8- jenkins. ubuntu. com/job/ build-0- fetch/4936 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 4744 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 4744/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= zesty/4744 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= zesty/4744/ artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 4744 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 4744/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= zesty/4744 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= zesty/4744/ artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 4744 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 4744/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= zesty/4744 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= zesty/4744/ artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
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: /unity8- jenkins. ubuntu. com/job/ lp-qtmir- ci/670/ rebuild
https:/