Merge lp:~unity-team/qtubuntu/revert-eglconvenience into lp:qtubuntu
- revert-eglconvenience
- Merge into trunk
Proposed by
Michał Sawicz
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Gerry Boland | ||||
Approved revision: | 327 | ||||
Merged at revision: | 327 | ||||
Proposed branch: | lp:~unity-team/qtubuntu/revert-eglconvenience | ||||
Merge into: | lp:qtubuntu | ||||
Diff against target: |
671 lines (+242/-163) 7 files modified
README (+7/-6) src/ubuntumirclient/glcontext.cpp (+165/-30) src/ubuntumirclient/glcontext.h (+19/-11) src/ubuntumirclient/integration.cpp (+25/-27) src/ubuntumirclient/integration.h (+4/-0) src/ubuntumirclient/window.cpp (+21/-86) src/ubuntumirclient/window.h (+1/-3) |
||||
To merge this branch: | bzr merge lp:~unity-team/qtubuntu/revert-eglconvenience | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity8 CI Bot | continuous-integration | Approve | |
Gerry Boland | Pending | ||
Review via email: mp+297880@code.launchpad.net |
Commit message
Revert r324 "EGL convenience"
Description of the change
* Are there any related MPs required for this MP to build/function as expected? Please list.
N
* Did you perform an exploratory manual test run of your code change and any related functionality?
Y
* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A
To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
review:
Approve
(continuous-integration)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'README' |
2 | --- README 2016-05-30 17:14:14 +0000 |
3 | +++ README 2016-06-20 08:42:54 +0000 |
4 | @@ -23,10 +23,13 @@ |
5 | $ qmlscene -platform ubuntumirclient Foo.qml |
6 | $ QT_QPA_PLATFORM=ubuntumirclient qmlscene Foo.qml |
7 | |
8 | - This QPA plugin exposes the following environment variables: |
9 | - |
10 | - QT_QPA_EGLFS_SWAPINTERVAL: Specifies the required swap interval as an |
11 | - integer. 1 by default. |
12 | + The QPA plugins expose the following environment variables: |
13 | + |
14 | + QTUBUNTU_SWAPINTERVAL: Specifies the required swap interval as an |
15 | + integer. 1 by default. |
16 | + |
17 | + QTUBUNTU_MULTISAMPLE: Enables multisampling with using 4 samples |
18 | + per fragment. |
19 | |
20 | QTUBUNTU_NO_THREADED_OPENGL: Disables QtQuick threaded OpenGL |
21 | rendering. |
22 | @@ -48,8 +51,6 @@ |
23 | * ubuntumirclient.swapBuffers - Messages related to surface buffer swapping. |
24 | * ubuntumirclient - For all other messages. |
25 | |
26 | - The QT_QPA_EGLFS_DEBUG environment variable prints a little more information |
27 | - from Qt's internals. |
28 | |
29 | 4. Building |
30 | ----------- |
31 | |
32 | === modified file 'src/ubuntumirclient/glcontext.cpp' |
33 | --- src/ubuntumirclient/glcontext.cpp 2016-06-03 09:55:43 +0000 |
34 | +++ src/ubuntumirclient/glcontext.cpp 2016-06-20 08:42:54 +0000 |
35 | @@ -25,12 +25,58 @@ |
36 | |
37 | namespace { |
38 | |
39 | -void printEglConfig(EGLDisplay display, EGLConfig config) |
40 | -{ |
41 | +void printOpenGLESConfig() { |
42 | + static bool once = true; |
43 | + if (once) { |
44 | + const char* string = (const char*) glGetString(GL_VENDOR); |
45 | + qCDebug(ubuntumirclient, "OpenGL ES vendor: %s", string); |
46 | + string = (const char*) glGetString(GL_RENDERER); |
47 | + qCDebug(ubuntumirclient, "OpenGL ES renderer: %s", string); |
48 | + string = (const char*) glGetString(GL_VERSION); |
49 | + qCDebug(ubuntumirclient, "OpenGL ES version: %s", string); |
50 | + string = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION); |
51 | + qCDebug(ubuntumirclient, "OpenGL ES Shading Language version: %s", string); |
52 | + string = (const char*) glGetString(GL_EXTENSIONS); |
53 | + qCDebug(ubuntumirclient, "OpenGL ES extensions: %s", string); |
54 | + once = false; |
55 | + } |
56 | +} |
57 | + |
58 | +void printEglConfig(EGLDisplay display, EGLConfig config) { |
59 | Q_ASSERT(display != EGL_NO_DISPLAY); |
60 | Q_ASSERT(config != nullptr); |
61 | |
62 | - const char *string = eglQueryString(display, EGL_VENDOR); |
63 | + static const struct { const EGLint attrib; const char* name; } kAttribs[] = { |
64 | + { EGL_BUFFER_SIZE, "EGL_BUFFER_SIZE" }, |
65 | + { EGL_ALPHA_SIZE, "EGL_ALPHA_SIZE" }, |
66 | + { EGL_BLUE_SIZE, "EGL_BLUE_SIZE" }, |
67 | + { EGL_GREEN_SIZE, "EGL_GREEN_SIZE" }, |
68 | + { EGL_RED_SIZE, "EGL_RED_SIZE" }, |
69 | + { EGL_DEPTH_SIZE, "EGL_DEPTH_SIZE" }, |
70 | + { EGL_STENCIL_SIZE, "EGL_STENCIL_SIZE" }, |
71 | + { EGL_CONFIG_CAVEAT, "EGL_CONFIG_CAVEAT" }, |
72 | + { EGL_CONFIG_ID, "EGL_CONFIG_ID" }, |
73 | + { EGL_LEVEL, "EGL_LEVEL" }, |
74 | + { EGL_MAX_PBUFFER_HEIGHT, "EGL_MAX_PBUFFER_HEIGHT" }, |
75 | + { EGL_MAX_PBUFFER_PIXELS, "EGL_MAX_PBUFFER_PIXELS" }, |
76 | + { EGL_MAX_PBUFFER_WIDTH, "EGL_MAX_PBUFFER_WIDTH" }, |
77 | + { EGL_NATIVE_RENDERABLE, "EGL_NATIVE_RENDERABLE" }, |
78 | + { EGL_NATIVE_VISUAL_ID, "EGL_NATIVE_VISUAL_ID" }, |
79 | + { EGL_NATIVE_VISUAL_TYPE, "EGL_NATIVE_VISUAL_TYPE" }, |
80 | + { EGL_SAMPLES, "EGL_SAMPLES" }, |
81 | + { EGL_SAMPLE_BUFFERS, "EGL_SAMPLE_BUFFERS" }, |
82 | + { EGL_SURFACE_TYPE, "EGL_SURFACE_TYPE" }, |
83 | + { EGL_TRANSPARENT_TYPE, "EGL_TRANSPARENT_TYPE" }, |
84 | + { EGL_TRANSPARENT_BLUE_VALUE, "EGL_TRANSPARENT_BLUE_VALUE" }, |
85 | + { EGL_TRANSPARENT_GREEN_VALUE, "EGL_TRANSPARENT_GREEN_VALUE" }, |
86 | + { EGL_TRANSPARENT_RED_VALUE, "EGL_TRANSPARENT_RED_VALUE" }, |
87 | + { EGL_BIND_TO_TEXTURE_RGB, "EGL_BIND_TO_TEXTURE_RGB" }, |
88 | + { EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA" }, |
89 | + { EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL" }, |
90 | + { EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL" }, |
91 | + { -1, NULL } |
92 | + }; |
93 | + const char* string = eglQueryString(display, EGL_VENDOR); |
94 | qCDebug(ubuntumirclient, "EGL vendor: %s", string); |
95 | |
96 | string = eglQueryString(display, EGL_VERSION); |
97 | @@ -39,19 +85,93 @@ |
98 | string = eglQueryString(display, EGL_EXTENSIONS); |
99 | qCDebug(ubuntumirclient, "EGL extensions: %s", string); |
100 | |
101 | - qCDebug(ubuntumirclient, "EGL configuration attributes:"); |
102 | - q_printEglConfig(display, config); |
103 | + qCDebug(ubuntumirclient, "EGL configuration attibutes:"); |
104 | + for (int index = 0; kAttribs[index].attrib != -1; index++) { |
105 | + EGLint value; |
106 | + if (eglGetConfigAttrib(display, config, kAttribs[index].attrib, &value)) |
107 | + qCDebug(ubuntumirclient, " %s: %d", kAttribs[index].name, static_cast<int>(value)); |
108 | + } |
109 | +} |
110 | + |
111 | +QString eglErrorToString(EGLint errorNumber) |
112 | +{ |
113 | + #define EGL_ERROR_CASE(error) case error: return QString(#error); |
114 | + |
115 | + switch (errorNumber) { |
116 | + EGL_ERROR_CASE(EGL_SUCCESS) |
117 | + EGL_ERROR_CASE(EGL_NOT_INITIALIZED) |
118 | + EGL_ERROR_CASE(EGL_BAD_ACCESS) |
119 | + EGL_ERROR_CASE(EGL_BAD_ALLOC) |
120 | + EGL_ERROR_CASE(EGL_BAD_ATTRIBUTE) |
121 | + EGL_ERROR_CASE(EGL_BAD_CONTEXT) |
122 | + EGL_ERROR_CASE(EGL_BAD_CONFIG) |
123 | + EGL_ERROR_CASE(EGL_BAD_CURRENT_SURFACE) |
124 | + EGL_ERROR_CASE(EGL_BAD_DISPLAY) |
125 | + EGL_ERROR_CASE(EGL_BAD_SURFACE) |
126 | + EGL_ERROR_CASE(EGL_BAD_MATCH) |
127 | + EGL_ERROR_CASE(EGL_BAD_PARAMETER) |
128 | + EGL_ERROR_CASE(EGL_BAD_NATIVE_PIXMAP) |
129 | + EGL_ERROR_CASE(EGL_BAD_NATIVE_WINDOW) |
130 | + EGL_ERROR_CASE(EGL_CONTEXT_LOST) |
131 | + default: |
132 | + return QString("?"); |
133 | + } |
134 | + |
135 | + #undef EGL_ERROR_CASE |
136 | +} |
137 | + |
138 | +EGLenum api_in_use() |
139 | +{ |
140 | + #ifdef QTUBUNTU_USE_OPENGL |
141 | + return EGL_OPENGL_API; |
142 | + #else |
143 | + return EGL_OPENGL_ES_API; |
144 | + #endif |
145 | +} |
146 | + |
147 | +const int kSwapInterval = 1; |
148 | + |
149 | +int qGetEnvIntValue(const char *varName, bool *ok) |
150 | +{ |
151 | + return qgetenv(varName).toInt(ok); |
152 | } |
153 | |
154 | } // anonymous namespace |
155 | |
156 | -UbuntuOpenGLContext::UbuntuOpenGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, |
157 | - EGLDisplay display) |
158 | - : QEGLPlatformContext(format, share, display, 0) |
159 | +UbuntuOpenGLContext::UbuntuOpenGLContext(const QSurfaceFormat &surfaceFormat, UbuntuOpenGLContext *share, |
160 | + EGLDisplay display, EGLConfig config) |
161 | + : mSurfaceFormat(surfaceFormat) |
162 | + , mEglDisplay(display) |
163 | { |
164 | + // Create an OpenGL ES 2 context. |
165 | + QVector<EGLint> attribs; |
166 | + attribs.append(EGL_CONTEXT_CLIENT_VERSION); |
167 | + attribs.append(2); |
168 | + attribs.append(EGL_NONE); |
169 | + ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); |
170 | + |
171 | if (ubuntumirclient().isDebugEnabled()) { |
172 | - printEglConfig(display, eglConfig()); |
173 | + printEglConfig(mEglDisplay, config); |
174 | } |
175 | + |
176 | + // Set vblank swap interval. |
177 | + bool ok; |
178 | + int swapInterval = qGetEnvIntValue("QTUBUNTU_SWAPINTERVAL", &ok); |
179 | + if (!ok) |
180 | + swapInterval = kSwapInterval; |
181 | + |
182 | + qCDebug(ubuntumirclient, "Setting swap interval to %d", swapInterval); |
183 | + eglSwapInterval(mEglDisplay, swapInterval); |
184 | + |
185 | + mEglContext = eglCreateContext(mEglDisplay, config, share ? share->eglContext() : EGL_NO_CONTEXT, |
186 | + attribs.constData()); |
187 | + |
188 | + Q_ASSERT(mEglContext != EGL_NO_CONTEXT); |
189 | +} |
190 | + |
191 | +UbuntuOpenGLContext::~UbuntuOpenGLContext() |
192 | +{ |
193 | + ASSERT(eglDestroyContext(mEglDisplay, mEglContext) == EGL_TRUE); |
194 | } |
195 | |
196 | static bool needsFBOReadBackWorkaround() |
197 | @@ -59,7 +179,7 @@ |
198 | static bool set = false; |
199 | static bool needsWorkaround = false; |
200 | |
201 | - if (Q_UNLIKELY(!set)) { |
202 | + if (!set) { |
203 | const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER)); |
204 | needsWorkaround = qstrncmp(rendererString, "Mali-400", 8) == 0 |
205 | || qstrncmp(rendererString, "Mali-T7", 7) == 0 |
206 | @@ -82,32 +202,47 @@ |
207 | } |
208 | return offscreen->buffer()->bind(); |
209 | } else { |
210 | - const bool ret = QEGLPlatformContext::makeCurrent(surface); |
211 | - |
212 | - if (Q_LIKELY(ret)) { |
213 | - QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context()); |
214 | - if (!ctx_d->workaround_brokenFBOReadBack && needsFBOReadBackWorkaround()) { |
215 | - ctx_d->workaround_brokenFBOReadBack = true; |
216 | - } |
217 | - } |
218 | - |
219 | - return ret; |
220 | + EGLSurface eglSurface = static_cast<UbuntuWindow*>(surface)->eglSurface(); |
221 | + ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); |
222 | + |
223 | + EGLBoolean result = eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext); |
224 | + if (result == EGL_FALSE) { |
225 | + qCCritical(ubuntumirclient, "eglMakeCurrent() failed with %s", |
226 | + qPrintable(eglErrorToString(eglGetError()))); |
227 | + return false; |
228 | + } |
229 | + |
230 | + QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context()); |
231 | + if (!ctx_d->workaround_brokenFBOReadBack && needsFBOReadBackWorkaround()) { |
232 | + ctx_d->workaround_brokenFBOReadBack = true; |
233 | + } |
234 | + |
235 | + if (ubuntumirclient().isDebugEnabled()) { |
236 | + printOpenGLESConfig(); |
237 | + } |
238 | + return true; |
239 | } |
240 | } |
241 | |
242 | -// Following method used internally in the base class QEGLPlatformContext to access |
243 | -// the egl surface of a QPlatformSurface/UbuntuWindow |
244 | -EGLSurface UbuntuOpenGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface) |
245 | +void UbuntuOpenGLContext::doneCurrent() |
246 | { |
247 | - auto ubuntuWindow = static_cast<UbuntuWindow *>(surface); |
248 | - return ubuntuWindow->eglSurface(); |
249 | + ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); |
250 | + ASSERT(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) == EGL_TRUE); |
251 | } |
252 | |
253 | -void UbuntuOpenGLContext::swapBuffers(QPlatformSurface *surface) |
254 | +void UbuntuOpenGLContext::swapBuffers(QPlatformSurface* surface) |
255 | { |
256 | - QEGLPlatformContext::swapBuffers(surface); |
257 | - |
258 | - // notify window on swap completion |
259 | - auto ubuntuWindow = static_cast<UbuntuWindow *>(surface); |
260 | + UbuntuWindow *ubuntuWindow = static_cast<UbuntuWindow*>(surface); |
261 | + |
262 | + EGLSurface eglSurface = ubuntuWindow->eglSurface(); |
263 | + ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); |
264 | + ASSERT(eglSwapBuffers(mEglDisplay, eglSurface) == EGL_TRUE); |
265 | + |
266 | ubuntuWindow->onSwapBuffersDone(); |
267 | } |
268 | + |
269 | +void (*UbuntuOpenGLContext::getProcAddress(const QByteArray& procName)) () |
270 | +{ |
271 | + ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); |
272 | + return eglGetProcAddress(procName.constData()); |
273 | +} |
274 | |
275 | === modified file 'src/ubuntumirclient/glcontext.h' |
276 | --- src/ubuntumirclient/glcontext.h 2016-05-19 16:26:30 +0000 |
277 | +++ src/ubuntumirclient/glcontext.h 2016-06-20 08:42:54 +0000 |
278 | @@ -18,22 +18,30 @@ |
279 | #define UBUNTU_OPENGL_CONTEXT_H |
280 | |
281 | #include <qpa/qplatformopenglcontext.h> |
282 | -#include <private/qeglplatformcontext_p.h> |
283 | |
284 | #include <EGL/egl.h> |
285 | |
286 | -class UbuntuOpenGLContext : public QEGLPlatformContext |
287 | +class UbuntuOpenGLContext : public QPlatformOpenGLContext |
288 | { |
289 | public: |
290 | - UbuntuOpenGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, |
291 | - EGLDisplay display); |
292 | - |
293 | - // QEGLPlatformContext methods. |
294 | - void swapBuffers(QPlatformSurface *surface) final; |
295 | - bool makeCurrent(QPlatformSurface *surface) final; |
296 | - |
297 | -protected: |
298 | - EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) final; |
299 | + UbuntuOpenGLContext(const QSurfaceFormat &surfaceFormat, UbuntuOpenGLContext *share, |
300 | + EGLDisplay display, EGLConfig config); |
301 | + virtual ~UbuntuOpenGLContext(); |
302 | + |
303 | + // QPlatformOpenGLContext methods. |
304 | + QSurfaceFormat format() const override { return mSurfaceFormat; } |
305 | + void swapBuffers(QPlatformSurface *surface) override; |
306 | + bool makeCurrent(QPlatformSurface *surface) override; |
307 | + void doneCurrent() override; |
308 | + bool isValid() const override { return mEglContext != EGL_NO_CONTEXT; } |
309 | + void (*getProcAddress(const QByteArray& procName)) () override; |
310 | + |
311 | + EGLContext eglContext() const { return mEglContext; } |
312 | + |
313 | +private: |
314 | + const QSurfaceFormat mSurfaceFormat; |
315 | + EGLContext mEglContext; |
316 | + EGLDisplay mEglDisplay; |
317 | }; |
318 | |
319 | #endif // UBUNTU_OPENGL_CONTEXT_H |
320 | |
321 | === modified file 'src/ubuntumirclient/integration.cpp' |
322 | --- src/ubuntumirclient/integration.cpp 2016-06-14 08:33:49 +0000 |
323 | +++ src/ubuntumirclient/integration.cpp 2016-06-20 08:42:54 +0000 |
324 | @@ -30,6 +30,7 @@ |
325 | // Qt |
326 | #include <QFileInfo> |
327 | #include <QGuiApplication> |
328 | +#include <private/qguiapplication_p.h> |
329 | #include <qpa/qplatformnativeinterface.h> |
330 | #include <qpa/qplatforminputcontextfactory_p.h> |
331 | #include <qpa/qplatforminputcontext.h> |
332 | @@ -94,17 +95,31 @@ |
333 | |
334 | mMirConnection = u_application_instance_get_mir_connection(mInstance); |
335 | |
336 | - // Choose the default surface format suited to the Mir platform |
337 | - QSurfaceFormat defaultFormat; |
338 | - defaultFormat.setRedBufferSize(8); |
339 | - defaultFormat.setGreenBufferSize(8); |
340 | - defaultFormat.setBlueBufferSize(8); |
341 | - QSurfaceFormat::setDefaultFormat(defaultFormat); |
342 | - |
343 | // Initialize EGL. |
344 | + ASSERT(eglBindAPI(EGL_OPENGL_ES_API) == EGL_TRUE); |
345 | + |
346 | mEglNativeDisplay = mir_connection_get_egl_native_display(mMirConnection); |
347 | ASSERT((mEglDisplay = eglGetDisplay(mEglNativeDisplay)) != EGL_NO_DISPLAY); |
348 | ASSERT(eglInitialize(mEglDisplay, nullptr, nullptr) == EGL_TRUE); |
349 | + |
350 | + // Configure EGL buffers format for all Windows. |
351 | + mSurfaceFormat.setRedBufferSize(8); |
352 | + mSurfaceFormat.setGreenBufferSize(8); |
353 | + mSurfaceFormat.setBlueBufferSize(8); |
354 | + mSurfaceFormat.setAlphaBufferSize(8); |
355 | + mSurfaceFormat.setDepthBufferSize(24); |
356 | + mSurfaceFormat.setStencilBufferSize(8); |
357 | + if (!qEnvironmentVariableIsEmpty("QTUBUNTU_MULTISAMPLE")) { |
358 | + mSurfaceFormat.setSamples(4); |
359 | + qCDebug(ubuntumirclient, "setting MSAA to 4 samples"); |
360 | + } |
361 | +#ifdef QTUBUNTU_USE_OPENGL |
362 | + mSurfaceFormat.setRenderableType(QSurfaceFormat::OpenGL); |
363 | +#else |
364 | + mSurfaceFormat.setRenderableType(QSurfaceFormat::OpenGLES); |
365 | +#endif |
366 | + |
367 | + mEglConfig = q_configFromGLFormat(mEglDisplay, mSurfaceFormat, true); |
368 | } |
369 | |
370 | void UbuntuClientIntegration::initialize() |
371 | @@ -211,7 +226,7 @@ |
372 | |
373 | QPlatformWindow* UbuntuClientIntegration::createPlatformWindow(QWindow* window) const |
374 | { |
375 | - return new UbuntuWindow(window, mClipboard, mInput, mNativeInterface, mEglDisplay, mMirConnection); |
376 | + return new UbuntuWindow(window, mClipboard, mInput, mNativeInterface, mEglDisplay, mEglConfig, mMirConnection); |
377 | } |
378 | |
379 | bool UbuntuClientIntegration::hasCapability(QPlatformIntegration::Capability cap) const |
380 | @@ -254,25 +269,8 @@ |
381 | QPlatformOpenGLContext* UbuntuClientIntegration::createPlatformOpenGLContext( |
382 | QOpenGLContext* context) const |
383 | { |
384 | - QSurfaceFormat format(context->format()); |
385 | - |
386 | - auto platformContext = new UbuntuOpenGLContext(format, context->shareHandle(), mEglDisplay); |
387 | - if (!platformContext->isValid()) { |
388 | - // Older Intel Atom-based devices only support OpenGL 1.4 compatibility profile but by default |
389 | - // QML asks for at least OpenGL 2.0. The XCB GLX backend ignores this request and returns a |
390 | - // 1.4 context, but the XCB EGL backend tries to honour it, and fails. The 1.4 context appears to |
391 | - // have sufficient capabilities on MESA (i915) to render correctly however. So reduce the default |
392 | - // requested OpenGL version to 1.0 to ensure EGL will give us a working context (lp:1549455). |
393 | - static const bool isMesa = QString(eglQueryString(mEglDisplay, EGL_VENDOR)).contains(QStringLiteral("Mesa")); |
394 | - if (isMesa) { |
395 | - qCDebug(ubuntumirclient, "Attempting to choose OpenGL 1.4 context which may suit Mesa"); |
396 | - format.setMajorVersion(1); |
397 | - format.setMinorVersion(4); |
398 | - delete platformContext; |
399 | - platformContext = new UbuntuOpenGLContext(format, context->shareHandle(), mEglDisplay); |
400 | - } |
401 | - } |
402 | - return platformContext; |
403 | + return new UbuntuOpenGLContext(mSurfaceFormat, static_cast<UbuntuOpenGLContext*>(context->shareHandle()), |
404 | + mEglDisplay, mEglConfig); |
405 | } |
406 | |
407 | QStringList UbuntuClientIntegration::themeNames() const |
408 | |
409 | === modified file 'src/ubuntumirclient/integration.h' |
410 | --- src/ubuntumirclient/integration.h 2016-06-14 08:33:49 +0000 |
411 | +++ src/ubuntumirclient/integration.h 2016-06-20 08:42:54 +0000 |
412 | @@ -62,7 +62,9 @@ |
413 | |
414 | // New methods. |
415 | MirConnection *mirConnection() const { return mMirConnection; } |
416 | + QSurfaceFormat surfaceFormat() const { return mSurfaceFormat; } |
417 | EGLDisplay eglDisplay() const { return mEglDisplay; } |
418 | + EGLConfig eglConfig() const { return mEglConfig; } |
419 | EGLNativeDisplayType eglNativeDisplay() const { return mEglNativeDisplay; } |
420 | UbuntuScreenObserver *screenObserver() const { return mScreenObserver.data(); } |
421 | |
422 | @@ -95,7 +97,9 @@ |
423 | |
424 | // EGL related |
425 | EGLDisplay mEglDisplay{EGL_NO_DISPLAY}; |
426 | + EGLConfig mEglConfig{nullptr}; |
427 | EGLNativeDisplayType mEglNativeDisplay; |
428 | + QSurfaceFormat mSurfaceFormat; |
429 | }; |
430 | |
431 | #endif // UBUNTU_CLIENT_INTEGRATION_H |
432 | |
433 | === modified file 'src/ubuntumirclient/window.cpp' |
434 | --- src/ubuntumirclient/window.cpp 2016-05-30 17:14:14 +0000 |
435 | +++ src/ubuntumirclient/window.cpp 2016-06-20 08:42:54 +0000 |
436 | @@ -29,7 +29,6 @@ |
437 | #include <QMutexLocker> |
438 | #include <QSize> |
439 | #include <QtMath> |
440 | -#include <private/qeglconvenience_p.h> |
441 | |
442 | // Platform API |
443 | #include <ubuntu/application/instance.h> |
444 | @@ -102,24 +101,6 @@ |
445 | } |
446 | } |
447 | |
448 | -const char *mirPixelFormatToStr(MirPixelFormat pixelFormat) |
449 | -{ |
450 | - switch (pixelFormat) { |
451 | - case mir_pixel_format_invalid: return "invalid"; |
452 | - case mir_pixel_format_abgr_8888: return "ABGR8888"; |
453 | - case mir_pixel_format_xbgr_8888: return "XBGR8888"; |
454 | - case mir_pixel_format_argb_8888: return "ARGB8888"; |
455 | - case mir_pixel_format_xrgb_8888: return "XRGB8888"; |
456 | - case mir_pixel_format_bgr_888: return "BGR888"; |
457 | - case mir_pixel_format_rgb_888: return "RGB888"; |
458 | - case mir_pixel_format_rgb_565: return "RGB565"; |
459 | - case mir_pixel_format_rgba_5551: return "RGBA5551"; |
460 | - case mir_pixel_format_rgba_4444: return "RGBA4444"; |
461 | - case mir_pixel_formats: |
462 | - default: return "???"; |
463 | - } |
464 | -} |
465 | - |
466 | MirSurfaceState qtWindowStateToMirSurfaceState(Qt::WindowState state) |
467 | { |
468 | switch (state) { |
469 | @@ -143,6 +124,14 @@ |
470 | return id++; |
471 | } |
472 | |
473 | +MirPixelFormat defaultPixelFormatFor(MirConnection *connection) |
474 | +{ |
475 | + MirPixelFormat format; |
476 | + unsigned int nformats; |
477 | + mir_connection_get_available_surface_formats(connection, &format, 1, &nformats); |
478 | + return format; |
479 | +} |
480 | + |
481 | UAUiWindowRole roleFor(QWindow *window) |
482 | { |
483 | QVariant roleVariant = window->property("role"); |
484 | @@ -162,11 +151,12 @@ |
485 | return parent ? static_cast<UbuntuWindow *>(parent->handle()) : nullptr; |
486 | } |
487 | |
488 | -Spec makeSurfaceSpec(QWindow *window, UbuntuInput *input, MirPixelFormat pixelFormat, MirConnection *connection) |
489 | +Spec makeSurfaceSpec(QWindow *window, UbuntuInput *input, MirConnection *connection) |
490 | { |
491 | const auto geom = window->geometry(); |
492 | const int width = geom.width() > 0 ? geom.width() : 1; |
493 | const int height = geom.height() > 0 ? geom.height() : 1; |
494 | + const auto pixelFormat = defaultPixelFormatFor(connection); |
495 | |
496 | if (U_ON_SCREEN_KEYBOARD_ROLE == roleFor(window)) { |
497 | qCDebug(ubuntumirclient, "makeSurfaceSpec(window=%p) - creating input method surface (width=%d, height=%d", window, width, height); |
498 | @@ -227,11 +217,11 @@ |
499 | } |
500 | } |
501 | |
502 | -MirSurface *createMirSurface(QWindow *window, int mirOutputId, UbuntuInput *input, MirPixelFormat pixelFormat, |
503 | +MirSurface *createMirSurface(QWindow *window, int mirOutputId, UbuntuInput *input, |
504 | MirConnection *connection, mir_surface_event_callback inputCallback, |
505 | void* inputContext) |
506 | { |
507 | - auto spec = makeSurfaceSpec(window, input, pixelFormat, connection); |
508 | + auto spec = makeSurfaceSpec(window, input, connection); |
509 | |
510 | // Install event handler as early as possible |
511 | mir_surface_spec_set_event_handler(spec.get(), inputCallback, inputContext); |
512 | @@ -254,18 +244,6 @@ |
513 | return surface; |
514 | } |
515 | |
516 | -MirPixelFormat disableAlphaBufferIfPossible(MirPixelFormat pixelFormat) |
517 | -{ |
518 | - switch(pixelFormat) { |
519 | - case mir_pixel_format_abgr_8888: |
520 | - return mir_pixel_format_xbgr_8888; |
521 | - case mir_pixel_format_argb_8888: |
522 | - return mir_pixel_format_xrgb_8888; |
523 | - default: // can do nothing, leave it alone |
524 | - return pixelFormat; |
525 | - } |
526 | -} |
527 | - |
528 | // FIXME - in order to work around https://bugs.launchpad.net/mir/+bug/1346633 |
529 | // we need to guess the panel height (3GU) |
530 | int panelHeight() |
531 | @@ -288,7 +266,8 @@ |
532 | class UbuntuSurface |
533 | { |
534 | public: |
535 | - UbuntuSurface(UbuntuWindow *platformWindow, EGLDisplay display, UbuntuInput *input, MirConnection *connection) |
536 | + UbuntuSurface(UbuntuWindow *platformWindow, EGLDisplay display, EGLConfig config, int mirOutputId, |
537 | + UbuntuInput *input, MirConnection *connection) |
538 | : mWindow(platformWindow->window()) |
539 | , mPlatformWindow(platformWindow) |
540 | , mInput(input) |
541 | @@ -296,44 +275,9 @@ |
542 | , mEglDisplay(display) |
543 | , mNeedsRepaint(false) |
544 | , mParented(mWindow->transientParent() || mWindow->parent()) |
545 | - , mFormat(mWindow->requestedFormat()) |
546 | , mShellChrome(mWindow->flags() & LowChromeWindowHint ? mir_shell_chrome_low : mir_shell_chrome_normal) |
547 | { |
548 | - // Have Qt choose most suitable EGLConfig for the requested surface format, and update format to reflect it |
549 | - EGLConfig config = q_configFromGLFormat(display, mFormat, true); |
550 | - if (config == 0) { |
551 | - // Older Intel Atom-based devices only support OpenGL 1.4 compatibility profile but by default |
552 | - // QML asks for at least OpenGL 2.0. The XCB GLX backend ignores this request and returns a |
553 | - // 1.4 context, but the XCB EGL backend tries to honour it, and fails. The 1.4 context appears to |
554 | - // have sufficient capabilities on MESA (i915) to render correctly however. So reduce the default |
555 | - // requested OpenGL version to 1.0 to ensure EGL will give us a working context (lp:1549455). |
556 | - static const bool isMesa = QString(eglQueryString(display, EGL_VENDOR)).contains(QStringLiteral("Mesa")); |
557 | - if (isMesa) { |
558 | - qCDebug(ubuntumirclient, "Attempting to choose OpenGL 1.4 context which may suit Mesa"); |
559 | - mFormat.setMajorVersion(1); |
560 | - mFormat.setMinorVersion(4); |
561 | - config = q_configFromGLFormat(display, mFormat, true); |
562 | - } |
563 | - } |
564 | - if (config == 0) { |
565 | - qCritical() << "Qt failed to choose a suitable EGLConfig to suit the surface format" << mFormat; |
566 | - } |
567 | - |
568 | - mFormat = q_glFormatFromConfig(display, config, mFormat); |
569 | - |
570 | - // Have Mir decide the pixel format most suited to the chosen EGLConfig. This is the only way |
571 | - // Mir will know what EGLConfig has been chosen - it cannot deduce it from the buffers. |
572 | - auto pixelFormat = mir_connection_get_egl_pixel_format(connection, display, config); |
573 | - // But the chosen EGLConfig might have an alpha buffer enabled, even if not requested by the client. |
574 | - // If that's the case, try to edit the chosen pixel format in order to disable the alpha buffer. |
575 | - // This is an optimisation for the compositor, as it can avoid blending this surface. |
576 | - if (mWindow->requestedFormat().alphaBufferSize() < 0) { |
577 | - pixelFormat = disableAlphaBufferIfPossible(pixelFormat); |
578 | - } |
579 | - |
580 | - const auto outputId = static_cast<UbuntuScreen *>(mWindow->screen()->handle())->mirOutputId(); |
581 | - |
582 | - mMirSurface = createMirSurface(mWindow, outputId, input, pixelFormat, connection, surfaceEventCallback, this); |
583 | + mMirSurface = createMirSurface(mWindow, mirOutputId, input, connection, surfaceEventCallback, this); |
584 | mEglSurface = eglCreateWindowSurface(mEglDisplay, config, nativeWindowFor(mMirSurface), nullptr); |
585 | |
586 | // Window manager can give us a final size different from what we asked for |
587 | @@ -355,11 +299,8 @@ |
588 | platformWindow->QPlatformWindow::setGeometry(geom); |
589 | QWindowSystemInterface::handleGeometryChange(mWindow, geom); |
590 | |
591 | - qCDebug(ubuntumirclient) << "Created surface with geometry:" << geom << "title:" << mWindow->title() |
592 | - << "role:" << roleFor(mWindow) |
593 | - << "\nRequested format:" << mWindow->requestedFormat() |
594 | - << "\nActual format:" << mFormat |
595 | - << "with associated Mir pixel format:" << mirPixelFormatToStr(pixelFormat); |
596 | + qCDebug(ubuntumirclient, "created surface at (%d, %d) with size (%d, %d), title '%s', role: '%d'\n", |
597 | + geom.x(), geom.y(), geom.width(), geom.height(), mWindow->title().toUtf8().constData(), roleFor(mWindow)); |
598 | } |
599 | |
600 | ~UbuntuSurface() |
601 | @@ -394,8 +335,6 @@ |
602 | void setSurfaceParent(MirSurface*); |
603 | bool hasParent() const { return mParented; } |
604 | |
605 | - QSurfaceFormat format() const { return mFormat; } |
606 | - |
607 | private: |
608 | static void surfaceEventCallback(MirSurface* surface, const MirEvent *event, void* context); |
609 | void postEvent(const MirEvent *event); |
610 | @@ -412,7 +351,6 @@ |
611 | bool mNeedsRepaint; |
612 | bool mParented; |
613 | QSize mBufferSize; |
614 | - QSurfaceFormat mFormat; |
615 | |
616 | QMutex mTargetSizeMutex; |
617 | QSize mTargetSize; |
618 | @@ -571,7 +509,8 @@ |
619 | } |
620 | |
621 | UbuntuWindow::UbuntuWindow(QWindow *w, const QSharedPointer<UbuntuClipboard> &clipboard, |
622 | - UbuntuInput *input, UbuntuNativeInterface *native, EGLDisplay eglDisplay, MirConnection *mirConnection) |
623 | + UbuntuInput *input, UbuntuNativeInterface *native, EGLDisplay eglDisplay, |
624 | + EGLConfig eglConfig, MirConnection *mirConnection) |
625 | : QObject(nullptr) |
626 | , QPlatformWindow(w) |
627 | , mId(makeId()) |
628 | @@ -581,7 +520,8 @@ |
629 | , mWindowVisible(false) |
630 | , mWindowExposed(true) |
631 | , mNativeInterface(native) |
632 | - , mSurface(new UbuntuSurface{this, eglDisplay, input, mirConnection}) |
633 | + , mSurface(new UbuntuSurface{this, eglDisplay, eglConfig, |
634 | + static_cast<UbuntuScreen*>(w->screen()->handle())->mirOutputId(), input, mirConnection}) |
635 | , mScale(1.0) |
636 | , mFormFactor(mir_form_factor_unknown) |
637 | { |
638 | @@ -769,11 +709,6 @@ |
639 | return mWindowVisible && mWindowExposed; |
640 | } |
641 | |
642 | -QSurfaceFormat UbuntuWindow::format() const |
643 | -{ |
644 | - return mSurface->format(); |
645 | -} |
646 | - |
647 | void* UbuntuWindow::eglSurface() const |
648 | { |
649 | return mSurface->eglSurface(); |
650 | |
651 | === modified file 'src/ubuntumirclient/window.h' |
652 | --- src/ubuntumirclient/window.h 2016-05-11 18:59:46 +0000 |
653 | +++ src/ubuntumirclient/window.h 2016-06-20 08:42:54 +0000 |
654 | @@ -40,7 +40,7 @@ |
655 | Q_OBJECT |
656 | public: |
657 | UbuntuWindow(QWindow *w, const QSharedPointer<UbuntuClipboard> &clipboard, |
658 | - UbuntuInput *input, UbuntuNativeInterface* native, EGLDisplay eglDisplay, |
659 | + UbuntuInput *input, UbuntuNativeInterface* native, EGLDisplay eglDisplay, EGLConfig eglConfig, |
660 | MirConnection *mirConnection); |
661 | virtual ~UbuntuWindow(); |
662 | |
663 | @@ -54,8 +54,6 @@ |
664 | void propagateSizeHints() override; |
665 | bool isExposed() const override; |
666 | |
667 | - QSurfaceFormat format() const override; |
668 | - |
669 | // Additional Window properties exposed by NativeInterface |
670 | MirFormFactor formFactor() const { return mFormFactor; } |
671 | float scale() const { return mScale; } |
PASSED: Continuous integration, rev:327 /unity8- jenkins. ubuntu. com/job/ lp-qtubuntu- ci/82/ /unity8- jenkins. ubuntu. com/job/ build/2060 /unity8- jenkins. ubuntu. com/job/ build-0- fetch/2088 /unity8- jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= vivid+overlay/ 1999 /unity8- jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial+ overlay/ 1999 /unity8- jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= yakkety/ 1999 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 1990 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 1990/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1990 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1990/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 1990 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 1990/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 1990 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 1990/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1990 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1990/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 1990 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 1990/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 1990 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 1990/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1990 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1990/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= yakkety/ 1990 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= yakkety/ 1990/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:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /unity8- jenkins. ubuntu. com/job/ lp-qtubuntu- ci/82/rebuild
https:/