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

Proposed by Florian Boucault
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 618
Merged at revision: 617
Proposed branch: lp:~fboucault/unity-2d/opengl_plus_composite_fix
Merge into: lp:unity-2d/3.0
Diff against target: 128 lines (+66/-23)
2 files modified
libunity-2d-private/src/unity2ddeclarativeview.cpp (+63/-23)
libunity-2d-private/src/unity2ddeclarativeview.h (+3/-0)
To merge this branch: bzr merge lp:~fboucault/unity-2d/opengl_plus_composite_fix
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
Review via email: mp+66932@code.launchpad.net

Description of the change

[dash] Fix use of opengl rendering backend: artifacts were displayed, even more so with transparency enabled.

The cause of the issue was that the QGLWidget viewport was set on the QDeclarativeView
before having setup the QGLWidget's flags.
Implementation of Unity2dDeclarativeView is much clarified as a result and this change
impacts all the components using it:
- launcher
- dash
- spread

Synchronization to VBlank has also been activated.
Set viewport update mode to QGraphicsView::FullViewportUpdate when using OpenGL.

To post a comment you must log in.
618. By Florian Boucault

Set viewport update mode to QGraphicsView::FullViewportUpdate when using OpenGL.

Revision history for this message
Ricardo Salveti (rsalveti) wrote :

The code seems fine, but I'm unable to reproduce the original problem at least when using with the OpenGLES QT backend.

Did you only see this issue when using with normal OpenGL? I'll reproduce this on my host machine tomorrow to see if I'm at least able to reproduce the issue.

Revision history for this message
Ricardo Salveti (rsalveti) wrote :

When using OpenGL at my desktop I'm able to reproduce the issue this patch fixes. After applying the patch the transparency is now working same way when using without -opengl.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libunity-2d-private/src/unity2ddeclarativeview.cpp'
--- libunity-2d-private/src/unity2ddeclarativeview.cpp 2011-06-13 00:31:52 +0000
+++ libunity-2d-private/src/unity2ddeclarativeview.cpp 2011-07-05 18:52:39 +0000
@@ -2,10 +2,9 @@
2#include <QGLWidget>2#include <QGLWidget>
33
4Unity2DDeclarativeView::Unity2DDeclarativeView(QWidget *parent) :4Unity2DDeclarativeView::Unity2DDeclarativeView(QWidget *parent) :
5 QDeclarativeView(parent), m_useOpenGL(false)5 QDeclarativeView(parent), m_useOpenGL(false), m_transparentBackground(false)
6{6{
7 setAttribute(Qt::WA_NoSystemBackground);7 setupViewport();
8 setTransparentBackground(false);
9}8}
109
11bool Unity2DDeclarativeView::useOpenGL() const10bool Unity2DDeclarativeView::useOpenGL() const
@@ -19,36 +18,77 @@
19 return;18 return;
20 }19 }
2120
22 if (useOpenGL) {21 m_useOpenGL = useOpenGL;
22 setupViewport();
23
24 Q_EMIT useOpenGLChanged(useOpenGL);
25}
26
27bool Unity2DDeclarativeView::transparentBackground() const
28{
29 return m_transparentBackground;
30}
31
32void Unity2DDeclarativeView::setTransparentBackground(bool transparentBackground)
33{
34 if (transparentBackground == m_transparentBackground) {
35 return;
36 }
37
38 m_transparentBackground = transparentBackground;
39 setupViewport();
40
41 Q_EMIT transparentBackgroundChanged(transparentBackground);
42}
43
44void Unity2DDeclarativeView::setupViewport()
45{
46 if (m_useOpenGL) {
23 QGLFormat format = QGLFormat::defaultFormat();47 QGLFormat format = QGLFormat::defaultFormat();
24 format.setSampleBuffers(false);48 format.setSampleBuffers(false);
49 /* Synchronise rendering with vblank */
50 format.setSwapInterval(1);
2551
26 QGLWidget *glWidget = new QGLWidget(format);52 QGLWidget *glWidget = new QGLWidget(format);
27 /* TODO: possibly faster, to be tested */53 /* TODO: possibly faster, to be tested, only works with non transparent windows */
28 //glWidget->setAutoFillBackground(false);54 //glWidget->setAutoFillBackground(false);
2955
56 if (m_transparentBackground) {
57 glWidget->setAttribute(Qt::WA_TranslucentBackground, true);
58 setAttribute(Qt::WA_TranslucentBackground, true);
59 /* automatically set by setting WA_TranslucentBackground */
60 setAttribute(Qt::WA_NoSystemBackground, true);
61 setAttribute(Qt::WA_OpaquePaintEvent, true);
62 } else {
63 glWidget->setAttribute(Qt::WA_TranslucentBackground, false);
64 setAttribute(Qt::WA_TranslucentBackground, false);
65 setAttribute(Qt::WA_NoSystemBackground, true);
66 setAttribute(Qt::WA_OpaquePaintEvent, true);
67 }
68
30 setViewport(glWidget);69 setViewport(glWidget);
70 /* According to Qt's documentation: "This is the preferred update mode
71 for viewports that do not support partial updates, such as QGLWidget [...]"
72 */
73 setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
31 } else {74 } else {
32 setViewport(0);75 setViewport(0);
76 /* This is the default update mode */
77 setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
78
79 if (m_transparentBackground) {
80 viewport()->setAttribute(Qt::WA_TranslucentBackground, true);
81 setAttribute(Qt::WA_TranslucentBackground, true);
82 /* automatically set by setting WA_TranslucentBackground */
83 setAttribute(Qt::WA_NoSystemBackground, true);
84 setAttribute(Qt::WA_OpaquePaintEvent, false);
85 } else {
86 viewport()->setAttribute(Qt::WA_TranslucentBackground, false);
87 setAttribute(Qt::WA_TranslucentBackground, false);
88 setAttribute(Qt::WA_NoSystemBackground, true);
89 setAttribute(Qt::WA_OpaquePaintEvent, true);
90 }
33 }91 }
34
35 m_useOpenGL = useOpenGL;
36 Q_EMIT useOpenGLChanged(useOpenGL);
37}
38
39bool Unity2DDeclarativeView::transparentBackground() const
40{
41 return m_transparentBackground;
42}
43
44void Unity2DDeclarativeView::setTransparentBackground(bool transparentBackground)
45{
46 setAttribute(Qt::WA_TranslucentBackground, transparentBackground);
47 viewport()->setAttribute(Qt::WA_TranslucentBackground, transparentBackground);
48 setAttribute(Qt::WA_OpaquePaintEvent, !transparentBackground);
49
50 m_transparentBackground = transparentBackground;
51 Q_EMIT transparentBackgroundChanged(transparentBackground);
52}92}
5393
54#include <unity2ddeclarativeview.moc>94#include <unity2ddeclarativeview.moc>
5595
=== modified file 'libunity-2d-private/src/unity2ddeclarativeview.h'
--- libunity-2d-private/src/unity2ddeclarativeview.h 2011-06-13 00:31:52 +0000
+++ libunity-2d-private/src/unity2ddeclarativeview.h 2011-07-05 18:52:39 +0000
@@ -25,6 +25,9 @@
25 void useOpenGLChanged(bool);25 void useOpenGLChanged(bool);
26 void transparentBackgroundChanged(bool);26 void transparentBackgroundChanged(bool);
2727
28protected:
29 void setupViewport();
30
28private:31private:
29 bool m_useOpenGL;32 bool m_useOpenGL;
30 bool m_transparentBackground;33 bool m_transparentBackground;

Subscribers

People subscribed via source and target branches