Mir

Merge lp:~afrantzis/mir/expose-display-buffer-only-for-power-mode-on into lp:mir

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: no longer in the source branch.
Merged at revision: 1546
Proposed branch: lp:~afrantzis/mir/expose-display-buffer-only-for-power-mode-on
Merge into: lp:mir
Diff against target: 196 lines (+71/-4)
8 files modified
src/platform/graphics/android/android_display.cpp (+8/-1)
src/platform/graphics/android/android_display.h (+2/-0)
src/platform/graphics/mesa/display.cpp (+9/-1)
src/platform/graphics/overlapping_output_grouping.cpp (+1/-0)
tests/unit-tests/graphics/CMakeLists.txt (+1/-0)
tests/unit-tests/graphics/mesa/CMakeLists.txt (+0/-1)
tests/unit-tests/graphics/test_display.cpp (+23/-0)
tests/unit-tests/graphics/test_overlapping_output_grouping.cpp (+27/-1)
To merge this branch: bzr merge lp:~afrantzis/mir/expose-display-buffer-only-for-power-mode-on
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Kevin DuBois (community) Approve
Alberto Aguirre (community) Approve
Review via email: mp+214758@code.launchpad.net

Commit message

mesa,android: Expose display buffers only for outputs with mir_power_mode_on

Description of the change

mesa,android: Expose display buffers only for outputs with mir_power_mode_on

Exposing display buffers for inactive outputs is not only wasteful but can cause other problems/crashes depending on the platform.

This is part of the series to avoid blocking swap buffers for surfaces that are not rendered by the compositor.

Other MPs in the non-blocking eglSwapBuffers() series:
https://code.launchpad.net/~afrantzis/mir/non-blocking-swap-buffers/+merge/214755/+merge/214758
https://code.launchpad.net/~afrantzis/unity-system-compositor/non-blocking-swap-buffers/+merge/214759

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
Alberto Aguirre (albaguirre) wrote :

LGTM

review: Approve
Revision history for this message
Kevin DuBois (kdub) wrote :

might be pre-existing, but I think android needs some locking around the power_mode configuring and skipping the DisplayBuffer.

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

> might be pre-existing, but I think android needs some locking around the power_mode configuring and skipping the DisplayBuffer.

The problem is that we will be calling a callback with a lock held. We are doing the same in mesa/display.cpp though, so we might as well make the two backends equally susceptible to deadlock. Of course we could try to fix them both somehow, but I don't see any reasonable solution other than creating copies of the DisplayBuffers, which has its own set of problems.

Revision history for this message
Kevin DuBois (kdub) wrote :

> > might be pre-existing, but I think android needs some locking around the
> power_mode configuring and skipping the DisplayBuffer.
>
> The problem is that we will be calling a callback with a lock held. We are
> doing the same in mesa/display.cpp though, so we might as well make the two
> backends equally susceptible to deadlock. Of course we could try to fix them
> both somehow, but I don't see any reasonable solution other than creating
> copies of the DisplayBuffers, which has its own set of problems.

okay, looks good to me

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

Install these packages without verification? [y/N] Build timed out (after 60 minutes). Marking the build as failed.

