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
=== removed file 'src/include/server/mir/compositor/frame_dropping_policy.h'
--- src/include/server/mir/compositor/frame_dropping_policy.h 2015-02-22 07:46:25 +0000
+++ src/include/server/mir/compositor/frame_dropping_policy.h 1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_COMPOSITOR_FRAME_DROPPING_POLICY_H_
20#define MIR_COMPOSITOR_FRAME_DROPPING_POLICY_H_
21
22#include <functional>
23
24namespace mir
25{
26namespace compositor
27{
28/**
29 * \brief Policy to determine when to drop a frame from a client
30 *
31 * The FrameDroppingPolicy objects are constructed from a
32 * \ref FrameDroppingPolicyFactory
33 *
34 * The frame dropping mechanism is provided as the
35 * \a drop_frames argument of \ref FrameDroppingPolicyFactory::create_policy
36 *
37 * The policy may decide to drop a frame any time that there is an outstanding
38 * swap - namely, when there have been more calls to \ref swap_now_blocking
39 * than to \ref swap_unblocked
40 */
41class FrameDroppingPolicy
42{
43public:
44 virtual ~FrameDroppingPolicy() = default;
45
46 FrameDroppingPolicy(FrameDroppingPolicy const&) = delete;
47 FrameDroppingPolicy& operator=(FrameDroppingPolicy const&) = delete;
48
49 /**
50 * \brief Notify that a swap is now blocking
51 */
52 virtual void swap_now_blocking() = 0;
53 /**
54 * \brief Notify that previous swap is no longer blocking
55 */
56 virtual void swap_unblocked() = 0;
57
58protected:
59 /**
60 * \note FrameDroppingPolicies should not be constructed directly;
61 * use a \ref FrameDroppingPolicyFactory
62 */
63 FrameDroppingPolicy() = default;
64};
65
66}
67}
68
69#endif // MIR_COMPOSITOR_FRAME_DROPPING_POLICY_H_
700
=== removed file 'src/include/server/mir/compositor/frame_dropping_policy_factory.h'
--- src/include/server/mir/compositor/frame_dropping_policy_factory.h 2017-01-18 02:29:37 +0000
+++ src/include/server/mir/compositor/frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000
@@ -1,74 +0,0 @@
1/*
2 * Copyright © 2014-2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 * Alberto Aguirre <alberto.aguirre@canonical.com>
18 */
19
20#ifndef MIR_COMPOSITOR_FRAME_DROPPING_POLICY_FACTORY_H_
21#define MIR_COMPOSITOR_FRAME_DROPPING_POLICY_FACTORY_H_
22
23#include <memory>
24
25namespace mir
26{
27class LockableCallback;
28
29namespace compositor
30{
31class FrameDroppingPolicy;
32
33/**
34 * \brief Creator of FrameDroppingPolicies
35 *
36 * The FrameDroppingPolicyFactory is how you go from a means of dropping frames -
37 * the \a drop_frames parameter of \ref create_policy -
38 * to a \ref FrameDroppingPolicy
39 */
40class FrameDroppingPolicyFactory
41{
42public:
43 FrameDroppingPolicyFactory() = default;
44 virtual ~FrameDroppingPolicyFactory() = default;
45
46 FrameDroppingPolicyFactory(FrameDroppingPolicyFactory const&) = delete;
47 FrameDroppingPolicyFactory& operator=(FrameDroppingPolicyFactory const&) = delete;
48
49 /**
50 * \brief Create a FrameDroppingPolicy that will call \a drop_frame when it
51 * decides to drop a frame
52 *
53 * A LockableCallback allows the user to preserve lock ordering
54 * in situations where FrameDroppingPolicy methods need to be called under
55 * external lock and the callback implementation needs to run code protected
56 * by the same lock. A FrameDroppingPolicy implementation may have internal
57 * locks of its own, which maybe acquired during callback dispatching;
58 * to preserve lock ordering LockableCallback::lock will be invoked during
59 * callback dispatch before any internal locks are acquired.
60 *
61 * \param drop_frame Function to call when a frame needs to be dropped
62 * \param lock Function called within the callback dispatcher context
63 * before any internal locks are acquired.
64 * \param unlock Function called within the callback dispatcher context
65 * after any internal locks are released.
66 */
67 virtual std::unique_ptr<FrameDroppingPolicy> create_policy(
68 std::unique_ptr<LockableCallback> drop_frame) const = 0;
69};
70
71}
72}
73
74#endif // MIR_COMPOSITOR_FRAME_DROPPING_POLICY_FACTORY_H_
750
=== modified file 'src/include/server/mir/default_server_configuration.h'
--- src/include/server/mir/default_server_configuration.h 2017-04-13 07:00:27 +0000
+++ src/include/server/mir/default_server_configuration.h 2017-05-02 09:09:50 +0000
@@ -54,7 +54,6 @@
54class DisplayBufferCompositorFactory;54class DisplayBufferCompositorFactory;
55class Compositor;55class Compositor;
56class CompositorReport;56class CompositorReport;
57class FrameDroppingPolicyFactory;
58}57}
59namespace frontend58namespace frontend
60{59{
@@ -240,7 +239,6 @@
240 * @{ */239 * @{ */
241 virtual std::shared_ptr<graphics::GraphicBufferAllocator> the_buffer_allocator();240 virtual std::shared_ptr<graphics::GraphicBufferAllocator> the_buffer_allocator();
242 virtual std::shared_ptr<compositor::Scene> the_scene();241 virtual std::shared_ptr<compositor::Scene> the_scene();
243 virtual std::shared_ptr<compositor::FrameDroppingPolicyFactory> the_frame_dropping_policy_factory();
244 /** @} */242 /** @} */
245243
246 /** @name frontend configuration - dependencies244 /** @name frontend configuration - dependencies
@@ -409,7 +407,6 @@
409 CachedPtr<frontend::InputConfigurationChanger> input_configuration_changer;407 CachedPtr<frontend::InputConfigurationChanger> input_configuration_changer;
410 CachedPtr<renderer::RendererFactory> renderer_factory;408 CachedPtr<renderer::RendererFactory> renderer_factory;
411 CachedPtr<compositor::BufferStreamFactory> buffer_stream_factory;409 CachedPtr<compositor::BufferStreamFactory> buffer_stream_factory;
412 CachedPtr<compositor::FrameDroppingPolicyFactory> frame_dropping_policy_factory;
413 CachedPtr<scene::SurfaceStack> scene_surface_stack;410 CachedPtr<scene::SurfaceStack> scene_surface_stack;
414 CachedPtr<shell::SurfaceStack> surface_stack;411 CachedPtr<shell::SurfaceStack> surface_stack;
415 CachedPtr<scene::SceneReport> scene_report;412 CachedPtr<scene::SceneReport> scene_report;
416413
=== modified file 'src/server/compositor/CMakeLists.txt'
--- src/server/compositor/CMakeLists.txt 2017-01-18 02:29:37 +0000
+++ src/server/compositor/CMakeLists.txt 2017-05-02 09:09:50 +0000
@@ -16,14 +16,11 @@
16 default_configuration.cpp16 default_configuration.cpp
17 screencast_display_buffer.cpp17 screencast_display_buffer.cpp
18 compositing_screencast.cpp18 compositing_screencast.cpp
19 timeout_frame_dropping_policy_factory.cpp
20 stream.cpp19 stream.cpp
21 multi_monitor_arbiter.cpp20 multi_monitor_arbiter.cpp
22 buffer_map.cpp21 buffer_map.cpp
23 dropping_schedule.cpp22 dropping_schedule.cpp
24 queueing_schedule.cpp23 queueing_schedule.cpp
25 ${PROJECT_SOURCE_DIR}/src/include/server/mir/compositor/frame_dropping_policy.h
26 ${PROJECT_SOURCE_DIR}/src/include/server/mir/compositor/frame_dropping_policy_factory.h
27)24)
2825
29ADD_LIBRARY(26ADD_LIBRARY(
3027
=== modified file 'src/server/compositor/buffer_stream_factory.cpp'
--- src/server/compositor/buffer_stream_factory.cpp 2017-01-18 02:29:37 +0000
+++ src/server/compositor/buffer_stream_factory.cpp 2017-05-02 09:09:50 +0000
@@ -26,7 +26,6 @@
26#include "mir/graphics/buffer_id.h"26#include "mir/graphics/buffer_id.h"
27#include "mir/graphics/graphic_buffer_allocator.h"27#include "mir/graphics/graphic_buffer_allocator.h"
28#include "mir/graphics/display.h"28#include "mir/graphics/display.h"
29#include "mir/compositor/frame_dropping_policy.h"
3029
31#include <cassert>30#include <cassert>
32#include <memory>31#include <memory>
@@ -36,11 +35,8 @@
36namespace ms = mir::scene;35namespace ms = mir::scene;
37namespace mf = mir::frontend;36namespace mf = mir::frontend;
3837
39mc::BufferStreamFactory::BufferStreamFactory(38mc::BufferStreamFactory::BufferStreamFactory()
40 std::shared_ptr<mc::FrameDroppingPolicyFactory> const& policy_factory) :
41 policy_factory{policy_factory}
42{39{
43 assert(policy_factory);
44}40}
4541
46std::shared_ptr<mc::BufferStream> mc::BufferStreamFactory::create_buffer_stream(42std::shared_ptr<mc::BufferStream> mc::BufferStreamFactory::create_buffer_stream(
@@ -55,7 +51,6 @@
55 int, mg::BufferProperties const& buffer_properties)51 int, mg::BufferProperties const& buffer_properties)
56{52{
57 return std::make_shared<mc::Stream>(53 return std::make_shared<mc::Stream>(
58 *policy_factory,
59 buffers,54 buffers,
60 buffer_properties.size, buffer_properties.format);55 buffer_properties.size, buffer_properties.format);
61}56}
6257
=== modified file 'src/server/compositor/buffer_stream_factory.h'
--- src/server/compositor/buffer_stream_factory.h 2017-01-18 02:29:37 +0000
+++ src/server/compositor/buffer_stream_factory.h 2017-05-02 09:09:50 +0000
@@ -22,7 +22,6 @@
22#define MIR_COMPOSITOR_BUFFER_STREAM_FACTORY_H_22#define MIR_COMPOSITOR_BUFFER_STREAM_FACTORY_H_
2323
24#include "mir/scene/buffer_stream_factory.h"24#include "mir/scene/buffer_stream_factory.h"
25#include "mir/compositor/frame_dropping_policy_factory.h"
2625
27#include <memory>26#include <memory>
2827
@@ -38,7 +37,7 @@
38class BufferStreamFactory : public scene::BufferStreamFactory37class BufferStreamFactory : public scene::BufferStreamFactory
39{38{
40public:39public:
41 BufferStreamFactory(std::shared_ptr<FrameDroppingPolicyFactory> const& policy_factory);40 BufferStreamFactory();
4241
43 virtual ~BufferStreamFactory() {}42 virtual ~BufferStreamFactory() {}
4443
@@ -50,9 +49,6 @@
50 graphics::BufferProperties const&) override;49 graphics::BufferProperties const&) override;
51 virtual std::shared_ptr<frontend::ClientBuffers> create_buffer_map(50 virtual std::shared_ptr<frontend::ClientBuffers> create_buffer_map(
52 std::shared_ptr<frontend::BufferSink> const& sink) override;51 std::shared_ptr<frontend::BufferSink> const& sink) override;
53
54private:
55 std::shared_ptr<FrameDroppingPolicyFactory> const policy_factory;
56};52};
5753
58}54}
5955
=== modified file 'src/server/compositor/default_configuration.cpp'
--- src/server/compositor/default_configuration.cpp 2017-01-30 05:18:36 +0000
+++ src/server/compositor/default_configuration.cpp 2017-05-02 09:09:50 +0000
@@ -24,7 +24,6 @@
24#include "multi_threaded_compositor.h"24#include "multi_threaded_compositor.h"
25#include "gl/renderer_factory.h"25#include "gl/renderer_factory.h"
26#include "compositing_screencast.h"26#include "compositing_screencast.h"
27#include "timeout_frame_dropping_policy_factory.h"
28#include "mir/main_loop.h"27#include "mir/main_loop.h"
2928
30#include "mir/frontend/screencast.h"29#include "mir/frontend/screencast.h"
@@ -42,19 +41,7 @@
42 return buffer_stream_factory(41 return buffer_stream_factory(
43 [this]()42 [this]()
44 {43 {
45 return std::make_shared<mc::BufferStreamFactory>(44 return std::make_shared<mc::BufferStreamFactory>();
46 the_frame_dropping_policy_factory());
47 });
48}
49
50std::shared_ptr<mc::FrameDroppingPolicyFactory>
51mir::DefaultServerConfiguration::the_frame_dropping_policy_factory()
52{
53 return frame_dropping_policy_factory(
54 [this]()
55 {
56 return std::make_shared<mc::TimeoutFrameDroppingPolicyFactory>(the_main_loop(),
57 std::chrono::milliseconds{100});
58 });45 });
59}46}
6047
6148
=== modified file 'src/server/compositor/stream.cpp'
--- src/server/compositor/stream.cpp 2017-03-14 02:26:28 +0000
+++ src/server/compositor/stream.cpp 2017-05-02 09:09:50 +0000
@@ -23,8 +23,6 @@
23#include "temporary_buffers.h"23#include "temporary_buffers.h"
24#include "mir/frontend/client_buffers.h"24#include "mir/frontend/client_buffers.h"
25#include "mir/graphics/buffer.h"25#include "mir/graphics/buffer.h"
26#include "mir/compositor/frame_dropping_policy_factory.h"
27#include "mir/compositor/frame_dropping_policy.h"
28#include <boost/throw_exception.hpp>26#include <boost/throw_exception.hpp>
2927
30namespace mc = mir::compositor;28namespace mc = mir::compositor;
@@ -38,31 +36,8 @@
38 Dropping36 Dropping
39};37};
4038
41mc::Stream::DroppingCallback::DroppingCallback(Stream* stream) :
42 stream(stream)
43{
44}
45
46void mc::Stream::DroppingCallback::operator()()
47{
48 stream->drop_frame();
49}
50
51void mc::Stream::DroppingCallback::lock()
52{
53 guard_lock = std::unique_lock<std::mutex>{stream->mutex};
54}
55
56void mc::Stream::DroppingCallback::unlock()
57{
58 if (guard_lock.owns_lock())
59 guard_lock.unlock();
60}
61
62mc::Stream::Stream(39mc::Stream::Stream(
63 mc::FrameDroppingPolicyFactory const& policy_factory,
64 std::shared_ptr<frontend::ClientBuffers> map, geom::Size size, MirPixelFormat pf) :40 std::shared_ptr<frontend::ClientBuffers> map, geom::Size size, MirPixelFormat pf) :
65 drop_policy(policy_factory.create_policy(std::make_unique<DroppingCallback>(this))),
66 schedule_mode(ScheduleMode::Queueing),41 schedule_mode(ScheduleMode::Queueing),
67 schedule(std::make_shared<mc::QueueingSchedule>()),42 schedule(std::make_shared<mc::QueueingSchedule>()),
68 buffers(map),43 buffers(map),
@@ -100,8 +75,6 @@
100 first_frame_posted = true;75 first_frame_posted = true;
101 buffers->receive_buffer(buffer->id());76 buffers->receive_buffer(buffer->id());
102 deferred_io = schedule->schedule_nonblocking(buffers->get(buffer->id()));77 deferred_io = schedule->schedule_nonblocking(buffers->get(buffer->id()));
103 if (!associated_buffers.empty() && (client_owned_buffer_count(lk) == 0))
104 drop_policy->swap_now_blocking();
105 }78 }
106 observers.frame_posted(1, buffer->size());79 observers.frame_posted(1, buffer->size());
10780
@@ -139,10 +112,6 @@
139112
140std::shared_ptr<mg::Buffer> mc::Stream::lock_compositor_buffer(void const* id)113std::shared_ptr<mg::Buffer> mc::Stream::lock_compositor_buffer(void const* id)
141{114{
142 {
143 std::lock_guard<decltype(mutex)> lk(mutex);
144 drop_policy->swap_unblocked();
145 }
146 return std::make_shared<mc::TemporaryCompositorBuffer>(arbiter, id);115 return std::make_shared<mc::TemporaryCompositorBuffer>(arbiter, id);
147}116}
148117
@@ -242,12 +211,6 @@
242{211{
243}212}
244213
245void mc::Stream::drop_frame()
246{
247 if (schedule->num_scheduled() > 1)
248 buffers->send_buffer(schedule->next_buffer()->id());
249}
250
251bool mc::Stream::suitable_for_cursor() const214bool mc::Stream::suitable_for_cursor() const
252{215{
253 if (associated_buffers.empty())216 if (associated_buffers.empty())
254217
=== modified file 'src/server/compositor/stream.h'
--- src/server/compositor/stream.h 2017-03-14 02:26:28 +0000
+++ src/server/compositor/stream.h 2017-05-02 09:09:50 +0000
@@ -36,14 +36,10 @@
36namespace compositor36namespace compositor
37{37{
38class Schedule;38class Schedule;
39class FrameDroppingPolicyFactory;
40class FrameDroppingPolicy;
41class Stream : public BufferStream39class Stream : public BufferStream
42{40{
43public:41public:
44 Stream(42 Stream(std::shared_ptr<frontend::ClientBuffers>, geometry::Size sz, MirPixelFormat format);
45 FrameDroppingPolicyFactory const& policy_factory,
46 std::shared_ptr<frontend::ClientBuffers>, geometry::Size sz, MirPixelFormat format);
47 ~Stream();43 ~Stream();
4844
49 void submit_buffer(std::shared_ptr<graphics::Buffer> const& buffer) override;45 void submit_buffer(std::shared_ptr<graphics::Buffer> const& buffer) override;
@@ -67,20 +63,9 @@
6763
68private:64private:
69 enum class ScheduleMode;65 enum class ScheduleMode;
70 struct DroppingCallback : mir::LockableCallback
71 {
72 DroppingCallback(Stream* stream);
73 void operator()() override;
74 void lock() override;
75 void unlock() override;
76 Stream* stream;
77 std::unique_lock<std::mutex> guard_lock;
78 };
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&);
80 void drop_frame();
8167
82 std::mutex mutable mutex;68 std::mutex mutable mutex;
83 std::unique_ptr<compositor::FrameDroppingPolicy> drop_policy;
84 ScheduleMode schedule_mode;69 ScheduleMode schedule_mode;
85 std::shared_ptr<Schedule> schedule;70 std::shared_ptr<Schedule> schedule;
86 std::shared_ptr<frontend::ClientBuffers> const buffers;71 std::shared_ptr<frontend::ClientBuffers> const buffers;
8772
=== removed file 'src/server/compositor/timeout_frame_dropping_policy_factory.cpp'
--- src/server/compositor/timeout_frame_dropping_policy_factory.cpp 2017-03-14 02:26:28 +0000
+++ src/server/compositor/timeout_frame_dropping_policy_factory.cpp 1970-01-01 00:00:00 +0000
@@ -1,95 +0,0 @@
1/*
2 * Copyright © 2014-2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 * Alberto Aguirre <alberto.aguirre@canonical.com>
18 */
19
20#include "mir/compositor/frame_dropping_policy.h"
21#include "mir/lockable_callback_wrapper.h"
22
23#include "timeout_frame_dropping_policy_factory.h"
24
25#include <cassert>
26#include <atomic>
27#include <chrono>
28#include <boost/throw_exception.hpp>
29
30namespace mc = mir::compositor;
31
32namespace
33{
34class TimeoutFrameDroppingPolicy : public mc::FrameDroppingPolicy
35{
36public:
37 TimeoutFrameDroppingPolicy(std::shared_ptr<mir::time::AlarmFactory> const& factory,
38 std::chrono::milliseconds timeout,
39 std::unique_ptr<mir::LockableCallback> drop_frame);
40
41 void swap_now_blocking() override;
42 void swap_unblocked() override;
43
44private:
45 std::chrono::milliseconds const timeout;
46 std::atomic<unsigned int> pending_swaps;
47
48 // Ensure alarm gets destroyed first so its handler does not access dead
49 // objects.
50 std::unique_ptr<mir::time::Alarm> const alarm;
51};
52
53TimeoutFrameDroppingPolicy::TimeoutFrameDroppingPolicy(std::shared_ptr<mir::time::AlarmFactory> const& factory,
54 std::chrono::milliseconds timeout,
55 std::unique_ptr<mir::LockableCallback> callback)
56 : timeout{timeout},
57 pending_swaps{0},
58 alarm{factory->create_alarm(
59 std::make_unique<mir::LockableCallbackWrapper>(std::move(callback),
60 [this] { assert(pending_swaps.load() > 0); },
61 [this] { if (--pending_swaps > 0) alarm->reschedule_in(this->timeout);} ))}
62{
63}
64
65void TimeoutFrameDroppingPolicy::swap_now_blocking()
66{
67 if (pending_swaps++ == 0)
68 alarm->reschedule_in(timeout);
69}
70
71void TimeoutFrameDroppingPolicy::swap_unblocked()
72{
73 if (alarm->state() != mir::time::Alarm::cancelled && alarm->cancel())
74 {
75 if (--pending_swaps > 0)
76 {
77 alarm->reschedule_in(timeout);
78 }
79 }
80}
81}
82
83mc::TimeoutFrameDroppingPolicyFactory::TimeoutFrameDroppingPolicyFactory(
84 std::shared_ptr<mir::time::AlarmFactory> const& timer,
85 std::chrono::milliseconds timeout)
86 : factory{timer},
87 timeout{timeout}
88{
89}
90
91std::unique_ptr<mc::FrameDroppingPolicy>
92mc::TimeoutFrameDroppingPolicyFactory::create_policy(std::unique_ptr<LockableCallback> drop_frame) const
93{
94 return std::make_unique<TimeoutFrameDroppingPolicy>(factory, timeout, std::move(drop_frame));
95}
960
=== removed file 'src/server/compositor/timeout_frame_dropping_policy_factory.h'
--- src/server/compositor/timeout_frame_dropping_policy_factory.h 2017-01-18 02:29:37 +0000
+++ src/server/compositor/timeout_frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000
@@ -1,59 +0,0 @@
1/*
2 * Copyright © 2014-2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 * Alberto Aguirre <alberto.aguirre@canonical.com>
18 */
19
20
21#ifndef MIR_COMPOSITOR_TIMEOUT_FRAME_DROPPING_POLICY_FACTORY_H_
22#define MIR_COMPOSITOR_TIMEOUT_FRAME_DROPPING_POLICY_FACTORY_H_
23
24#include "mir/compositor/frame_dropping_policy_factory.h"
25#include "mir/time/alarm_factory.h"
26
27#include <memory>
28#include <chrono>
29
30namespace mir
31{
32namespace compositor
33{
34
35/**
36 * \brief Creator of timeout-based FrameDroppingPolicies
37 */
38class TimeoutFrameDroppingPolicyFactory : public FrameDroppingPolicyFactory
39{
40public:
41 /**
42 * \param factory Factory which can create alarms used to schedule frame drops.
43 * \param timeout Number of milliseconds to wait before dropping a frame
44 */
45 TimeoutFrameDroppingPolicyFactory(
46 std::shared_ptr<mir::time::AlarmFactory> const& factory,
47 std::chrono::milliseconds timeout);
48
49 std::unique_ptr<FrameDroppingPolicy> create_policy(
50 std::unique_ptr<LockableCallback> drop_frame) const override;
51private:
52 std::shared_ptr<mir::time::AlarmFactory> const factory;
53 std::chrono::milliseconds timeout;
54};
55
56}
57}
58
59#endif // MIR_COMPOSITOR_TIMEOUT_FRAME_DROPPING_POLICY_FACTORY_FACTORY_H_
600
=== modified file 'src/server/symbols.map'
--- src/server/symbols.map 2017-04-13 07:00:27 +0000
+++ src/server/symbols.map 2017-05-02 09:09:50 +0000
@@ -861,7 +861,6 @@
861 mir::DefaultServerConfiguration::the_event_filter_chain_dispatcher*;861 mir::DefaultServerConfiguration::the_event_filter_chain_dispatcher*;
862 mir::DefaultServerConfiguration::the_fatal_error_strategy*;862 mir::DefaultServerConfiguration::the_fatal_error_strategy*;
863 mir::DefaultServerConfiguration::the_focus_controller*;863 mir::DefaultServerConfiguration::the_focus_controller*;
864 mir::DefaultServerConfiguration::the_frame_dropping_policy_factory*;
865 mir::DefaultServerConfiguration::the_frontend_display_changer*;864 mir::DefaultServerConfiguration::the_frontend_display_changer*;
866 mir::DefaultServerConfiguration::the_frontend_shell*;865 mir::DefaultServerConfiguration::the_frontend_shell*;
867 mir::DefaultServerConfiguration::the_gl_config*;866 mir::DefaultServerConfiguration::the_gl_config*;
868867
=== modified file 'tests/acceptance-tests/test_client_surface_swap_buffers.cpp'
--- tests/acceptance-tests/test_client_surface_swap_buffers.cpp 2017-04-13 07:00:27 +0000
+++ tests/acceptance-tests/test_client_surface_swap_buffers.cpp 2017-05-02 09:09:50 +0000
@@ -26,6 +26,7 @@
26#include "mir/graphics/cursor.h"26#include "mir/graphics/cursor.h"
2727
28#include <gtest/gtest.h>28#include <gtest/gtest.h>
29#include <thread>
2930
30namespace mtf = mir_test_framework;31namespace mtf = mir_test_framework;
31namespace mt = mir::test;32namespace mt = mir::test;
@@ -36,11 +37,6 @@
3637
37namespace38namespace
38{39{
39void swap_buffers_callback(MirBufferStream*, void* ctx)
40{
41 auto buffers_swapped = static_cast<mt::Signal*>(ctx);
42 buffers_swapped->raise();
43}
4440
45struct SurfaceSwapBuffers : mtf::ConnectedClientWithAWindow41struct SurfaceSwapBuffers : mtf::ConnectedClientWithAWindow
46{42{
@@ -64,13 +60,25 @@
64 mt::Signal buffers_swapped;60 mt::Signal buffers_swapped;
65#pragma GCC diagnostic push61#pragma GCC diagnostic push
66#pragma GCC diagnostic ignored "-Wdeprecated-declarations"62#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
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);
68#pragma GCC diagnostic pop64#pragma GCC diagnostic pop
65
66 /*
67 * Since we're using client-side vsync now, it should always return on
68 * the swap interval regardless of whether the server actually used
69 * the frame.
70 */
71 std::thread attempt_swap([bs, &buffers_swapped]{
72 mir_buffer_stream_swap_buffers_sync(bs);
73 buffers_swapped.raise();
74 });
75
69 /*76 /*
70 * ASSERT instead of EXPECT, since if we continue we will block in future77 * ASSERT instead of EXPECT, since if we continue we will block in future
71 * mir client calls (e.g mir_connection_release).78 * mir client calls (e.g mir_connection_release).
72 */79 */
73 ASSERT_TRUE(buffers_swapped.wait_for(std::chrono::seconds{20}));80 ASSERT_TRUE(buffers_swapped.wait_for(std::chrono::seconds{20}));
81 attempt_swap.join();
74 }82 }
75}83}
7684
7785
=== removed file 'tests/include/mir/test/doubles/mock_frame_dropping_policy_factory.h'
--- tests/include/mir/test/doubles/mock_frame_dropping_policy_factory.h 2017-01-18 02:29:37 +0000
+++ tests/include/mir/test/doubles/mock_frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000
@@ -1,104 +0,0 @@
1/*
2 * Copyright © 2014-2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 * Alberto Aguirre <alberto.aguirre@canonical.com>
18 */
19
20
21#ifndef MIR_TEST_DOUBLES_MOCK_FRAME_DROPPING_POLICY_FACTORY_H_
22#define MIR_TEST_DOUBLES_MOCK_FRAME_DROPPING_POLICY_FACTORY_H_
23
24#include "mir/compositor/frame_dropping_policy_factory.h"
25#include "mir/compositor/frame_dropping_policy.h"
26
27#include "mir/test/gmock_fixes.h"
28
29#include <unordered_set>
30#include <functional>
31#include <memory>
32
33#include <gmock/gmock.h>
34
35namespace mc = mir::compositor;
36
37namespace mir
38{
39class LockableCallback;
40
41namespace test
42{
43namespace doubles
44{
45
46class MockFrameDroppingPolicyFactory;
47
48class MockFrameDroppingPolicy : public mc::FrameDroppingPolicy
49{
50public:
51 MockFrameDroppingPolicy(mir::LockableCallback* callback,
52 MockFrameDroppingPolicyFactory const* parent);
53 ~MockFrameDroppingPolicy();
54
55 MOCK_METHOD0(swap_now_blocking, void(void));
56 MOCK_METHOD0(swap_unblocked, void(void));
57
58 void trigger();
59
60private:
61 friend class MockFrameDroppingPolicyFactory;
62 void parent_destroyed();
63
64 std::shared_ptr<mir::LockableCallback> callback;
65 MockFrameDroppingPolicyFactory const* parent;
66};
67
68class MockFrameDroppingPolicyFactory : public mc::FrameDroppingPolicyFactory
69{
70public:
71 std::unique_ptr<mc::FrameDroppingPolicy> create_policy(
72 std::unique_ptr<mir::LockableCallback> callback) const override;
73
74 ~MockFrameDroppingPolicyFactory();
75
76 void trigger_policies() const;
77
78private:
79 friend class MockFrameDroppingPolicy;
80
81 void policy_destroyed(MockFrameDroppingPolicy* policy) const;
82 mutable std::unordered_set<MockFrameDroppingPolicy*> policies;
83};
84
85class FrameDroppingPolicyFactoryMock : public mc::FrameDroppingPolicyFactory
86{
87public:
88 MOCK_CONST_METHOD1(create_policy,
89 std::unique_ptr<mc::FrameDroppingPolicy>(mir::LockableCallback* callback));
90
91 std::unique_ptr<mc::FrameDroppingPolicy> create_policy(
92 std::unique_ptr<mir::LockableCallback> callback) const override
93 {
94 return create_policy(callback.get());
95 }
96
97};
98
99}
100}
101}
102
103
104#endif // MIR_TEST_DOUBLES_MOCK_FRAME_DROPPING_POLICY_FACTORY_H_
1050
=== removed file 'tests/include/mir/test/doubles/stub_frame_dropping_policy_factory.h'
--- tests/include/mir/test/doubles/stub_frame_dropping_policy_factory.h 2017-01-18 02:29:37 +0000
+++ tests/include/mir/test/doubles/stub_frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000
@@ -1,60 +0,0 @@
1/*
2 * Copyright © 2014-2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 * Alberto Aguirre <alberto.aguirre@canonical.com>
18 */
19
20
21#ifndef MIR_TEST_DOUBLES_STUB_FRAME_DROPPING_POLICY_FACTORY_H_
22#define MIR_TEST_DOUBLES_STUB_FRAME_DROPPING_POLICY_FACTORY_H_
23
24#include "mir/compositor/frame_dropping_policy_factory.h"
25#include "mir/compositor/frame_dropping_policy.h"
26
27namespace mc = mir::compositor;
28
29namespace mir
30{
31namespace test
32{
33namespace doubles
34{
35
36class StubFrameDroppingPolicy : public mc::FrameDroppingPolicy
37{
38public:
39 void swap_now_blocking()
40 {
41 }
42 void swap_unblocked()
43 {
44 }
45};
46
47class StubFrameDroppingPolicyFactory : public mc::FrameDroppingPolicyFactory
48{
49public:
50 std::unique_ptr<mc::FrameDroppingPolicy> create_policy(
51 std::unique_ptr<mir::LockableCallback>) const override
52 {
53 return std::unique_ptr<mc::FrameDroppingPolicy>{new StubFrameDroppingPolicy};
54 }
55};
56
57}
58}
59}
60#endif // TEST_DOUBLES_STUB_FRAME_DROPPING_POLICY_FACTORY_H_
610
=== modified file 'tests/integration-tests/compositor/test_swapping_swappers.cpp'
--- tests/integration-tests/compositor/test_swapping_swappers.cpp 2017-01-18 02:29:37 +0000
+++ tests/integration-tests/compositor/test_swapping_swappers.cpp 2017-05-02 09:09:50 +0000
@@ -16,7 +16,6 @@
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */17 */
1818
19#include "mir/test/doubles/stub_frame_dropping_policy_factory.h"
20#include "multithread_harness.h"19#include "multithread_harness.h"
2120
22#include "src/server/compositor/stream.h"21#include "src/server/compositor/stream.h"
@@ -34,7 +33,6 @@
34namespace mg = mir::graphics;33namespace mg = mir::graphics;
35namespace mt = mir::testing;34namespace mt = mir::testing;
36namespace geom = mir::geometry;35namespace geom = mir::geometry;
37namespace mtd = mir::test::doubles;
3836
39namespace37namespace
40{38{
@@ -43,8 +41,7 @@
43{41{
44 void SetUp()42 void SetUp()
45 {43 {
46 mtd::StubFrameDroppingPolicyFactory policy_factory;44 stream = std::make_shared<mc::Stream>(
47 stream = std::make_shared<mc::Stream>(policy_factory,
48 std::make_shared<mc::BufferMap>(nullptr),45 std::make_shared<mc::BufferMap>(nullptr),
49 geom::Size{380, 210}, mir_pixel_format_abgr_8888);46 geom::Size{380, 210}, mir_pixel_format_abgr_8888);
50 }47 }
5148
=== modified file 'tests/integration-tests/test_buffer_scheduling.cpp'
--- tests/integration-tests/test_buffer_scheduling.cpp 2017-03-13 08:12:52 +0000
+++ tests/integration-tests/test_buffer_scheduling.cpp 2017-05-02 09:09:50 +0000
@@ -30,7 +30,6 @@
30#include "mir/test/doubles/stub_client_buffer_factory.h"30#include "mir/test/doubles/stub_client_buffer_factory.h"
31#include "mir/test/doubles/mock_client_buffer_factory.h"31#include "mir/test/doubles/mock_client_buffer_factory.h"
32#include "mir/test/doubles/stub_buffer_allocator.h"32#include "mir/test/doubles/stub_buffer_allocator.h"
33#include "mir/test/doubles/mock_frame_dropping_policy_factory.h"
34#include "mir/test/fake_shared.h"33#include "mir/test/fake_shared.h"
35#include "mir_protobuf.pb.h"34#include "mir_protobuf.pb.h"
36#include <gtest/gtest.h>35#include <gtest/gtest.h>
@@ -473,7 +472,6 @@
473 sink = std::make_shared<StubEventSink>(ipc);472 sink = std::make_shared<StubEventSink>(ipc);
474 map = std::make_shared<mc::BufferMap>(sink);473 map = std::make_shared<mc::BufferMap>(sink);
475 auto submit_stream = std::make_shared<mc::Stream>(474 auto submit_stream = std::make_shared<mc::Stream>(
476 drop_policy,
477 map,475 map,
478 geom::Size{100,100},476 geom::Size{100,100},
479 mir_pixel_format_abgr_8888);477 mir_pixel_format_abgr_8888);
@@ -519,7 +517,6 @@
519 consumer->set_framedropping(false);517 consumer->set_framedropping(false);
520 }518 }
521519
522 mtd::MockFrameDroppingPolicyFactory drop_policy;
523 mtd::MockClientBufferFactory client_buffer_factory;520 mtd::MockClientBufferFactory client_buffer_factory;
524 mtd::StubBufferAllocator server_buffer_factory;521 mtd::StubBufferAllocator server_buffer_factory;
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};
@@ -805,36 +802,6 @@
805 }802 }
806}803}
807804
808// Regression test for LP: #1396006
809TEST_P(WithTwoOrMoreBuffers, framedropping_policy_never_drops_newest_frame)
810{
811 for(auto i = 0; i < nbuffers; i++)
812 producer->produce();
813 drop_policy.trigger_policies();
814 producer->produce();
815
816 auto production_log = producer->production_log();
817 ASSERT_THAT(production_log, SizeIs(nbuffers + 1));
818 EXPECT_THAT(production_log[nbuffers], Not(Eq(production_log[nbuffers - 1])));
819}
820
821//TODO: (kdub) switch this test back to 2 buffers when we have timeout framedropping for NBS and nbuffers == 2
822TEST_P(WithThreeOrMoreBuffers, client_is_unblocked_after_policy_is_triggered)
823{
824 producer->produce();
825 consumer->consume();
826
827 for(auto i = 0; i < nbuffers; i++)
828 producer->produce();
829 drop_policy.trigger_policies();
830 producer->produce();
831
832 auto production_log = producer->production_log();
833 ASSERT_THAT(production_log, SizeIs(nbuffers + 2));
834 EXPECT_THAT(production_log[nbuffers].blockage, Eq(Access::blocked));
835 EXPECT_THAT(production_log[nbuffers + 1].blockage, Eq(Access::unblocked));
836}
837
838TEST_P(WithTwoOrMoreBuffers, client_is_not_woken_by_compositor_release)805TEST_P(WithTwoOrMoreBuffers, client_is_not_woken_by_compositor_release)
839{806{
840 // If early release is accidentally active, make sure we see it. But it807 // If early release is accidentally active, make sure we see it. But it
841808
=== modified file 'tests/integration-tests/test_server_shutdown.cpp'
--- tests/integration-tests/test_server_shutdown.cpp 2017-04-13 07:00:27 +0000
+++ tests/integration-tests/test_server_shutdown.cpp 2017-05-02 09:09:50 +0000
@@ -31,7 +31,6 @@
31#include "mir_test_framework/testing_server_configuration.h"31#include "mir_test_framework/testing_server_configuration.h"
3232
33#include "mir/test/doubles/null_display_buffer_compositor_factory.h"33#include "mir/test/doubles/null_display_buffer_compositor_factory.h"
34#include "mir/test/doubles/stub_frame_dropping_policy_factory.h"
3534
36#include "mir/test/doubles/stub_renderer.h"35#include "mir/test/doubles/stub_renderer.h"
3736
@@ -126,12 +125,6 @@
126 return display_buffer_compositor_factory(125 return display_buffer_compositor_factory(
127 [] { return std::make_shared<mtd::NullDisplayBufferCompositorFactory>(); });126 [] { return std::make_shared<mtd::NullDisplayBufferCompositorFactory>(); });
128 }127 }
129 // Don't drop frames, so the clients can block waiting for a buffer
130 std::shared_ptr<mc::FrameDroppingPolicyFactory> the_frame_dropping_policy_factory() override
131 {
132 return frame_dropping_policy_factory(
133 [] { return std::make_shared<mtd::StubFrameDroppingPolicyFactory>(); });
134 }
135 };128 };
136 server_configuration.reset(new ServerConfig{});129 server_configuration.reset(new ServerConfig{});
137130
138131
=== modified file 'tests/integration-tests/test_submit_buffer.cpp'
--- tests/integration-tests/test_submit_buffer.cpp 2017-04-13 07:00:27 +0000
+++ tests/integration-tests/test_submit_buffer.cpp 2017-05-02 09:09:50 +0000
@@ -22,7 +22,6 @@
22#include "mir_test_framework/any_surface.h"22#include "mir_test_framework/any_surface.h"
23#include "mir/test/doubles/stub_buffer.h"23#include "mir/test/doubles/stub_buffer.h"
24#include "mir/test/doubles/stub_buffer_allocator.h"24#include "mir/test/doubles/stub_buffer_allocator.h"
25#include "mir/test/doubles/stub_frame_dropping_policy_factory.h"
26#include "mir/test/doubles/stub_display.h"25#include "mir/test/doubles/stub_display.h"
27#include "mir/test/doubles/null_platform.h"26#include "mir/test/doubles/null_platform.h"
28#include "mir/graphics/buffer_id.h"27#include "mir/graphics/buffer_id.h"
@@ -81,7 +80,7 @@
81 mf::BufferStreamId, std::shared_ptr<mf::ClientBuffers> const& sink,80 mf::BufferStreamId, std::shared_ptr<mf::ClientBuffers> const& sink,
82 mg::BufferProperties const& properties) override81 mg::BufferProperties const& properties) override
83 {82 {
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);
85 }84 }
8685
87 std::shared_ptr<mf::ClientBuffers> create_buffer_map(std::shared_ptr<mf::BufferSink> const& sink) override86 std::shared_ptr<mf::ClientBuffers> create_buffer_map(std::shared_ptr<mf::BufferSink> const& sink) override
@@ -164,7 +163,6 @@
164 }163 }
165164
166 std::vector<mg::BufferID> const buffer_id_seq;165 std::vector<mg::BufferID> const buffer_id_seq;
167 mtd::StubFrameDroppingPolicyFactory factory;
168};166};
169167
170struct StubBufferPacker : public mg::PlatformIpcOperations168struct StubBufferPacker : public mg::PlatformIpcOperations
171169
=== modified file 'tests/integration-tests/test_surface_stack_with_compositor.cpp'
--- tests/integration-tests/test_surface_stack_with_compositor.cpp 2017-02-15 14:45:41 +0000
+++ tests/integration-tests/test_surface_stack_with_compositor.cpp 2017-05-02 09:09:50 +0000
@@ -33,7 +33,6 @@
33#include "mir/test/doubles/stub_display_buffer.h"33#include "mir/test/doubles/stub_display_buffer.h"
34#include "mir/test/doubles/stub_buffer.h"34#include "mir/test/doubles/stub_buffer.h"
35#include "mir/test/doubles/null_display_sync_group.h"35#include "mir/test/doubles/null_display_sync_group.h"
36#include "mir/test/doubles/stub_frame_dropping_policy_factory.h"
37#include "mir/test/doubles/mock_event_sink.h"36#include "mir/test/doubles/mock_event_sink.h"
38#include "mir/test/doubles/stub_buffer_allocator.h"37#include "mir/test/doubles/stub_buffer_allocator.h"
3938
@@ -125,7 +124,7 @@
125 SurfaceStackCompositor() :124 SurfaceStackCompositor() :
126 timeout{std::chrono::system_clock::now() + std::chrono::seconds(5)},125 timeout{std::chrono::system_clock::now() + std::chrono::seconds(5)},
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>>())),
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 )),
129 mock_buffer_stream(std::make_shared<NiceMock<mtd::MockBufferStream>>()),128 mock_buffer_stream(std::make_shared<NiceMock<mtd::MockBufferStream>>()),
130 streams({ { stream, {0,0}, {} } }),129 streams({ { stream, {0,0}, {} } }),
131 stub_surface{std::make_shared<ms::BasicSurface>(130 stub_surface{std::make_shared<ms::BasicSurface>(
@@ -141,7 +140,6 @@
141 ON_CALL(*mock_buffer_stream, lock_compositor_buffer(_))140 ON_CALL(*mock_buffer_stream, lock_compositor_buffer(_))
142 .WillByDefault(Return(mt::fake_shared(*stub_buffer)));141 .WillByDefault(Return(mt::fake_shared(*stub_buffer)));
143 }142 }
144 mtd::StubFrameDroppingPolicyFactory policy_factory;
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()};
146 ms::SurfaceStack stack{null_scene_report};144 ms::SurfaceStack stack{null_scene_report};
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()};
148146
=== modified file 'tests/mir_test_doubles/CMakeLists.txt'
--- tests/mir_test_doubles/CMakeLists.txt 2017-04-21 03:08:25 +0000
+++ tests/mir_test_doubles/CMakeLists.txt 2017-05-02 09:09:50 +0000
@@ -15,7 +15,6 @@
15 TEST_UTILS_SRCS15 TEST_UTILS_SRCS
1616
17 mock_input_device.cpp17 mock_input_device.cpp
18 mock_frame_dropping_policy_factory.cpp
19 mock_timer.cpp18 mock_timer.cpp
20 test_protobuf_client.cpp19 test_protobuf_client.cpp
21 test_protobuf_socket_server.cpp20 test_protobuf_socket_server.cpp
2221
=== removed file 'tests/mir_test_doubles/mock_frame_dropping_policy_factory.cpp'
--- tests/mir_test_doubles/mock_frame_dropping_policy_factory.cpp 2017-01-18 02:29:37 +0000
+++ tests/mir_test_doubles/mock_frame_dropping_policy_factory.cpp 1970-01-01 00:00:00 +0000
@@ -1,78 +0,0 @@
1/*
2 * Copyright © 2014-2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 * Alberto Aguirre <alberto.aguirre@canonical.com>
18 */
19
20#include "mir/test/doubles/mock_frame_dropping_policy_factory.h"
21
22#include "mir/lockable_callback.h"
23
24#include <mutex>
25
26namespace mc = mir::compositor;
27namespace mtd = mir::test::doubles;
28
29mtd::MockFrameDroppingPolicy::MockFrameDroppingPolicy(
30 mir::LockableCallback* callback,
31 MockFrameDroppingPolicyFactory const* parent)
32 : callback{callback},
33 parent{parent}
34{
35}
36
37mtd::MockFrameDroppingPolicy::~MockFrameDroppingPolicy()
38{
39 if (parent)
40 parent->policy_destroyed(this);
41}
42
43void mtd::MockFrameDroppingPolicy::trigger()
44{
45 auto& handler = *callback;
46 std::lock_guard<LockableCallback> lock{handler};
47 handler();
48}
49
50void mtd::MockFrameDroppingPolicy::parent_destroyed()
51{
52 parent = nullptr;
53}
54
55std::unique_ptr<mc::FrameDroppingPolicy>
56mtd::MockFrameDroppingPolicyFactory::create_policy(std::unique_ptr<mir::LockableCallback> callback) const
57{
58 auto policy = new testing::NiceMock<MockFrameDroppingPolicy>{callback.release(), this};
59 policies.insert(policy);
60 return std::unique_ptr<mc::FrameDroppingPolicy>{policy};
61}
62
63mtd::MockFrameDroppingPolicyFactory::~MockFrameDroppingPolicyFactory()
64{
65 for (auto policy : policies)
66 policy->parent_destroyed();
67}
68
69void mtd::MockFrameDroppingPolicyFactory::trigger_policies() const
70{
71 for (auto policy : policies)
72 policy->trigger();
73}
74
75void mtd::MockFrameDroppingPolicyFactory::policy_destroyed(MockFrameDroppingPolicy* policy) const
76{
77 policies.erase(policy);
78}
790
=== modified file 'tests/unit-tests/compositor/CMakeLists.txt'
--- tests/unit-tests/compositor/CMakeLists.txt 2017-01-18 02:29:37 +0000
+++ tests/unit-tests/compositor/CMakeLists.txt 2017-05-02 09:09:50 +0000
@@ -6,7 +6,6 @@
6 ${CMAKE_CURRENT_SOURCE_DIR}/test_occlusion.cpp6 ${CMAKE_CURRENT_SOURCE_DIR}/test_occlusion.cpp
7 ${CMAKE_CURRENT_SOURCE_DIR}/test_screencast_display_buffer.cpp7 ${CMAKE_CURRENT_SOURCE_DIR}/test_screencast_display_buffer.cpp
8 ${CMAKE_CURRENT_SOURCE_DIR}/test_compositing_screencast.cpp8 ${CMAKE_CURRENT_SOURCE_DIR}/test_compositing_screencast.cpp
9 ${CMAKE_CURRENT_SOURCE_DIR}/test_timeout_frame_dropping_policy.cpp
10 ${CMAKE_CURRENT_SOURCE_DIR}/test_multi_monitor_arbiter.cpp9 ${CMAKE_CURRENT_SOURCE_DIR}/test_multi_monitor_arbiter.cpp
11 ${CMAKE_CURRENT_SOURCE_DIR}/test_client_buffers.cpp10 ${CMAKE_CURRENT_SOURCE_DIR}/test_client_buffers.cpp
12 ${CMAKE_CURRENT_SOURCE_DIR}/test_dropping_schedule.cpp11 ${CMAKE_CURRENT_SOURCE_DIR}/test_dropping_schedule.cpp
1312
=== modified file 'tests/unit-tests/compositor/test_stream.cpp'
--- tests/unit-tests/compositor/test_stream.cpp 2017-03-14 02:26:28 +0000
+++ tests/unit-tests/compositor/test_stream.cpp 2017-05-02 09:09:50 +0000
@@ -19,7 +19,6 @@
19#include "mir/test/doubles/stub_buffer.h"19#include "mir/test/doubles/stub_buffer.h"
20#include "mir/test/doubles/stub_buffer_allocator.h"20#include "mir/test/doubles/stub_buffer_allocator.h"
21#include "mir/test/doubles/mock_event_sink.h"21#include "mir/test/doubles/mock_event_sink.h"
22#include "mir/test/doubles/mock_frame_dropping_policy_factory.h"
23#include "mir/test/fake_shared.h"22#include "mir/test/fake_shared.h"
24#include "src/server/compositor/stream.h"23#include "src/server/compositor/stream.h"
25#include "mir/scene/null_surface_observer.h"24#include "mir/scene/null_surface_observer.h"
@@ -97,9 +96,7 @@
97 std::vector<std::shared_ptr<mg::Buffer>> buffers;96 std::vector<std::shared_ptr<mg::Buffer>> buffers;
98 NiceMock<mtd::MockEventSink> mock_sink;97 NiceMock<mtd::MockEventSink> mock_sink;
99 MirPixelFormat construction_format{mir_pixel_format_rgb_565};98 MirPixelFormat construction_format{mir_pixel_format_rgb_565};
100 mtd::MockFrameDroppingPolicyFactory framedrop_factory;
101 mc::Stream stream{99 mc::Stream stream{
102 framedrop_factory,
103 std::make_unique<StubBufferMap>(mock_sink, buffers), initial_size, construction_format};100 std::make_unique<StubBufferMap>(mock_sink, buffers), initial_size, construction_format};
104};101};
105}102}
@@ -266,116 +263,6 @@
266 EXPECT_THAT(stream.pixel_format(), Eq(construction_format));263 EXPECT_THAT(stream.pixel_format(), Eq(construction_format));
267}264}
268265
269//confusingly, we have two framedrops. One is swapinterval zero, where old buffers are dropped as quickly as possible.
270//In non-framedropping mode, we drop based on a timeout according to a policy, mostly for screen-off scenarios.
271//
272namespace
273{
274struct MockPolicy : mc::FrameDroppingPolicy
275{
276 MOCK_METHOD0(swap_now_blocking, void(void));
277 MOCK_METHOD0(swap_unblocked, void(void));
278};
279}
280TEST_F(Stream, timer_starts_when_buffers_run_out_and_framedropping_disabled)
281{
282 auto policy = std::make_unique<MockPolicy>();
283 mtd::FrameDroppingPolicyFactoryMock policy_factory;
284 EXPECT_CALL(*policy, swap_now_blocking());
285 EXPECT_CALL(policy_factory, create_policy(_))
286 .WillOnce(InvokeWithoutArgs([&]{ return std::move(policy); }));
287 mc::Stream stream{
288 policy_factory,
289 std::make_unique<StubBufferMap>(mock_sink, buffers), initial_size, construction_format};
290 for (auto const& buffer : buffers)
291 stream.associate_buffer(buffer->id());
292
293 for (auto& buffer : buffers)
294 stream.submit_buffer(buffer);
295}
296
297TEST_F(Stream, timer_does_not_start_when_no_associated_buffers)
298{
299 auto policy = std::make_unique<MockPolicy>();
300 mtd::FrameDroppingPolicyFactoryMock policy_factory;
301 EXPECT_CALL(*policy, swap_now_blocking())
302 .Times(0);
303 EXPECT_CALL(policy_factory, create_policy(_))
304 .WillOnce(InvokeWithoutArgs([&]{ return std::move(policy); }));
305 mc::Stream stream{
306 policy_factory,
307 std::make_unique<StubBufferMap>(mock_sink, buffers), initial_size, construction_format};
308 for (auto& buffer : buffers)
309 stream.submit_buffer(buffer);
310}
311
312TEST_F(Stream, timer_stops_if_a_buffer_is_available)
313{
314 auto policy = std::make_unique<MockPolicy>();
315 mtd::FrameDroppingPolicyFactoryMock policy_factory;
316 EXPECT_CALL(*policy, swap_now_blocking());
317 EXPECT_CALL(*policy, swap_unblocked());
318 EXPECT_CALL(policy_factory, create_policy(_))
319 .WillOnce(InvokeWithoutArgs([&]{ return std::move(policy); }));
320 mc::Stream stream{
321 policy_factory,
322 std::make_unique<StubBufferMap>(mock_sink, buffers), initial_size, construction_format};
323 for (auto const& buffer : buffers)
324 stream.associate_buffer(buffer->id());
325 for (auto& buffer : buffers)
326 stream.submit_buffer(buffer);
327 stream.lock_compositor_buffer(this);
328}
329
330TEST_F(Stream, triggering_policy_gives_a_buffer_back)
331{
332 for (auto& buffer : buffers)
333 stream.submit_buffer(buffer);
334 stream.lock_compositor_buffer(this);
335
336 Mock::VerifyAndClearExpectations(&mock_sink);
337 EXPECT_CALL(mock_sink, send_buffer(_,_,_));
338 framedrop_factory.trigger_policies();
339 Mock::VerifyAndClearExpectations(&mock_sink);
340}
341
342TEST_F(Stream, doesnt_drop_the_only_frame_when_arbiter_has_none)
343{
344 stream.submit_buffer(buffers[0]);
345 Mock::VerifyAndClearExpectations(&mock_sink);
346 EXPECT_CALL(mock_sink, send_buffer(_,_,_))
347 .Times(0);
348 framedrop_factory.trigger_policies();
349 Mock::VerifyAndClearExpectations(&mock_sink);
350}
351
352TEST_F(Stream, doesnt_drop_the_latest_frame_with_a_longer_queue)
353{
354 stream.submit_buffer(buffers[0]);
355 stream.lock_compositor_buffer(this);
356 stream.submit_buffer(buffers[1]);
357 stream.submit_buffer(buffers[2]);
358
359 Mock::VerifyAndClearExpectations(&mock_sink);
360 EXPECT_CALL(mock_sink, send_buffer(_,Ref(*buffers[1]),_))
361 .Times(1);
362 framedrop_factory.trigger_policies();
363 Mock::VerifyAndClearExpectations(&mock_sink);
364}
365
366TEST_F(Stream, doesnt_drop_the_latest_frame_with_a_2_buffer_queue)
367{
368 stream.submit_buffer(buffers[0]);
369 stream.lock_compositor_buffer(this);
370 stream.submit_buffer(buffers[1]);
371
372 Mock::VerifyAndClearExpectations(&mock_sink);
373 EXPECT_CALL(mock_sink, send_buffer(_,Ref(*buffers[1]),_))
374 .Times(0);
375 framedrop_factory.trigger_policies();
376 Mock::VerifyAndClearExpectations(&mock_sink);
377}
378
379TEST_F(Stream, returns_buffers_to_client_when_told_to_bring_queue_up_to_date)266TEST_F(Stream, returns_buffers_to_client_when_told_to_bring_queue_up_to_date)
380{267{
381 stream.submit_buffer(buffers[0]);268 stream.submit_buffer(buffers[0]);
382269
=== removed file 'tests/unit-tests/compositor/test_timeout_frame_dropping_policy.cpp'
--- tests/unit-tests/compositor/test_timeout_frame_dropping_policy.cpp 2017-01-18 02:29:37 +0000
+++ tests/unit-tests/compositor/test_timeout_frame_dropping_policy.cpp 1970-01-01 00:00:00 +0000
@@ -1,196 +0,0 @@
1/*
2 * Copyright © 2014-2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 * Alberto Aguirre <alberto.aguirre@canonical.com>
18 */
19
20#include "src/server/compositor/timeout_frame_dropping_policy_factory.h"
21#include "mir/compositor/frame_dropping_policy.h"
22#include "mir/basic_callback.h"
23
24#include "mir/test/doubles/mock_timer.h"
25#include "mir/test/doubles/mock_lockable_callback.h"
26#include "mir/test/auto_unblock_thread.h"
27#include "mir/test/fake_shared.h"
28#include "mir/test/gmock_fixes.h"
29
30#include <stdexcept>
31#include <mutex>
32
33#include <gtest/gtest.h>
34#include <gmock/gmock.h>
35
36namespace mc = mir::compositor;
37namespace mt = mir::test;
38namespace mtd = mir::test::doubles;
39
40namespace
41{
42class TimeoutFrameDroppingPolicy : public ::testing::Test
43{
44public:
45
46 void SetUp() override
47 {
48 clock = std::make_shared<mt::FakeClock>();
49 timer = std::make_shared<mtd::FakeTimer>(clock);
50 handler = std::make_unique<mir::BasicCallback>([this]{ frame_dropped = true; });
51 }
52
53 auto create_default_policy()
54 {
55 mc::TimeoutFrameDroppingPolicyFactory factory{timer, timeout};
56 return factory.create_policy(std::move(handler));
57 }
58
59protected:
60 std::shared_ptr<mt::FakeClock> clock;
61 std::shared_ptr<mtd::FakeTimer> timer;
62 std::chrono::milliseconds const timeout = std::chrono::milliseconds(1000);
63 std::unique_ptr<mir::BasicCallback> handler;
64 bool frame_dropped = false;
65};
66}
67
68TEST_F(TimeoutFrameDroppingPolicy, does_not_fire_before_notified_of_block)
69{
70 auto policy = create_default_policy();
71
72 clock->advance_time(timeout + std::chrono::milliseconds{1});
73 EXPECT_FALSE(frame_dropped);
74}
75
76TEST_F(TimeoutFrameDroppingPolicy, schedules_alarm_for_correct_timeout)
77{
78 auto policy = create_default_policy();
79 policy->swap_now_blocking();
80
81 clock->advance_time(timeout - std::chrono::milliseconds{1});
82 EXPECT_FALSE(frame_dropped);
83 clock->advance_time(std::chrono::milliseconds{2});
84 EXPECT_TRUE(frame_dropped);
85}
86
87TEST_F(TimeoutFrameDroppingPolicy, framedrop_callback_cancelled_by_unblock)
88{
89 auto policy = create_default_policy();
90
91 policy->swap_now_blocking();
92 policy->swap_unblocked();
93
94 clock->advance_time(timeout * 10);
95
96 EXPECT_FALSE(frame_dropped);
97}
98
99TEST_F(TimeoutFrameDroppingPolicy, policy_drops_one_frame_per_blocking_swap)
100{
101 auto policy = create_default_policy();
102
103 policy->swap_now_blocking();
104 policy->swap_now_blocking();
105 policy->swap_now_blocking();
106
107 clock->advance_time(timeout + std::chrono::milliseconds{1});
108 EXPECT_TRUE(frame_dropped);
109
110 frame_dropped = false;
111 clock->advance_time(timeout + std::chrono::milliseconds{2});
112 EXPECT_TRUE(frame_dropped);
113
114 frame_dropped = false;
115 clock->advance_time(timeout + std::chrono::milliseconds{1});
116 EXPECT_TRUE(frame_dropped);
117
118 frame_dropped = false;
119 clock->advance_time(timeout + std::chrono::milliseconds{1});
120 EXPECT_FALSE(frame_dropped);
121}
122
123TEST_F(TimeoutFrameDroppingPolicy, policy_drops_frames_no_more_frequently_than_timeout)
124{
125 auto policy = create_default_policy();
126
127 policy->swap_now_blocking();
128 policy->swap_now_blocking();
129
130 clock->advance_time(timeout + std::chrono::milliseconds{1});
131 EXPECT_TRUE(frame_dropped);
132
133 frame_dropped = false;
134 clock->advance_time(timeout - std::chrono::milliseconds{1});
135 EXPECT_FALSE(frame_dropped);
136 clock->advance_time(std::chrono::milliseconds{2});
137 EXPECT_TRUE(frame_dropped);
138}
139
140TEST_F(TimeoutFrameDroppingPolicy, newly_blocking_frame_doesnt_reset_timeout)
141{
142 auto policy = create_default_policy();
143
144 policy->swap_now_blocking();
145 clock->advance_time(timeout - std::chrono::milliseconds{1});
146
147 policy->swap_now_blocking();
148 clock->advance_time(std::chrono::milliseconds{2});
149 EXPECT_TRUE(frame_dropped);
150}
151
152TEST_F(TimeoutFrameDroppingPolicy, interspersed_timeouts_and_unblocks)
153{
154 auto policy = create_default_policy();
155
156 policy->swap_now_blocking();
157 policy->swap_now_blocking();
158 policy->swap_now_blocking();
159
160 /* First frame gets dropped... */
161 clock->advance_time(timeout + std::chrono::milliseconds{1});
162 EXPECT_TRUE(frame_dropped);
163
164 /* ...Compositor gets its act in order and consumes a frame... */
165 frame_dropped = false;
166 policy->swap_unblocked();
167 clock->advance_time(timeout - std::chrono::milliseconds{1});
168 EXPECT_FALSE(frame_dropped);
169
170 /* ...but not a second frame, so third swap should trigger a timeout */
171 clock->advance_time(std::chrono::milliseconds{2});
172 EXPECT_TRUE(frame_dropped);
173
174 frame_dropped = false;
175 clock->advance_time(timeout + std::chrono::milliseconds{1});
176 EXPECT_FALSE(frame_dropped);
177}
178
179TEST_F(TimeoutFrameDroppingPolicy, policy_calls_lock_unlock_functions)
180{
181 using namespace testing;
182
183 mc::TimeoutFrameDroppingPolicyFactory factory{timer, timeout};
184 auto handler = std::make_unique<mtd::MockLockableCallback>();
185 {
186 InSequence s;
187 EXPECT_CALL(*handler, lock());
188 EXPECT_CALL(*handler, functor());
189 EXPECT_CALL(*handler, unlock());
190 }
191
192 auto policy = factory.create_policy(std::move(handler));
193
194 policy->swap_now_blocking();
195 clock->advance_time(timeout + std::chrono::milliseconds{1});
196}
1970
=== modified file 'tests/unit-tests/scene/test_surface_stack.cpp'
--- tests/unit-tests/scene/test_surface_stack.cpp 2017-03-14 02:26:28 +0000
+++ tests/unit-tests/scene/test_surface_stack.cpp 2017-05-02 09:09:50 +0000
@@ -31,7 +31,6 @@
31#include "mir/test/doubles/stub_buffer_stream_factory.h"31#include "mir/test/doubles/stub_buffer_stream_factory.h"
32#include "mir/test/doubles/stub_renderable.h"32#include "mir/test/doubles/stub_renderable.h"
33#include "mir/test/doubles/mock_buffer_stream.h"33#include "mir/test/doubles/mock_buffer_stream.h"
34#include "mir/test/doubles/stub_frame_dropping_policy_factory.h"
3534
36#include <gmock/gmock.h>35#include <gmock/gmock.h>
37#include <gtest/gtest.h>36#include <gtest/gtest.h>
@@ -300,8 +299,7 @@
300 };299 };
301300
302 auto buffers = std::make_shared<StubBuffers>();301 auto buffers = std::make_shared<StubBuffers>();
303 mtd::StubFrameDroppingPolicyFactory factory;302 auto stream = std::make_shared<mc::Stream>(buffers, geom::Size{ 1, 1 }, mir_pixel_format_abgr_8888);
304 auto stream = std::make_shared<mc::Stream>(factory, buffers, geom::Size{ 1, 1 }, mir_pixel_format_abgr_8888);
305303
306 auto surface = std::make_shared<ms::BasicSurface>(304 auto surface = std::make_shared<ms::BasicSurface>(
307 std::string("stub"),305 std::string("stub"),

Subscribers

People subscribed via source and target branches