Mir

Merge lp:~vanvugt/mir/fix-1672269 into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 4101
Proposed branch: lp:~vanvugt/mir/fix-1672269
Merge into: lp:mir
Diff against target: 111 lines (+65/-1)
3 files modified
src/renderers/gl/renderer.cpp (+12/-1)
src/renderers/gl/renderer.h (+2/-0)
tests/unit-tests/renderers/gl/test_gl_renderer.cpp (+51/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1672269
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve
Alan Griffiths Approve
Alexandros Frantzis (community) Approve
Review via email: mp+320463@code.launchpad.net

Commit message

Remember the glViewport calculation can change as a result of a
new output transformation (rotation) and not just a change in the
viewport rectangle. (LP: #1672269)

Description of the change

Technically the rotation does change the rectangle by transposing its
dimenions, however in LP: #1672269 this fact doesn't help because the
mode change has reconstructed the renderer with the newly transposed
dimensions before ever notifying there is an output transformation. So
the second set_viewport call that should have triggered glViewport
bailed out early thinking nothing had changed. But now we do it as
early (and seldom) as possible in both functions to cover all bases.

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:4100
https://mir-jenkins.ubuntu.com/job/mir-ci/3203/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/4307
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/4394
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/4384
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/4384
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/4384
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4339
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4339/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4339
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4339/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4339
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4339/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4339
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4339/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4339
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4339/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4339
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4339/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3203/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

OK.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/renderers/gl/renderer.cpp'
2--- src/renderers/gl/renderer.cpp 2017-03-16 04:08:46 +0000
3+++ src/renderers/gl/renderer.cpp 2017-03-21 09:09:36 +0000
4@@ -372,12 +372,18 @@
5 0.0f});
6
7 viewport = rect;
8+ update_gl_viewport();
9+}
10
11+void mrg::Renderer::update_gl_viewport()
12+{
13 /*
14 * Letterboxing: Move the glViewport to add black bars in the case that
15 * the logical viewport aspect ratio doesn't match the display aspect.
16 * This keeps pixels square. Note "black"-bars are really glClearColor.
17 */
18+ render_target.ensure_current();
19+
20 auto transformed_viewport = display_transform *
21 glm::vec4(viewport.size.width.as_int(),
22 viewport.size.height.as_int(), 0, 1);
23@@ -407,7 +413,12 @@
24
25 void mrg::Renderer::set_output_transform(glm::mat2 const& t)
26 {
27- display_transform = glm::mat4(t);
28+ auto const new_display_transform = glm::mat4(t);
29+ if (new_display_transform != display_transform)
30+ {
31+ display_transform = new_display_transform;
32+ update_gl_viewport();
33+ }
34 }
35
36 void mrg::Renderer::suspend()
37
38=== modified file 'src/renderers/gl/renderer.h'
39--- src/renderers/gl/renderer.h 2017-01-27 08:13:36 +0000
40+++ src/renderers/gl/renderer.h 2017-03-21 09:09:36 +0000
41@@ -123,6 +123,8 @@
42 Renderer::Program const& prog) const;
43
44 private:
45+ void update_gl_viewport();
46+
47 std::unique_ptr<mir::gl::TextureCache> const texture_cache;
48 geometry::Rectangle viewport;
49 glm::mat4 screen_to_gl_coords;
50
51=== modified file 'tests/unit-tests/renderers/gl/test_gl_renderer.cpp'
52--- tests/unit-tests/renderers/gl/test_gl_renderer.cpp 2017-02-15 10:17:21 +0000
53+++ tests/unit-tests/renderers/gl/test_gl_renderer.cpp 2017-03-21 09:09:36 +0000
54@@ -316,6 +316,57 @@
55 renderer.render(renderable_list);
56 }
57
58+TEST_F(GLRenderer, unchanged_viewport_avoids_gl_calls)
59+{
60+ int const screen_width = 1920;
61+ int const screen_height = 1080;
62+ mir::geometry::Rectangle const view_area{{0,0}, {1920,1080}};
63+
64+ ON_CALL(mock_egl, eglQuerySurface(_,_,EGL_WIDTH,_))
65+ .WillByDefault(DoAll(SetArgPointee<3>(screen_width),
66+ Return(EGL_TRUE)));
67+ ON_CALL(mock_egl, eglQuerySurface(_,_,EGL_HEIGHT,_))
68+ .WillByDefault(DoAll(SetArgPointee<3>(screen_height),
69+ Return(EGL_TRUE)));
70+ ON_CALL(mock_display_buffer, view_area())
71+ .WillByDefault(Return(view_area));
72+
73+ mrg::Renderer renderer(mock_display_buffer);
74+
75+ renderer.set_viewport(view_area);
76+
77+ EXPECT_CALL(mock_gl, glViewport(_,_,_,_))
78+ .Times(0);
79+ renderer.set_viewport(view_area);
80+}
81+
82+TEST_F(GLRenderer, unchanged_viewport_updates_gl_if_rotated)
83+{ // Regression test for LP: #1672269
84+ int const screen_width = 1920;
85+ int const screen_height = 1080;
86+ mir::geometry::Rectangle const view_area{{0,0}, {1920,1080}};
87+
88+ ON_CALL(mock_egl, eglQuerySurface(_,_,EGL_WIDTH,_))
89+ .WillByDefault(DoAll(SetArgPointee<3>(screen_width),
90+ Return(EGL_TRUE)));
91+ ON_CALL(mock_egl, eglQuerySurface(_,_,EGL_HEIGHT,_))
92+ .WillByDefault(DoAll(SetArgPointee<3>(screen_height),
93+ Return(EGL_TRUE)));
94+ ON_CALL(mock_display_buffer, view_area())
95+ .WillByDefault(Return(view_area));
96+
97+ mrg::Renderer renderer(mock_display_buffer);
98+
99+ renderer.set_viewport(view_area);
100+
101+ EXPECT_CALL(mock_gl, glViewport(_,_,_,_))
102+ .Times(1);
103+ glm::mat2 const something_different{0,-1,
104+ 1, 0};
105+ renderer.set_output_transform(something_different);
106+ renderer.set_viewport(view_area);
107+}
108+
109 TEST_F(GLRenderer, sets_viewport_unscaled_exact)
110 {
111 int const screen_width = 1920;

Subscribers

People subscribed via source and target branches