Mir

Merge lp:~kdub/mir/android-physical-size into lp:mir

Proposed by Kevin DuBois
Status: Merged
Approved by: Kevin DuBois
Approved revision: no longer in the source branch.
Merged at revision: 2386
Proposed branch: lp:~kdub/mir/android-physical-size
Merge into: lp:mir
Diff against target: 131 lines (+43/-14)
2 files modified
src/platforms/android/server/hwc_blanking_control.cpp (+14/-1)
tests/unit-tests/graphics/android/test_hwc_configuration.cpp (+29/-13)
To merge this branch: bzr merge lp:~kdub/mir/android-physical-size
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Chris Halse Rogers Approve
Daniel van Vugt Approve
Alan Griffiths Approve
Robert Carr (community) Approve
Review via email: mp+252338@code.launchpad.net

Commit message

android: pass the reported physical size of the display from the driver to the rest of the mir system.

fixes: lp: #1430315

Description of the change

android: pass the reported physical size of the display from the driver to the rest of the mir system.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Mostly OK. But...

72 -TEST_F(HwcConfiguration, no_fpe_from_malformed_refresh)
73 +TEST_F(HwcConfiguration, no_fpe_from_malformed_refresh_or_dpi)

"no_fpe_from_malformed_refresh_or_dpi" is a bit hard to parse (especially as what the test does).

"no_fpe_or_dpi_from_malformed_refresh" is probably better, but breaks the "one test per condition" rule.

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

LGTM

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

failure looks unrelated, filed: https://bugs.launchpad.net/mir/+bug/1430000

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: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Cool. If you can however, try using or extending "mir/geometry/length.h" instead of:

10 +int dpi_to_mm(uint32_t dpi, int pixel_num)

Suggest fixing, not needs fixing.

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

OK

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

The above http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-mako/4560/console build was aborted due to an unbootable image making it into the pipeline. The build has been restarted.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Looks sensible, to the extent that Android allows you to be. Do you really have to calculate display size from DPI?

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Judging by the HWC API, yes it probably does need to be done this way.

