Mir

Merge lp:~afrantzis/mir/multimonitor-misc-fixes into lp:~mir-team/mir/trunk

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 923
Proposed branch: lp:~afrantzis/mir/multimonitor-misc-fixes
Merge into: lp:~mir-team/mir/trunk
Diff against target: 151 lines (+63/-18)
5 files modified
include/server/mir/compositor/gl_renderer_factory.h (+5/-0)
src/server/compositor/gl_renderer_factory.cpp (+8/-0)
src/server/graphics/gbm/gbm_cursor.cpp (+29/-18)
src/server/graphics/gbm/gbm_cursor.h (+2/-0)
tests/unit-tests/graphics/gbm/test_gbm_cursor.cpp (+19/-0)
To merge this branch: bzr merge lp:~afrantzis/mir/multimonitor-misc-fixes
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+178219@code.launchpad.net

Commit message

gbm,compositor: Misc multimonitor related fixes

Description of the change

gbm,compositor: Misc multimonitor related fixes

This MP forces a reset of the cursor position and associated state when starting, and disallows concurrent creation of GLRenderers. See individual commits for more info.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

show_at_last_known_position() looks horribly like duplicated code with move_to() - there must be a more expressive way to differentiate the logic.

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

            auto dp = position - output_rect.top_left;
            output.move_cursor({dp.dx.as_int(), dp.dy.as_int()});

This (Displacement->Point) conversion looks like a common requirement. Maybe we should have a geom::change_origin() function to do it.

BTW Another way to write it is:

    auto displacement_of_output = geom::Point{} - output_rect.top_left;
    output.move_cursor(position + displacement_of_output);

Which keeps things at a higher level of abstraction.

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

I don't think either of the above are blockers - but won't top-approve as someone else might.

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

> show_at_last_known_position() looks horribly like duplicated code with move_to() - there must be a more expressive way to differentiate the logic.

Fixed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Spurious failure... resubmitting.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

90 + auto dp = position - output_rect.top_left;
91 + output.move_cursor({dp.dx.as_int(), dp.dy.as_int()});

I still prefer something like:

    auto change_of_origin = geom::Point{} - output_rect.top_left;
    output.move_cursor(position + change_of_origin);

