Merge lp:~fboucault/unity-2d/opengl_switch into lp:unity-2d/3.0

Proposed by Florian Boucault
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 553
Merged at revision: 553
Proposed branch: lp:~fboucault/unity-2d/opengl_switch
Merge into: lp:unity-2d/3.0
Diff against target: 245 lines (+85/-6)
13 files modified
CMakeLists.txt (+1/-0)
launcher/app/launcher.cpp (+2/-0)
launcher/app/launcherview.cpp (+1/-1)
launcher/app/launcherview.h (+3/-1)
libunity-2d-private/src/CMakeLists.txt (+2/-0)
libunity-2d-private/src/unity2ddeclarativeview.cpp (+37/-0)
libunity-2d-private/src/unity2ddeclarativeview.h (+27/-0)
places/app/dashdeclarativeview.cpp (+1/-1)
places/app/dashdeclarativeview.h (+2/-1)
places/app/places.cpp (+3/-0)
spread/app/spread.cpp (+2/-0)
spread/app/spreadview.cpp (+1/-1)
spread/app/spreadview.h (+3/-1)
To merge this branch: bzr merge lp:~fboucault/unity-2d/opengl_switch
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
Olivier Tilloy Pending
Review via email: mp+59530@code.launchpad.net

Description of the change

[dash, launcher, spread] Added a new command line switch (-opengl) that triggers the use of a QGLWidget for the QML viewport.

To post a comment you must log in.
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Code seems fine, and was able to test and confirm the opengl usage when using with -opengl.

The initial broken window for places is also gone, as we're also using the raster engine.

Just remember that an additional change is needed at the package side, to add libqt4-opengl-dev as build-depends.

review: Approve
Revision history for this message
Olivier Tilloy (osomon) wrote :

@Ricardo: the status of a MR should not be set to Approved until all the necessary changes/fixes have been applied. This is because the buildbot is automatically merging approved MRs. The latest nightly build on ARM failed precisely because of the missing build dependency you were mentioning in your comment (see https://launchpadlibrarian.net/70884789/buildlog_ubuntu-natty-armel.unity-2d_3.8.4.1-0ubuntu2~bzr553_FAILEDTOBUILD.txt.gz).

Revision history for this message
Olivier Tilloy (osomon) wrote :

@Florian: the code looks good to me, I still need to test it.

One comment/question on your way of retrieving the command line arguments for the application:

+ QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments());