Although in hindsight, this particular case allows for very little utilization of mir::geometry::Length.

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 :
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
1=== modified file 'src/platforms/android/server/hwc_blanking_control.cpp'
2--- src/platforms/android/server/hwc_blanking_control.cpp 2015-03-05 05:47:28 +0000
3+++ src/platforms/android/server/hwc_blanking_control.cpp 2015-03-10 19:31:31 +0000
4@@ -20,6 +20,7 @@
5 #include "hwc_wrapper.h"
6 #include "mir/raii.h"
7 #include "android_format_conversion-inl.h"
8+#include "mir/geometry/length.h"
9 #include <EGL/egl.h>
10 #include <EGL/eglext.h>
11 #include <boost/throw_exception.hpp>
12@@ -27,6 +28,7 @@
13 #include <chrono>
14
15 namespace mga = mir::graphics::android;
16+namespace geom = mir::geometry;
17
18 namespace
19 {
20@@ -100,6 +102,17 @@
21 }
22 }
23
24+namespace
25+{
26+int dpi_to_mm(uint32_t dpi, int pixel_num)
27+{
28+ if (dpi == 0) return 0;
29+ float dpi_inches = dpi / 1000.0f; //android multiplies by 1000
30+ geom::Length length(pixel_num / dpi_inches, geom::Length::Units::inches);
31+ return length.as(geom::Length::Units::millimetres);
32+}
33+}
34+
35 mga::DisplayAttribs mga::HwcBlankingControl::active_attribs_for(DisplayName display_name)
36 {
37 auto configs = hwc_device->display_configs(display_name);
38@@ -137,7 +150,7 @@
39
40 return {
41 {values[0], values[1]},
42- {0, 0}, //TODO: convert DPI to MM and return
43+ {dpi_to_mm(values[3], values[0]), dpi_to_mm(values[4], values[1])},
44 period_to_hz(std::chrono::nanoseconds{values[2]}),
45 true,
46 format,
47
48=== modified file 'tests/unit-tests/graphics/android/test_hwc_configuration.cpp'
49--- tests/unit-tests/graphics/android/test_hwc_configuration.cpp 2015-03-05 05:47:28 +0000
50+++ tests/unit-tests/graphics/android/test_hwc_configuration.cpp 2015-03-10 19:31:31 +0000
51@@ -128,7 +128,10 @@
52 TEST_F(HwcConfiguration, queries_connected_primary_display_properties)
53 {
54 using namespace testing;
55- geom::Size px_size {343, 254};
56+ auto android_reported_dpi_x = 390000u;
57+ auto android_reported_dpi_y = 400000u;
58+ geom::Size px_size {768, 1280};
59+ geom::Size mm_size {50, 81};
60
61 std::vector<mga::ConfigId> hwc_config {mga::ConfigId{0xA1}, mga::ConfigId{0xBEE}};
62 std::chrono::milliseconds vrefresh_period {16};
63@@ -153,6 +156,12 @@
64 case HWC_DISPLAY_VSYNC_PERIOD:
65 values[i] = std::chrono::duration_cast<std::chrono::nanoseconds>(vrefresh_period).count();
66 break;
67+ case HWC_DISPLAY_DPI_X:
68+ values[i] = android_reported_dpi_x;
69+ break;
70+ case HWC_DISPLAY_DPI_Y:
71+ values[i] = android_reported_dpi_y;
72+ break;
73 default:
74 break;
75 }
76@@ -166,6 +175,7 @@
77 auto vrefresh_hz = 1000.0 / vrefresh_period.count();
78 auto attribs = config.active_attribs_for(display);
79 EXPECT_THAT(attribs.pixel_size, Eq(px_size));
80+ EXPECT_THAT(attribs.mm_size, Eq(mm_size));
81 EXPECT_THAT(attribs.vrefresh_hz, Eq(vrefresh_hz));
82 EXPECT_TRUE(attribs.connected);
83 }
84@@ -205,29 +215,35 @@
85 TEST_F(HwcConfiguration, no_fpe_from_malformed_refresh)
86 {
87 using namespace testing;
88- EXPECT_CALL(*mock_hwc_wrapper, display_attributes( _, _, _, _))
89+ EXPECT_CALL(*mock_hwc_wrapper, display_attributes(_,_,_,_))
90 .WillOnce(Invoke([]
91 (mga::DisplayName, mga::ConfigId, uint32_t const* attribute_list, int32_t* values)
92 {
93 int i = 0;
94 while(attribute_list[i] != HWC_DISPLAY_NO_ATTRIBUTE)
95- {
96- switch(attribute_list[i])
97- {
98- case HWC_DISPLAY_VSYNC_PERIOD:
99- values[i] = 0;
100- break;
101- default:
102- break;
103- }
104- i++;
105- }
106+ values[i++] = 0;
107 return 0;
108 }));
109 auto attribs = config.active_attribs_for(mga::DisplayName::external);
110 EXPECT_THAT(attribs.vrefresh_hz, Eq(0.0f));
111 }
112
113+TEST_F(HwcConfiguration, no_fpe_from_malformed_dpi)
114+{
115+ using namespace testing;
116+ EXPECT_CALL(*mock_hwc_wrapper, display_attributes(_,_,_,_))
117+ .WillOnce(Invoke([]
118+ (mga::DisplayName, mga::ConfigId, uint32_t const* attribute_list, int32_t* values)
119+ {
120+ int i = 0;
121+ while(attribute_list[i] != HWC_DISPLAY_NO_ATTRIBUTE)
122+ values[i++] = 0;
123+ return 0;
124+ }));
125+ auto attribs = config.active_attribs_for(mga::DisplayName::external);
126+ EXPECT_THAT(attribs.mm_size, Eq(geom::Size{0,0}));
127+}
128+
129 TEST_F(HwcConfiguration, subscribes_to_hotplug_and_vsync)
130 {
131 using namespace testing;

Subscribers

People subscribed via source and target branches