Merge lp:~albaguirre/mir/fix-1656164 into lp:mir
- fix-1656164
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Daniel van Vugt |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3948 |
Proposed branch: | lp:~albaguirre/mir/fix-1656164 |
Merge into: | lp:mir |
Diff against target: |
255 lines (+85/-48) 7 files modified
include/platform/mir/graphics/gamma_curves.h (+11/-0) src/platform/graphics/gamma_curves.cpp (+22/-0) src/platform/symbols.map (+1/-0) src/platforms/mesa/server/kms/real_kms_display_configuration.cpp (+2/-21) src/platforms/mesa/server/kms/real_kms_display_configuration.h (+0/-1) tests/unit-tests/graphics/test_gamma_curves.cpp (+49/-20) tests/unit-tests/platforms/mesa/kms/test_display.cpp (+0/-6) |
To merge this branch: | bzr merge lp:~albaguirre/mir/fix-1656164 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir CI Bot | continuous-integration | Approve | |
Daniel van Vugt | Approve | ||
Brandon Schaefer (community) | Approve | ||
Review via email: mp+314776@code.launchpad.net |
Commit message
Initialize gamma LUTs with a linear ramp.
drmModeCrtcGetGamma does not query the h/w; instead it simply returns
the previous set configured with drmModeCrtcSetGamma or zeros if
drmModeCrtcSetGamma has not been previously called. (LP: #1656164)
Description of the change
Mir CI Bot (mir-ci-bot) wrote : | # |
Brandon Schaefer (brandontschaefer) wrote : | # |
nit
+26 LinearGammaLUTs(int size);
Should be explicit
Daniel van Vugt (vanvugt) wrote : | # |
(1) A gamma size of 1 is going to throw an exception (which we are close to fixing already so probably should):
50 + if (size < 2)
51 + BOOST_THROW_
121 + if (crtc->gamma_size > 0)
122 + gamma = mg::LinearGamma
(2) For more advanced desktop drivers which might have a nonlinear ramp already set, won't this clobber it?
Alberto Aguirre (albaguirre) wrote : | # |
> (1) A gamma size of 1 is going to throw an exception (which we are close to
> fixing already so probably should):
>
> 50 + if (size < 2)
> 51 + BOOST_THROW_
> small"));
>
Yes a size of 1 should throw otherwise you'd get a division by zero.
> 121 + if (crtc->gamma_size > 0)
> 122 + gamma = mg::LinearGamma
>
> (2) For more advanced desktop drivers which might have a nonlinear ramp
> already set, won't this clobber it?
Yeah but that's pre-existing behavior given the current design of drmModeCrtcGetG
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3936
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3936
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Brandon Schaefer (brandontschaefer) wrote : | # |
[ FAILED ] ApplicationNotR
Daniel van Vugt (vanvugt) wrote : | # |
I mean that we should only throw exceptions for things we don't know how to handle. We probably know how to handle the problem of a length 1 table... just log a warning/error and ignore it.
Daniel van Vugt (vanvugt) wrote : | # |
Although... this probably falls into the bucket of things that might go wrong during display config changes. So yeah expect an exception in that case.
Mir CI Bot (mir-ci-bot) : | # |
Preview Diff
1 | === modified file 'include/platform/mir/graphics/gamma_curves.h' |
2 | --- include/platform/mir/graphics/gamma_curves.h 2016-10-31 02:37:31 +0000 |
3 | +++ include/platform/mir/graphics/gamma_curves.h 2017-01-16 15:30:49 +0000 |
4 | @@ -33,16 +33,27 @@ |
5 | { |
6 | public: |
7 | GammaCurves() = default; |
8 | + GammaCurves(GammaCurves const& other) = default; |
9 | + GammaCurves(GammaCurves&& other) = default; |
10 | |
11 | GammaCurves(GammaCurve const& red, |
12 | GammaCurve const& green, |
13 | GammaCurve const& blue); |
14 | |
15 | + GammaCurves& operator=(GammaCurves const& other) = default; |
16 | + GammaCurves& operator=(GammaCurves&& other) = default; |
17 | + |
18 | GammaCurve red; |
19 | GammaCurve green; |
20 | GammaCurve blue; |
21 | }; |
22 | |
23 | +class LinearGammaLUTs : public GammaCurves |
24 | +{ |
25 | +public: |
26 | + explicit LinearGammaLUTs(int size); |
27 | +}; |
28 | + |
29 | } |
30 | } |
31 | |
32 | |
33 | === modified file 'src/platform/graphics/gamma_curves.cpp' |
34 | --- src/platform/graphics/gamma_curves.cpp 2016-10-31 02:37:31 +0000 |
35 | +++ src/platform/graphics/gamma_curves.cpp 2017-01-16 15:30:49 +0000 |
36 | @@ -19,10 +19,27 @@ |
37 | #include "mir/graphics/gamma_curves.h" |
38 | |
39 | #include <boost/throw_exception.hpp> |
40 | + |
41 | +#include <algorithm> |
42 | #include <stdexcept> |
43 | |
44 | namespace mg = mir::graphics; |
45 | |
46 | +namespace |
47 | +{ |
48 | +mg::GammaCurves make_linear_ramp(int size) |
49 | +{ |
50 | + if (size < 2) |
51 | + BOOST_THROW_EXCEPTION(std::logic_error("gamma LUT size is too small")); |
52 | + |
53 | + mg::GammaCurve ramp(size); |
54 | + auto const step = std::numeric_limits<mg::GammaCurve::value_type>::max() / (size - 1); |
55 | + mg::GammaCurve::value_type n = 0; |
56 | + std::generate(ramp.begin(), ramp.end(), [&n, step]{ auto current = n; n += step; return current; }); |
57 | + |
58 | + return {ramp, ramp, ramp}; |
59 | +} |
60 | +} |
61 | mg::GammaCurves::GammaCurves(GammaCurve const& red, |
62 | GammaCurve const& green, |
63 | GammaCurve const& blue) : |
64 | @@ -36,3 +53,8 @@ |
65 | BOOST_THROW_EXCEPTION(std::logic_error("Different gamma LUT sizes")); |
66 | } |
67 | } |
68 | + |
69 | +mg::LinearGammaLUTs::LinearGammaLUTs(int size) |
70 | + : GammaCurves(make_linear_ramp(size)) |
71 | +{ |
72 | +} |
73 | |
74 | === modified file 'src/platform/symbols.map' |
75 | --- src/platform/symbols.map 2016-11-16 13:24:41 +0000 |
76 | +++ src/platform/symbols.map 2017-01-16 15:30:49 +0000 |
77 | @@ -67,6 +67,7 @@ |
78 | mir::graphics::GraphicBufferAllocator::GraphicBufferAllocator*; |
79 | mir::graphics::GraphicBufferAllocator::operator*; |
80 | mir::graphics::GraphicBufferAllocator::supported_pixel_formats*; |
81 | + mir::graphics::LinearGammaLUTs::LinearGammaLUTs*; |
82 | mir::graphics::module_for_device*; |
83 | mir::graphics::operator*; |
84 | mir::graphics::Platform::create_buffer_allocator*; |
85 | |
86 | === modified file 'src/platforms/mesa/server/kms/real_kms_display_configuration.cpp' |
87 | --- src/platforms/mesa/server/kms/real_kms_display_configuration.cpp 2016-12-09 02:54:31 +0000 |
88 | +++ src/platforms/mesa/server/kms/real_kms_display_configuration.cpp 2017-01-16 15:30:49 +0000 |
89 | @@ -179,26 +179,6 @@ |
90 | return conf_mode_index; |
91 | } |
92 | |
93 | -mg::GammaCurves mgm::RealKMSDisplayConfiguration::get_drm_gamma( |
94 | - drmModeCrtc const* crtc) const |
95 | -{ |
96 | - uint32_t gamma_size = crtc->gamma_size; |
97 | - uint16_t red[gamma_size]; |
98 | - uint16_t green[gamma_size]; |
99 | - uint16_t blue[gamma_size]; |
100 | - |
101 | - int ret; |
102 | - if ((ret = drmModeCrtcGetGamma(drm_fd, crtc->crtc_id, gamma_size, red, green, blue)) != 0) |
103 | - { |
104 | - BOOST_THROW_EXCEPTION( |
105 | - std::system_error(errno, std::system_category(), "drmModeCrtcGetGamma Failed")); |
106 | - } |
107 | - |
108 | - return {GammaCurve(red, red + gamma_size), |
109 | - GammaCurve(green, green + gamma_size), |
110 | - GammaCurve(blue, blue + gamma_size)}; |
111 | -} |
112 | - |
113 | void mgm::RealKMSDisplayConfiguration::update() |
114 | { |
115 | kms::DRMModeResources resources{drm_fd}; |
116 | @@ -327,7 +307,8 @@ |
117 | current_mode_info = resources.crtc(encoder->crtc_id)->mode; |
118 | |
119 | auto crtc = resources.crtc(encoder->crtc_id); |
120 | - gamma = get_drm_gamma(crtc.get()); |
121 | + if (crtc->gamma_size > 0) |
122 | + gamma = mg::LinearGammaLUTs(crtc->gamma_size); |
123 | } |
124 | } |
125 | |
126 | |
127 | === modified file 'src/platforms/mesa/server/kms/real_kms_display_configuration.h' |
128 | --- src/platforms/mesa/server/kms/real_kms_display_configuration.h 2016-10-12 06:03:15 +0000 |
129 | +++ src/platforms/mesa/server/kms/real_kms_display_configuration.h 2017-01-16 15:30:49 +0000 |
130 | @@ -53,7 +53,6 @@ |
131 | void add_or_update_output(kms::DRMModeResources const& resources, drmModeConnector const& connector); |
132 | std::vector<DisplayConfigurationOutput>::iterator find_output_with_id(DisplayConfigurationOutputId id); |
133 | std::vector<DisplayConfigurationOutput>::const_iterator find_output_with_id(DisplayConfigurationOutputId id) const; |
134 | - GammaCurves get_drm_gamma(drmModeCrtc const* crtc) const; |
135 | |
136 | int drm_fd; |
137 | DisplayConfigurationCard card; |
138 | |
139 | === modified file 'tests/unit-tests/graphics/test_gamma_curves.cpp' |
140 | --- tests/unit-tests/graphics/test_gamma_curves.cpp 2016-09-27 08:16:43 +0000 |
141 | +++ tests/unit-tests/graphics/test_gamma_curves.cpp 2017-01-16 15:30:49 +0000 |
142 | @@ -21,47 +21,76 @@ |
143 | #include <gtest/gtest.h> |
144 | #include <gmock/gmock.h> |
145 | |
146 | +#include <algorithm> |
147 | + |
148 | namespace mg = mir::graphics; |
149 | |
150 | namespace |
151 | { |
152 | -mg::GammaCurve const r{1}; |
153 | -mg::GammaCurve const g{2}; |
154 | -mg::GammaCurve const b{3}; |
155 | -} |
156 | - |
157 | -class MockGammaCurves : public testing::Test |
158 | +MATCHER(IsMonotonicallyIncreasing, "") |
159 | +{ |
160 | + return std::is_sorted(std::begin(arg), std::end(arg)); |
161 | +} |
162 | +} |
163 | +class GammaCurves : public testing::Test |
164 | { |
165 | public: |
166 | - MockGammaCurves() : |
167 | - gamma(r, g, b) |
168 | - { |
169 | - } |
170 | - |
171 | - mg::GammaCurves gamma; |
172 | + mg::GammaCurve const r{1}; |
173 | + mg::GammaCurve const g{2}; |
174 | + mg::GammaCurve const b{3}; |
175 | + mg::GammaCurves gamma{r, g, b}; |
176 | }; |
177 | |
178 | -TEST_F(MockGammaCurves, test_uint16_gamma_curves_size) |
179 | +TEST_F(GammaCurves, have_correct_size) |
180 | { |
181 | EXPECT_THAT(gamma.red.size(), r.size()); |
182 | + EXPECT_THAT(gamma.green.size(), g.size()); |
183 | + EXPECT_THAT(gamma.blue.size(), b.size()); |
184 | } |
185 | |
186 | -TEST_F(MockGammaCurves, test_uint16_gamma_curves_rgb_correct) |
187 | +TEST_F(GammaCurves, have_expected_content) |
188 | { |
189 | - ASSERT_THAT(gamma.red.size(), r.size()); |
190 | - EXPECT_THAT(gamma.red[0], r[0]); |
191 | - EXPECT_THAT(gamma.green[0], g[0]); |
192 | - EXPECT_THAT(gamma.blue[0], b[0]); |
193 | + using namespace testing; |
194 | + EXPECT_THAT(gamma.red, ContainerEq(r)); |
195 | + EXPECT_THAT(gamma.green, ContainerEq(g)); |
196 | + EXPECT_THAT(gamma.blue, ContainerEq(b)); |
197 | } |
198 | |
199 | -TEST(GammaCurvesEmpty, test_gamma_curves_empty) |
200 | +TEST_F(GammaCurves, are_empty_by_default) |
201 | { |
202 | mg::GammaCurves gamma; |
203 | |
204 | EXPECT_THAT(gamma.red.size(), 0); |
205 | + EXPECT_THAT(gamma.green.size(), 0); |
206 | + EXPECT_THAT(gamma.blue.size(), 0); |
207 | } |
208 | |
209 | -TEST(GammaCurvesEmpty, test_invalid_lut_size_gamma_curves_throw) |
210 | +TEST_F(GammaCurves, throw_with_differing_lut_sizes) |
211 | { |
212 | EXPECT_THROW({ mg::GammaCurves({1}, {2, 3}, {4, 5, 6}); }, std::logic_error); |
213 | } |
214 | + |
215 | +TEST(LinearGammaLUTs, throw_when_size_is_too_small) |
216 | +{ |
217 | + EXPECT_THROW({ mg::LinearGammaLUTs(1); }, std::logic_error); |
218 | +} |
219 | + |
220 | +TEST(LinearGammaLUTs, have_expected_size) |
221 | +{ |
222 | + int const expected_size = 10; |
223 | + mg::LinearGammaLUTs luts(expected_size); |
224 | + |
225 | + EXPECT_THAT(luts.red.size(), expected_size); |
226 | + EXPECT_THAT(luts.green.size(), expected_size); |
227 | + EXPECT_THAT(luts.blue.size(), expected_size); |
228 | +} |
229 | + |
230 | +TEST(LinearGammaLUTs, is_monotonically_increasing) |
231 | +{ |
232 | + mg::LinearGammaLUTs luts(256); |
233 | + |
234 | + EXPECT_THAT(luts.red, IsMonotonicallyIncreasing()); |
235 | + EXPECT_THAT(luts.green, IsMonotonicallyIncreasing()); |
236 | + EXPECT_THAT(luts.blue, IsMonotonicallyIncreasing()); |
237 | +} |
238 | + |
239 | |
240 | === modified file 'tests/unit-tests/platforms/mesa/kms/test_display.cpp' |
241 | --- tests/unit-tests/platforms/mesa/kms/test_display.cpp 2016-11-11 07:56:09 +0000 |
242 | +++ tests/unit-tests/platforms/mesa/kms/test_display.cpp 2017-01-16 15:30:49 +0000 |
243 | @@ -234,12 +234,6 @@ |
244 | EXPECT_CALL(mock_gbm, gbm_surface_create(mock_gbm.fake_gbm.device,_,_,_,_)) |
245 | .Times(Exactly(1)); |
246 | |
247 | - /* Get the DRM gamma ramp */ |
248 | - EXPECT_CALL(mock_drm, drmModeCrtcGetGamma(mock_drm.fake_drm.fd(), |
249 | - crtc_id, fake.crtc.gamma_size, |
250 | - _, _, _)) |
251 | - .Times(Exactly(1)); |
252 | - |
253 | /* Create an EGL window surface backed by the gbm surface */ |
254 | EXPECT_CALL(mock_egl, eglCreateWindowSurface(mock_egl.fake_egl_display, |
255 | mock_egl.fake_configs[0], |
PASSED: Continuous integration, rev:3935 /mir-jenkins. ubuntu. com/job/ mir-ci/ 2702/ /mir-jenkins. ubuntu. com/job/ build-mir/ 3512 /mir-jenkins. ubuntu. com/job/ build-0- fetch/3580 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= vivid+overlay/ 3570 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial+ overlay/ 3570 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= zesty/3570 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= zesty/3539 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= zesty/3539/ artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial+ overlay/ 3539 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial+ overlay/ 3539/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= zesty/3539 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= zesty/3539/ artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= android, release= vivid+overlay/ 3539 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= android, release= vivid+overlay/ 3539/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= android, release= vivid+overlay/ 3539 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= android, release= vivid+overlay/ 3539/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial+ overlay/ 3539 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial+ overlay/ 3539/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /mir-jenkins. ubuntu. com/job/ mir-ci/ 2702/rebuild
https:/