Merge lp:~dandrader/qtubuntu/offscreenSurface-lp1527737 into lp:qtubuntu

Proposed by Daniel d'Andrada on 2016-01-05
Status: Merged
Approved by: Gerry Boland on 2016-01-07
Approved revision: 303
Merged at revision: 309
Proposed branch: lp:~dandrader/qtubuntu/offscreenSurface-lp1527737
Merge into: lp:qtubuntu
Prerequisite: lp:~dandrader/qtubuntu/loggingCategory
Diff against target: 206 lines (+120/-8)
6 files modified
src/ubuntumirclient/glcontext.cpp (+21/-8)
src/ubuntumirclient/integration.cpp (+7/-0)
src/ubuntumirclient/integration.h (+2/-0)
src/ubuntumirclient/offscreensurface.cpp (+47/-0)
src/ubuntumirclient/offscreensurface.h (+41/-0)
src/ubuntumirclient/ubuntumirclient.pro (+2/-0)
To merge this branch: bzr merge lp:~dandrader/qtubuntu/offscreenSurface-lp1527737
Reviewer Review Type Date Requested Status
Gerry Boland 2016-01-05 Approve on 2016-01-07
PS Jenkins bot continuous-integration Approve on 2016-01-05
Review via email: mp+281638@code.launchpad.net

Commit Message

Implement QPlatformOffscreenSurface

Otherwise Qt might create a full QPlatformWindow during shutdown (which will cause the creation of a mir surface) while cleaning up the GL context and we don't want that.

Description of the Change

Helps to sanitize the situation of bug 1527737 (as the spurious surface creation on shutdown was taking place there), but *does not* fix it.

To post a comment you must log in.
Gerry Boland (gerboland) wrote :

Code looks good to me. Found no negative impact on phone, need to check desktop.

review: Approve (code)
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Gerry Boland (gerboland) wrote :

