Merge lp:~vanvugt/mir/drop-frame-dropping-policy into lp:mir
- drop-frame-dropping-policy
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Daniel van Vugt |
Approved revision: | no longer in the source branch. |
Merged at revision: | 4162 |
Proposed branch: | lp:~vanvugt/mir/drop-frame-dropping-policy |
Merge into: | lp:mir |
Diff against target: |
1463 lines (+22/-994) 26 files modified
src/include/server/mir/compositor/frame_dropping_policy.h (+0/-69) src/include/server/mir/compositor/frame_dropping_policy_factory.h (+0/-74) src/include/server/mir/default_server_configuration.h (+0/-3) src/server/compositor/CMakeLists.txt (+0/-3) src/server/compositor/buffer_stream_factory.cpp (+1/-6) src/server/compositor/buffer_stream_factory.h (+1/-5) src/server/compositor/default_configuration.cpp (+1/-14) src/server/compositor/stream.cpp (+0/-37) src/server/compositor/stream.h (+1/-16) src/server/compositor/timeout_frame_dropping_policy_factory.cpp (+0/-95) src/server/compositor/timeout_frame_dropping_policy_factory.h (+0/-59) src/server/symbols.map (+0/-1) tests/acceptance-tests/test_client_surface_swap_buffers.cpp (+14/-6) tests/include/mir/test/doubles/mock_frame_dropping_policy_factory.h (+0/-104) tests/include/mir/test/doubles/stub_frame_dropping_policy_factory.h (+0/-60) tests/integration-tests/compositor/test_swapping_swappers.cpp (+1/-4) tests/integration-tests/test_buffer_scheduling.cpp (+0/-33) tests/integration-tests/test_server_shutdown.cpp (+0/-7) tests/integration-tests/test_submit_buffer.cpp (+1/-3) tests/integration-tests/test_surface_stack_with_compositor.cpp (+1/-3) tests/mir_test_doubles/CMakeLists.txt (+0/-1) tests/mir_test_doubles/mock_frame_dropping_policy_factory.cpp (+0/-78) tests/unit-tests/compositor/CMakeLists.txt (+0/-1) tests/unit-tests/compositor/test_stream.cpp (+0/-113) tests/unit-tests/compositor/test_timeout_frame_dropping_policy.cpp (+0/-196) tests/unit-tests/scene/test_surface_stack.cpp (+1/-3) |
To merge this branch: | bzr merge lp:~vanvugt/mir/drop-frame-dropping-policy |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andreas Pokorny (community) | Approve | ||
Mir CI Bot | continuous-integration | Approve | |
Mir development team | Pending | ||
Review via email: mp+323485@code.launchpad.net |
Commit message
Drop FrameDroppingPolicy
For a few reasons:
* It is no longer possible to trigger at all with client-side vsync,
because swaps now always return after 16ms (hence the 100ms timeout
is never reached).
* The original use case for it is deprecated: The music player app
in Unity8. And even if it wasn't, it still would never trigger since
all toolkits other than Xmir already use client-side vsync.
* Only mir_buffer_
that is either deprecated [1] or will stop triggering it once
ported to client-side vsync at least.
[1] https:/
Description of the change
This branch has a weak prerequisite on either [1] landing, or it
getting ported to client-side vsync.
Mir CI Bot (mir-ci-bot) wrote : | # |
Andreas Pokorny (andreas-pokorny) wrote : | # |
yes this should no longer be needed.
Preview Diff
1 | === removed file 'src/include/server/mir/compositor/frame_dropping_policy.h' | |||
2 | --- src/include/server/mir/compositor/frame_dropping_policy.h 2015-02-22 07:46:25 +0000 | |||
3 | +++ src/include/server/mir/compositor/frame_dropping_policy.h 1970-01-01 00:00:00 +0000 | |||
4 | @@ -1,69 +0,0 @@ | |||
5 | 1 | /* | ||
6 | 2 | * Copyright © 2014 Canonical Ltd. | ||
7 | 3 | * | ||
8 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
9 | 5 | * under the terms of the GNU General Public License version 3, | ||
10 | 6 | * as published by the Free Software Foundation. | ||
11 | 7 | * | ||
12 | 8 | * This program is distributed in the hope that it will be useful, | ||
13 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | 11 | * GNU General Public License for more details. | ||
16 | 12 | * | ||
17 | 13 | * You should have received a copy of the GNU General Public License | ||
18 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | 15 | * | ||
20 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> | ||
21 | 17 | */ | ||
22 | 18 | |||
23 | 19 | #ifndef MIR_COMPOSITOR_FRAME_DROPPING_POLICY_H_ | ||
24 | 20 | #define MIR_COMPOSITOR_FRAME_DROPPING_POLICY_H_ | ||
25 | 21 | |||
26 | 22 | #include <functional> | ||
27 | 23 | |||
28 | 24 | namespace mir | ||
29 | 25 | { | ||
30 | 26 | namespace compositor | ||
31 | 27 | { | ||
32 | 28 | /** | ||
33 | 29 | * \brief Policy to determine when to drop a frame from a client | ||
34 | 30 | * | ||
35 | 31 | * The FrameDroppingPolicy objects are constructed from a | ||
36 | 32 | * \ref FrameDroppingPolicyFactory | ||
37 | 33 | * | ||
38 | 34 | * The frame dropping mechanism is provided as the | ||
39 | 35 | * \a drop_frames argument of \ref FrameDroppingPolicyFactory::create_policy | ||
40 | 36 | * | ||
41 | 37 | * The policy may decide to drop a frame any time that there is an outstanding | ||
42 | 38 | * swap - namely, when there have been more calls to \ref swap_now_blocking | ||
43 | 39 | * than to \ref swap_unblocked | ||
44 | 40 | */ | ||
45 | 41 | class FrameDroppingPolicy | ||
46 | 42 | { | ||
47 | 43 | public: | ||
48 | 44 | virtual ~FrameDroppingPolicy() = default; | ||
49 | 45 | |||
50 | 46 | FrameDroppingPolicy(FrameDroppingPolicy const&) = delete; | ||
51 | 47 | FrameDroppingPolicy& operator=(FrameDroppingPolicy const&) = delete; | ||
52 | 48 | |||
53 | 49 | /** | ||
54 | 50 | * \brief Notify that a swap is now blocking | ||
55 | 51 | */ | ||
56 | 52 | virtual void swap_now_blocking() = 0; | ||
57 | 53 | /** | ||
58 | 54 | * \brief Notify that previous swap is no longer blocking | ||
59 | 55 | */ | ||
60 | 56 | virtual void swap_unblocked() = 0; | ||
61 | 57 | |||
62 | 58 | protected: | ||
63 | 59 | /** | ||
64 | 60 | * \note FrameDroppingPolicies should not be constructed directly; | ||
65 | 61 | * use a \ref FrameDroppingPolicyFactory | ||
66 | 62 | */ | ||
67 | 63 | FrameDroppingPolicy() = default; | ||
68 | 64 | }; | ||
69 | 65 | |||
70 | 66 | } | ||
71 | 67 | } | ||
72 | 68 | |||
73 | 69 | #endif // MIR_COMPOSITOR_FRAME_DROPPING_POLICY_H_ | ||
74 | 70 | 0 | ||
75 | === removed file 'src/include/server/mir/compositor/frame_dropping_policy_factory.h' | |||
76 | --- src/include/server/mir/compositor/frame_dropping_policy_factory.h 2017-01-18 02:29:37 +0000 | |||
77 | +++ src/include/server/mir/compositor/frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000 | |||
78 | @@ -1,74 +0,0 @@ | |||
79 | 1 | /* | ||
80 | 2 | * Copyright © 2014-2015 Canonical Ltd. | ||
81 | 3 | * | ||
82 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
83 | 5 | * under the terms of the GNU General Public License version 3, | ||
84 | 6 | * as published by the Free Software Foundation. | ||
85 | 7 | * | ||
86 | 8 | * This program is distributed in the hope that it will be useful, | ||
87 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
88 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
89 | 11 | * GNU General Public License for more details. | ||
90 | 12 | * | ||
91 | 13 | * You should have received a copy of the GNU General Public License | ||
92 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
93 | 15 | * | ||
94 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> | ||
95 | 17 | * Alberto Aguirre <alberto.aguirre@canonical.com> | ||
96 | 18 | */ | ||
97 | 19 | |||
98 | 20 | #ifndef MIR_COMPOSITOR_FRAME_DROPPING_POLICY_FACTORY_H_ | ||
99 | 21 | #define MIR_COMPOSITOR_FRAME_DROPPING_POLICY_FACTORY_H_ | ||
100 | 22 | |||
101 | 23 | #include <memory> | ||
102 | 24 | |||
103 | 25 | namespace mir | ||
104 | 26 | { | ||
105 | 27 | class LockableCallback; | ||
106 | 28 | |||
107 | 29 | namespace compositor | ||
108 | 30 | { | ||
109 | 31 | class FrameDroppingPolicy; | ||
110 | 32 | |||
111 | 33 | /** | ||
112 | 34 | * \brief Creator of FrameDroppingPolicies | ||
113 | 35 | * | ||
114 | 36 | * The FrameDroppingPolicyFactory is how you go from a means of dropping frames - | ||
115 | 37 | * the \a drop_frames parameter of \ref create_policy - | ||
116 | 38 | * to a \ref FrameDroppingPolicy | ||
117 | 39 | */ | ||
118 | 40 | class FrameDroppingPolicyFactory | ||
119 | 41 | { | ||
120 | 42 | public: | ||
121 | 43 | FrameDroppingPolicyFactory() = default; | ||
122 | 44 | virtual ~FrameDroppingPolicyFactory() = default; | ||
123 | 45 | |||
124 | 46 | FrameDroppingPolicyFactory(FrameDroppingPolicyFactory const&) = delete; | ||
125 | 47 | FrameDroppingPolicyFactory& operator=(FrameDroppingPolicyFactory const&) = delete; | ||
126 | 48 | |||
127 | 49 | /** | ||
128 | 50 | * \brief Create a FrameDroppingPolicy that will call \a drop_frame when it | ||
129 | 51 | * decides to drop a frame | ||
130 | 52 | * | ||
131 | 53 | * A LockableCallback allows the user to preserve lock ordering | ||
132 | 54 | * in situations where FrameDroppingPolicy methods need to be called under | ||
133 | 55 | * external lock and the callback implementation needs to run code protected | ||
134 | 56 | * by the same lock. A FrameDroppingPolicy implementation may have internal | ||
135 | 57 | * locks of its own, which maybe acquired during callback dispatching; | ||
136 | 58 | * to preserve lock ordering LockableCallback::lock will be invoked during | ||
137 | 59 | * callback dispatch before any internal locks are acquired. | ||
138 | 60 | * | ||
139 | 61 | * \param drop_frame Function to call when a frame needs to be dropped | ||
140 | 62 | * \param lock Function called within the callback dispatcher context | ||
141 | 63 | * before any internal locks are acquired. | ||
142 | 64 | * \param unlock Function called within the callback dispatcher context | ||
143 | 65 | * after any internal locks are released. | ||
144 | 66 | */ | ||
145 | 67 | virtual std::unique_ptr<FrameDroppingPolicy> create_policy( | ||
146 | 68 | std::unique_ptr<LockableCallback> drop_frame) const = 0; | ||
147 | 69 | }; | ||
148 | 70 | |||
149 | 71 | } | ||
150 | 72 | } | ||
151 | 73 | |||
152 | 74 | #endif // MIR_COMPOSITOR_FRAME_DROPPING_POLICY_FACTORY_H_ | ||
153 | 75 | 0 | ||
154 | === modified file 'src/include/server/mir/default_server_configuration.h' | |||
155 | --- src/include/server/mir/default_server_configuration.h 2017-04-13 07:00:27 +0000 | |||
156 | +++ src/include/server/mir/default_server_configuration.h 2017-05-02 09:09:50 +0000 | |||
157 | @@ -54,7 +54,6 @@ | |||
158 | 54 | class DisplayBufferCompositorFactory; | 54 | class DisplayBufferCompositorFactory; |
159 | 55 | class Compositor; | 55 | class Compositor; |
160 | 56 | class CompositorReport; | 56 | class CompositorReport; |
161 | 57 | class FrameDroppingPolicyFactory; | ||
162 | 58 | } | 57 | } |
163 | 59 | namespace frontend | 58 | namespace frontend |
164 | 60 | { | 59 | { |
165 | @@ -240,7 +239,6 @@ | |||
166 | 240 | * @{ */ | 239 | * @{ */ |
167 | 241 | virtual std::shared_ptr<graphics::GraphicBufferAllocator> the_buffer_allocator(); | 240 | virtual std::shared_ptr<graphics::GraphicBufferAllocator> the_buffer_allocator(); |
168 | 242 | virtual std::shared_ptr<compositor::Scene> the_scene(); | 241 | virtual std::shared_ptr<compositor::Scene> the_scene(); |
169 | 243 | virtual std::shared_ptr<compositor::FrameDroppingPolicyFactory> the_frame_dropping_policy_factory(); | ||
170 | 244 | /** @} */ | 242 | /** @} */ |
171 | 245 | 243 | ||
172 | 246 | /** @name frontend configuration - dependencies | 244 | /** @name frontend configuration - dependencies |
173 | @@ -409,7 +407,6 @@ | |||
174 | 409 | CachedPtr<frontend::InputConfigurationChanger> input_configuration_changer; | 407 | CachedPtr<frontend::InputConfigurationChanger> input_configuration_changer; |
175 | 410 | CachedPtr<renderer::RendererFactory> renderer_factory; | 408 | CachedPtr<renderer::RendererFactory> renderer_factory; |
176 | 411 | CachedPtr<compositor::BufferStreamFactory> buffer_stream_factory; | 409 | CachedPtr<compositor::BufferStreamFactory> buffer_stream_factory; |
177 | 412 | CachedPtr<compositor::FrameDroppingPolicyFactory> frame_dropping_policy_factory; | ||
178 | 413 | CachedPtr<scene::SurfaceStack> scene_surface_stack; | 410 | CachedPtr<scene::SurfaceStack> scene_surface_stack; |
179 | 414 | CachedPtr<shell::SurfaceStack> surface_stack; | 411 | CachedPtr<shell::SurfaceStack> surface_stack; |
180 | 415 | CachedPtr<scene::SceneReport> scene_report; | 412 | CachedPtr<scene::SceneReport> scene_report; |
181 | 416 | 413 | ||
182 | === modified file 'src/server/compositor/CMakeLists.txt' | |||
183 | --- src/server/compositor/CMakeLists.txt 2017-01-18 02:29:37 +0000 | |||
184 | +++ src/server/compositor/CMakeLists.txt 2017-05-02 09:09:50 +0000 | |||
185 | @@ -16,14 +16,11 @@ | |||
186 | 16 | default_configuration.cpp | 16 | default_configuration.cpp |
187 | 17 | screencast_display_buffer.cpp | 17 | screencast_display_buffer.cpp |
188 | 18 | compositing_screencast.cpp | 18 | compositing_screencast.cpp |
189 | 19 | timeout_frame_dropping_policy_factory.cpp | ||
190 | 20 | stream.cpp | 19 | stream.cpp |
191 | 21 | multi_monitor_arbiter.cpp | 20 | multi_monitor_arbiter.cpp |
192 | 22 | buffer_map.cpp | 21 | buffer_map.cpp |
193 | 23 | dropping_schedule.cpp | 22 | dropping_schedule.cpp |
194 | 24 | queueing_schedule.cpp | 23 | queueing_schedule.cpp |
195 | 25 | ${PROJECT_SOURCE_DIR}/src/include/server/mir/compositor/frame_dropping_policy.h | ||
196 | 26 | ${PROJECT_SOURCE_DIR}/src/include/server/mir/compositor/frame_dropping_policy_factory.h | ||
197 | 27 | ) | 24 | ) |
198 | 28 | 25 | ||
199 | 29 | ADD_LIBRARY( | 26 | ADD_LIBRARY( |
200 | 30 | 27 | ||
201 | === modified file 'src/server/compositor/buffer_stream_factory.cpp' | |||
202 | --- src/server/compositor/buffer_stream_factory.cpp 2017-01-18 02:29:37 +0000 | |||
203 | +++ src/server/compositor/buffer_stream_factory.cpp 2017-05-02 09:09:50 +0000 | |||
204 | @@ -26,7 +26,6 @@ | |||
205 | 26 | #include "mir/graphics/buffer_id.h" | 26 | #include "mir/graphics/buffer_id.h" |
206 | 27 | #include "mir/graphics/graphic_buffer_allocator.h" | 27 | #include "mir/graphics/graphic_buffer_allocator.h" |
207 | 28 | #include "mir/graphics/display.h" | 28 | #include "mir/graphics/display.h" |
208 | 29 | #include "mir/compositor/frame_dropping_policy.h" | ||
209 | 30 | 29 | ||
210 | 31 | #include <cassert> | 30 | #include <cassert> |
211 | 32 | #include <memory> | 31 | #include <memory> |
212 | @@ -36,11 +35,8 @@ | |||
213 | 36 | namespace ms = mir::scene; | 35 | namespace ms = mir::scene; |
214 | 37 | namespace mf = mir::frontend; | 36 | namespace mf = mir::frontend; |
215 | 38 | 37 | ||
219 | 39 | mc::BufferStreamFactory::BufferStreamFactory( | 38 | mc::BufferStreamFactory::BufferStreamFactory() |
217 | 40 | std::shared_ptr<mc::FrameDroppingPolicyFactory> const& policy_factory) : | ||
218 | 41 | policy_factory{policy_factory} | ||
220 | 42 | { | 39 | { |
221 | 43 | assert(policy_factory); | ||
222 | 44 | } | 40 | } |
223 | 45 | 41 | ||
224 | 46 | std::shared_ptr<mc::BufferStream> mc::BufferStreamFactory::create_buffer_stream( | 42 | std::shared_ptr<mc::BufferStream> mc::BufferStreamFactory::create_buffer_stream( |
225 | @@ -55,7 +51,6 @@ | |||
226 | 55 | int, mg::BufferProperties const& buffer_properties) | 51 | int, mg::BufferProperties const& buffer_properties) |
227 | 56 | { | 52 | { |
228 | 57 | return std::make_shared<mc::Stream>( | 53 | return std::make_shared<mc::Stream>( |
229 | 58 | *policy_factory, | ||
230 | 59 | buffers, | 54 | buffers, |
231 | 60 | buffer_properties.size, buffer_properties.format); | 55 | buffer_properties.size, buffer_properties.format); |
232 | 61 | } | 56 | } |
233 | 62 | 57 | ||
234 | === modified file 'src/server/compositor/buffer_stream_factory.h' | |||
235 | --- src/server/compositor/buffer_stream_factory.h 2017-01-18 02:29:37 +0000 | |||
236 | +++ src/server/compositor/buffer_stream_factory.h 2017-05-02 09:09:50 +0000 | |||
237 | @@ -22,7 +22,6 @@ | |||
238 | 22 | #define MIR_COMPOSITOR_BUFFER_STREAM_FACTORY_H_ | 22 | #define MIR_COMPOSITOR_BUFFER_STREAM_FACTORY_H_ |
239 | 23 | 23 | ||
240 | 24 | #include "mir/scene/buffer_stream_factory.h" | 24 | #include "mir/scene/buffer_stream_factory.h" |
241 | 25 | #include "mir/compositor/frame_dropping_policy_factory.h" | ||
242 | 26 | 25 | ||
243 | 27 | #include <memory> | 26 | #include <memory> |
244 | 28 | 27 | ||
245 | @@ -38,7 +37,7 @@ | |||
246 | 38 | class BufferStreamFactory : public scene::BufferStreamFactory | 37 | class BufferStreamFactory : public scene::BufferStreamFactory |
247 | 39 | { | 38 | { |
248 | 40 | public: | 39 | public: |
250 | 41 | BufferStreamFactory(std::shared_ptr<FrameDroppingPolicyFactory> const& policy_factory); | 40 | BufferStreamFactory(); |
251 | 42 | 41 | ||
252 | 43 | virtual ~BufferStreamFactory() {} | 42 | virtual ~BufferStreamFactory() {} |
253 | 44 | 43 | ||
254 | @@ -50,9 +49,6 @@ | |||
255 | 50 | graphics::BufferProperties const&) override; | 49 | graphics::BufferProperties const&) override; |
256 | 51 | virtual std::shared_ptr<frontend::ClientBuffers> create_buffer_map( | 50 | virtual std::shared_ptr<frontend::ClientBuffers> create_buffer_map( |
257 | 52 | std::shared_ptr<frontend::BufferSink> const& sink) override; | 51 | std::shared_ptr<frontend::BufferSink> const& sink) override; |
258 | 53 | |||
259 | 54 | private: | ||
260 | 55 | std::shared_ptr<FrameDroppingPolicyFactory> const policy_factory; | ||
261 | 56 | }; | 52 | }; |
262 | 57 | 53 | ||
263 | 58 | } | 54 | } |
264 | 59 | 55 | ||
265 | === modified file 'src/server/compositor/default_configuration.cpp' | |||
266 | --- src/server/compositor/default_configuration.cpp 2017-01-30 05:18:36 +0000 | |||
267 | +++ src/server/compositor/default_configuration.cpp 2017-05-02 09:09:50 +0000 | |||
268 | @@ -24,7 +24,6 @@ | |||
269 | 24 | #include "multi_threaded_compositor.h" | 24 | #include "multi_threaded_compositor.h" |
270 | 25 | #include "gl/renderer_factory.h" | 25 | #include "gl/renderer_factory.h" |
271 | 26 | #include "compositing_screencast.h" | 26 | #include "compositing_screencast.h" |
272 | 27 | #include "timeout_frame_dropping_policy_factory.h" | ||
273 | 28 | #include "mir/main_loop.h" | 27 | #include "mir/main_loop.h" |
274 | 29 | 28 | ||
275 | 30 | #include "mir/frontend/screencast.h" | 29 | #include "mir/frontend/screencast.h" |
276 | @@ -42,19 +41,7 @@ | |||
277 | 42 | return buffer_stream_factory( | 41 | return buffer_stream_factory( |
278 | 43 | [this]() | 42 | [this]() |
279 | 44 | { | 43 | { |
293 | 45 | return std::make_shared<mc::BufferStreamFactory>( | 44 | return std::make_shared<mc::BufferStreamFactory>(); |
281 | 46 | the_frame_dropping_policy_factory()); | ||
282 | 47 | }); | ||
283 | 48 | } | ||
284 | 49 | |||
285 | 50 | std::shared_ptr<mc::FrameDroppingPolicyFactory> | ||
286 | 51 | mir::DefaultServerConfiguration::the_frame_dropping_policy_factory() | ||
287 | 52 | { | ||
288 | 53 | return frame_dropping_policy_factory( | ||
289 | 54 | [this]() | ||
290 | 55 | { | ||
291 | 56 | return std::make_shared<mc::TimeoutFrameDroppingPolicyFactory>(the_main_loop(), | ||
292 | 57 | std::chrono::milliseconds{100}); | ||
294 | 58 | }); | 45 | }); |
295 | 59 | } | 46 | } |
296 | 60 | 47 | ||
297 | 61 | 48 | ||
298 | === modified file 'src/server/compositor/stream.cpp' | |||
299 | --- src/server/compositor/stream.cpp 2017-03-14 02:26:28 +0000 | |||
300 | +++ src/server/compositor/stream.cpp 2017-05-02 09:09:50 +0000 | |||
301 | @@ -23,8 +23,6 @@ | |||
302 | 23 | #include "temporary_buffers.h" | 23 | #include "temporary_buffers.h" |
303 | 24 | #include "mir/frontend/client_buffers.h" | 24 | #include "mir/frontend/client_buffers.h" |
304 | 25 | #include "mir/graphics/buffer.h" | 25 | #include "mir/graphics/buffer.h" |
305 | 26 | #include "mir/compositor/frame_dropping_policy_factory.h" | ||
306 | 27 | #include "mir/compositor/frame_dropping_policy.h" | ||
307 | 28 | #include <boost/throw_exception.hpp> | 26 | #include <boost/throw_exception.hpp> |
308 | 29 | 27 | ||
309 | 30 | namespace mc = mir::compositor; | 28 | namespace mc = mir::compositor; |
310 | @@ -38,31 +36,8 @@ | |||
311 | 38 | Dropping | 36 | Dropping |
312 | 39 | }; | 37 | }; |
313 | 40 | 38 | ||
314 | 41 | mc::Stream::DroppingCallback::DroppingCallback(Stream* stream) : | ||
315 | 42 | stream(stream) | ||
316 | 43 | { | ||
317 | 44 | } | ||
318 | 45 | |||
319 | 46 | void mc::Stream::DroppingCallback::operator()() | ||
320 | 47 | { | ||
321 | 48 | stream->drop_frame(); | ||
322 | 49 | } | ||
323 | 50 | |||
324 | 51 | void mc::Stream::DroppingCallback::lock() | ||
325 | 52 | { | ||
326 | 53 | guard_lock = std::unique_lock<std::mutex>{stream->mutex}; | ||
327 | 54 | } | ||
328 | 55 | |||
329 | 56 | void mc::Stream::DroppingCallback::unlock() | ||
330 | 57 | { | ||
331 | 58 | if (guard_lock.owns_lock()) | ||
332 | 59 | guard_lock.unlock(); | ||
333 | 60 | } | ||
334 | 61 | |||
335 | 62 | mc::Stream::Stream( | 39 | mc::Stream::Stream( |
336 | 63 | mc::FrameDroppingPolicyFactory const& policy_factory, | ||
337 | 64 | std::shared_ptr<frontend::ClientBuffers> map, geom::Size size, MirPixelFormat pf) : | 40 | std::shared_ptr<frontend::ClientBuffers> map, geom::Size size, MirPixelFormat pf) : |
338 | 65 | drop_policy(policy_factory.create_policy(std::make_unique<DroppingCallback>(this))), | ||
339 | 66 | schedule_mode(ScheduleMode::Queueing), | 41 | schedule_mode(ScheduleMode::Queueing), |
340 | 67 | schedule(std::make_shared<mc::QueueingSchedule>()), | 42 | schedule(std::make_shared<mc::QueueingSchedule>()), |
341 | 68 | buffers(map), | 43 | buffers(map), |
342 | @@ -100,8 +75,6 @@ | |||
343 | 100 | first_frame_posted = true; | 75 | first_frame_posted = true; |
344 | 101 | buffers->receive_buffer(buffer->id()); | 76 | buffers->receive_buffer(buffer->id()); |
345 | 102 | deferred_io = schedule->schedule_nonblocking(buffers->get(buffer->id())); | 77 | deferred_io = schedule->schedule_nonblocking(buffers->get(buffer->id())); |
346 | 103 | if (!associated_buffers.empty() && (client_owned_buffer_count(lk) == 0)) | ||
347 | 104 | drop_policy->swap_now_blocking(); | ||
348 | 105 | } | 78 | } |
349 | 106 | observers.frame_posted(1, buffer->size()); | 79 | observers.frame_posted(1, buffer->size()); |
350 | 107 | 80 | ||
351 | @@ -139,10 +112,6 @@ | |||
352 | 139 | 112 | ||
353 | 140 | std::shared_ptr<mg::Buffer> mc::Stream::lock_compositor_buffer(void const* id) | 113 | std::shared_ptr<mg::Buffer> mc::Stream::lock_compositor_buffer(void const* id) |
354 | 141 | { | 114 | { |
355 | 142 | { | ||
356 | 143 | std::lock_guard<decltype(mutex)> lk(mutex); | ||
357 | 144 | drop_policy->swap_unblocked(); | ||
358 | 145 | } | ||
359 | 146 | return std::make_shared<mc::TemporaryCompositorBuffer>(arbiter, id); | 115 | return std::make_shared<mc::TemporaryCompositorBuffer>(arbiter, id); |
360 | 147 | } | 116 | } |
361 | 148 | 117 | ||
362 | @@ -242,12 +211,6 @@ | |||
363 | 242 | { | 211 | { |
364 | 243 | } | 212 | } |
365 | 244 | 213 | ||
366 | 245 | void mc::Stream::drop_frame() | ||
367 | 246 | { | ||
368 | 247 | if (schedule->num_scheduled() > 1) | ||
369 | 248 | buffers->send_buffer(schedule->next_buffer()->id()); | ||
370 | 249 | } | ||
371 | 250 | |||
372 | 251 | bool mc::Stream::suitable_for_cursor() const | 214 | bool mc::Stream::suitable_for_cursor() const |
373 | 252 | { | 215 | { |
374 | 253 | if (associated_buffers.empty()) | 216 | if (associated_buffers.empty()) |
375 | 254 | 217 | ||
376 | === modified file 'src/server/compositor/stream.h' | |||
377 | --- src/server/compositor/stream.h 2017-03-14 02:26:28 +0000 | |||
378 | +++ src/server/compositor/stream.h 2017-05-02 09:09:50 +0000 | |||
379 | @@ -36,14 +36,10 @@ | |||
380 | 36 | namespace compositor | 36 | namespace compositor |
381 | 37 | { | 37 | { |
382 | 38 | class Schedule; | 38 | class Schedule; |
383 | 39 | class FrameDroppingPolicyFactory; | ||
384 | 40 | class FrameDroppingPolicy; | ||
385 | 41 | class Stream : public BufferStream | 39 | class Stream : public BufferStream |
386 | 42 | { | 40 | { |
387 | 43 | public: | 41 | public: |
391 | 44 | Stream( | 42 | Stream(std::shared_ptr<frontend::ClientBuffers>, geometry::Size sz, MirPixelFormat format); |
389 | 45 | FrameDroppingPolicyFactory const& policy_factory, | ||
390 | 46 | std::shared_ptr<frontend::ClientBuffers>, geometry::Size sz, MirPixelFormat format); | ||
392 | 47 | ~Stream(); | 43 | ~Stream(); |
393 | 48 | 44 | ||
394 | 49 | void submit_buffer(std::shared_ptr<graphics::Buffer> const& buffer) override; | 45 | void submit_buffer(std::shared_ptr<graphics::Buffer> const& buffer) override; |
395 | @@ -67,20 +63,9 @@ | |||
396 | 67 | 63 | ||
397 | 68 | private: | 64 | private: |
398 | 69 | enum class ScheduleMode; | 65 | enum class ScheduleMode; |
399 | 70 | struct DroppingCallback : mir::LockableCallback | ||
400 | 71 | { | ||
401 | 72 | DroppingCallback(Stream* stream); | ||
402 | 73 | void operator()() override; | ||
403 | 74 | void lock() override; | ||
404 | 75 | void unlock() override; | ||
405 | 76 | Stream* stream; | ||
406 | 77 | std::unique_lock<std::mutex> guard_lock; | ||
407 | 78 | }; | ||
408 | 79 | void transition_schedule(std::shared_ptr<Schedule>&& new_schedule, std::lock_guard<std::mutex> const&); | 66 | void transition_schedule(std::shared_ptr<Schedule>&& new_schedule, std::lock_guard<std::mutex> const&); |
409 | 80 | void drop_frame(); | ||
410 | 81 | 67 | ||
411 | 82 | std::mutex mutable mutex; | 68 | std::mutex mutable mutex; |
412 | 83 | std::unique_ptr<compositor::FrameDroppingPolicy> drop_policy; | ||
413 | 84 | ScheduleMode schedule_mode; | 69 | ScheduleMode schedule_mode; |
414 | 85 | std::shared_ptr<Schedule> schedule; | 70 | std::shared_ptr<Schedule> schedule; |
415 | 86 | std::shared_ptr<frontend::ClientBuffers> const buffers; | 71 | std::shared_ptr<frontend::ClientBuffers> const buffers; |
416 | 87 | 72 | ||
417 | === removed file 'src/server/compositor/timeout_frame_dropping_policy_factory.cpp' | |||
418 | --- src/server/compositor/timeout_frame_dropping_policy_factory.cpp 2017-03-14 02:26:28 +0000 | |||
419 | +++ src/server/compositor/timeout_frame_dropping_policy_factory.cpp 1970-01-01 00:00:00 +0000 | |||
420 | @@ -1,95 +0,0 @@ | |||
421 | 1 | /* | ||
422 | 2 | * Copyright © 2014-2015 Canonical Ltd. | ||
423 | 3 | * | ||
424 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
425 | 5 | * under the terms of the GNU General Public License version 3, | ||
426 | 6 | * as published by the Free Software Foundation. | ||
427 | 7 | * | ||
428 | 8 | * This program is distributed in the hope that it will be useful, | ||
429 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
430 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
431 | 11 | * GNU General Public License for more details. | ||
432 | 12 | * | ||
433 | 13 | * You should have received a copy of the GNU General Public License | ||
434 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
435 | 15 | * | ||
436 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> | ||
437 | 17 | * Alberto Aguirre <alberto.aguirre@canonical.com> | ||
438 | 18 | */ | ||
439 | 19 | |||
440 | 20 | #include "mir/compositor/frame_dropping_policy.h" | ||
441 | 21 | #include "mir/lockable_callback_wrapper.h" | ||
442 | 22 | |||
443 | 23 | #include "timeout_frame_dropping_policy_factory.h" | ||
444 | 24 | |||
445 | 25 | #include <cassert> | ||
446 | 26 | #include <atomic> | ||
447 | 27 | #include <chrono> | ||
448 | 28 | #include <boost/throw_exception.hpp> | ||
449 | 29 | |||
450 | 30 | namespace mc = mir::compositor; | ||
451 | 31 | |||
452 | 32 | namespace | ||
453 | 33 | { | ||
454 | 34 | class TimeoutFrameDroppingPolicy : public mc::FrameDroppingPolicy | ||
455 | 35 | { | ||
456 | 36 | public: | ||
457 | 37 | TimeoutFrameDroppingPolicy(std::shared_ptr<mir::time::AlarmFactory> const& factory, | ||
458 | 38 | std::chrono::milliseconds timeout, | ||
459 | 39 | std::unique_ptr<mir::LockableCallback> drop_frame); | ||
460 | 40 | |||
461 | 41 | void swap_now_blocking() override; | ||
462 | 42 | void swap_unblocked() override; | ||
463 | 43 | |||
464 | 44 | private: | ||
465 | 45 | std::chrono::milliseconds const timeout; | ||
466 | 46 | std::atomic<unsigned int> pending_swaps; | ||
467 | 47 | |||
468 | 48 | // Ensure alarm gets destroyed first so its handler does not access dead | ||
469 | 49 | // objects. | ||
470 | 50 | std::unique_ptr<mir::time::Alarm> const alarm; | ||
471 | 51 | }; | ||
472 | 52 | |||
473 | 53 | TimeoutFrameDroppingPolicy::TimeoutFrameDroppingPolicy(std::shared_ptr<mir::time::AlarmFactory> const& factory, | ||
474 | 54 | std::chrono::milliseconds timeout, | ||
475 | 55 | std::unique_ptr<mir::LockableCallback> callback) | ||
476 | 56 | : timeout{timeout}, | ||
477 | 57 | pending_swaps{0}, | ||
478 | 58 | alarm{factory->create_alarm( | ||
479 | 59 | std::make_unique<mir::LockableCallbackWrapper>(std::move(callback), | ||
480 | 60 | [this] { assert(pending_swaps.load() > 0); }, | ||
481 | 61 | [this] { if (--pending_swaps > 0) alarm->reschedule_in(this->timeout);} ))} | ||
482 | 62 | { | ||
483 | 63 | } | ||
484 | 64 | |||
485 | 65 | void TimeoutFrameDroppingPolicy::swap_now_blocking() | ||
486 | 66 | { | ||
487 | 67 | if (pending_swaps++ == 0) | ||
488 | 68 | alarm->reschedule_in(timeout); | ||
489 | 69 | } | ||
490 | 70 | |||
491 | 71 | void TimeoutFrameDroppingPolicy::swap_unblocked() | ||
492 | 72 | { | ||
493 | 73 | if (alarm->state() != mir::time::Alarm::cancelled && alarm->cancel()) | ||
494 | 74 | { | ||
495 | 75 | if (--pending_swaps > 0) | ||
496 | 76 | { | ||
497 | 77 | alarm->reschedule_in(timeout); | ||
498 | 78 | } | ||
499 | 79 | } | ||
500 | 80 | } | ||
501 | 81 | } | ||
502 | 82 | |||
503 | 83 | mc::TimeoutFrameDroppingPolicyFactory::TimeoutFrameDroppingPolicyFactory( | ||
504 | 84 | std::shared_ptr<mir::time::AlarmFactory> const& timer, | ||
505 | 85 | std::chrono::milliseconds timeout) | ||
506 | 86 | : factory{timer}, | ||
507 | 87 | timeout{timeout} | ||
508 | 88 | { | ||
509 | 89 | } | ||
510 | 90 | |||
511 | 91 | std::unique_ptr<mc::FrameDroppingPolicy> | ||
512 | 92 | mc::TimeoutFrameDroppingPolicyFactory::create_policy(std::unique_ptr<LockableCallback> drop_frame) const | ||
513 | 93 | { | ||
514 | 94 | return std::make_unique<TimeoutFrameDroppingPolicy>(factory, timeout, std::move(drop_frame)); | ||
515 | 95 | } | ||
516 | 96 | 0 | ||
517 | === removed file 'src/server/compositor/timeout_frame_dropping_policy_factory.h' | |||
518 | --- src/server/compositor/timeout_frame_dropping_policy_factory.h 2017-01-18 02:29:37 +0000 | |||
519 | +++ src/server/compositor/timeout_frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000 | |||
520 | @@ -1,59 +0,0 @@ | |||
521 | 1 | /* | ||
522 | 2 | * Copyright © 2014-2015 Canonical Ltd. | ||
523 | 3 | * | ||
524 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
525 | 5 | * under the terms of the GNU General Public License version 3, | ||
526 | 6 | * as published by the Free Software Foundation. | ||
527 | 7 | * | ||
528 | 8 | * This program is distributed in the hope that it will be useful, | ||
529 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
530 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
531 | 11 | * GNU General Public License for more details. | ||
532 | 12 | * | ||
533 | 13 | * You should have received a copy of the GNU General Public License | ||
534 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
535 | 15 | * | ||
536 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> | ||
537 | 17 | * Alberto Aguirre <alberto.aguirre@canonical.com> | ||
538 | 18 | */ | ||
539 | 19 | |||
540 | 20 | |||
541 | 21 | #ifndef MIR_COMPOSITOR_TIMEOUT_FRAME_DROPPING_POLICY_FACTORY_H_ | ||
542 | 22 | #define MIR_COMPOSITOR_TIMEOUT_FRAME_DROPPING_POLICY_FACTORY_H_ | ||
543 | 23 | |||
544 | 24 | #include "mir/compositor/frame_dropping_policy_factory.h" | ||
545 | 25 | #include "mir/time/alarm_factory.h" | ||
546 | 26 | |||
547 | 27 | #include <memory> | ||
548 | 28 | #include <chrono> | ||
549 | 29 | |||
550 | 30 | namespace mir | ||
551 | 31 | { | ||
552 | 32 | namespace compositor | ||
553 | 33 | { | ||
554 | 34 | |||
555 | 35 | /** | ||
556 | 36 | * \brief Creator of timeout-based FrameDroppingPolicies | ||
557 | 37 | */ | ||
558 | 38 | class TimeoutFrameDroppingPolicyFactory : public FrameDroppingPolicyFactory | ||
559 | 39 | { | ||
560 | 40 | public: | ||
561 | 41 | /** | ||
562 | 42 | * \param factory Factory which can create alarms used to schedule frame drops. | ||
563 | 43 | * \param timeout Number of milliseconds to wait before dropping a frame | ||
564 | 44 | */ | ||
565 | 45 | TimeoutFrameDroppingPolicyFactory( | ||
566 | 46 | std::shared_ptr<mir::time::AlarmFactory> const& factory, | ||
567 | 47 | std::chrono::milliseconds timeout); | ||
568 | 48 | |||
569 | 49 | std::unique_ptr<FrameDroppingPolicy> create_policy( | ||
570 | 50 | std::unique_ptr<LockableCallback> drop_frame) const override; | ||
571 | 51 | private: | ||
572 | 52 | std::shared_ptr<mir::time::AlarmFactory> const factory; | ||
573 | 53 | std::chrono::milliseconds timeout; | ||
574 | 54 | }; | ||
575 | 55 | |||
576 | 56 | } | ||
577 | 57 | } | ||
578 | 58 | |||
579 | 59 | #endif // MIR_COMPOSITOR_TIMEOUT_FRAME_DROPPING_POLICY_FACTORY_FACTORY_H_ | ||
580 | 60 | 0 | ||
581 | === modified file 'src/server/symbols.map' | |||
582 | --- src/server/symbols.map 2017-04-13 07:00:27 +0000 | |||
583 | +++ src/server/symbols.map 2017-05-02 09:09:50 +0000 | |||
584 | @@ -861,7 +861,6 @@ | |||
585 | 861 | mir::DefaultServerConfiguration::the_event_filter_chain_dispatcher*; | 861 | mir::DefaultServerConfiguration::the_event_filter_chain_dispatcher*; |
586 | 862 | mir::DefaultServerConfiguration::the_fatal_error_strategy*; | 862 | mir::DefaultServerConfiguration::the_fatal_error_strategy*; |
587 | 863 | mir::DefaultServerConfiguration::the_focus_controller*; | 863 | mir::DefaultServerConfiguration::the_focus_controller*; |
588 | 864 | mir::DefaultServerConfiguration::the_frame_dropping_policy_factory*; | ||
589 | 865 | mir::DefaultServerConfiguration::the_frontend_display_changer*; | 864 | mir::DefaultServerConfiguration::the_frontend_display_changer*; |
590 | 866 | mir::DefaultServerConfiguration::the_frontend_shell*; | 865 | mir::DefaultServerConfiguration::the_frontend_shell*; |
591 | 867 | mir::DefaultServerConfiguration::the_gl_config*; | 866 | mir::DefaultServerConfiguration::the_gl_config*; |
592 | 868 | 867 | ||
593 | === modified file 'tests/acceptance-tests/test_client_surface_swap_buffers.cpp' | |||
594 | --- tests/acceptance-tests/test_client_surface_swap_buffers.cpp 2017-04-13 07:00:27 +0000 | |||
595 | +++ tests/acceptance-tests/test_client_surface_swap_buffers.cpp 2017-05-02 09:09:50 +0000 | |||
596 | @@ -26,6 +26,7 @@ | |||
597 | 26 | #include "mir/graphics/cursor.h" | 26 | #include "mir/graphics/cursor.h" |
598 | 27 | 27 | ||
599 | 28 | #include <gtest/gtest.h> | 28 | #include <gtest/gtest.h> |
600 | 29 | #include <thread> | ||
601 | 29 | 30 | ||
602 | 30 | namespace mtf = mir_test_framework; | 31 | namespace mtf = mir_test_framework; |
603 | 31 | namespace mt = mir::test; | 32 | namespace mt = mir::test; |
604 | @@ -36,11 +37,6 @@ | |||
605 | 36 | 37 | ||
606 | 37 | namespace | 38 | namespace |
607 | 38 | { | 39 | { |
608 | 39 | void swap_buffers_callback(MirBufferStream*, void* ctx) | ||
609 | 40 | { | ||
610 | 41 | auto buffers_swapped = static_cast<mt::Signal*>(ctx); | ||
611 | 42 | buffers_swapped->raise(); | ||
612 | 43 | } | ||
613 | 44 | 40 | ||
614 | 45 | struct SurfaceSwapBuffers : mtf::ConnectedClientWithAWindow | 41 | struct SurfaceSwapBuffers : mtf::ConnectedClientWithAWindow |
615 | 46 | { | 42 | { |
616 | @@ -64,13 +60,25 @@ | |||
617 | 64 | mt::Signal buffers_swapped; | 60 | mt::Signal buffers_swapped; |
618 | 65 | #pragma GCC diagnostic push | 61 | #pragma GCC diagnostic push |
619 | 66 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | 62 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
621 | 67 | mir_buffer_stream_swap_buffers(mir_window_get_buffer_stream(window), swap_buffers_callback, &buffers_swapped); | 63 | auto bs = mir_window_get_buffer_stream(window); |
622 | 68 | #pragma GCC diagnostic pop | 64 | #pragma GCC diagnostic pop |
623 | 65 | |||
624 | 66 | /* | ||
625 | 67 | * Since we're using client-side vsync now, it should always return on | ||
626 | 68 | * the swap interval regardless of whether the server actually used | ||
627 | 69 | * the frame. | ||
628 | 70 | */ | ||
629 | 71 | std::thread attempt_swap([bs, &buffers_swapped]{ | ||
630 | 72 | mir_buffer_stream_swap_buffers_sync(bs); | ||
631 | 73 | buffers_swapped.raise(); | ||
632 | 74 | }); | ||
633 | 75 | |||
634 | 69 | /* | 76 | /* |
635 | 70 | * ASSERT instead of EXPECT, since if we continue we will block in future | 77 | * ASSERT instead of EXPECT, since if we continue we will block in future |
636 | 71 | * mir client calls (e.g mir_connection_release). | 78 | * mir client calls (e.g mir_connection_release). |
637 | 72 | */ | 79 | */ |
638 | 73 | ASSERT_TRUE(buffers_swapped.wait_for(std::chrono::seconds{20})); | 80 | ASSERT_TRUE(buffers_swapped.wait_for(std::chrono::seconds{20})); |
639 | 81 | attempt_swap.join(); | ||
640 | 74 | } | 82 | } |
641 | 75 | } | 83 | } |
642 | 76 | 84 | ||
643 | 77 | 85 | ||
644 | === removed file 'tests/include/mir/test/doubles/mock_frame_dropping_policy_factory.h' | |||
645 | --- tests/include/mir/test/doubles/mock_frame_dropping_policy_factory.h 2017-01-18 02:29:37 +0000 | |||
646 | +++ tests/include/mir/test/doubles/mock_frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000 | |||
647 | @@ -1,104 +0,0 @@ | |||
648 | 1 | /* | ||
649 | 2 | * Copyright © 2014-2015 Canonical Ltd. | ||
650 | 3 | * | ||
651 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
652 | 5 | * under the terms of the GNU General Public License version 3, | ||
653 | 6 | * as published by the Free Software Foundation. | ||
654 | 7 | * | ||
655 | 8 | * This program is distributed in the hope that it will be useful, | ||
656 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
657 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
658 | 11 | * GNU General Public License for more details. | ||
659 | 12 | * | ||
660 | 13 | * You should have received a copy of the GNU General Public License | ||
661 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
662 | 15 | * | ||
663 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> | ||
664 | 17 | * Alberto Aguirre <alberto.aguirre@canonical.com> | ||
665 | 18 | */ | ||
666 | 19 | |||
667 | 20 | |||
668 | 21 | #ifndef MIR_TEST_DOUBLES_MOCK_FRAME_DROPPING_POLICY_FACTORY_H_ | ||
669 | 22 | #define MIR_TEST_DOUBLES_MOCK_FRAME_DROPPING_POLICY_FACTORY_H_ | ||
670 | 23 | |||
671 | 24 | #include "mir/compositor/frame_dropping_policy_factory.h" | ||
672 | 25 | #include "mir/compositor/frame_dropping_policy.h" | ||
673 | 26 | |||
674 | 27 | #include "mir/test/gmock_fixes.h" | ||
675 | 28 | |||
676 | 29 | #include <unordered_set> | ||
677 | 30 | #include <functional> | ||
678 | 31 | #include <memory> | ||
679 | 32 | |||
680 | 33 | #include <gmock/gmock.h> | ||
681 | 34 | |||
682 | 35 | namespace mc = mir::compositor; | ||
683 | 36 | |||
684 | 37 | namespace mir | ||
685 | 38 | { | ||
686 | 39 | class LockableCallback; | ||
687 | 40 | |||
688 | 41 | namespace test | ||
689 | 42 | { | ||
690 | 43 | namespace doubles | ||
691 | 44 | { | ||
692 | 45 | |||
693 | 46 | class MockFrameDroppingPolicyFactory; | ||
694 | 47 | |||
695 | 48 | class MockFrameDroppingPolicy : public mc::FrameDroppingPolicy | ||
696 | 49 | { | ||
697 | 50 | public: | ||
698 | 51 | MockFrameDroppingPolicy(mir::LockableCallback* callback, | ||
699 | 52 | MockFrameDroppingPolicyFactory const* parent); | ||
700 | 53 | ~MockFrameDroppingPolicy(); | ||
701 | 54 | |||
702 | 55 | MOCK_METHOD0(swap_now_blocking, void(void)); | ||
703 | 56 | MOCK_METHOD0(swap_unblocked, void(void)); | ||
704 | 57 | |||
705 | 58 | void trigger(); | ||
706 | 59 | |||
707 | 60 | private: | ||
708 | 61 | friend class MockFrameDroppingPolicyFactory; | ||
709 | 62 | void parent_destroyed(); | ||
710 | 63 | |||
711 | 64 | std::shared_ptr<mir::LockableCallback> callback; | ||
712 | 65 | MockFrameDroppingPolicyFactory const* parent; | ||
713 | 66 | }; | ||
714 | 67 | |||
715 | 68 | class MockFrameDroppingPolicyFactory : public mc::FrameDroppingPolicyFactory | ||
716 | 69 | { | ||
717 | 70 | public: | ||
718 | 71 | std::unique_ptr<mc::FrameDroppingPolicy> create_policy( | ||
719 | 72 | std::unique_ptr<mir::LockableCallback> callback) const override; | ||
720 | 73 | |||
721 | 74 | ~MockFrameDroppingPolicyFactory(); | ||
722 | 75 | |||
723 | 76 | void trigger_policies() const; | ||
724 | 77 | |||
725 | 78 | private: | ||
726 | 79 | friend class MockFrameDroppingPolicy; | ||
727 | 80 | |||
728 | 81 | void policy_destroyed(MockFrameDroppingPolicy* policy) const; | ||
729 | 82 | mutable std::unordered_set<MockFrameDroppingPolicy*> policies; | ||
730 | 83 | }; | ||
731 | 84 | |||
732 | 85 | class FrameDroppingPolicyFactoryMock : public mc::FrameDroppingPolicyFactory | ||
733 | 86 | { | ||
734 | 87 | public: | ||
735 | 88 | MOCK_CONST_METHOD1(create_policy, | ||
736 | 89 | std::unique_ptr<mc::FrameDroppingPolicy>(mir::LockableCallback* callback)); | ||
737 | 90 | |||
738 | 91 | std::unique_ptr<mc::FrameDroppingPolicy> create_policy( | ||
739 | 92 | std::unique_ptr<mir::LockableCallback> callback) const override | ||
740 | 93 | { | ||
741 | 94 | return create_policy(callback.get()); | ||
742 | 95 | } | ||
743 | 96 | |||
744 | 97 | }; | ||
745 | 98 | |||
746 | 99 | } | ||
747 | 100 | } | ||
748 | 101 | } | ||
749 | 102 | |||
750 | 103 | |||
751 | 104 | #endif // MIR_TEST_DOUBLES_MOCK_FRAME_DROPPING_POLICY_FACTORY_H_ | ||
752 | 105 | 0 | ||
753 | === removed file 'tests/include/mir/test/doubles/stub_frame_dropping_policy_factory.h' | |||
754 | --- tests/include/mir/test/doubles/stub_frame_dropping_policy_factory.h 2017-01-18 02:29:37 +0000 | |||
755 | +++ tests/include/mir/test/doubles/stub_frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000 | |||
756 | @@ -1,60 +0,0 @@ | |||
757 | 1 | /* | ||
758 | 2 | * Copyright © 2014-2015 Canonical Ltd. | ||
759 | 3 | * | ||
760 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
761 | 5 | * under the terms of the GNU General Public License version 3, | ||
762 | 6 | * as published by the Free Software Foundation. | ||
763 | 7 | * | ||
764 | 8 | * This program is distributed in the hope that it will be useful, | ||
765 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
766 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
767 | 11 | * GNU General Public License for more details. | ||
768 | 12 | * | ||
769 | 13 | * You should have received a copy of the GNU General Public License | ||
770 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
771 | 15 | * | ||
772 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> | ||
773 | 17 | * Alberto Aguirre <alberto.aguirre@canonical.com> | ||
774 | 18 | */ | ||
775 | 19 | |||
776 | 20 | |||
777 | 21 | #ifndef MIR_TEST_DOUBLES_STUB_FRAME_DROPPING_POLICY_FACTORY_H_ | ||
778 | 22 | #define MIR_TEST_DOUBLES_STUB_FRAME_DROPPING_POLICY_FACTORY_H_ | ||
779 | 23 | |||
780 | 24 | #include "mir/compositor/frame_dropping_policy_factory.h" | ||
781 | 25 | #include "mir/compositor/frame_dropping_policy.h" | ||
782 | 26 | |||
783 | 27 | namespace mc = mir::compositor; | ||
784 | 28 | |||
785 | 29 | namespace mir | ||
786 | 30 | { | ||
787 | 31 | namespace test | ||
788 | 32 | { | ||
789 | 33 | namespace doubles | ||
790 | 34 | { | ||
791 | 35 | |||
792 | 36 | class StubFrameDroppingPolicy : public mc::FrameDroppingPolicy | ||
793 | 37 | { | ||
794 | 38 | public: | ||
795 | 39 | void swap_now_blocking() | ||
796 | 40 | { | ||
797 | 41 | } | ||
798 | 42 | void swap_unblocked() | ||
799 | 43 | { | ||
800 | 44 | } | ||
801 | 45 | }; | ||
802 | 46 | |||
803 | 47 | class StubFrameDroppingPolicyFactory : public mc::FrameDroppingPolicyFactory | ||
804 | 48 | { | ||
805 | 49 | public: | ||
806 | 50 | std::unique_ptr<mc::FrameDroppingPolicy> create_policy( | ||
807 | 51 | std::unique_ptr<mir::LockableCallback>) const override | ||
808 | 52 | { | ||
809 | 53 | return std::unique_ptr<mc::FrameDroppingPolicy>{new StubFrameDroppingPolicy}; | ||
810 | 54 | } | ||
811 | 55 | }; | ||
812 | 56 | |||
813 | 57 | } | ||
814 | 58 | } | ||
815 | 59 | } | ||
816 | 60 | #endif // TEST_DOUBLES_STUB_FRAME_DROPPING_POLICY_FACTORY_H_ | ||
817 | 61 | 0 | ||
818 | === modified file 'tests/integration-tests/compositor/test_swapping_swappers.cpp' | |||
819 | --- tests/integration-tests/compositor/test_swapping_swappers.cpp 2017-01-18 02:29:37 +0000 | |||
820 | +++ tests/integration-tests/compositor/test_swapping_swappers.cpp 2017-05-02 09:09:50 +0000 | |||
821 | @@ -16,7 +16,6 @@ | |||
822 | 16 | * Authored by: Kevin DuBois <kevin.dubois@canonical.com> | 16 | * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
823 | 17 | */ | 17 | */ |
824 | 18 | 18 | ||
825 | 19 | #include "mir/test/doubles/stub_frame_dropping_policy_factory.h" | ||
826 | 20 | #include "multithread_harness.h" | 19 | #include "multithread_harness.h" |
827 | 21 | 20 | ||
828 | 22 | #include "src/server/compositor/stream.h" | 21 | #include "src/server/compositor/stream.h" |
829 | @@ -34,7 +33,6 @@ | |||
830 | 34 | namespace mg = mir::graphics; | 33 | namespace mg = mir::graphics; |
831 | 35 | namespace mt = mir::testing; | 34 | namespace mt = mir::testing; |
832 | 36 | namespace geom = mir::geometry; | 35 | namespace geom = mir::geometry; |
833 | 37 | namespace mtd = mir::test::doubles; | ||
834 | 38 | 36 | ||
835 | 39 | namespace | 37 | namespace |
836 | 40 | { | 38 | { |
837 | @@ -43,8 +41,7 @@ | |||
838 | 43 | { | 41 | { |
839 | 44 | void SetUp() | 42 | void SetUp() |
840 | 45 | { | 43 | { |
843 | 46 | mtd::StubFrameDroppingPolicyFactory policy_factory; | 44 | stream = std::make_shared<mc::Stream>( |
842 | 47 | stream = std::make_shared<mc::Stream>(policy_factory, | ||
844 | 48 | std::make_shared<mc::BufferMap>(nullptr), | 45 | std::make_shared<mc::BufferMap>(nullptr), |
845 | 49 | geom::Size{380, 210}, mir_pixel_format_abgr_8888); | 46 | geom::Size{380, 210}, mir_pixel_format_abgr_8888); |
846 | 50 | } | 47 | } |
847 | 51 | 48 | ||
848 | === modified file 'tests/integration-tests/test_buffer_scheduling.cpp' | |||
849 | --- tests/integration-tests/test_buffer_scheduling.cpp 2017-03-13 08:12:52 +0000 | |||
850 | +++ tests/integration-tests/test_buffer_scheduling.cpp 2017-05-02 09:09:50 +0000 | |||
851 | @@ -30,7 +30,6 @@ | |||
852 | 30 | #include "mir/test/doubles/stub_client_buffer_factory.h" | 30 | #include "mir/test/doubles/stub_client_buffer_factory.h" |
853 | 31 | #include "mir/test/doubles/mock_client_buffer_factory.h" | 31 | #include "mir/test/doubles/mock_client_buffer_factory.h" |
854 | 32 | #include "mir/test/doubles/stub_buffer_allocator.h" | 32 | #include "mir/test/doubles/stub_buffer_allocator.h" |
855 | 33 | #include "mir/test/doubles/mock_frame_dropping_policy_factory.h" | ||
856 | 34 | #include "mir/test/fake_shared.h" | 33 | #include "mir/test/fake_shared.h" |
857 | 35 | #include "mir_protobuf.pb.h" | 34 | #include "mir_protobuf.pb.h" |
858 | 36 | #include <gtest/gtest.h> | 35 | #include <gtest/gtest.h> |
859 | @@ -473,7 +472,6 @@ | |||
860 | 473 | sink = std::make_shared<StubEventSink>(ipc); | 472 | sink = std::make_shared<StubEventSink>(ipc); |
861 | 474 | map = std::make_shared<mc::BufferMap>(sink); | 473 | map = std::make_shared<mc::BufferMap>(sink); |
862 | 475 | auto submit_stream = std::make_shared<mc::Stream>( | 474 | auto submit_stream = std::make_shared<mc::Stream>( |
863 | 476 | drop_policy, | ||
864 | 477 | map, | 475 | map, |
865 | 478 | geom::Size{100,100}, | 476 | geom::Size{100,100}, |
866 | 479 | mir_pixel_format_abgr_8888); | 477 | mir_pixel_format_abgr_8888); |
867 | @@ -519,7 +517,6 @@ | |||
868 | 519 | consumer->set_framedropping(false); | 517 | consumer->set_framedropping(false); |
869 | 520 | } | 518 | } |
870 | 521 | 519 | ||
871 | 522 | mtd::MockFrameDroppingPolicyFactory drop_policy; | ||
872 | 523 | mtd::MockClientBufferFactory client_buffer_factory; | 520 | mtd::MockClientBufferFactory client_buffer_factory; |
873 | 524 | mtd::StubBufferAllocator server_buffer_factory; | 521 | mtd::StubBufferAllocator server_buffer_factory; |
874 | 525 | mg::BufferProperties properties{geom::Size{3,3}, mir_pixel_format_abgr_8888, mg::BufferUsage::hardware}; | 522 | mg::BufferProperties properties{geom::Size{3,3}, mir_pixel_format_abgr_8888, mg::BufferUsage::hardware}; |
875 | @@ -805,36 +802,6 @@ | |||
876 | 805 | } | 802 | } |
877 | 806 | } | 803 | } |
878 | 807 | 804 | ||
879 | 808 | // Regression test for LP: #1396006 | ||
880 | 809 | TEST_P(WithTwoOrMoreBuffers, framedropping_policy_never_drops_newest_frame) | ||
881 | 810 | { | ||
882 | 811 | for(auto i = 0; i < nbuffers; i++) | ||
883 | 812 | producer->produce(); | ||
884 | 813 | drop_policy.trigger_policies(); | ||
885 | 814 | producer->produce(); | ||
886 | 815 | |||
887 | 816 | auto production_log = producer->production_log(); | ||
888 | 817 | ASSERT_THAT(production_log, SizeIs(nbuffers + 1)); | ||
889 | 818 | EXPECT_THAT(production_log[nbuffers], Not(Eq(production_log[nbuffers - 1]))); | ||
890 | 819 | } | ||
891 | 820 | |||
892 | 821 | //TODO: (kdub) switch this test back to 2 buffers when we have timeout framedropping for NBS and nbuffers == 2 | ||
893 | 822 | TEST_P(WithThreeOrMoreBuffers, client_is_unblocked_after_policy_is_triggered) | ||
894 | 823 | { | ||
895 | 824 | producer->produce(); | ||
896 | 825 | consumer->consume(); | ||
897 | 826 | |||
898 | 827 | for(auto i = 0; i < nbuffers; i++) | ||
899 | 828 | producer->produce(); | ||
900 | 829 | drop_policy.trigger_policies(); | ||
901 | 830 | producer->produce(); | ||
902 | 831 | |||
903 | 832 | auto production_log = producer->production_log(); | ||
904 | 833 | ASSERT_THAT(production_log, SizeIs(nbuffers + 2)); | ||
905 | 834 | EXPECT_THAT(production_log[nbuffers].blockage, Eq(Access::blocked)); | ||
906 | 835 | EXPECT_THAT(production_log[nbuffers + 1].blockage, Eq(Access::unblocked)); | ||
907 | 836 | } | ||
908 | 837 | |||
909 | 838 | TEST_P(WithTwoOrMoreBuffers, client_is_not_woken_by_compositor_release) | 805 | TEST_P(WithTwoOrMoreBuffers, client_is_not_woken_by_compositor_release) |
910 | 839 | { | 806 | { |
911 | 840 | // If early release is accidentally active, make sure we see it. But it | 807 | // If early release is accidentally active, make sure we see it. But it |
912 | 841 | 808 | ||
913 | === modified file 'tests/integration-tests/test_server_shutdown.cpp' | |||
914 | --- tests/integration-tests/test_server_shutdown.cpp 2017-04-13 07:00:27 +0000 | |||
915 | +++ tests/integration-tests/test_server_shutdown.cpp 2017-05-02 09:09:50 +0000 | |||
916 | @@ -31,7 +31,6 @@ | |||
917 | 31 | #include "mir_test_framework/testing_server_configuration.h" | 31 | #include "mir_test_framework/testing_server_configuration.h" |
918 | 32 | 32 | ||
919 | 33 | #include "mir/test/doubles/null_display_buffer_compositor_factory.h" | 33 | #include "mir/test/doubles/null_display_buffer_compositor_factory.h" |
920 | 34 | #include "mir/test/doubles/stub_frame_dropping_policy_factory.h" | ||
921 | 35 | 34 | ||
922 | 36 | #include "mir/test/doubles/stub_renderer.h" | 35 | #include "mir/test/doubles/stub_renderer.h" |
923 | 37 | 36 | ||
924 | @@ -126,12 +125,6 @@ | |||
925 | 126 | return display_buffer_compositor_factory( | 125 | return display_buffer_compositor_factory( |
926 | 127 | [] { return std::make_shared<mtd::NullDisplayBufferCompositorFactory>(); }); | 126 | [] { return std::make_shared<mtd::NullDisplayBufferCompositorFactory>(); }); |
927 | 128 | } | 127 | } |
928 | 129 | // Don't drop frames, so the clients can block waiting for a buffer | ||
929 | 130 | std::shared_ptr<mc::FrameDroppingPolicyFactory> the_frame_dropping_policy_factory() override | ||
930 | 131 | { | ||
931 | 132 | return frame_dropping_policy_factory( | ||
932 | 133 | [] { return std::make_shared<mtd::StubFrameDroppingPolicyFactory>(); }); | ||
933 | 134 | } | ||
934 | 135 | }; | 128 | }; |
935 | 136 | server_configuration.reset(new ServerConfig{}); | 129 | server_configuration.reset(new ServerConfig{}); |
936 | 137 | 130 | ||
937 | 138 | 131 | ||
938 | === modified file 'tests/integration-tests/test_submit_buffer.cpp' | |||
939 | --- tests/integration-tests/test_submit_buffer.cpp 2017-04-13 07:00:27 +0000 | |||
940 | +++ tests/integration-tests/test_submit_buffer.cpp 2017-05-02 09:09:50 +0000 | |||
941 | @@ -22,7 +22,6 @@ | |||
942 | 22 | #include "mir_test_framework/any_surface.h" | 22 | #include "mir_test_framework/any_surface.h" |
943 | 23 | #include "mir/test/doubles/stub_buffer.h" | 23 | #include "mir/test/doubles/stub_buffer.h" |
944 | 24 | #include "mir/test/doubles/stub_buffer_allocator.h" | 24 | #include "mir/test/doubles/stub_buffer_allocator.h" |
945 | 25 | #include "mir/test/doubles/stub_frame_dropping_policy_factory.h" | ||
946 | 26 | #include "mir/test/doubles/stub_display.h" | 25 | #include "mir/test/doubles/stub_display.h" |
947 | 27 | #include "mir/test/doubles/null_platform.h" | 26 | #include "mir/test/doubles/null_platform.h" |
948 | 28 | #include "mir/graphics/buffer_id.h" | 27 | #include "mir/graphics/buffer_id.h" |
949 | @@ -81,7 +80,7 @@ | |||
950 | 81 | mf::BufferStreamId, std::shared_ptr<mf::ClientBuffers> const& sink, | 80 | mf::BufferStreamId, std::shared_ptr<mf::ClientBuffers> const& sink, |
951 | 82 | mg::BufferProperties const& properties) override | 81 | mg::BufferProperties const& properties) override |
952 | 83 | { | 82 | { |
954 | 84 | return std::make_shared<mc::Stream>(factory, sink, properties.size, properties.format); | 83 | return std::make_shared<mc::Stream>(sink, properties.size, properties.format); |
955 | 85 | } | 84 | } |
956 | 86 | 85 | ||
957 | 87 | std::shared_ptr<mf::ClientBuffers> create_buffer_map(std::shared_ptr<mf::BufferSink> const& sink) override | 86 | std::shared_ptr<mf::ClientBuffers> create_buffer_map(std::shared_ptr<mf::BufferSink> const& sink) override |
958 | @@ -164,7 +163,6 @@ | |||
959 | 164 | } | 163 | } |
960 | 165 | 164 | ||
961 | 166 | std::vector<mg::BufferID> const buffer_id_seq; | 165 | std::vector<mg::BufferID> const buffer_id_seq; |
962 | 167 | mtd::StubFrameDroppingPolicyFactory factory; | ||
963 | 168 | }; | 166 | }; |
964 | 169 | 167 | ||
965 | 170 | struct StubBufferPacker : public mg::PlatformIpcOperations | 168 | struct StubBufferPacker : public mg::PlatformIpcOperations |
966 | 171 | 169 | ||
967 | === modified file 'tests/integration-tests/test_surface_stack_with_compositor.cpp' | |||
968 | --- tests/integration-tests/test_surface_stack_with_compositor.cpp 2017-02-15 14:45:41 +0000 | |||
969 | +++ tests/integration-tests/test_surface_stack_with_compositor.cpp 2017-05-02 09:09:50 +0000 | |||
970 | @@ -33,7 +33,6 @@ | |||
971 | 33 | #include "mir/test/doubles/stub_display_buffer.h" | 33 | #include "mir/test/doubles/stub_display_buffer.h" |
972 | 34 | #include "mir/test/doubles/stub_buffer.h" | 34 | #include "mir/test/doubles/stub_buffer.h" |
973 | 35 | #include "mir/test/doubles/null_display_sync_group.h" | 35 | #include "mir/test/doubles/null_display_sync_group.h" |
974 | 36 | #include "mir/test/doubles/stub_frame_dropping_policy_factory.h" | ||
975 | 37 | #include "mir/test/doubles/mock_event_sink.h" | 36 | #include "mir/test/doubles/mock_event_sink.h" |
976 | 38 | #include "mir/test/doubles/stub_buffer_allocator.h" | 37 | #include "mir/test/doubles/stub_buffer_allocator.h" |
977 | 39 | 38 | ||
978 | @@ -125,7 +124,7 @@ | |||
979 | 125 | SurfaceStackCompositor() : | 124 | SurfaceStackCompositor() : |
980 | 126 | timeout{std::chrono::system_clock::now() + std::chrono::seconds(5)}, | 125 | timeout{std::chrono::system_clock::now() + std::chrono::seconds(5)}, |
981 | 127 | buffers(std::make_shared<mc::BufferMap>(std::make_shared<NiceMock<mtd::MockEventSink>>())), | 126 | buffers(std::make_shared<mc::BufferMap>(std::make_shared<NiceMock<mtd::MockEventSink>>())), |
983 | 128 | stream(std::make_shared<mc::Stream>(policy_factory, buffers, geom::Size{ 1, 1 }, mir_pixel_format_abgr_8888 )), | 127 | stream(std::make_shared<mc::Stream>(buffers, geom::Size{ 1, 1 }, mir_pixel_format_abgr_8888 )), |
984 | 129 | mock_buffer_stream(std::make_shared<NiceMock<mtd::MockBufferStream>>()), | 128 | mock_buffer_stream(std::make_shared<NiceMock<mtd::MockBufferStream>>()), |
985 | 130 | streams({ { stream, {0,0}, {} } }), | 129 | streams({ { stream, {0,0}, {} } }), |
986 | 131 | stub_surface{std::make_shared<ms::BasicSurface>( | 130 | stub_surface{std::make_shared<ms::BasicSurface>( |
987 | @@ -141,7 +140,6 @@ | |||
988 | 141 | ON_CALL(*mock_buffer_stream, lock_compositor_buffer(_)) | 140 | ON_CALL(*mock_buffer_stream, lock_compositor_buffer(_)) |
989 | 142 | .WillByDefault(Return(mt::fake_shared(*stub_buffer))); | 141 | .WillByDefault(Return(mt::fake_shared(*stub_buffer))); |
990 | 143 | } | 142 | } |
991 | 144 | mtd::StubFrameDroppingPolicyFactory policy_factory; | ||
992 | 145 | std::shared_ptr<ms::SceneReport> null_scene_report{mr::null_scene_report()}; | 143 | std::shared_ptr<ms::SceneReport> null_scene_report{mr::null_scene_report()}; |
993 | 146 | ms::SurfaceStack stack{null_scene_report}; | 144 | ms::SurfaceStack stack{null_scene_report}; |
994 | 147 | std::shared_ptr<mc::CompositorReport> null_comp_report{mr::null_compositor_report()}; | 145 | std::shared_ptr<mc::CompositorReport> null_comp_report{mr::null_compositor_report()}; |
995 | 148 | 146 | ||
996 | === modified file 'tests/mir_test_doubles/CMakeLists.txt' | |||
997 | --- tests/mir_test_doubles/CMakeLists.txt 2017-04-21 03:08:25 +0000 | |||
998 | +++ tests/mir_test_doubles/CMakeLists.txt 2017-05-02 09:09:50 +0000 | |||
999 | @@ -15,7 +15,6 @@ | |||
1000 | 15 | TEST_UTILS_SRCS | 15 | TEST_UTILS_SRCS |
1001 | 16 | 16 | ||
1002 | 17 | mock_input_device.cpp | 17 | mock_input_device.cpp |
1003 | 18 | mock_frame_dropping_policy_factory.cpp | ||
1004 | 19 | mock_timer.cpp | 18 | mock_timer.cpp |
1005 | 20 | test_protobuf_client.cpp | 19 | test_protobuf_client.cpp |
1006 | 21 | test_protobuf_socket_server.cpp | 20 | test_protobuf_socket_server.cpp |
1007 | 22 | 21 | ||
1008 | === removed file 'tests/mir_test_doubles/mock_frame_dropping_policy_factory.cpp' | |||
1009 | --- tests/mir_test_doubles/mock_frame_dropping_policy_factory.cpp 2017-01-18 02:29:37 +0000 | |||
1010 | +++ tests/mir_test_doubles/mock_frame_dropping_policy_factory.cpp 1970-01-01 00:00:00 +0000 | |||
1011 | @@ -1,78 +0,0 @@ | |||
1012 | 1 | /* | ||
1013 | 2 | * Copyright © 2014-2015 Canonical Ltd. | ||
1014 | 3 | * | ||
1015 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1016 | 5 | * under the terms of the GNU General Public License version 3, | ||
1017 | 6 | * as published by the Free Software Foundation. | ||
1018 | 7 | * | ||
1019 | 8 | * This program is distributed in the hope that it will be useful, | ||
1020 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1021 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1022 | 11 | * GNU General Public License for more details. | ||
1023 | 12 | * | ||
1024 | 13 | * You should have received a copy of the GNU General Public License | ||
1025 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1026 | 15 | * | ||
1027 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> | ||
1028 | 17 | * Alberto Aguirre <alberto.aguirre@canonical.com> | ||
1029 | 18 | */ | ||
1030 | 19 | |||
1031 | 20 | #include "mir/test/doubles/mock_frame_dropping_policy_factory.h" | ||
1032 | 21 | |||
1033 | 22 | #include "mir/lockable_callback.h" | ||
1034 | 23 | |||
1035 | 24 | #include <mutex> | ||
1036 | 25 | |||
1037 | 26 | namespace mc = mir::compositor; | ||
1038 | 27 | namespace mtd = mir::test::doubles; | ||
1039 | 28 | |||
1040 | 29 | mtd::MockFrameDroppingPolicy::MockFrameDroppingPolicy( | ||
1041 | 30 | mir::LockableCallback* callback, | ||
1042 | 31 | MockFrameDroppingPolicyFactory const* parent) | ||
1043 | 32 | : callback{callback}, | ||
1044 | 33 | parent{parent} | ||
1045 | 34 | { | ||
1046 | 35 | } | ||
1047 | 36 | |||
1048 | 37 | mtd::MockFrameDroppingPolicy::~MockFrameDroppingPolicy() | ||
1049 | 38 | { | ||
1050 | 39 | if (parent) | ||
1051 | 40 | parent->policy_destroyed(this); | ||
1052 | 41 | } | ||
1053 | 42 | |||
1054 | 43 | void mtd::MockFrameDroppingPolicy::trigger() | ||
1055 | 44 | { | ||
1056 | 45 | auto& handler = *callback; | ||
1057 | 46 | std::lock_guard<LockableCallback> lock{handler}; | ||
1058 | 47 | handler(); | ||
1059 | 48 | } | ||
1060 | 49 | |||
1061 | 50 | void mtd::MockFrameDroppingPolicy::parent_destroyed() | ||
1062 | 51 | { | ||
1063 | 52 | parent = nullptr; | ||
1064 | 53 | } | ||
1065 | 54 | |||
1066 | 55 | std::unique_ptr<mc::FrameDroppingPolicy> | ||
1067 | 56 | mtd::MockFrameDroppingPolicyFactory::create_policy(std::unique_ptr<mir::LockableCallback> callback) const | ||
1068 | 57 | { | ||
1069 | 58 | auto policy = new testing::NiceMock<MockFrameDroppingPolicy>{callback.release(), this}; | ||
1070 | 59 | policies.insert(policy); | ||
1071 | 60 | return std::unique_ptr<mc::FrameDroppingPolicy>{policy}; | ||
1072 | 61 | } | ||
1073 | 62 | |||
1074 | 63 | mtd::MockFrameDroppingPolicyFactory::~MockFrameDroppingPolicyFactory() | ||
1075 | 64 | { | ||
1076 | 65 | for (auto policy : policies) | ||
1077 | 66 | policy->parent_destroyed(); | ||
1078 | 67 | } | ||
1079 | 68 | |||
1080 | 69 | void mtd::MockFrameDroppingPolicyFactory::trigger_policies() const | ||
1081 | 70 | { | ||
1082 | 71 | for (auto policy : policies) | ||
1083 | 72 | policy->trigger(); | ||
1084 | 73 | } | ||
1085 | 74 | |||
1086 | 75 | void mtd::MockFrameDroppingPolicyFactory::policy_destroyed(MockFrameDroppingPolicy* policy) const | ||
1087 | 76 | { | ||
1088 | 77 | policies.erase(policy); | ||
1089 | 78 | } | ||
1090 | 79 | 0 | ||
1091 | === modified file 'tests/unit-tests/compositor/CMakeLists.txt' | |||
1092 | --- tests/unit-tests/compositor/CMakeLists.txt 2017-01-18 02:29:37 +0000 | |||
1093 | +++ tests/unit-tests/compositor/CMakeLists.txt 2017-05-02 09:09:50 +0000 | |||
1094 | @@ -6,7 +6,6 @@ | |||
1095 | 6 | ${CMAKE_CURRENT_SOURCE_DIR}/test_occlusion.cpp | 6 | ${CMAKE_CURRENT_SOURCE_DIR}/test_occlusion.cpp |
1096 | 7 | ${CMAKE_CURRENT_SOURCE_DIR}/test_screencast_display_buffer.cpp | 7 | ${CMAKE_CURRENT_SOURCE_DIR}/test_screencast_display_buffer.cpp |
1097 | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/test_compositing_screencast.cpp | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/test_compositing_screencast.cpp |
1098 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/test_timeout_frame_dropping_policy.cpp | ||
1099 | 10 | ${CMAKE_CURRENT_SOURCE_DIR}/test_multi_monitor_arbiter.cpp | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/test_multi_monitor_arbiter.cpp |
1100 | 11 | ${CMAKE_CURRENT_SOURCE_DIR}/test_client_buffers.cpp | 10 | ${CMAKE_CURRENT_SOURCE_DIR}/test_client_buffers.cpp |
1101 | 12 | ${CMAKE_CURRENT_SOURCE_DIR}/test_dropping_schedule.cpp | 11 | ${CMAKE_CURRENT_SOURCE_DIR}/test_dropping_schedule.cpp |
1102 | 13 | 12 | ||
1103 | === modified file 'tests/unit-tests/compositor/test_stream.cpp' | |||
1104 | --- tests/unit-tests/compositor/test_stream.cpp 2017-03-14 02:26:28 +0000 | |||
1105 | +++ tests/unit-tests/compositor/test_stream.cpp 2017-05-02 09:09:50 +0000 | |||
1106 | @@ -19,7 +19,6 @@ | |||
1107 | 19 | #include "mir/test/doubles/stub_buffer.h" | 19 | #include "mir/test/doubles/stub_buffer.h" |
1108 | 20 | #include "mir/test/doubles/stub_buffer_allocator.h" | 20 | #include "mir/test/doubles/stub_buffer_allocator.h" |
1109 | 21 | #include "mir/test/doubles/mock_event_sink.h" | 21 | #include "mir/test/doubles/mock_event_sink.h" |
1110 | 22 | #include "mir/test/doubles/mock_frame_dropping_policy_factory.h" | ||
1111 | 23 | #include "mir/test/fake_shared.h" | 22 | #include "mir/test/fake_shared.h" |
1112 | 24 | #include "src/server/compositor/stream.h" | 23 | #include "src/server/compositor/stream.h" |
1113 | 25 | #include "mir/scene/null_surface_observer.h" | 24 | #include "mir/scene/null_surface_observer.h" |
1114 | @@ -97,9 +96,7 @@ | |||
1115 | 97 | std::vector<std::shared_ptr<mg::Buffer>> buffers; | 96 | std::vector<std::shared_ptr<mg::Buffer>> buffers; |
1116 | 98 | NiceMock<mtd::MockEventSink> mock_sink; | 97 | NiceMock<mtd::MockEventSink> mock_sink; |
1117 | 99 | MirPixelFormat construction_format{mir_pixel_format_rgb_565}; | 98 | MirPixelFormat construction_format{mir_pixel_format_rgb_565}; |
1118 | 100 | mtd::MockFrameDroppingPolicyFactory framedrop_factory; | ||
1119 | 101 | mc::Stream stream{ | 99 | mc::Stream stream{ |
1120 | 102 | framedrop_factory, | ||
1121 | 103 | std::make_unique<StubBufferMap>(mock_sink, buffers), initial_size, construction_format}; | 100 | std::make_unique<StubBufferMap>(mock_sink, buffers), initial_size, construction_format}; |
1122 | 104 | }; | 101 | }; |
1123 | 105 | } | 102 | } |
1124 | @@ -266,116 +263,6 @@ | |||
1125 | 266 | EXPECT_THAT(stream.pixel_format(), Eq(construction_format)); | 263 | EXPECT_THAT(stream.pixel_format(), Eq(construction_format)); |
1126 | 267 | } | 264 | } |
1127 | 268 | 265 | ||
1128 | 269 | //confusingly, we have two framedrops. One is swapinterval zero, where old buffers are dropped as quickly as possible. | ||
1129 | 270 | //In non-framedropping mode, we drop based on a timeout according to a policy, mostly for screen-off scenarios. | ||
1130 | 271 | // | ||
1131 | 272 | namespace | ||
1132 | 273 | { | ||
1133 | 274 | struct MockPolicy : mc::FrameDroppingPolicy | ||
1134 | 275 | { | ||
1135 | 276 | MOCK_METHOD0(swap_now_blocking, void(void)); | ||
1136 | 277 | MOCK_METHOD0(swap_unblocked, void(void)); | ||
1137 | 278 | }; | ||
1138 | 279 | } | ||
1139 | 280 | TEST_F(Stream, timer_starts_when_buffers_run_out_and_framedropping_disabled) | ||
1140 | 281 | { | ||
1141 | 282 | auto policy = std::make_unique<MockPolicy>(); | ||
1142 | 283 | mtd::FrameDroppingPolicyFactoryMock policy_factory; | ||
1143 | 284 | EXPECT_CALL(*policy, swap_now_blocking()); | ||
1144 | 285 | EXPECT_CALL(policy_factory, create_policy(_)) | ||
1145 | 286 | .WillOnce(InvokeWithoutArgs([&]{ return std::move(policy); })); | ||
1146 | 287 | mc::Stream stream{ | ||
1147 | 288 | policy_factory, | ||
1148 | 289 | std::make_unique<StubBufferMap>(mock_sink, buffers), initial_size, construction_format}; | ||
1149 | 290 | for (auto const& buffer : buffers) | ||
1150 | 291 | stream.associate_buffer(buffer->id()); | ||
1151 | 292 | |||
1152 | 293 | for (auto& buffer : buffers) | ||
1153 | 294 | stream.submit_buffer(buffer); | ||
1154 | 295 | } | ||
1155 | 296 | |||
1156 | 297 | TEST_F(Stream, timer_does_not_start_when_no_associated_buffers) | ||
1157 | 298 | { | ||
1158 | 299 | auto policy = std::make_unique<MockPolicy>(); | ||
1159 | 300 | mtd::FrameDroppingPolicyFactoryMock policy_factory; | ||
1160 | 301 | EXPECT_CALL(*policy, swap_now_blocking()) | ||
1161 | 302 | .Times(0); | ||
1162 | 303 | EXPECT_CALL(policy_factory, create_policy(_)) | ||
1163 | 304 | .WillOnce(InvokeWithoutArgs([&]{ return std::move(policy); })); | ||
1164 | 305 | mc::Stream stream{ | ||
1165 | 306 | policy_factory, | ||
1166 | 307 | std::make_unique<StubBufferMap>(mock_sink, buffers), initial_size, construction_format}; | ||
1167 | 308 | for (auto& buffer : buffers) | ||
1168 | 309 | stream.submit_buffer(buffer); | ||
1169 | 310 | } | ||
1170 | 311 | |||
1171 | 312 | TEST_F(Stream, timer_stops_if_a_buffer_is_available) | ||
1172 | 313 | { | ||
1173 | 314 | auto policy = std::make_unique<MockPolicy>(); | ||
1174 | 315 | mtd::FrameDroppingPolicyFactoryMock policy_factory; | ||
1175 | 316 | EXPECT_CALL(*policy, swap_now_blocking()); | ||
1176 | 317 | EXPECT_CALL(*policy, swap_unblocked()); | ||
1177 | 318 | EXPECT_CALL(policy_factory, create_policy(_)) | ||
1178 | 319 | .WillOnce(InvokeWithoutArgs([&]{ return std::move(policy); })); | ||
1179 | 320 | mc::Stream stream{ | ||
1180 | 321 | policy_factory, | ||
1181 | 322 | std::make_unique<StubBufferMap>(mock_sink, buffers), initial_size, construction_format}; | ||
1182 | 323 | for (auto const& buffer : buffers) | ||
1183 | 324 | stream.associate_buffer(buffer->id()); | ||
1184 | 325 | for (auto& buffer : buffers) | ||
1185 | 326 | stream.submit_buffer(buffer); | ||
1186 | 327 | stream.lock_compositor_buffer(this); | ||
1187 | 328 | } | ||
1188 | 329 | |||
1189 | 330 | TEST_F(Stream, triggering_policy_gives_a_buffer_back) | ||
1190 | 331 | { | ||
1191 | 332 | for (auto& buffer : buffers) | ||
1192 | 333 | stream.submit_buffer(buffer); | ||
1193 | 334 | stream.lock_compositor_buffer(this); | ||
1194 | 335 | |||
1195 | 336 | Mock::VerifyAndClearExpectations(&mock_sink); | ||
1196 | 337 | EXPECT_CALL(mock_sink, send_buffer(_,_,_)); | ||
1197 | 338 | framedrop_factory.trigger_policies(); | ||
1198 | 339 | Mock::VerifyAndClearExpectations(&mock_sink); | ||
1199 | 340 | } | ||
1200 | 341 | |||
1201 | 342 | TEST_F(Stream, doesnt_drop_the_only_frame_when_arbiter_has_none) | ||
1202 | 343 | { | ||
1203 | 344 | stream.submit_buffer(buffers[0]); | ||
1204 | 345 | Mock::VerifyAndClearExpectations(&mock_sink); | ||
1205 | 346 | EXPECT_CALL(mock_sink, send_buffer(_,_,_)) | ||
1206 | 347 | .Times(0); | ||
1207 | 348 | framedrop_factory.trigger_policies(); | ||
1208 | 349 | Mock::VerifyAndClearExpectations(&mock_sink); | ||
1209 | 350 | } | ||
1210 | 351 | |||
1211 | 352 | TEST_F(Stream, doesnt_drop_the_latest_frame_with_a_longer_queue) | ||
1212 | 353 | { | ||
1213 | 354 | stream.submit_buffer(buffers[0]); | ||
1214 | 355 | stream.lock_compositor_buffer(this); | ||
1215 | 356 | stream.submit_buffer(buffers[1]); | ||
1216 | 357 | stream.submit_buffer(buffers[2]); | ||
1217 | 358 | |||
1218 | 359 | Mock::VerifyAndClearExpectations(&mock_sink); | ||
1219 | 360 | EXPECT_CALL(mock_sink, send_buffer(_,Ref(*buffers[1]),_)) | ||
1220 | 361 | .Times(1); | ||
1221 | 362 | framedrop_factory.trigger_policies(); | ||
1222 | 363 | Mock::VerifyAndClearExpectations(&mock_sink); | ||
1223 | 364 | } | ||
1224 | 365 | |||
1225 | 366 | TEST_F(Stream, doesnt_drop_the_latest_frame_with_a_2_buffer_queue) | ||
1226 | 367 | { | ||
1227 | 368 | stream.submit_buffer(buffers[0]); | ||
1228 | 369 | stream.lock_compositor_buffer(this); | ||
1229 | 370 | stream.submit_buffer(buffers[1]); | ||
1230 | 371 | |||
1231 | 372 | Mock::VerifyAndClearExpectations(&mock_sink); | ||
1232 | 373 | EXPECT_CALL(mock_sink, send_buffer(_,Ref(*buffers[1]),_)) | ||
1233 | 374 | .Times(0); | ||
1234 | 375 | framedrop_factory.trigger_policies(); | ||
1235 | 376 | Mock::VerifyAndClearExpectations(&mock_sink); | ||
1236 | 377 | } | ||
1237 | 378 | |||
1238 | 379 | TEST_F(Stream, returns_buffers_to_client_when_told_to_bring_queue_up_to_date) | 266 | TEST_F(Stream, returns_buffers_to_client_when_told_to_bring_queue_up_to_date) |
1239 | 380 | { | 267 | { |
1240 | 381 | stream.submit_buffer(buffers[0]); | 268 | stream.submit_buffer(buffers[0]); |
1241 | 382 | 269 | ||
1242 | === removed file 'tests/unit-tests/compositor/test_timeout_frame_dropping_policy.cpp' | |||
1243 | --- tests/unit-tests/compositor/test_timeout_frame_dropping_policy.cpp 2017-01-18 02:29:37 +0000 | |||
1244 | +++ tests/unit-tests/compositor/test_timeout_frame_dropping_policy.cpp 1970-01-01 00:00:00 +0000 | |||
1245 | @@ -1,196 +0,0 @@ | |||
1246 | 1 | /* | ||
1247 | 2 | * Copyright © 2014-2015 Canonical Ltd. | ||
1248 | 3 | * | ||
1249 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1250 | 5 | * under the terms of the GNU General Public License version 3, | ||
1251 | 6 | * as published by the Free Software Foundation. | ||
1252 | 7 | * | ||
1253 | 8 | * This program is distributed in the hope that it will be useful, | ||
1254 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1255 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1256 | 11 | * GNU General Public License for more details. | ||
1257 | 12 | * | ||
1258 | 13 | * You should have received a copy of the GNU General Public License | ||
1259 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1260 | 15 | * | ||
1261 | 16 | * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> | ||
1262 | 17 | * Alberto Aguirre <alberto.aguirre@canonical.com> | ||
1263 | 18 | */ | ||
1264 | 19 | |||
1265 | 20 | #include "src/server/compositor/timeout_frame_dropping_policy_factory.h" | ||
1266 | 21 | #include "mir/compositor/frame_dropping_policy.h" | ||
1267 | 22 | #include "mir/basic_callback.h" | ||
1268 | 23 | |||
1269 | 24 | #include "mir/test/doubles/mock_timer.h" | ||
1270 | 25 | #include "mir/test/doubles/mock_lockable_callback.h" | ||
1271 | 26 | #include "mir/test/auto_unblock_thread.h" | ||
1272 | 27 | #include "mir/test/fake_shared.h" | ||
1273 | 28 | #include "mir/test/gmock_fixes.h" | ||
1274 | 29 | |||
1275 | 30 | #include <stdexcept> | ||
1276 | 31 | #include <mutex> | ||
1277 | 32 | |||
1278 | 33 | #include <gtest/gtest.h> | ||
1279 | 34 | #include <gmock/gmock.h> | ||
1280 | 35 | |||
1281 | 36 | namespace mc = mir::compositor; | ||
1282 | 37 | namespace mt = mir::test; | ||
1283 | 38 | namespace mtd = mir::test::doubles; | ||
1284 | 39 | |||
1285 | 40 | namespace | ||
1286 | 41 | { | ||
1287 | 42 | class TimeoutFrameDroppingPolicy : public ::testing::Test | ||
1288 | 43 | { | ||
1289 | 44 | public: | ||
1290 | 45 | |||
1291 | 46 | void SetUp() override | ||
1292 | 47 | { | ||
1293 | 48 | clock = std::make_shared<mt::FakeClock>(); | ||
1294 | 49 | timer = std::make_shared<mtd::FakeTimer>(clock); | ||
1295 | 50 | handler = std::make_unique<mir::BasicCallback>([this]{ frame_dropped = true; }); | ||
1296 | 51 | } | ||
1297 | 52 | |||
1298 | 53 | auto create_default_policy() | ||
1299 | 54 | { | ||
1300 | 55 | mc::TimeoutFrameDroppingPolicyFactory factory{timer, timeout}; | ||
1301 | 56 | return factory.create_policy(std::move(handler)); | ||
1302 | 57 | } | ||
1303 | 58 | |||
1304 | 59 | protected: | ||
1305 | 60 | std::shared_ptr<mt::FakeClock> clock; | ||
1306 | 61 | std::shared_ptr<mtd::FakeTimer> timer; | ||
1307 | 62 | std::chrono::milliseconds const timeout = std::chrono::milliseconds(1000); | ||
1308 | 63 | std::unique_ptr<mir::BasicCallback> handler; | ||
1309 | 64 | bool frame_dropped = false; | ||
1310 | 65 | }; | ||
1311 | 66 | } | ||
1312 | 67 | |||
1313 | 68 | TEST_F(TimeoutFrameDroppingPolicy, does_not_fire_before_notified_of_block) | ||
1314 | 69 | { | ||
1315 | 70 | auto policy = create_default_policy(); | ||
1316 | 71 | |||
1317 | 72 | clock->advance_time(timeout + std::chrono::milliseconds{1}); | ||
1318 | 73 | EXPECT_FALSE(frame_dropped); | ||
1319 | 74 | } | ||
1320 | 75 | |||
1321 | 76 | TEST_F(TimeoutFrameDroppingPolicy, schedules_alarm_for_correct_timeout) | ||
1322 | 77 | { | ||
1323 | 78 | auto policy = create_default_policy(); | ||
1324 | 79 | policy->swap_now_blocking(); | ||
1325 | 80 | |||
1326 | 81 | clock->advance_time(timeout - std::chrono::milliseconds{1}); | ||
1327 | 82 | EXPECT_FALSE(frame_dropped); | ||
1328 | 83 | clock->advance_time(std::chrono::milliseconds{2}); | ||
1329 | 84 | EXPECT_TRUE(frame_dropped); | ||
1330 | 85 | } | ||
1331 | 86 | |||
1332 | 87 | TEST_F(TimeoutFrameDroppingPolicy, framedrop_callback_cancelled_by_unblock) | ||
1333 | 88 | { | ||
1334 | 89 | auto policy = create_default_policy(); | ||
1335 | 90 | |||
1336 | 91 | policy->swap_now_blocking(); | ||
1337 | 92 | policy->swap_unblocked(); | ||
1338 | 93 | |||
1339 | 94 | clock->advance_time(timeout * 10); | ||
1340 | 95 | |||
1341 | 96 | EXPECT_FALSE(frame_dropped); | ||
1342 | 97 | } | ||
1343 | 98 | |||
1344 | 99 | TEST_F(TimeoutFrameDroppingPolicy, policy_drops_one_frame_per_blocking_swap) | ||
1345 | 100 | { | ||
1346 | 101 | auto policy = create_default_policy(); | ||
1347 | 102 | |||
1348 | 103 | policy->swap_now_blocking(); | ||
1349 | 104 | policy->swap_now_blocking(); | ||
1350 | 105 | policy->swap_now_blocking(); | ||
1351 | 106 | |||
1352 | 107 | clock->advance_time(timeout + std::chrono::milliseconds{1}); | ||
1353 | 108 | EXPECT_TRUE(frame_dropped); | ||
1354 | 109 | |||
1355 | 110 | frame_dropped = false; | ||
1356 | 111 | clock->advance_time(timeout + std::chrono::milliseconds{2}); | ||
1357 | 112 | EXPECT_TRUE(frame_dropped); | ||
1358 | 113 | |||
1359 | 114 | frame_dropped = false; | ||
1360 | 115 | clock->advance_time(timeout + std::chrono::milliseconds{1}); | ||
1361 | 116 | EXPECT_TRUE(frame_dropped); | ||
1362 | 117 | |||
1363 | 118 | frame_dropped = false; | ||
1364 | 119 | clock->advance_time(timeout + std::chrono::milliseconds{1}); | ||
1365 | 120 | EXPECT_FALSE(frame_dropped); | ||
1366 | 121 | } | ||
1367 | 122 | |||
1368 | 123 | TEST_F(TimeoutFrameDroppingPolicy, policy_drops_frames_no_more_frequently_than_timeout) | ||
1369 | 124 | { | ||
1370 | 125 | auto policy = create_default_policy(); | ||
1371 | 126 | |||
1372 | 127 | policy->swap_now_blocking(); | ||
1373 | 128 | policy->swap_now_blocking(); | ||
1374 | 129 | |||
1375 | 130 | clock->advance_time(timeout + std::chrono::milliseconds{1}); | ||
1376 | 131 | EXPECT_TRUE(frame_dropped); | ||
1377 | 132 | |||
1378 | 133 | frame_dropped = false; | ||
1379 | 134 | clock->advance_time(timeout - std::chrono::milliseconds{1}); | ||
1380 | 135 | EXPECT_FALSE(frame_dropped); | ||
1381 | 136 | clock->advance_time(std::chrono::milliseconds{2}); | ||
1382 | 137 | EXPECT_TRUE(frame_dropped); | ||
1383 | 138 | } | ||
1384 | 139 | |||
1385 | 140 | TEST_F(TimeoutFrameDroppingPolicy, newly_blocking_frame_doesnt_reset_timeout) | ||
1386 | 141 | { | ||
1387 | 142 | auto policy = create_default_policy(); | ||
1388 | 143 | |||
1389 | 144 | policy->swap_now_blocking(); | ||
1390 | 145 | clock->advance_time(timeout - std::chrono::milliseconds{1}); | ||
1391 | 146 | |||
1392 | 147 | policy->swap_now_blocking(); | ||
1393 | 148 | clock->advance_time(std::chrono::milliseconds{2}); | ||
1394 | 149 | EXPECT_TRUE(frame_dropped); | ||
1395 | 150 | } | ||
1396 | 151 | |||
1397 | 152 | TEST_F(TimeoutFrameDroppingPolicy, interspersed_timeouts_and_unblocks) | ||
1398 | 153 | { | ||
1399 | 154 | auto policy = create_default_policy(); | ||
1400 | 155 | |||
1401 | 156 | policy->swap_now_blocking(); | ||
1402 | 157 | policy->swap_now_blocking(); | ||
1403 | 158 | policy->swap_now_blocking(); | ||
1404 | 159 | |||
1405 | 160 | /* First frame gets dropped... */ | ||
1406 | 161 | clock->advance_time(timeout + std::chrono::milliseconds{1}); | ||
1407 | 162 | EXPECT_TRUE(frame_dropped); | ||
1408 | 163 | |||
1409 | 164 | /* ...Compositor gets its act in order and consumes a frame... */ | ||
1410 | 165 | frame_dropped = false; | ||
1411 | 166 | policy->swap_unblocked(); | ||
1412 | 167 | clock->advance_time(timeout - std::chrono::milliseconds{1}); | ||
1413 | 168 | EXPECT_FALSE(frame_dropped); | ||
1414 | 169 | |||
1415 | 170 | /* ...but not a second frame, so third swap should trigger a timeout */ | ||
1416 | 171 | clock->advance_time(std::chrono::milliseconds{2}); | ||
1417 | 172 | EXPECT_TRUE(frame_dropped); | ||
1418 | 173 | |||
1419 | 174 | frame_dropped = false; | ||
1420 | 175 | clock->advance_time(timeout + std::chrono::milliseconds{1}); | ||
1421 | 176 | EXPECT_FALSE(frame_dropped); | ||
1422 | 177 | } | ||
1423 | 178 | |||
1424 | 179 | TEST_F(TimeoutFrameDroppingPolicy, policy_calls_lock_unlock_functions) | ||
1425 | 180 | { | ||
1426 | 181 | using namespace testing; | ||
1427 | 182 | |||
1428 | 183 | mc::TimeoutFrameDroppingPolicyFactory factory{timer, timeout}; | ||
1429 | 184 | auto handler = std::make_unique<mtd::MockLockableCallback>(); | ||
1430 | 185 | { | ||
1431 | 186 | InSequence s; | ||
1432 | 187 | EXPECT_CALL(*handler, lock()); | ||
1433 | 188 | EXPECT_CALL(*handler, functor()); | ||
1434 | 189 | EXPECT_CALL(*handler, unlock()); | ||
1435 | 190 | } | ||
1436 | 191 | |||
1437 | 192 | auto policy = factory.create_policy(std::move(handler)); | ||
1438 | 193 | |||
1439 | 194 | policy->swap_now_blocking(); | ||
1440 | 195 | clock->advance_time(timeout + std::chrono::milliseconds{1}); | ||
1441 | 196 | } | ||
1442 | 197 | 0 | ||
1443 | === modified file 'tests/unit-tests/scene/test_surface_stack.cpp' | |||
1444 | --- tests/unit-tests/scene/test_surface_stack.cpp 2017-03-14 02:26:28 +0000 | |||
1445 | +++ tests/unit-tests/scene/test_surface_stack.cpp 2017-05-02 09:09:50 +0000 | |||
1446 | @@ -31,7 +31,6 @@ | |||
1447 | 31 | #include "mir/test/doubles/stub_buffer_stream_factory.h" | 31 | #include "mir/test/doubles/stub_buffer_stream_factory.h" |
1448 | 32 | #include "mir/test/doubles/stub_renderable.h" | 32 | #include "mir/test/doubles/stub_renderable.h" |
1449 | 33 | #include "mir/test/doubles/mock_buffer_stream.h" | 33 | #include "mir/test/doubles/mock_buffer_stream.h" |
1450 | 34 | #include "mir/test/doubles/stub_frame_dropping_policy_factory.h" | ||
1451 | 35 | 34 | ||
1452 | 36 | #include <gmock/gmock.h> | 35 | #include <gmock/gmock.h> |
1453 | 37 | #include <gtest/gtest.h> | 36 | #include <gtest/gtest.h> |
1454 | @@ -300,8 +299,7 @@ | |||
1455 | 300 | }; | 299 | }; |
1456 | 301 | 300 | ||
1457 | 302 | auto buffers = std::make_shared<StubBuffers>(); | 301 | auto buffers = std::make_shared<StubBuffers>(); |
1460 | 303 | mtd::StubFrameDroppingPolicyFactory factory; | 302 | auto stream = std::make_shared<mc::Stream>(buffers, geom::Size{ 1, 1 }, mir_pixel_format_abgr_8888); |
1459 | 304 | auto stream = std::make_shared<mc::Stream>(factory, buffers, geom::Size{ 1, 1 }, mir_pixel_format_abgr_8888); | ||
1461 | 305 | 303 | ||
1462 | 306 | auto surface = std::make_shared<ms::BasicSurface>( | 304 | auto surface = std::make_shared<ms::BasicSurface>( |
1463 | 307 | std::string("stub"), | 305 | std::string("stub"), |
PASSED: Continuous integration, rev:3959 /mir-jenkins. ubuntu. com/job/ mir-ci/ 3389/ /mir-jenkins. ubuntu. com/job/ build-mir/ 4588 /mir-jenkins. ubuntu. com/job/ build-0- fetch/4716 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial+ overlay/ 4705 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= zesty/4705 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= zesty/4620 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= zesty/4620/ artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial+ overlay/ 4620 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial+ overlay/ 4620/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= zesty/4620 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= zesty/4620/ artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= mesa,release= zesty/4620 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= mesa,release= zesty/4620/ artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial+ overlay/ 4620 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial+ overlay/ 4620/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
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:/
Click here to trigger a rebuild: /mir-jenkins. ubuntu. com/job/ mir-ci/ 3389/rebuild
https:/