Mir

Merge lp:~vanvugt/mir/drop-frame-dropping-policy into lp:mir

Proposed by Daniel van Vugt
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
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_stream_swap_buffers can possibly trigger it and
    that is either deprecated [1] or will stop triggering it once
    ported to client-side vsync at least.

[1] https://code.launchpad.net/~vanvugt/mir/deprecate-mir_buffer_stream_swap_buffers/+merge/323484

Description of the change

This branch has a weak prerequisite on either [1] landing, or it
getting ported to client-side vsync.

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3959
https://mir-jenkins.ubuntu.com/job/mir-ci/3389/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/4588
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/4716
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/4705
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/4705
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4620
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4620/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4620
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4620/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4620
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4620/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4620
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4620/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4620
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4620/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3389/rebuild

review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

yes this should no longer be needed.

review: Approve

Preview Diff

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

Subscribers

People subscribed via source and target branches