But top-approving as no-one else cares.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/server/mir/compositor/gl_renderer_factory.h'
--- include/server/mir/compositor/gl_renderer_factory.h 2013-07-22 10:44:21 +0000
+++ include/server/mir/compositor/gl_renderer_factory.h 2013-08-02 10:56:25 +0000
@@ -21,6 +21,8 @@
2121
22#include "mir/compositor/renderer_factory.h"22#include "mir/compositor/renderer_factory.h"
2323
24#include <mutex>
25
24namespace mir26namespace mir
25{27{
26namespace compositor28namespace compositor
@@ -30,6 +32,9 @@
30{32{
31public:33public:
32 std::unique_ptr<Renderer> create_renderer_for(geometry::Rectangle const& rect);34 std::unique_ptr<Renderer> create_renderer_for(geometry::Rectangle const& rect);
35
36private:
37 std::mutex renderer_mutex;
33};38};
3439
35}40}
3641
=== modified file 'src/server/compositor/gl_renderer_factory.cpp'
--- src/server/compositor/gl_renderer_factory.cpp 2013-07-25 10:25:58 +0000
+++ src/server/compositor/gl_renderer_factory.cpp 2013-08-02 10:56:25 +0000
@@ -26,6 +26,14 @@
26std::unique_ptr<mc::Renderer>26std::unique_ptr<mc::Renderer>
27mc::GLRendererFactory::create_renderer_for(geom::Rectangle const& rect)27mc::GLRendererFactory::create_renderer_for(geom::Rectangle const& rect)
28{28{
29 /*
30 * We need to serialize renderer creation because some GL calls used
31 * during renderer construction that create unique resource ids
32 * (e.g. glCreateProgram) are not thread-safe when the threads are
33 * have the same or shared EGL contexts.
34 */
35 std::lock_guard<std::mutex> lg{renderer_mutex};
36
29 auto raw = new GLRenderer(rect);37 auto raw = new GLRenderer(rect);
30 return std::unique_ptr<mc::Renderer>(raw);38 return std::unique_ptr<mc::Renderer>(raw);
31}39}
3240
=== modified file 'src/server/graphics/gbm/gbm_cursor.cpp'
--- src/server/graphics/gbm/gbm_cursor.cpp 2013-07-30 14:23:10 +0000
+++ src/server/graphics/gbm/gbm_cursor.cpp 2013-08-02 10:56:25 +0000
@@ -88,28 +88,12 @@
8888
89void mgg::GBMCursor::move_to(geometry::Point position)89void mgg::GBMCursor::move_to(geometry::Point position)
90{90{
91 for_each_used_output([&](KMSOutput& output, geom::Rectangle const& output_rect)91 place_cursor_at(position, UpdateState);
92 {
93 if (output_rect.contains(position))
94 {
95 auto dp = position - output_rect.top_left;
96 output.move_cursor({dp.dx.as_int(), dp.dy.as_int()});
97 if (!output.has_cursor())
98 output.set_cursor(buffer);
99 }
100 else
101 {
102 if (output.has_cursor())
103 output.clear_cursor();
104 }
105 });
106
107 current_position = position;
108}92}
10993
110void mgg::GBMCursor::show_at_last_known_position()94void mgg::GBMCursor::show_at_last_known_position()
111{95{
112 move_to(current_position);96 place_cursor_at(current_position, ForceState);
113}97}
11498
115void mgg::GBMCursor::hide()99void mgg::GBMCursor::hide()
@@ -140,3 +124,30 @@
140 });124 });
141 });125 });
142}126}
127
128void mgg::GBMCursor::place_cursor_at(
129 geometry::Point position,
130 ForceCursorState force_state)
131{
132 for_each_used_output([&](KMSOutput& output, geom::Rectangle const& output_rect)
133 {
134 if (output_rect.contains(position))
135 {
136 auto dp = position - output_rect.top_left;
137 output.move_cursor({dp.dx.as_int(), dp.dy.as_int()});
138 if (force_state || !output.has_cursor())
139 {
140 output.set_cursor(buffer);
141 }
142 }
143 else
144 {
145 if (force_state || output.has_cursor())
146 {
147 output.clear_cursor();
148 }
149 }
150 });
151
152 current_position = position;
153}
143154
=== modified file 'src/server/graphics/gbm/gbm_cursor.h'
--- src/server/graphics/gbm/gbm_cursor.h 2013-07-30 14:23:10 +0000
+++ src/server/graphics/gbm/gbm_cursor.h 2013-08-02 10:56:25 +0000
@@ -72,7 +72,9 @@
72 void hide();72 void hide();
7373
74private:74private:
75 enum ForceCursorState { UpdateState, ForceState };
75 void for_each_used_output(std::function<void(KMSOutput&, geometry::Rectangle const&)> const& f);76 void for_each_used_output(std::function<void(KMSOutput&, geometry::Rectangle const&)> const& f);
77 void place_cursor_at(geometry::Point position, ForceCursorState force_state);
7678
77 KMSOutputContainer& output_container;79 KMSOutputContainer& output_container;
78 geometry::Point current_position;80 geometry::Point current_position;
7981
=== modified file 'tests/unit-tests/graphics/gbm/test_gbm_cursor.cpp'
--- tests/unit-tests/graphics/gbm/test_gbm_cursor.cpp 2013-07-30 14:23:10 +0000
+++ tests/unit-tests/graphics/gbm/test_gbm_cursor.cpp 2013-08-02 10:56:25 +0000
@@ -215,6 +215,25 @@
215 , std::logic_error);215 , std::logic_error);
216}216}
217217
218TEST_F(GBMCursorTest, forces_cursor_state_on_construction)
219{
220 using namespace testing;
221
222 EXPECT_CALL(*output_container.outputs[10], move_cursor(geom::Point{0,0}));
223 EXPECT_CALL(*output_container.outputs[10], set_cursor(_));
224 EXPECT_CALL(*output_container.outputs[11], clear_cursor());
225
226 /* No checking of existing cursor state */
227 EXPECT_CALL(*output_container.outputs[10], has_cursor()).Times(0);
228 EXPECT_CALL(*output_container.outputs[11], has_cursor()).Times(0);
229
230 mgg::GBMCursor cursor_tmp{mock_gbm.fake_gbm.device, output_container,
231 std::make_shared<StubCurrentConfiguration>()};
232
233 output_container.verify_and_clear_expectations();
234}
235
236
218TEST_F(GBMCursorTest, move_to_sets_clears_cursor_if_needed)237TEST_F(GBMCursorTest, move_to_sets_clears_cursor_if_needed)
219{238{
220 using namespace testing;239 using namespace testing;

Subscribers

People subscribed via source and target branches