Why do you need a QSet? Can’t you just use the QStringList returned by QCoreApplication::arguments() ?
QLists also have a 'contains' method, so it should be fine.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2011-02-18 17:05:47 +0000
3+++ CMakeLists.txt 2011-04-29 16:29:42 +0000
4@@ -24,6 +24,7 @@
5 ${QT_QTDECLARATIVE_INCLUDE_DIR}
6 ${QT_QTXML_INCLUDE_DIR}
7 ${QT_QTGUI_INCLUDE_DIR}
8+ ${QT_QTOPENGL_INCLUDE_DIR}
9 ${X11_INCLUDE_DIR}
10 )
11
12
13=== modified file 'launcher/app/launcher.cpp'
14--- launcher/app/launcher.cpp 2011-04-28 13:09:25 +0000
15+++ launcher/app/launcher.cpp 2011-04-29 16:29:42 +0000
16@@ -90,6 +90,7 @@
17 */
18 QApplication::setGraphicsSystem("raster");
19 Unity2dApplication application(argc, argv);
20+ QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments());
21
22 GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-launcher.desktop");
23 client.connectToSessionManager();
24@@ -110,6 +111,7 @@
25
26 /* QML declarative view */
27 LauncherView *launcherView = new LauncherView(&panel);
28+ launcherView->setUseOpenGL(arguments.contains("-opengl"));
29
30 /* FIXME: possible optimisations */
31 // launcherView->setAttribute(Qt::WA_OpaquePaintEvent);
32
33=== modified file 'launcher/app/launcherview.cpp'
34--- launcher/app/launcherview.cpp 2011-04-28 13:09:25 +0000
35+++ launcher/app/launcherview.cpp 2011-04-29 16:29:42 +0000
36@@ -58,7 +58,7 @@
37 static const char* COMMANDS_PLACE_ENTRY = "Runner";
38
39 LauncherView::LauncherView(QWidget* parent) :
40- QDeclarativeView(parent),
41+ Unity2DDeclarativeView(parent),
42 m_superKeyPressed(false), m_superKeyHeld(false)
43 {
44 m_superKeyHoldTimer.setSingleShot(true);
45
46=== modified file 'launcher/app/launcherview.h'
47--- launcher/app/launcherview.h 2011-04-01 09:23:58 +0000
48+++ launcher/app/launcherview.h 2011-04-29 16:29:42 +0000
49@@ -27,10 +27,12 @@
50
51 #include "gconfitem-qml-wrapper.h"
52
53+#include <unity2ddeclarativeview.h>
54+
55 class DeclarativeDragDropEvent;
56 class LauncherDBus;
57
58-class LauncherView : public QDeclarativeView
59+class LauncherView : public Unity2DDeclarativeView
60 {
61 Q_OBJECT
62 Q_PROPERTY(bool superKeyHeld READ superKeyHeld NOTIFY superKeyHeldChanged)
63
64=== modified file 'libunity-2d-private/src/CMakeLists.txt'
65--- libunity-2d-private/src/CMakeLists.txt 2011-03-21 13:46:48 +0000
66+++ libunity-2d-private/src/CMakeLists.txt 2011-04-29 16:29:42 +0000
67@@ -13,6 +13,7 @@
68 unity2ddebug.cpp
69 unity2dpanel.cpp
70 unity2dtr.cpp
71+ unity2ddeclarativeview.cpp
72 mimedata.cpp
73 dragdropevent.cpp
74 propertybinder.cpp
75@@ -38,6 +39,7 @@
76 ${QT_QTCORE_LIBRARIES}
77 ${QT_QTDBUS_LIBRARIES}
78 ${QT_QTDECLARATIVE_LIBRARIES}
79+ ${QT_QTOPENGL_LIBRARIES}
80 ${X11_LIBRARIES}
81 ${GLIB_LDFLAGS}
82 )
83
84=== added file 'libunity-2d-private/src/unity2ddeclarativeview.cpp'
85--- libunity-2d-private/src/unity2ddeclarativeview.cpp 1970-01-01 00:00:00 +0000
86+++ libunity-2d-private/src/unity2ddeclarativeview.cpp 2011-04-29 16:29:42 +0000
87@@ -0,0 +1,37 @@
88+#include "unity2ddeclarativeview.h"
89+#include <QGLWidget>
90+
91+Unity2DDeclarativeView::Unity2DDeclarativeView(QWidget *parent) :
92+ QDeclarativeView(parent), m_useOpenGL(false)
93+{
94+}
95+
96+bool Unity2DDeclarativeView::useOpenGL() const
97+{
98+ return m_useOpenGL;
99+}
100+
101+void Unity2DDeclarativeView::setUseOpenGL(bool useOpenGL)
102+{
103+ if (useOpenGL == m_useOpenGL) {
104+ return;
105+ }
106+
107+ if (useOpenGL) {
108+ QGLFormat format = QGLFormat::defaultFormat();
109+ format.setSampleBuffers(false);
110+
111+ QGLWidget *glWidget = new QGLWidget(format);
112+ /* TODO: possibly faster, to be tested */
113+ //glWidget->setAutoFillBackground(false);
114+
115+ setViewport(glWidget);
116+ } else {
117+ setViewport(0);
118+ }
119+
120+ m_useOpenGL = useOpenGL;
121+ Q_EMIT useOpenGLChanged(useOpenGL);
122+}
123+
124+#include <unity2ddeclarativeview.moc>
125
126=== added file 'libunity-2d-private/src/unity2ddeclarativeview.h'
127--- libunity-2d-private/src/unity2ddeclarativeview.h 1970-01-01 00:00:00 +0000
128+++ libunity-2d-private/src/unity2ddeclarativeview.h 2011-04-29 16:29:42 +0000
129@@ -0,0 +1,27 @@
130+#ifndef UNITY2DDECLARATIVEVIEW_H
131+#define UNITY2DDECLARATIVEVIEW_H
132+
133+#include <QDeclarativeView>
134+
135+class Unity2DDeclarativeView : public QDeclarativeView
136+{
137+ Q_OBJECT
138+
139+ Q_PROPERTY(bool useOpenGL READ useOpenGL WRITE setUseOpenGL NOTIFY useOpenGLChanged)
140+
141+public:
142+ Unity2DDeclarativeView(QWidget *parent = 0);
143+
144+ bool useOpenGL() const;
145+ void setUseOpenGL(bool);
146+
147+Q_SIGNALS:
148+ void useOpenGLChanged(bool);
149+
150+private:
151+ bool m_useOpenGL;
152+};
153+
154+Q_DECLARE_METATYPE(Unity2DDeclarativeView*)
155+
156+#endif // UNITY2DDECLARATIVEVIEW_H
157
158=== modified file 'places/app/dashdeclarativeview.cpp'
159--- places/app/dashdeclarativeview.cpp 2011-04-12 17:28:33 +0000
160+++ places/app/dashdeclarativeview.cpp 2011-04-29 16:29:42 +0000
161@@ -47,7 +47,7 @@
162 static const char* DASH_DBUS_OBJECT_PATH = "/Dash";
163
164 DashDeclarativeView::DashDeclarativeView()
165-: QDeclarativeView()
166+: Unity2DDeclarativeView()
167 , m_launcherClient(new LauncherClient(this))
168 , m_mode(HiddenMode)
169 , m_expanded(false)
170
171=== modified file 'places/app/dashdeclarativeview.h'
172--- places/app/dashdeclarativeview.h 2011-04-12 15:40:46 +0000
173+++ places/app/dashdeclarativeview.h 2011-04-29 16:29:42 +0000
174@@ -18,10 +18,11 @@
175 #define DashDeclarativeView_H
176
177 #include <QDeclarativeView>
178+#include <unity2ddeclarativeview.h>
179
180 class LauncherClient;
181
182-class DashDeclarativeView : public QDeclarativeView
183+class DashDeclarativeView : public Unity2DDeclarativeView
184 {
185 Q_OBJECT
186 Q_ENUMS(DashMode)
187
188=== modified file 'places/app/places.cpp'
189--- places/app/places.cpp 2011-04-13 13:44:28 +0000
190+++ places/app/places.cpp 2011-04-29 16:29:42 +0000
191@@ -57,9 +57,12 @@
192 */
193 QApplication::setGraphicsSystem("raster");
194 QApplication application(argc, argv);
195+ QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments());
196
197 qmlRegisterType<DashDeclarativeView>("Places", 1, 0, "DashDeclarativeView");
198 DashDeclarativeView view;
199+ view.setUseOpenGL(arguments.contains("-opengl"));
200+
201 if (!view.connectToBus()) {
202 qCritical() << "Another instance of the Dash already exists. Quitting.";
203 return -1;
204
205=== modified file 'spread/app/spread.cpp'
206--- spread/app/spread.cpp 2011-04-19 14:11:36 +0000
207+++ spread/app/spread.cpp 2011-04-29 16:29:42 +0000
208@@ -50,8 +50,10 @@
209 */
210 QApplication::setGraphicsSystem("raster");
211 QApplication application(argc, argv);
212+ QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments());
213
214 SpreadView view;
215+ view.setUseOpenGL(arguments.contains("-opengl"));
216
217 /* The spread window is borderless and not moveable by the user, yet not
218 fullscreen */
219
220=== modified file 'spread/app/spreadview.cpp'
221--- spread/app/spreadview.cpp 2011-03-17 16:05:29 +0000
222+++ spread/app/spreadview.cpp 2011-04-29 16:29:42 +0000
223@@ -29,7 +29,7 @@
224
225 #include "launcherclient.h"
226
227-SpreadView::SpreadView() : QDeclarativeView()
228+SpreadView::SpreadView() : Unity2DDeclarativeView()
229 {
230 }
231
232
233=== modified file 'spread/app/spreadview.h'
234--- spread/app/spreadview.h 2011-02-03 02:39:53 +0000
235+++ spread/app/spreadview.h 2011-04-29 16:29:42 +0000
236@@ -23,7 +23,9 @@
237 #include <QDeclarativeView>
238 #include <QEvent>
239
240-class SpreadView : public QDeclarativeView
241+#include <unity2ddeclarativeview.h>
242+
243+class SpreadView : public Unity2DDeclarativeView
244 {
245 Q_OBJECT
246

Subscribers

People subscribed via source and target branches