Fine on desktop

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ubuntumirclient/glcontext.cpp'
2--- src/ubuntumirclient/glcontext.cpp 2016-01-05 14:28:30 +0000
3+++ src/ubuntumirclient/glcontext.cpp 2016-01-05 14:28:30 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright (C) 2014-2015 Canonical, Ltd.
7+ * Copyright (C) 2014-2016 Canonical, Ltd.
8 *
9 * This program is free software: you can redistribute it and/or modify it under
10 * the terms of the GNU Lesser General Public License version 3, as published by
11@@ -15,8 +15,11 @@
12 */
13
14 #include "glcontext.h"
15+#include "logging.h"
16+#include "offscreensurface.h"
17 #include "window.h"
18-#include "logging.h"
19+
20+#include <QOpenGLFramebufferObject>
21 #include <QtPlatformSupport/private/qeglconvenience_p.h>
22
23 static void printOpenGLESConfig() {
24@@ -71,13 +74,23 @@
25 bool UbuntuOpenGLContext::makeCurrent(QPlatformSurface* surface)
26 {
27 Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface);
28- EGLSurface eglSurface = static_cast<UbuntuWindow*>(surface)->eglSurface();
29- ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE);
30- ASSERT(eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext) == EGL_TRUE);
31- if (ubuntumirclient().isDebugEnabled()) {
32- printOpenGLESConfig();
33+
34+ if (surface->surface()->surfaceClass() == QSurface::Offscreen) {
35+ auto offscreen = static_cast<UbuntuOffscreenSurface *>(surface);
36+ if (!offscreen->buffer()) {
37+ auto buffer = new QOpenGLFramebufferObject(surface->surface()->size());
38+ offscreen->setBuffer(buffer);
39+ }
40+ return offscreen->buffer()->bind();
41+ } else {
42+ EGLSurface eglSurface = static_cast<UbuntuWindow*>(surface)->eglSurface();
43+ ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE);
44+ ASSERT(eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext) == EGL_TRUE);
45+ if (ubuntumirclient().isDebugEnabled()) {
46+ printOpenGLESConfig();
47+ }
48+ return true;
49 }
50- return true;
51 }
52
53 void UbuntuOpenGLContext::doneCurrent()
54
55=== modified file 'src/ubuntumirclient/integration.cpp'
56--- src/ubuntumirclient/integration.cpp 2016-01-05 14:28:30 +0000
57+++ src/ubuntumirclient/integration.cpp 2016-01-05 14:28:30 +0000
58@@ -22,6 +22,7 @@
59 #include "input.h"
60 #include "logging.h"
61 #include "nativeinterface.h"
62+#include "offscreensurface.h"
63 #include "screen.h"
64 #include "theme.h"
65 #include "window.h"
66@@ -255,3 +256,9 @@
67 {
68 return mNativeInterface;
69 }
70+
71+QPlatformOffscreenSurface *UbuntuClientIntegration::createPlatformOffscreenSurface(
72+ QOffscreenSurface *surface) const
73+{
74+ return new UbuntuOffscreenSurface(surface);
75+}
76
77=== modified file 'src/ubuntumirclient/integration.h'
78--- src/ubuntumirclient/integration.h 2015-08-27 09:41:47 +0000
79+++ src/ubuntumirclient/integration.h 2016-01-05 14:28:30 +0000
80@@ -55,6 +55,8 @@
81 QPlatformWindow* createPlatformWindow(QWindow* window);
82 UbuntuScreen* screen() const { return mScreen; }
83
84+ QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override;
85+
86 private:
87 void setupOptions();
88 void setupDescription();
89
90=== added file 'src/ubuntumirclient/offscreensurface.cpp'
91--- src/ubuntumirclient/offscreensurface.cpp 1970-01-01 00:00:00 +0000
92+++ src/ubuntumirclient/offscreensurface.cpp 2016-01-05 14:28:30 +0000
93@@ -0,0 +1,47 @@
94+/*
95+ * Copyright (C) 2016 Canonical, Ltd.
96+ *
97+ * This program is free software: you can redistribute it and/or modify it under
98+ * the terms of the GNU Lesser General Public License version 3, as published by
99+ * the Free Software Foundation.
100+ *
101+ * This program is distributed in the hope that it will be useful, but WITHOUT
102+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
103+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
104+ * Lesser General Public License for more details.
105+ *
106+ * You should have received a copy of the GNU Lesser General Public License
107+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
108+ */
109+
110+#include "offscreensurface.h"
111+
112+#include <QOffscreenSurface>
113+#include <QOpenGLFramebufferObject>
114+
115+UbuntuOffscreenSurface::UbuntuOffscreenSurface(QOffscreenSurface *offscreenSurface)
116+ : QPlatformOffscreenSurface(offscreenSurface)
117+ , m_buffer(nullptr)
118+ , m_format(offscreenSurface->requestedFormat())
119+{
120+}
121+
122+QSurfaceFormat UbuntuOffscreenSurface::format() const
123+{
124+ return m_format;
125+}
126+
127+bool UbuntuOffscreenSurface::isValid() const
128+{
129+ return m_buffer != nullptr && m_buffer->isValid();
130+}
131+
132+QOpenGLFramebufferObject* UbuntuOffscreenSurface::buffer() const
133+{
134+ return m_buffer;
135+}
136+
137+void UbuntuOffscreenSurface::setBuffer(QOpenGLFramebufferObject *buffer)
138+{
139+ m_buffer = buffer;
140+}
141
142=== added file 'src/ubuntumirclient/offscreensurface.h'
143--- src/ubuntumirclient/offscreensurface.h 1970-01-01 00:00:00 +0000
144+++ src/ubuntumirclient/offscreensurface.h 2016-01-05 14:28:30 +0000
145@@ -0,0 +1,41 @@
146+/*
147+ * Copyright (C) 2016 Canonical, Ltd.
148+ *
149+ * This program is free software: you can redistribute it and/or modify it under
150+ * the terms of the GNU Lesser General Public License version 3, as published by
151+ * the Free Software Foundation.
152+ *
153+ * This program is distributed in the hope that it will be useful, but WITHOUT
154+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
155+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
156+ * Lesser General Public License for more details.
157+ *
158+ * You should have received a copy of the GNU Lesser General Public License
159+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
160+ */
161+
162+#ifndef UBUNTU_OFFSCREEN_SURFACE_H
163+#define UBUNTU_OFFSCREEN_SURFACE_H
164+
165+#include <qpa/qplatformoffscreensurface.h>
166+#include <QSurfaceFormat>
167+
168+class QOpenGLFramebufferObject;
169+
170+class UbuntuOffscreenSurface : public QPlatformOffscreenSurface
171+{
172+public:
173+ UbuntuOffscreenSurface(QOffscreenSurface *offscreenSurface);
174+
175+ QSurfaceFormat format() const override;
176+ bool isValid() const override;
177+
178+ QOpenGLFramebufferObject* buffer() const;
179+ void setBuffer(QOpenGLFramebufferObject *buffer);
180+
181+private:
182+ QOpenGLFramebufferObject *m_buffer;
183+ QSurfaceFormat m_format;
184+};
185+
186+#endif // UBUNTU_OFFSCREEN_SURFACE_H
187
188=== modified file 'src/ubuntumirclient/ubuntumirclient.pro'
189--- src/ubuntumirclient/ubuntumirclient.pro 2015-11-10 11:16:14 +0000
190+++ src/ubuntumirclient/ubuntumirclient.pro 2016-01-05 14:28:30 +0000
191@@ -22,6 +22,7 @@
192 input.cpp \
193 integration.cpp \
194 nativeinterface.cpp \
195+ offscreensurface.cpp \
196 platformservices.cpp \
197 plugin.cpp \
198 screen.cpp \
199@@ -37,6 +38,7 @@
200 integration.h \
201 logging.h \
202 nativeinterface.h \
203+ offscreensurface.h \
204 orientationchangeevent_p.h \
205 platformservices.h \
206 plugin.h \

Subscribers

People subscribed via source and target branches