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
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-03-11 14:43:18 +0000
3+++ CMakeLists.txt 2016-03-22 12:04:55 +0000
4@@ -49,6 +49,10 @@
5 find_package(GLESv2 REQUIRED)
6 find_package(PIL REQUIRED)
7
8+if (UBUNTU_PLATFORM_HARDWARE_API_FOUND)
9+ add_definitions(-DUSC_HAVE_UBUNTU_PLATFORM_HARDWARE_API)
10+endif()
11+
12 add_subdirectory(spinner/)
13 add_subdirectory(src/)
14
15
16=== modified file 'debian/control'
17--- debian/control 2016-03-11 14:43:18 +0000
18+++ debian/control 2016-03-22 12:04:55 +0000
19@@ -21,7 +21,7 @@
20 python:any (>= 2.7),
21 python-setuptools,
22 python-pil,
23- libubuntu-platform-hardware-api-dev,
24+ libubuntu-platform-hardware-api-dev [!arm64 !ppc64el !powerpc !s390x],
25 Standards-Version: 3.9.4
26 Homepage: https://launchpad.net/unity-system-compositor
27 # if you don't have have commit access to this branch but would like to upload
28
29=== modified file 'src/CMakeLists.txt'
30--- src/CMakeLists.txt 2016-03-11 14:43:18 +0000
31+++ src/CMakeLists.txt 2016-03-22 12:04:55 +0000
32@@ -14,6 +14,12 @@
33 #
34 # Authored by: Robert Ancell <robert.ancell@canonical.com>
35
36+if (UBUNTU_PLATFORM_HARDWARE_API_FOUND)
37+ set(PERFORMANCE_BOOSTER_IMPL_SRCS hw_performance_booster.cpp null_performance_booster.cpp)
38+else()
39+ set(PERFORMANCE_BOOSTER_IMPL_SRCS null_performance_booster.cpp)
40+endif()
41+
42 set(USC_SRCS
43 asio_dm_connection.cpp
44 dbus_connection_handle.cpp
45@@ -21,11 +27,10 @@
46 dbus_message_handle.cpp
47 display_configuration_policy.cpp
48 external_spinner.cpp
49- hw_performance_booster.cpp
50 mir_screen.cpp
51 mir_input_configuration.cpp
52- null_performance_booster.cpp
53 performance_booster.h
54+ performance_booster.cpp
55 powerd_mediator.cpp
56 screen_event_handler.cpp
57 server.cpp
58@@ -39,6 +44,8 @@
59 unity_screen_service.cpp
60 unity_screen_service_introspection.h
61 window_manager.cpp
62+
63+ ${PERFORMANCE_BOOSTER_IMPL_SRCS}
64 )
65
66 # Generate unity_screen_service_introspection.h from the introspection XML file
67
68=== added file 'src/performance_booster.cpp'
69--- src/performance_booster.cpp 1970-01-01 00:00:00 +0000
70+++ src/performance_booster.cpp 2016-03-22 12:04:55 +0000
71@@ -0,0 +1,52 @@
72+/*
73+ * Copyright © 2016 Canonical Ltd.
74+ *
75+ * This program is free software: you can redistribute it and/or modify it
76+ * under the terms of the GNU General Public License version 3,
77+ * as published by the Free Software Foundation.
78+ *
79+ * This program is distributed in the hope that it will be useful,
80+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
81+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82+ * GNU General Public License for more details.
83+ *
84+ * You should have received a copy of the GNU General Public License
85+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
86+ *
87+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
88+ */
89+
90+#define MIR_LOG_COMPONENT "UnitySystemCompositor"
91+
92+#include "performance_booster.h"
93+#include "null_performance_booster.h"
94+
95+#include <mir/log.h>
96+
97+#include <boost/exception/all.hpp>
98+
99+#if defined(USC_HAVE_UBUNTU_PLATFORM_HARDWARE_API)
100+#include "hw_performance_booster.h"
101+
102+std::shared_ptr<usc::PerformanceBooster> usc::platform_default_performance_booster()
103+{
104+ // We are treating access to a functional implementation of PerformanceBooster as optional.
105+ // With that, we gracefully fall back to a NullImplementation if we cannot gain access
106+ // to hw-provided booster capabilities.
107+ try
108+ {
109+ return std::make_shared<HwPerformanceBooster>();
110+ }
111+ catch (boost::exception const& e)
112+ {
113+ mir::log_warning(boost::diagnostic_information(e));
114+ }
115+
116+ return std::make_shared<NullPerformanceBooster>();
117+}
118+#else
119+std::shared_ptr<usc::PerformanceBooster> usc::platform_default_performance_booster()
120+{
121+ return std::make_shared<NullPerformanceBooster>();
122+}
123+#endif // USC_HAVE_UBUNTU_PLATFORM_HARDWARE_API
124
125=== modified file 'src/performance_booster.h'
126--- src/performance_booster.h 2016-03-11 14:43:18 +0000
127+++ src/performance_booster.h 2016-03-22 12:04:55 +0000
128@@ -19,6 +19,8 @@
129 #ifndef USC_PERFORMANCE_BOOSTER_H_
130 #define USC_PERFORMANCE_BOOSTER_H_
131
132+#include <memory>
133+
134 namespace usc
135 {
136 class PerformanceBooster
137@@ -32,6 +34,8 @@
138 virtual void enable_performance_boost_during_user_interaction() = 0;
139 virtual void disable_performance_boost_during_user_interaction() = 0;
140 };
141+
142+std::shared_ptr<PerformanceBooster> platform_default_performance_booster();
143 }
144
145 #endif // USC_PERFORMANCE_BOOSTER_H_
146
147=== modified file 'src/server.cpp'
148--- src/server.cpp 2016-03-11 14:43:18 +0000
149+++ src/server.cpp 2016-03-22 12:04:55 +0000
150@@ -26,13 +26,12 @@
151 #include "mir_screen.h"
152 #include "mir_input_configuration.h"
153 #include "screen_event_handler.h"
154+#include "performance_booster.h"
155 #include "powerd_mediator.h"
156 #include "unity_screen_service.h"
157 #include "unity_input_service.h"
158 #include "dbus_connection_thread.h"
159 #include "dbus_event_loop.h"
160-#include "hw_performance_booster.h"
161-#include "null_performance_booster.h"
162 #include "display_configuration_policy.h"
163 #include "steady_clock.h"
164
165@@ -210,19 +209,7 @@
166
167 std::shared_ptr<usc::PerformanceBooster> usc::Server::the_performance_booster()
168 {
169- // We are treating access to a functional implementation of PerformanceBooster as optional.
170- // With that, we gracefully fall back to a NullImplementation if we cannot gain access
171- // to hw-provided booster capabilities.
172- try
173- {
174- return std::make_shared<HwPerformanceBooster>();
175- }
176- catch (boost::exception const& e)
177- {
178- mir::log_warning(boost::diagnostic_information(e));
179- }
180-
181- return std::make_shared<NullPerformanceBooster>();
182+ return platform_default_performance_booster();
183 }
184
185 std::shared_ptr<usc::Spinner> usc::Server::the_spinner()

Subscribers

People subscribed via source and target branches