Merge lp:~thomas-voss/unity-system-compositor/fallback-gracefully-if-hw-api-is-missing-0.4 into lp:unity-system-compositor/0.4

Proposed by Thomas Voß
Status: Merged
Approved by: Kevin DuBois
Approved revision: 284
Merged at revision: 284
Proposed branch: lp:~thomas-voss/unity-system-compositor/fallback-gracefully-if-hw-api-is-missing-0.4
Merge into: lp:unity-system-compositor/0.4
Diff against target: 185 lines (+72/-18)
6 files modified
CMakeLists.txt (+4/-0)
debian/control (+1/-1)
src/CMakeLists.txt (+9/-2)
src/performance_booster.cpp (+52/-0)
src/performance_booster.h (+4/-0)
src/server.cpp (+2/-15)
To merge this branch: bzr merge lp:~thomas-voss/unity-system-compositor/fallback-gracefully-if-hw-api-is-missing-0.4
Reviewer Review Type Date Requested Status
Kevin DuBois (community) Approve
Review via email: mp+289779@code.launchpad.net

Commit message

Gracefully fallback if ubuntu's platform hw api is not available.

Cherry pick r285 from lp:unity-system-compositor.

Description of the change

Gracefully fallback if ubuntu's platform hw api is not available.

Cherry pick r285 from lp:unity-system-compositor.

To post a comment you must log in.
Revision history for this message
Kevin DuBois (kdub) wrote :