seems safe to retrigger

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/platform/graphics/android/android_display.cpp'
--- src/platform/graphics/android/android_display.cpp 2014-03-27 13:38:00 +0000
+++ src/platform/graphics/android/android_display.cpp 2014-04-09 14:53:50 +0000
@@ -49,11 +49,16 @@
4949
50void mga::AndroidDisplay::for_each_display_buffer(std::function<void(mg::DisplayBuffer&)> const& f)50void mga::AndroidDisplay::for_each_display_buffer(std::function<void(mg::DisplayBuffer&)> const& f)
51{51{
52 f(*display_buffer);52 std::lock_guard<decltype(configuration_mutex)> lock{configuration_mutex};
53
54 if (display_buffer->configuration().power_mode == mir_power_mode_on)
55 f(*display_buffer);
53}56}
5457
55std::unique_ptr<mg::DisplayConfiguration> mga::AndroidDisplay::configuration() const58std::unique_ptr<mg::DisplayConfiguration> mga::AndroidDisplay::configuration() const
56{59{
60 std::lock_guard<decltype(configuration_mutex)> lock{configuration_mutex};
61
57 return std::unique_ptr<mg::DisplayConfiguration>(62 return std::unique_ptr<mg::DisplayConfiguration>(
58 new mga::AndroidDisplayConfiguration(display_buffer->configuration()));63 new mga::AndroidDisplayConfiguration(display_buffer->configuration()));
59}64}
@@ -66,6 +71,8 @@
66 std::logic_error("Invalid or inconsistent display configuration"));71 std::logic_error("Invalid or inconsistent display configuration"));
67 }72 }
6873
74 std::lock_guard<decltype(configuration_mutex)> lock{configuration_mutex};
75
69 configuration.for_each_output([&](mg::DisplayConfigurationOutput const& output)76 configuration.for_each_output([&](mg::DisplayConfigurationOutput const& output)
70 {77 {
71 display_buffer->configure(output);78 display_buffer->configure(output);
7279
=== modified file 'src/platform/graphics/android/android_display.h'
--- src/platform/graphics/android/android_display.h 2014-03-27 13:38:00 +0000
+++ src/platform/graphics/android/android_display.h 2014-04-09 14:53:50 +0000
@@ -23,6 +23,7 @@
23#include "gl_context.h"23#include "gl_context.h"
2424
25#include <memory>25#include <memory>
26#include <mutex>
2627
27namespace mir28namespace mir
28{29{
@@ -68,6 +69,7 @@
68private:69private:
69 std::shared_ptr<DisplayBuilder> const display_builder;70 std::shared_ptr<DisplayBuilder> const display_builder;
70 GLContext gl_context;71 GLContext gl_context;
72 mutable std::mutex configuration_mutex;
7173
72 //we only have a primary display at the moment74 //we only have a primary display at the moment
73 std::unique_ptr<ConfigurableDisplayBuffer> const display_buffer;75 std::unique_ptr<ConfigurableDisplayBuffer> const display_buffer;
7476
=== modified file 'src/platform/graphics/mesa/display.cpp'
--- src/platform/graphics/mesa/display.cpp 2014-03-27 09:52:04 +0000
+++ src/platform/graphics/mesa/display.cpp 2014-04-09 14:53:50 +0000
@@ -337,11 +337,19 @@
337{337{
338 current_display_configuration.for_each_output([&](DisplayConfigurationOutput const& conf_output)338 current_display_configuration.for_each_output([&](DisplayConfigurationOutput const& conf_output)
339 {339 {
340 if (conf_output.connected && !conf_output.used)340 /*
341 * An output may be unused either because it's explicitly not used
342 * (DisplayConfigurationOutput::used) or because its power mode is
343 * not mir_power_mode_on.
344 */
345 if (conf_output.connected &&
346 (!conf_output.used || (conf_output.power_mode != mir_power_mode_on)))
341 {347 {
342 uint32_t const connector_id = current_display_configuration.get_kms_connector_id(conf_output.id);348 uint32_t const connector_id = current_display_configuration.get_kms_connector_id(conf_output.id);
343 auto kms_output = output_container.get_kms_output_for(connector_id);349 auto kms_output = output_container.get_kms_output_for(connector_id);
350
344 kms_output->clear_crtc();351 kms_output->clear_crtc();
352 kms_output->set_power_mode(conf_output.power_mode);
345 }353 }
346 });354 });
347}355}
348356
=== modified file 'src/platform/graphics/overlapping_output_grouping.cpp'
--- src/platform/graphics/overlapping_output_grouping.cpp 2014-03-10 03:02:32 +0000
+++ src/platform/graphics/overlapping_output_grouping.cpp 2014-04-09 14:53:50 +0000
@@ -76,6 +76,7 @@
76 conf.for_each_output([&](DisplayConfigurationOutput const& conf_output)76 conf.for_each_output([&](DisplayConfigurationOutput const& conf_output)
77 {77 {
78 if (conf_output.connected && conf_output.used &&78 if (conf_output.connected && conf_output.used &&
79 conf_output.power_mode == mir_power_mode_on &&
79 conf_output.current_mode_index < conf_output.modes.size())80 conf_output.current_mode_index < conf_output.modes.size())
80 {81 {
81 add_output(conf_output);82 add_output(conf_output);
8283
=== modified file 'tests/unit-tests/graphics/CMakeLists.txt'
--- tests/unit-tests/graphics/CMakeLists.txt 2014-03-12 02:46:58 +0000
+++ tests/unit-tests/graphics/CMakeLists.txt 2014-04-09 14:53:50 +0000
@@ -8,6 +8,7 @@
8 ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_properties.cpp8 ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_properties.cpp
9 ${CMAKE_CURRENT_SOURCE_DIR}/test_pixel_format_utils.cpp9 ${CMAKE_CURRENT_SOURCE_DIR}/test_pixel_format_utils.cpp
10 ${CMAKE_CURRENT_SOURCE_DIR}/test_surfaceless_egl_context.cpp10 ${CMAKE_CURRENT_SOURCE_DIR}/test_surfaceless_egl_context.cpp
11 ${CMAKE_CURRENT_SOURCE_DIR}/test_overlapping_output_grouping.cpp
11)12)
1213
13add_subdirectory(nested/)14add_subdirectory(nested/)
1415
=== modified file 'tests/unit-tests/graphics/mesa/CMakeLists.txt'
--- tests/unit-tests/graphics/mesa/CMakeLists.txt 2014-03-06 06:05:17 +0000
+++ tests/unit-tests/graphics/mesa/CMakeLists.txt 2014-04-09 14:53:50 +0000
@@ -12,7 +12,6 @@
12 ${CMAKE_CURRENT_SOURCE_DIR}/test_linux_virtual_terminal.cpp12 ${CMAKE_CURRENT_SOURCE_DIR}/test_linux_virtual_terminal.cpp
13 ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_native_display.cpp13 ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_native_display.cpp
14 ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_native_surface.cpp14 ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_native_surface.cpp
15 ${CMAKE_CURRENT_SOURCE_DIR}/test_overlapping_output_grouping.cpp
16 ${CMAKE_CURRENT_SOURCE_DIR}/test_cursor.cpp15 ${CMAKE_CURRENT_SOURCE_DIR}/test_cursor.cpp
17 ${CMAKE_CURRENT_SOURCE_DIR}/test_native_platform.cpp16 ${CMAKE_CURRENT_SOURCE_DIR}/test_native_platform.cpp
18 ${CMAKE_CURRENT_SOURCE_DIR}/test_anonymous_shm_file.cpp17 ${CMAKE_CURRENT_SOURCE_DIR}/test_anonymous_shm_file.cpp
1918
=== modified file 'tests/unit-tests/graphics/test_display.cpp'
--- tests/unit-tests/graphics/test_display.cpp 2014-03-27 09:52:04 +0000
+++ tests/unit-tests/graphics/test_display.cpp 2014-04-09 14:53:50 +0000
@@ -199,3 +199,26 @@
199 EXPECT_CALL(mock_egl, eglMakeCurrent(_,EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT))199 EXPECT_CALL(mock_egl, eglMakeCurrent(_,EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT))
200 .Times(AtLeast(0));200 .Times(AtLeast(0));
201}201}
202
203TEST_F(DisplayTest, does_not_expose_display_buffer_for_output_with_power_mode_off)
204{
205 using namespace testing;
206 auto display = create_display();
207 int db_count{0};
208
209 display->for_each_display_buffer([&] (mg::DisplayBuffer&) { ++db_count; });
210 EXPECT_THAT(db_count, Eq(1));
211
212 auto conf = display->configuration();
213 conf->for_each_output(
214 [] (mg::UserDisplayConfigurationOutput& output)
215 {
216 output.power_mode = mir_power_mode_off;
217 });
218
219 display->configure(*conf);
220
221 db_count = 0;
222 display->for_each_display_buffer([&] (mg::DisplayBuffer&) { ++db_count; });
223 EXPECT_THAT(db_count, Eq(0));
224}
202225
=== renamed file 'tests/unit-tests/graphics/mesa/test_overlapping_output_grouping.cpp' => 'tests/unit-tests/graphics/test_overlapping_output_grouping.cpp'
--- tests/unit-tests/graphics/mesa/test_overlapping_output_grouping.cpp 2014-03-26 05:48:59 +0000
+++ tests/unit-tests/graphics/test_overlapping_output_grouping.cpp 2014-04-09 14:53:50 +0000
@@ -37,10 +37,22 @@
37public:37public:
38 struct OutputInfo38 struct OutputInfo
39 {39 {
40 OutputInfo(
41 geom::Rectangle const& rect,
42 bool connected,
43 bool used,
44 MirOrientation orientation,
45 MirPowerMode power_mode = mir_power_mode_on)
46 : rect(rect), connected{connected}, used{used},
47 orientation{orientation}, power_mode{power_mode}
48 {
49 }
50
40 geom::Rectangle rect;51 geom::Rectangle rect;
41 bool connected;52 bool connected;
42 bool used;53 bool used;
43 MirOrientation orientation;54 MirOrientation orientation;
55 MirPowerMode power_mode;
44 };56 };
4557
46 StubDisplayConfiguration(std::vector<OutputInfo> const& info)58 StubDisplayConfiguration(std::vector<OutputInfo> const& info)
@@ -81,7 +93,7 @@
81 info.rect.top_left,93 info.rect.top_left,
82 i - 1,94 i - 1,
83 mir_pixel_format_invalid,95 mir_pixel_format_invalid,
84 mir_power_mode_on,96 info.power_mode,
85 info.orientation97 info.orientation
86 };98 };
8799
@@ -291,3 +303,17 @@
291303
292 check_groupings(info, expected_groups);304 check_groupings(info, expected_groups);
293}305}
306
307TEST_F(OverlappingOutputGroupingTest, ignores_outputs_with_power_mode_not_on)
308{
309 std::vector<StubDisplayConfiguration::OutputInfo> info
310 {
311 {{{0,0}, {100, 100}}, true, true, mir_orientation_normal, mir_power_mode_off},
312 {{{0,0}, {100, 100}}, true, true, mir_orientation_normal, mir_power_mode_standby},
313 {{{0,0}, {100, 100}}, true, true, mir_orientation_normal, mir_power_mode_suspend}
314 };
315
316 std::vector<geom::Rectangles> expected_groups;
317
318 check_groupings(info, expected_groups);
319}

Subscribers

People subscribed via source and target branches