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
=== modified file 'src/renderers/gl/renderer.cpp'
--- src/renderers/gl/renderer.cpp 2017-03-16 04:08:46 +0000
+++ src/renderers/gl/renderer.cpp 2017-03-21 09:09:36 +0000
@@ -372,12 +372,18 @@
372 0.0f});372 0.0f});
373373
374 viewport = rect;374 viewport = rect;
375 update_gl_viewport();
376}
375377
378void mrg::Renderer::update_gl_viewport()
379{
376 /*380 /*
377 * Letterboxing: Move the glViewport to add black bars in the case that381 * Letterboxing: Move the glViewport to add black bars in the case that
378 * the logical viewport aspect ratio doesn't match the display aspect.382 * the logical viewport aspect ratio doesn't match the display aspect.
379 * This keeps pixels square. Note "black"-bars are really glClearColor.383 * This keeps pixels square. Note "black"-bars are really glClearColor.
380 */384 */
385 render_target.ensure_current();
386
381 auto transformed_viewport = display_transform *387 auto transformed_viewport = display_transform *
382 glm::vec4(viewport.size.width.as_int(),388 glm::vec4(viewport.size.width.as_int(),
383 viewport.size.height.as_int(), 0, 1);389 viewport.size.height.as_int(), 0, 1);
@@ -407,7 +413,12 @@
407413
408void mrg::Renderer::set_output_transform(glm::mat2 const& t)414void mrg::Renderer::set_output_transform(glm::mat2 const& t)
409{415{
410 display_transform = glm::mat4(t);416 auto const new_display_transform = glm::mat4(t);
417 if (new_display_transform != display_transform)
418 {
419 display_transform = new_display_transform;
420 update_gl_viewport();
421 }
411}422}
412423
413void mrg::Renderer::suspend()424void mrg::Renderer::suspend()
414425
=== modified file 'src/renderers/gl/renderer.h'
--- src/renderers/gl/renderer.h 2017-01-27 08:13:36 +0000
+++ src/renderers/gl/renderer.h 2017-03-21 09:09:36 +0000
@@ -123,6 +123,8 @@
123 Renderer::Program const& prog) const;123 Renderer::Program const& prog) const;
124124
125private:125private:
126 void update_gl_viewport();
127
126 std::unique_ptr<mir::gl::TextureCache> const texture_cache;128 std::unique_ptr<mir::gl::TextureCache> const texture_cache;
127 geometry::Rectangle viewport;129 geometry::Rectangle viewport;
128 glm::mat4 screen_to_gl_coords;130 glm::mat4 screen_to_gl_coords;
129131
=== modified file 'tests/unit-tests/renderers/gl/test_gl_renderer.cpp'
--- tests/unit-tests/renderers/gl/test_gl_renderer.cpp 2017-02-15 10:17:21 +0000
+++ tests/unit-tests/renderers/gl/test_gl_renderer.cpp 2017-03-21 09:09:36 +0000
@@ -316,6 +316,57 @@
316 renderer.render(renderable_list);316 renderer.render(renderable_list);
317}317}
318318
319TEST_F(GLRenderer, unchanged_viewport_avoids_gl_calls)
320{
321 int const screen_width = 1920;
322 int const screen_height = 1080;
323 mir::geometry::Rectangle const view_area{{0,0}, {1920,1080}};
324
325 ON_CALL(mock_egl, eglQuerySurface(_,_,EGL_WIDTH,_))
326 .WillByDefault(DoAll(SetArgPointee<3>(screen_width),
327 Return(EGL_TRUE)));
328 ON_CALL(mock_egl, eglQuerySurface(_,_,EGL_HEIGHT,_))
329 .WillByDefault(DoAll(SetArgPointee<3>(screen_height),
330 Return(EGL_TRUE)));
331 ON_CALL(mock_display_buffer, view_area())
332 .WillByDefault(Return(view_area));
333
334 mrg::Renderer renderer(mock_display_buffer);
335
336 renderer.set_viewport(view_area);
337
338 EXPECT_CALL(mock_gl, glViewport(_,_,_,_))
339 .Times(0);
340 renderer.set_viewport(view_area);
341}
342
343TEST_F(GLRenderer, unchanged_viewport_updates_gl_if_rotated)
344{ // Regression test for LP: #1672269
345 int const screen_width = 1920;
346 int const screen_height = 1080;
347 mir::geometry::Rectangle const view_area{{0,0}, {1920,1080}};
348
349 ON_CALL(mock_egl, eglQuerySurface(_,_,EGL_WIDTH,_))
350 .WillByDefault(DoAll(SetArgPointee<3>(screen_width),
351 Return(EGL_TRUE)));
352 ON_CALL(mock_egl, eglQuerySurface(_,_,EGL_HEIGHT,_))
353 .WillByDefault(DoAll(SetArgPointee<3>(screen_height),
354 Return(EGL_TRUE)));
355 ON_CALL(mock_display_buffer, view_area())
356 .WillByDefault(Return(view_area));
357
358 mrg::Renderer renderer(mock_display_buffer);
359
360 renderer.set_viewport(view_area);
361
362 EXPECT_CALL(mock_gl, glViewport(_,_,_,_))
363 .Times(1);
364 glm::mat2 const something_different{0,-1,
365 1, 0};
366 renderer.set_output_transform(something_different);
367 renderer.set_viewport(view_area);
368}
369
319TEST_F(GLRenderer, sets_viewport_unscaled_exact)370TEST_F(GLRenderer, sets_viewport_unscaled_exact)
320{371{
321 int const screen_width = 1920;372 int const screen_width = 1920;

Subscribers

People subscribed via source and target branches