Merge lp:~gerboland/qtmir/fix-glcontext-loss-on-reconfigure into lp:qtmir

Proposed by Gerry Boland
Status: Merged
Approved by: Daniel d'Andrada
Approved revision: 587
Merged at revision: 600
Proposed branch: lp:~gerboland/qtmir/fix-glcontext-loss-on-reconfigure
Merge into: lp:qtmir
Diff against target: 92 lines (+31/-10)
3 files modified
src/platforms/mirserver/screensmodel.cpp (+29/-8)
src/platforms/mirserver/screensmodel.h (+2/-1)
src/platforms/mirserver/screenwindow.cpp (+0/-1)
To merge this branch: bzr merge lp:~gerboland/qtmir/fix-glcontext-loss-on-reconfigure
Reviewer Review Type Date Requested Status
Daniel d'Andrada (community) Approve
Unity8 CI Bot (community) continuous-integration Approve
Review via email: mp+315065@code.launchpad.net

Commit message

ScreenModel: Only expose windows on displays that are turned on

It seems the GL context Mir gives us for a display that is turned off is invalid. But there is no point rendering to a display that is turned off anyway.

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote :

Handy test, grab
https://code.launchpad.net/~gerboland/+git/display-configurator
Run it with
./display-configurator -- --desktop_file_hint=gedit
and hit the letter "O" - big o. (I find you need to click on the surface for it to get input correctly)

The display should turn off.

P isn't turning it on yet - need to figure out why, if input is disabled or if QtMir isn't passing input to non-exposed windows or something.

To turn display on, kill the display-configurator process. Mir/U8 should revert to the previous state

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:587
https://unity8-jenkins.ubuntu.com/job/lp-qtmir-ci/449/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3847
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3875
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3718
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3718/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3718
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3718/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3718
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3718/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3718
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3718/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3718
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3718/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3718
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3718/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtmir-ci/449/rebuild

review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

should probably remove the binary and object file from the git repo of display-configurator

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Code looks ok. Passes manual test.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/mirserver/screensmodel.cpp'
2--- src/platforms/mirserver/screensmodel.cpp 2016-11-03 20:17:46 +0000
3+++ src/platforms/mirserver/screensmodel.cpp 2017-01-18 18:40:03 +0000
4@@ -79,10 +79,9 @@
5 qCDebug(QTMIR_SCREENS) << "ScreensModel::onCompositorStarting";
6 m_compositing = true;
7
8- update();
9+ update(); // must handle all hardware changes before starting the renderer
10
11- // (Re)Start Qt's render thread by setting all windows with a corresponding screen to exposed.
12- allWindowsSetExposed(true);
13+ startRenderer();
14 }
15
16 void ScreensModel::onCompositorStopping()
17@@ -90,9 +89,7 @@
18 qCDebug(QTMIR_SCREENS) << "ScreensModel::onCompositorStopping";
19 m_compositing = false;
20
21- // Stop Qt's render threads by setting all its windows it obscured. Must
22- // block until all windows have their GL contexts released.
23- allWindowsSetExposed(false);
24+ haltRenderer(); // must stop all rendering before handling any hardware changes
25
26 update();
27 }
28@@ -221,12 +218,36 @@
29 return canUpdateExisting;
30 }
31
32-void ScreensModel::allWindowsSetExposed(bool exposed)
33+/*
34+ * ScreensModel::startRenderer()
35+ * (Re)Start Qt's render thread by setting all windows with a corresponding screen to exposed.
36+ * It is asynchronous, it returns before the render thread(s) have started.
37+ */
38+void ScreensModel::startRenderer()
39+{
40+ Q_FOREACH (const auto screen, m_screenList) {
41+ // Only set windows exposed on displays which are turned on, as the GL context Mir provided
42+ // is invalid in that situation
43+ if (screen->powerMode() == mir_power_mode_on) {
44+ const auto window = static_cast<ScreenWindow *>(screen->window());
45+ if (window && window->window()) {
46+ window->setExposed(true);
47+ }
48+ }
49+ }
50+}
51+
52+/*
53+ * ScreensModel::haltRenderer()
54+ * Stop Qt's render thread(s) by setting all windows with a corresponding screen to not exposed.
55+ * It is blocking, it returns after the render thread(s) have all stopped.
56+ */
57+void ScreensModel::haltRenderer()
58 {
59 Q_FOREACH (const auto screen, m_screenList) {
60 const auto window = static_cast<ScreenWindow *>(screen->window());
61 if (window && window->window()) {
62- window->setExposed(exposed);
63+ window->setExposed(false);
64 }
65 }
66 }
67
68=== modified file 'src/platforms/mirserver/screensmodel.h'
69--- src/platforms/mirserver/screensmodel.h 2016-11-03 20:17:46 +0000
70+++ src/platforms/mirserver/screensmodel.h 2017-01-18 18:40:03 +0000
71@@ -90,7 +90,8 @@
72 private:
73 Screen* findScreenWithId(const QList<Screen*> &list, const mir::graphics::DisplayConfigurationOutputId id);
74 bool canUpdateExistingScreen(const Screen *screen, const mir::graphics::DisplayConfigurationOutput &output);
75- void allWindowsSetExposed(bool exposed);
76+ void startRenderer();
77+ void haltRenderer();
78
79 std::weak_ptr<mir::graphics::Display> m_display;
80 std::shared_ptr<QtCompositor> m_compositor;
81
82=== modified file 'src/platforms/mirserver/screenwindow.cpp'
83--- src/platforms/mirserver/screenwindow.cpp 2016-06-07 20:52:43 +0000
84+++ src/platforms/mirserver/screenwindow.cpp 2017-01-18 18:40:03 +0000
85@@ -109,7 +109,6 @@
86 myScreen->setWindow(this);
87
88 QWindowSystemInterface::handleWindowScreenChanged(window(), myScreen->screen());
89- setExposed(true); //GERRY - assumption setScreen only called while compositor running
90
91 qCDebug(QTMIR_SCREENS) << "ScreenWindow" << this << "with window ID" << uint(m_winId) << "NEWLY backed by" << myScreen;
92 }

Subscribers

People subscribed via source and target branches