would be better if we had an interface and runtime detection, but alright as a cherry pick to solve a problem.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-03-11 14:43:18 +0000
+++ CMakeLists.txt 2016-03-22 12:04:55 +0000
@@ -49,6 +49,10 @@
49find_package(GLESv2 REQUIRED)49find_package(GLESv2 REQUIRED)
50find_package(PIL REQUIRED)50find_package(PIL REQUIRED)
5151
52if (UBUNTU_PLATFORM_HARDWARE_API_FOUND)
53 add_definitions(-DUSC_HAVE_UBUNTU_PLATFORM_HARDWARE_API)
54endif()
55
52add_subdirectory(spinner/)56add_subdirectory(spinner/)
53add_subdirectory(src/)57add_subdirectory(src/)
5458
5559
=== modified file 'debian/control'
--- debian/control 2016-03-11 14:43:18 +0000
+++ debian/control 2016-03-22 12:04:55 +0000
@@ -21,7 +21,7 @@
21 python:any (>= 2.7),21 python:any (>= 2.7),
22 python-setuptools,22 python-setuptools,
23 python-pil,23 python-pil,
24 libubuntu-platform-hardware-api-dev,24 libubuntu-platform-hardware-api-dev [!arm64 !ppc64el !powerpc !s390x],
25Standards-Version: 3.9.425Standards-Version: 3.9.4
26Homepage: https://launchpad.net/unity-system-compositor26Homepage: https://launchpad.net/unity-system-compositor
27# if you don't have have commit access to this branch but would like to upload27# if you don't have have commit access to this branch but would like to upload
2828
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2016-03-11 14:43:18 +0000
+++ src/CMakeLists.txt 2016-03-22 12:04:55 +0000
@@ -14,6 +14,12 @@
14#14#
15# Authored by: Robert Ancell <robert.ancell@canonical.com>15# Authored by: Robert Ancell <robert.ancell@canonical.com>
1616
17if (UBUNTU_PLATFORM_HARDWARE_API_FOUND)
18 set(PERFORMANCE_BOOSTER_IMPL_SRCS hw_performance_booster.cpp null_performance_booster.cpp)
19else()
20 set(PERFORMANCE_BOOSTER_IMPL_SRCS null_performance_booster.cpp)
21endif()
22
17set(USC_SRCS23set(USC_SRCS
18 asio_dm_connection.cpp24 asio_dm_connection.cpp
19 dbus_connection_handle.cpp25 dbus_connection_handle.cpp
@@ -21,11 +27,10 @@
21 dbus_message_handle.cpp27 dbus_message_handle.cpp
22 display_configuration_policy.cpp28 display_configuration_policy.cpp
23 external_spinner.cpp 29 external_spinner.cpp
24 hw_performance_booster.cpp
25 mir_screen.cpp30 mir_screen.cpp
26 mir_input_configuration.cpp31 mir_input_configuration.cpp
27 null_performance_booster.cpp
28 performance_booster.h32 performance_booster.h
33 performance_booster.cpp
29 powerd_mediator.cpp34 powerd_mediator.cpp
30 screen_event_handler.cpp35 screen_event_handler.cpp
31 server.cpp36 server.cpp
@@ -39,6 +44,8 @@
39 unity_screen_service.cpp44 unity_screen_service.cpp
40 unity_screen_service_introspection.h45 unity_screen_service_introspection.h
41 window_manager.cpp46 window_manager.cpp
47
48 ${PERFORMANCE_BOOSTER_IMPL_SRCS}
42)49)
4350
44# Generate unity_screen_service_introspection.h from the introspection XML file51# Generate unity_screen_service_introspection.h from the introspection XML file
4552
=== added file 'src/performance_booster.cpp'
--- src/performance_booster.cpp 1970-01-01 00:00:00 +0000
+++ src/performance_booster.cpp 2016-03-22 12:04:55 +0000
@@ -0,0 +1,52 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18
19#define MIR_LOG_COMPONENT "UnitySystemCompositor"
20
21#include "performance_booster.h"
22#include "null_performance_booster.h"
23
24#include <mir/log.h>
25
26#include <boost/exception/all.hpp>
27
28#if defined(USC_HAVE_UBUNTU_PLATFORM_HARDWARE_API)
29#include "hw_performance_booster.h"
30
31std::shared_ptr<usc::PerformanceBooster> usc::platform_default_performance_booster()
32{
33 // We are treating access to a functional implementation of PerformanceBooster as optional.
34 // With that, we gracefully fall back to a NullImplementation if we cannot gain access
35 // to hw-provided booster capabilities.
36 try
37 {
38 return std::make_shared<HwPerformanceBooster>();
39 }
40 catch (boost::exception const& e)
41 {
42 mir::log_warning(boost::diagnostic_information(e));
43 }
44
45 return std::make_shared<NullPerformanceBooster>();
46}
47#else
48std::shared_ptr<usc::PerformanceBooster> usc::platform_default_performance_booster()
49{
50 return std::make_shared<NullPerformanceBooster>();
51}
52#endif // USC_HAVE_UBUNTU_PLATFORM_HARDWARE_API
053
=== modified file 'src/performance_booster.h'
--- src/performance_booster.h 2016-03-11 14:43:18 +0000
+++ src/performance_booster.h 2016-03-22 12:04:55 +0000
@@ -19,6 +19,8 @@
19#ifndef USC_PERFORMANCE_BOOSTER_H_19#ifndef USC_PERFORMANCE_BOOSTER_H_
20#define USC_PERFORMANCE_BOOSTER_H_20#define USC_PERFORMANCE_BOOSTER_H_
2121
22#include <memory>
23
22namespace usc24namespace usc
23{25{
24class PerformanceBooster26class PerformanceBooster
@@ -32,6 +34,8 @@
32 virtual void enable_performance_boost_during_user_interaction() = 0;34 virtual void enable_performance_boost_during_user_interaction() = 0;
33 virtual void disable_performance_boost_during_user_interaction() = 0;35 virtual void disable_performance_boost_during_user_interaction() = 0;
34};36};
37
38std::shared_ptr<PerformanceBooster> platform_default_performance_booster();
35}39}
3640
37#endif // USC_PERFORMANCE_BOOSTER_H_41#endif // USC_PERFORMANCE_BOOSTER_H_
3842
=== modified file 'src/server.cpp'
--- src/server.cpp 2016-03-11 14:43:18 +0000
+++ src/server.cpp 2016-03-22 12:04:55 +0000
@@ -26,13 +26,12 @@
26#include "mir_screen.h"26#include "mir_screen.h"
27#include "mir_input_configuration.h"27#include "mir_input_configuration.h"
28#include "screen_event_handler.h"28#include "screen_event_handler.h"
29#include "performance_booster.h"
29#include "powerd_mediator.h"30#include "powerd_mediator.h"
30#include "unity_screen_service.h"31#include "unity_screen_service.h"
31#include "unity_input_service.h"32#include "unity_input_service.h"
32#include "dbus_connection_thread.h"33#include "dbus_connection_thread.h"
33#include "dbus_event_loop.h"34#include "dbus_event_loop.h"
34#include "hw_performance_booster.h"
35#include "null_performance_booster.h"
36#include "display_configuration_policy.h"35#include "display_configuration_policy.h"
37#include "steady_clock.h"36#include "steady_clock.h"
3837
@@ -210,19 +209,7 @@
210209
211std::shared_ptr<usc::PerformanceBooster> usc::Server::the_performance_booster()210std::shared_ptr<usc::PerformanceBooster> usc::Server::the_performance_booster()
212{211{
213 // We are treating access to a functional implementation of PerformanceBooster as optional.212 return platform_default_performance_booster();
214 // With that, we gracefully fall back to a NullImplementation if we cannot gain access
215 // to hw-provided booster capabilities.
216 try
217 {
218 return std::make_shared<HwPerformanceBooster>();
219 }
220 catch (boost::exception const& e)
221 {
222 mir::log_warning(boost::diagnostic_information(e));
223 }
224
225 return std::make_shared<NullPerformanceBooster>();
226}213}
227214
228std::shared_ptr<usc::Spinner> usc::Server::the_spinner()215std::shared_ptr<usc::Spinner> usc::Server::the_spinner()

Subscribers

People subscribed via source and target branches