Mir
stream.h
Go to the documentation of this file.
1 /*
2  * Copyright © 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:
17  * Kevin DuBois <kevin.dubois@canonical.com>
18  */
19 
20 #ifndef MIR_COMPOSITOR_STREAM_H_
21 #define MIR_COMPOSITOR_STREAM_H_
22 
26 #include "mir/lockable_callback.h"
27 #include "mir/geometry/size.h"
28 #include "multi_monitor_arbiter.h"
29 #include <mutex>
30 #include <memory>
31 #include <set>
32 
33 namespace mir
34 {
35 namespace frontend { class ClientBuffers; }
36 namespace compositor
37 {
38 class Schedule;
39 class FrameDroppingPolicyFactory;
40 class FrameDroppingPolicy;
41 class Stream : public BufferStream
42 {
43 public:
44  Stream(
45  FrameDroppingPolicyFactory const& policy_factory,
46  std::shared_ptr<frontend::ClientBuffers>, geometry::Size sz, MirPixelFormat format);
47 
48  void swap_buffers(
49  graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete) override;
50  void with_most_recent_buffer_do(std::function<void(graphics::Buffer&)> const& exec) override;
51  MirPixelFormat pixel_format() const override;
52  void add_observer(std::shared_ptr<scene::SurfaceObserver> const& observer) override;
53  void remove_observer(std::weak_ptr<scene::SurfaceObserver> const& observer) override;
54  std::shared_ptr<graphics::Buffer>
55  lock_compositor_buffer(void const* user_id) override;
56  geometry::Size stream_size() override;
57  void resize(geometry::Size const& size) override;
58  void allow_framedropping(bool) override;
59  void drop_outstanding_requests() override;
60  int buffers_ready_for_compositor(void const* user_id) const override;
61  void drop_old_buffers() override;
62  bool has_submitted_buffer() const override;
63  void associate_buffer(graphics::BufferID) override;
64  void disassociate_buffer(graphics::BufferID) override;
65  void set_scale(float scale) override;
66 
67 private:
68  enum class ScheduleMode;
69  struct DroppingCallback : mir::LockableCallback
70  {
71  DroppingCallback(Stream* stream);
72  void operator()() override;
73  void lock() override;
74  void unlock() override;
75  Stream* stream;
76  std::unique_lock<std::mutex> guard_lock;
77  };
78  void transition_schedule(std::shared_ptr<Schedule>&& new_schedule, std::lock_guard<std::mutex> const&);
79  void drop_frame();
80 
81  std::mutex mutable mutex;
82  std::unique_ptr<compositor::FrameDroppingPolicy> drop_policy;
83  ScheduleMode schedule_mode;
84  std::shared_ptr<Schedule> schedule;
85  std::shared_ptr<frontend::ClientBuffers> buffers;
86  std::shared_ptr<MultiMonitorArbiter> const arbiter;
88  MirPixelFormat const pf;
89  bool first_frame_posted;
90 
91  scene::SurfaceObservers observers;
92 
93  std::set<graphics::BufferID> associated_buffers;
94  unsigned int client_owned_buffer_count(std::lock_guard<decltype(mutex)> const&) const;
95 };
96 }
97 }
98 
99 #endif /* MIR_COMPOSITOR_STREAM_H_ */
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
ScheduleMode
Definition: stream.cpp:35
Definition: buffer_stream.h:40
Definition: stream.h:41
MirPixelFormat
32-bit pixel formats (8888): The order of components in the enum matches the order of the components ...
Definition: common.h:134
Definition: int_wrapper.h:27
Definition: surface_observers.h:30
Definition: lockable_callback.h:25
Definition: buffer.h:44
Creator of FrameDroppingPolicies.
Definition: frame_dropping_policy_factory.h:40
int const size
Definition: make_socket_rpc_channel.cpp:51

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016