Merge lp:unity-system-compositor/0.4 into lp:unity-system-compositor/ubuntu
- 0.4
- Merge into ubuntu
Proposed by
Thomas Voß
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Alexandros Frantzis | ||||
Approved revision: | 286 | ||||
Merged at revision: | 237 | ||||
Proposed branch: | lp:unity-system-compositor/0.4 | ||||
Merge into: | lp:unity-system-compositor/ubuntu | ||||
Diff against target: |
680 lines (+371/-5) 16 files modified
CMakeLists.txt (+6/-1) debian/changelog (+6/-0) debian/control (+1/-0) src/CMakeLists.txt (+13/-1) src/hw_performance_booster.cpp (+48/-0) src/hw_performance_booster.h (+44/-0) src/mir_screen.cpp (+7/-1) src/mir_screen.h (+4/-1) src/null_performance_booster.cpp (+28/-0) src/null_performance_booster.h (+34/-0) src/performance_booster.cpp (+52/-0) src/performance_booster.h (+41/-0) src/server.cpp (+12/-0) src/server.h (+2/-0) tests/integration-tests/test_deadlock_lp1491566.cpp (+7/-0) tests/unit-tests/test_mir_screen.cpp (+66/-1) |
||||
To merge this branch: | bzr merge lp:unity-system-compositor/0.4 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexandros Frantzis (community) | Approve | ||
Review via email: mp+289815@code.launchpad.net |
Commit message
Enable dynamic performance boosting whenever the screen is on.
Description of the change
Enable dynamic performance boosting whenever the screen is on.
To post a comment you must log in.
lp:unity-system-compositor/0.4
updated
- 286. By Thomas Voß
-
Bump minor revision.
Revision history for this message
Alexandros Frantzis (afrantzis) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2016-02-11 11:16:24 +0000 |
3 | +++ CMakeLists.txt 2016-03-23 09:41:12 +0000 |
4 | @@ -17,7 +17,7 @@ |
5 | project(UnitySystemCompositor) |
6 | set(USC_VERSION_MAJOR 0) |
7 | set(USC_VERSION_MINOR 4) |
8 | -set(USC_VERSION_PATCH 2) |
9 | +set(USC_VERSION_PATCH 3) |
10 | set(USC_VERSION "${USC_VERSION_MAJOR}.${USC_VERSION_MINOR}.${USC_VERSION_PATCH}") |
11 | |
12 | cmake_minimum_required(VERSION 2.8) |
13 | @@ -43,11 +43,16 @@ |
14 | pkg_check_modules(MIRCLIENT REQUIRED mirclient) |
15 | pkg_check_modules(MIRSERVER REQUIRED mirserver) |
16 | pkg_check_modules(DBUS REQUIRED dbus-1) |
17 | +pkg_check_modules(UBUNTU_PLATFORM_HARDWARE_API ubuntu-platform-hardware-api) |
18 | |
19 | find_package(Boost 1.48.0 COMPONENTS system REQUIRED) |
20 | find_package(GLESv2 REQUIRED) |
21 | find_package(PIL REQUIRED) |
22 | |
23 | +if (UBUNTU_PLATFORM_HARDWARE_API_FOUND) |
24 | + add_definitions(-DUSC_HAVE_UBUNTU_PLATFORM_HARDWARE_API) |
25 | +endif() |
26 | + |
27 | add_subdirectory(spinner/) |
28 | add_subdirectory(src/) |
29 | |
30 | |
31 | === modified file 'debian/changelog' |
32 | --- debian/changelog 2016-02-19 14:55:31 +0000 |
33 | +++ debian/changelog 2016-03-23 09:41:12 +0000 |
34 | @@ -1,3 +1,9 @@ |
35 | +unity-system-compositor (0.4.3) xenial; urgency=medium |
36 | + |
37 | + * Gracefully fallback if ubuntu's platform hw api is not available. |
38 | + |
39 | + -- Thomas Voß <thomas.voss@canonical.com> Tue, 22 Mar 2016 16:34:23 +0100 |
40 | + |
41 | unity-system-compositor (0.4.2+16.04.20160219.1-0ubuntu1) xenial; urgency=medium |
42 | |
43 | [ Alan Griffiths, Alexandros Frantzis, Brandon Schaefer ] |
44 | |
45 | === modified file 'debian/control' |
46 | --- debian/control 2016-02-17 11:04:24 +0000 |
47 | +++ debian/control 2016-03-23 09:41:12 +0000 |
48 | @@ -21,6 +21,7 @@ |
49 | python:any (>= 2.7), |
50 | python-setuptools, |
51 | python-pil, |
52 | + libubuntu-platform-hardware-api-dev [!arm64 !ppc64el !powerpc !s390x], |
53 | Standards-Version: 3.9.4 |
54 | Homepage: https://launchpad.net/unity-system-compositor |
55 | # if you don't have have commit access to this branch but would like to upload |
56 | |
57 | === modified file 'src/CMakeLists.txt' |
58 | --- src/CMakeLists.txt 2015-11-03 19:59:19 +0000 |
59 | +++ src/CMakeLists.txt 2016-03-23 09:41:12 +0000 |
60 | @@ -14,15 +14,23 @@ |
61 | # |
62 | # Authored by: Robert Ancell <robert.ancell@canonical.com> |
63 | |
64 | +if (UBUNTU_PLATFORM_HARDWARE_API_FOUND) |
65 | + set(PERFORMANCE_BOOSTER_IMPL_SRCS hw_performance_booster.cpp null_performance_booster.cpp) |
66 | +else() |
67 | + set(PERFORMANCE_BOOSTER_IMPL_SRCS null_performance_booster.cpp) |
68 | +endif() |
69 | + |
70 | set(USC_SRCS |
71 | asio_dm_connection.cpp |
72 | dbus_connection_handle.cpp |
73 | dbus_event_loop.cpp |
74 | dbus_message_handle.cpp |
75 | display_configuration_policy.cpp |
76 | - external_spinner.cpp |
77 | + external_spinner.cpp |
78 | mir_screen.cpp |
79 | mir_input_configuration.cpp |
80 | + performance_booster.h |
81 | + performance_booster.cpp |
82 | powerd_mediator.cpp |
83 | screen_event_handler.cpp |
84 | server.cpp |
85 | @@ -36,6 +44,8 @@ |
86 | unity_screen_service.cpp |
87 | unity_screen_service_introspection.h |
88 | window_manager.cpp |
89 | + |
90 | + ${PERFORMANCE_BOOSTER_IMPL_SRCS} |
91 | ) |
92 | |
93 | # Generate unity_screen_service_introspection.h from the introspection XML file |
94 | @@ -74,6 +84,7 @@ |
95 | ${MIRSERVER_INCLUDE_DIRS} |
96 | ${MIRCLIENT_INCLUDE_DIRS} |
97 | ${DBUS_INCLUDE_DIRS} |
98 | + ${UBUNTU_PLATFORM_HARDWARE_API_INCLUDE_DIRS} |
99 | ) |
100 | add_definitions( |
101 | -DDEFAULT_SPINNER="${CMAKE_INSTALL_FULL_BINDIR}/unity-system-compositor-spinner" |
102 | @@ -87,6 +98,7 @@ |
103 | ${Boost_LIBRARIES} |
104 | ${GLESv2_LIBRARIES} |
105 | ${DBUS_LIBRARIES} |
106 | + ${UBUNTU_PLATFORM_HARDWARE_API_LIBRARIES} |
107 | ) |
108 | |
109 | target_link_libraries(unity-system-compositor |
110 | |
111 | === added file 'src/hw_performance_booster.cpp' |
112 | --- src/hw_performance_booster.cpp 1970-01-01 00:00:00 +0000 |
113 | +++ src/hw_performance_booster.cpp 2016-03-23 09:41:12 +0000 |
114 | @@ -0,0 +1,48 @@ |
115 | +/* |
116 | + * Copyright © 2016 Canonical Ltd. |
117 | + * |
118 | + * This program is free software: you can redistribute it and/or modify it |
119 | + * under the terms of the GNU General Public License version 3, |
120 | + * as published by the Free Software Foundation. |
121 | + * |
122 | + * This program is distributed in the hope that it will be useful, |
123 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
124 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
125 | + * GNU General Public License for more details. |
126 | + * |
127 | + * You should have received a copy of the GNU General Public License |
128 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
129 | + * |
130 | + * Authored by: Thomas Voß <thomas.voss@canonical.com> |
131 | + */ |
132 | + |
133 | +#include "hw_performance_booster.h" |
134 | + |
135 | +#include <boost/exception/all.hpp> |
136 | + |
137 | +#include <stdexcept> |
138 | + |
139 | +namespace |
140 | +{ |
141 | +UHardwareBooster* create_hw_booster_or_throw() |
142 | +{ |
143 | + if (auto result = u_hardware_booster_new()) |
144 | + return result; |
145 | + |
146 | + BOOST_THROW_EXCEPTION(std::runtime_error{"Failed to acquire a valid UHardwareBooster instance."}); |
147 | +} |
148 | +} |
149 | + |
150 | +usc::HwPerformanceBooster::HwPerformanceBooster() : hw_booster{create_hw_booster_or_throw(), [](UHardwareBooster* booster) { if (booster) u_hardware_booster_unref(booster); }} |
151 | +{ |
152 | +} |
153 | + |
154 | +void usc::HwPerformanceBooster::enable_performance_boost_during_user_interaction() |
155 | +{ |
156 | + u_hardware_booster_enable_scenario(hw_booster.get(), U_HARDWARE_BOOSTER_SCENARIO_USER_INTERACTION); |
157 | +} |
158 | + |
159 | +void usc::HwPerformanceBooster::disable_performance_boost_during_user_interaction() |
160 | +{ |
161 | + u_hardware_booster_disable_scenario(hw_booster.get(), U_HARDWARE_BOOSTER_SCENARIO_USER_INTERACTION); |
162 | +} |
163 | |
164 | === added file 'src/hw_performance_booster.h' |
165 | --- src/hw_performance_booster.h 1970-01-01 00:00:00 +0000 |
166 | +++ src/hw_performance_booster.h 2016-03-23 09:41:12 +0000 |
167 | @@ -0,0 +1,44 @@ |
168 | +/* |
169 | + * Copyright © 2016 Canonical Ltd. |
170 | + * |
171 | + * This program is free software: you can redistribute it and/or modify it |
172 | + * under the terms of the GNU General Public License version 3, |
173 | + * as published by the Free Software Foundation. |
174 | + * |
175 | + * This program is distributed in the hope that it will be useful, |
176 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
177 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
178 | + * GNU General Public License for more details. |
179 | + * |
180 | + * You should have received a copy of the GNU General Public License |
181 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
182 | + * |
183 | + * Authored by: Thomas Voß <thomas.voss@canonical.com> |
184 | + */ |
185 | + |
186 | +#ifndef USC_HW_PERFORMANCE_BOOSTER_H_ |
187 | +#define USC_HW_PERFORMANCE_BOOSTER_H_ |
188 | + |
189 | +#include "performance_booster.h" |
190 | + |
191 | +#include <ubuntu/hardware/booster.h> |
192 | + |
193 | +#include <memory> |
194 | + |
195 | +namespace usc |
196 | +{ |
197 | +class HwPerformanceBooster : public PerformanceBooster |
198 | +{ |
199 | +public: |
200 | + // Throws std::runtime_error if we fail to gain access to the hw booster. |
201 | + HwPerformanceBooster(); |
202 | + |
203 | + void enable_performance_boost_during_user_interaction() override; |
204 | + void disable_performance_boost_during_user_interaction() override; |
205 | + |
206 | +protected: |
207 | + const std::shared_ptr<UHardwareBooster> hw_booster; |
208 | +}; |
209 | +} |
210 | + |
211 | +#endif // USC_HW_PERFORMANCE_BOOSTER_H_ |
212 | |
213 | === modified file 'src/mir_screen.cpp' |
214 | --- src/mir_screen.cpp 2016-01-28 10:38:08 +0000 |
215 | +++ src/mir_screen.cpp 2016-03-23 09:41:12 +0000 |
216 | @@ -31,6 +31,8 @@ |
217 | #include <sstream> |
218 | |
219 | #include <assert.h> |
220 | + |
221 | +#include "performance_booster.h" |
222 | #include "screen_hardware.h" |
223 | #include "power_state_change_reason.h" |
224 | #include "server.h" |
225 | @@ -102,6 +104,7 @@ |
226 | }; |
227 | |
228 | usc::MirScreen::MirScreen( |
229 | + std::shared_ptr<usc::PerformanceBooster> const& perf_booster, |
230 | std::shared_ptr<usc::ScreenHardware> const& screen_hardware, |
231 | std::shared_ptr<mir::compositor::Compositor> const& compositor, |
232 | std::shared_ptr<mir::graphics::Display> const& display, |
233 | @@ -111,7 +114,8 @@ |
234 | Timeouts inactivity_timeouts, |
235 | Timeouts notification_timeouts, |
236 | Timeouts snap_decision_timeouts) |
237 | - : screen_hardware{screen_hardware}, |
238 | + : perf_booster{perf_booster}, |
239 | + screen_hardware{screen_hardware}, |
240 | compositor{compositor}, |
241 | display{display}, |
242 | touch_visualizer{touch_visualizer}, |
243 | @@ -306,11 +310,13 @@ |
244 | bool const power_on = mode == MirPowerMode::mir_power_mode_on; |
245 | if (power_on) |
246 | { |
247 | + perf_booster->enable_performance_boost_during_user_interaction(); |
248 | //Some devices do not turn screen on properly from suspend mode |
249 | screen_hardware->disable_suspend(); |
250 | } |
251 | else |
252 | { |
253 | + perf_booster->disable_performance_boost_during_user_interaction(); |
254 | screen_hardware->turn_off_backlight(); |
255 | } |
256 | |
257 | |
258 | === modified file 'src/mir_screen.h' |
259 | --- src/mir_screen.h 2016-01-28 10:13:34 +0000 |
260 | +++ src/mir_screen.h 2016-03-23 09:41:12 +0000 |
261 | @@ -36,6 +36,7 @@ |
262 | |
263 | namespace usc |
264 | { |
265 | +class PerformanceBooster; |
266 | class Server; |
267 | class ScreenHardware; |
268 | class Clock; |
269 | @@ -49,7 +50,8 @@ |
270 | std::chrono::milliseconds dimming_timeout; |
271 | }; |
272 | |
273 | - MirScreen(std::shared_ptr<usc::ScreenHardware> const& screen_hardware, |
274 | + MirScreen(std::shared_ptr<usc::PerformanceBooster> const& perf_booster, |
275 | + std::shared_ptr<usc::ScreenHardware> const& screen_hardware, |
276 | std::shared_ptr<mir::compositor::Compositor> const& compositor, |
277 | std::shared_ptr<mir::graphics::Display> const& display, |
278 | std::shared_ptr<mir::input::TouchVisualizer> const& touch_visualizer, |
279 | @@ -97,6 +99,7 @@ |
280 | |
281 | void long_press_alarm_notification(); |
282 | |
283 | + std::shared_ptr<usc::PerformanceBooster> const perf_booster; |
284 | std::shared_ptr<usc::ScreenHardware> const screen_hardware; |
285 | std::shared_ptr<mir::compositor::Compositor> const compositor; |
286 | std::shared_ptr<mir::graphics::Display> const display; |
287 | |
288 | === added file 'src/null_performance_booster.cpp' |
289 | --- src/null_performance_booster.cpp 1970-01-01 00:00:00 +0000 |
290 | +++ src/null_performance_booster.cpp 2016-03-23 09:41:12 +0000 |
291 | @@ -0,0 +1,28 @@ |
292 | +/* |
293 | + * Copyright © 2016 Canonical Ltd. |
294 | + * |
295 | + * This program is free software: you can redistribute it and/or modify it |
296 | + * under the terms of the GNU General Public License version 3, |
297 | + * as published by the Free Software Foundation. |
298 | + * |
299 | + * This program is distributed in the hope that it will be useful, |
300 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
301 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
302 | + * GNU General Public License for more details. |
303 | + * |
304 | + * You should have received a copy of the GNU General Public License |
305 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
306 | + * |
307 | + * Authored by: Thomas Voß <thomas.voss@canonical.com> |
308 | + */ |
309 | + |
310 | +#include "null_performance_booster.h" |
311 | + |
312 | + |
313 | +void usc::NullPerformanceBooster::enable_performance_boost_during_user_interaction() |
314 | +{ |
315 | +} |
316 | + |
317 | +void usc::NullPerformanceBooster::disable_performance_boost_during_user_interaction() |
318 | +{ |
319 | +} |
320 | |
321 | === added file 'src/null_performance_booster.h' |
322 | --- src/null_performance_booster.h 1970-01-01 00:00:00 +0000 |
323 | +++ src/null_performance_booster.h 2016-03-23 09:41:12 +0000 |
324 | @@ -0,0 +1,34 @@ |
325 | +/* |
326 | + * Copyright © 2016 Canonical Ltd. |
327 | + * |
328 | + * This program is free software: you can redistribute it and/or modify it |
329 | + * under the terms of the GNU General Public License version 3, |
330 | + * as published by the Free Software Foundation. |
331 | + * |
332 | + * This program is distributed in the hope that it will be useful, |
333 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
334 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
335 | + * GNU General Public License for more details. |
336 | + * |
337 | + * You should have received a copy of the GNU General Public License |
338 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
339 | + * |
340 | + * Authored by: Thomas Voß <thomas.voss@canonical.com> |
341 | + */ |
342 | + |
343 | +#ifndef USC_NULL_PERFORMANCE_BOOSTER_H_ |
344 | +#define USC_NULL_PERFORMANCE_BOOSTER_H_ |
345 | + |
346 | +#include "performance_booster.h" |
347 | + |
348 | +namespace usc |
349 | +{ |
350 | +class NullPerformanceBooster : public PerformanceBooster |
351 | +{ |
352 | +public: |
353 | + void enable_performance_boost_during_user_interaction() override; |
354 | + void disable_performance_boost_during_user_interaction() override; |
355 | +}; |
356 | +} |
357 | + |
358 | +#endif // USC_NULL_PERFORMANCE_BOOSTER_H_ |
359 | |
360 | === added file 'src/performance_booster.cpp' |
361 | --- src/performance_booster.cpp 1970-01-01 00:00:00 +0000 |
362 | +++ src/performance_booster.cpp 2016-03-23 09:41:12 +0000 |
363 | @@ -0,0 +1,52 @@ |
364 | +/* |
365 | + * Copyright © 2016 Canonical Ltd. |
366 | + * |
367 | + * This program is free software: you can redistribute it and/or modify it |
368 | + * under the terms of the GNU General Public License version 3, |
369 | + * as published by the Free Software Foundation. |
370 | + * |
371 | + * This program is distributed in the hope that it will be useful, |
372 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
373 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
374 | + * GNU General Public License for more details. |
375 | + * |
376 | + * You should have received a copy of the GNU General Public License |
377 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
378 | + * |
379 | + * Authored by: Thomas Voß <thomas.voss@canonical.com> |
380 | + */ |
381 | + |
382 | +#define MIR_LOG_COMPONENT "UnitySystemCompositor" |
383 | + |
384 | +#include "performance_booster.h" |
385 | +#include "null_performance_booster.h" |
386 | + |
387 | +#include <mir/log.h> |
388 | + |
389 | +#include <boost/exception/all.hpp> |
390 | + |
391 | +#if defined(USC_HAVE_UBUNTU_PLATFORM_HARDWARE_API) |
392 | +#include "hw_performance_booster.h" |
393 | + |
394 | +std::shared_ptr<usc::PerformanceBooster> usc::platform_default_performance_booster() |
395 | +{ |
396 | + // We are treating access to a functional implementation of PerformanceBooster as optional. |
397 | + // With that, we gracefully fall back to a NullImplementation if we cannot gain access |
398 | + // to hw-provided booster capabilities. |
399 | + try |
400 | + { |
401 | + return std::make_shared<HwPerformanceBooster>(); |
402 | + } |
403 | + catch (boost::exception const& e) |
404 | + { |
405 | + mir::log_warning(boost::diagnostic_information(e)); |
406 | + } |
407 | + |
408 | + return std::make_shared<NullPerformanceBooster>(); |
409 | +} |
410 | +#else |
411 | +std::shared_ptr<usc::PerformanceBooster> usc::platform_default_performance_booster() |
412 | +{ |
413 | + return std::make_shared<NullPerformanceBooster>(); |
414 | +} |
415 | +#endif // USC_HAVE_UBUNTU_PLATFORM_HARDWARE_API |
416 | |
417 | === added file 'src/performance_booster.h' |
418 | --- src/performance_booster.h 1970-01-01 00:00:00 +0000 |
419 | +++ src/performance_booster.h 2016-03-23 09:41:12 +0000 |
420 | @@ -0,0 +1,41 @@ |
421 | +/* |
422 | + * Copyright © 2016 Canonical Ltd. |
423 | + * |
424 | + * This program is free software: you can redistribute it and/or modify it |
425 | + * under the terms of the GNU General Public License version 3, |
426 | + * as published by the Free Software Foundation. |
427 | + * |
428 | + * This program is distributed in the hope that it will be useful, |
429 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
430 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
431 | + * GNU General Public License for more details. |
432 | + * |
433 | + * You should have received a copy of the GNU General Public License |
434 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
435 | + * |
436 | + * Authored by: Thomas Voß <thomas.voss@canonical.com> |
437 | + */ |
438 | + |
439 | +#ifndef USC_PERFORMANCE_BOOSTER_H_ |
440 | +#define USC_PERFORMANCE_BOOSTER_H_ |
441 | + |
442 | +#include <memory> |
443 | + |
444 | +namespace usc |
445 | +{ |
446 | +class PerformanceBooster |
447 | +{ |
448 | +public: |
449 | + PerformanceBooster() = default; |
450 | + PerformanceBooster(const PerformanceBooster&) = delete; |
451 | + virtual ~PerformanceBooster() = default; |
452 | + PerformanceBooster& operator=(const PerformanceBooster&) = delete; |
453 | + |
454 | + virtual void enable_performance_boost_during_user_interaction() = 0; |
455 | + virtual void disable_performance_boost_during_user_interaction() = 0; |
456 | +}; |
457 | + |
458 | +std::shared_ptr<PerformanceBooster> platform_default_performance_booster(); |
459 | +} |
460 | + |
461 | +#endif // USC_PERFORMANCE_BOOSTER_H_ |
462 | |
463 | === modified file 'src/server.cpp' |
464 | --- src/server.cpp 2016-02-17 11:04:24 +0000 |
465 | +++ src/server.cpp 2016-03-23 09:41:12 +0000 |
466 | @@ -16,6 +16,8 @@ |
467 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
468 | */ |
469 | |
470 | +#define MIR_LOG_COMPONENT "UnitySystemCompositor" |
471 | + |
472 | #include "server.h" |
473 | #include "external_spinner.h" |
474 | #include "asio_dm_connection.h" |
475 | @@ -24,6 +26,7 @@ |
476 | #include "mir_screen.h" |
477 | #include "mir_input_configuration.h" |
478 | #include "screen_event_handler.h" |
479 | +#include "performance_booster.h" |
480 | #include "powerd_mediator.h" |
481 | #include "unity_screen_service.h" |
482 | #include "unity_input_service.h" |
483 | @@ -37,9 +40,12 @@ |
484 | #include <mir/server_status_listener.h> |
485 | #include <mir/shell/focus_controller.h> |
486 | #include <mir/scene/session.h> |
487 | +#include <mir/log.h> |
488 | #include <mir/abnormal_exit.h> |
489 | #include <mir/main_loop.h> |
490 | |
491 | +#include <boost/exception/all.hpp> |
492 | + |
493 | #include <iostream> |
494 | |
495 | namespace msh = mir::shell; |
496 | @@ -201,6 +207,11 @@ |
497 | apply_settings(); |
498 | } |
499 | |
500 | +std::shared_ptr<usc::PerformanceBooster> usc::Server::the_performance_booster() |
501 | +{ |
502 | + return platform_default_performance_booster(); |
503 | +} |
504 | + |
505 | std::shared_ptr<usc::Spinner> usc::Server::the_spinner() |
506 | { |
507 | return spinner( |
508 | @@ -288,6 +299,7 @@ |
509 | [this] |
510 | { |
511 | return std::make_shared<MirScreen>( |
512 | + the_performance_booster(), |
513 | the_screen_hardware(), |
514 | the_compositor(), |
515 | the_display(), |
516 | |
517 | === modified file 'src/server.h' |
518 | --- src/server.h 2016-01-19 21:43:11 +0000 |
519 | +++ src/server.h 2016-03-23 09:41:12 +0000 |
520 | @@ -39,6 +39,7 @@ |
521 | class SessionSwitcher; |
522 | class DMMessageHandler; |
523 | class DMConnection; |
524 | +class PerformanceBooster; |
525 | class Screen; |
526 | class ScreenHardware; |
527 | class UnityScreenService; |
528 | @@ -61,6 +62,7 @@ |
529 | using mir::Server::the_compositor; |
530 | using mir::Server::the_touch_visualizer; |
531 | |
532 | + virtual std::shared_ptr<PerformanceBooster> the_performance_booster(); |
533 | virtual std::shared_ptr<Spinner> the_spinner(); |
534 | virtual std::shared_ptr<DMMessageHandler> the_dm_message_handler(); |
535 | virtual std::shared_ptr<DMConnection> the_dm_connection(); |
536 | |
537 | === modified file 'tests/integration-tests/test_deadlock_lp1491566.cpp' |
538 | --- tests/integration-tests/test_deadlock_lp1491566.cpp 2016-01-28 10:13:34 +0000 |
539 | +++ tests/integration-tests/test_deadlock_lp1491566.cpp 2016-03-23 09:41:12 +0000 |
540 | @@ -18,6 +18,7 @@ |
541 | |
542 | #include "src/server.h" |
543 | #include "src/mir_screen.h" |
544 | +#include "src/performance_booster.h" |
545 | #include "src/screen_hardware.h" |
546 | #include "src/power_state_change_reason.h" |
547 | #include "spin_wait.h" |
548 | @@ -47,6 +48,11 @@ |
549 | void stop() override {} |
550 | }; |
551 | |
552 | +struct StubPerformanceBooster : usc::PerformanceBooster |
553 | +{ |
554 | + void enable_performance_boost_during_user_interaction() override {} |
555 | + void disable_performance_boost_during_user_interaction() override {} |
556 | +}; |
557 | |
558 | struct StubScreenHardware : usc::ScreenHardware |
559 | { |
560 | @@ -153,6 +159,7 @@ |
561 | std::chrono::milliseconds const dimmer_timeout{100}; |
562 | |
563 | TestMirScreen mir_screen{ |
564 | + std::make_shared<StubPerformanceBooster>(), |
565 | std::make_shared<StubScreenHardware>(), |
566 | std::make_shared<NullCompositor>(), |
567 | std::make_shared<::testing::NiceMock<ut::MockDisplay>>(), |
568 | |
569 | === modified file 'tests/unit-tests/test_mir_screen.cpp' |
570 | --- tests/unit-tests/test_mir_screen.cpp 2015-11-12 12:28:17 +0000 |
571 | +++ tests/unit-tests/test_mir_screen.cpp 2016-03-23 09:41:12 +0000 |
572 | @@ -17,6 +17,7 @@ |
573 | */ |
574 | |
575 | #include "src/mir_screen.h" |
576 | +#include "src/performance_booster.h" |
577 | #include "src/screen_hardware.h" |
578 | #include "src/power_state_change_reason.h" |
579 | #include "advanceable_timer.h" |
580 | @@ -45,6 +46,12 @@ |
581 | MOCK_METHOD0(stop, void()); |
582 | }; |
583 | |
584 | +struct MockPerformanceBooster : usc::PerformanceBooster |
585 | +{ |
586 | + MOCK_METHOD0(enable_performance_boost_during_user_interaction, void()); |
587 | + MOCK_METHOD0(disable_performance_boost_during_user_interaction, void()); |
588 | +}; |
589 | + |
590 | struct MockScreenHardware : usc::ScreenHardware |
591 | { |
592 | MOCK_METHOD0(set_dim_backlight, void()); |
593 | @@ -137,6 +144,18 @@ |
594 | std::chrono::seconds const fourty_seconds{40}; |
595 | std::chrono::seconds const fifty_seconds{50}; |
596 | |
597 | + void expect_performance_boost_is_enabled() |
598 | + { |
599 | + using namespace testing; |
600 | + EXPECT_CALL(*performance_booster, enable_performance_boost_during_user_interaction()); |
601 | + } |
602 | + |
603 | + void expect_performance_boost_is_disabled() |
604 | + { |
605 | + using namespace testing; |
606 | + EXPECT_CALL(*performance_booster, disable_performance_boost_during_user_interaction()); |
607 | + } |
608 | + |
609 | void expect_screen_is_turned_off() |
610 | { |
611 | using namespace testing; |
612 | @@ -274,6 +293,8 @@ |
613 | Mock::VerifyAndClearExpectations(compositor.get()); |
614 | } |
615 | |
616 | + std::shared_ptr<MockPerformanceBooster> performance_booster{ |
617 | + std::make_shared<testing::NiceMock<MockPerformanceBooster>>()}; |
618 | std::shared_ptr<MockScreenHardware> screen_hardware{ |
619 | std::make_shared<testing::NiceMock<MockScreenHardware>>()}; |
620 | std::shared_ptr<MockCompositor> compositor{ |
621 | @@ -286,6 +307,7 @@ |
622 | std::make_shared<AdvanceableTimer>()}; |
623 | |
624 | usc::MirScreen mir_screen{ |
625 | + performance_booster, |
626 | screen_hardware, |
627 | compositor, |
628 | display, |
629 | @@ -297,7 +319,50 @@ |
630 | {call_power_off_timeout, call_dimmer_timeout}}; |
631 | }; |
632 | |
633 | -} |
634 | +struct AParameterizedMirScreen : public AMirScreen, public ::testing::WithParamInterface<PowerStateChangeReason> {}; |
635 | +struct ImmediatePowerOnMirScreen : public AParameterizedMirScreen {}; |
636 | +struct DeferredPowerOnMirScreen : public AParameterizedMirScreen {}; |
637 | + |
638 | +} |
639 | + |
640 | +TEST_P(ImmediatePowerOnMirScreen, enables_performance_boost_for_screen_on) |
641 | +{ |
642 | + turn_screen_off(); |
643 | + expect_performance_boost_is_enabled(); |
644 | + mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on, GetParam()); |
645 | +} |
646 | + |
647 | +TEST_P(DeferredPowerOnMirScreen, enables_performance_boost_for_screen_on_with_reason_proximity) |
648 | +{ |
649 | + turn_screen_off(); |
650 | + expect_performance_boost_is_enabled(); |
651 | + mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on, GetParam()); |
652 | + mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on, PowerStateChangeReason::proximity); |
653 | +} |
654 | + |
655 | +TEST_P(AParameterizedMirScreen, disables_performance_boost_for_screen_off) |
656 | +{ |
657 | + turn_screen_on(); |
658 | + expect_performance_boost_is_disabled(); |
659 | + mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_off, GetParam()); |
660 | +} |
661 | + |
662 | +INSTANTIATE_TEST_CASE_P( |
663 | + AParameterizedMirScreen, |
664 | + AParameterizedMirScreen, |
665 | + ::testing::Values(PowerStateChangeReason::unknown, PowerStateChangeReason::inactivity, PowerStateChangeReason::power_key, |
666 | + PowerStateChangeReason::proximity, PowerStateChangeReason::notification, PowerStateChangeReason::snap_decision, |
667 | + PowerStateChangeReason::call_done)); |
668 | + |
669 | +INSTANTIATE_TEST_CASE_P( |
670 | + ImmediatePowerOnMirScreen, |
671 | + ImmediatePowerOnMirScreen, |
672 | + ::testing::Values(PowerStateChangeReason::unknown, PowerStateChangeReason::inactivity, PowerStateChangeReason::power_key)); |
673 | + |
674 | +INSTANTIATE_TEST_CASE_P( |
675 | + DeferredPowerOnMirScreen, |
676 | + DeferredPowerOnMirScreen, |
677 | + ::testing::Values(PowerStateChangeReason::notification, PowerStateChangeReason::snap_decision, PowerStateChangeReason::call_done)); |
678 | |
679 | TEST_F(AMirScreen, turns_screen_off_after_power_off_timeout) |
680 | { |
Debian changelog entry version number should be 0.4.3+...