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 
32 namespace mir
33 {
34 namespace frontend { class ClientBuffers; }
35 namespace compositor
36 {
37 class Schedule;
38 class FrameDroppingPolicyFactory;
39 class FrameDroppingPolicy;
40 class Stream : public BufferStream
41 {
42 public:
43  Stream(
44  FrameDroppingPolicyFactory const& policy_factory,
45  std::unique_ptr<frontend::ClientBuffers>, geometry::Size sz, MirPixelFormat format);
46 
47  void swap_buffers(
48  graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete) override;
49  void with_most_recent_buffer_do(std::function<void(graphics::Buffer&)> const& exec) override;
50  MirPixelFormat pixel_format() const override;
51  void add_observer(std::shared_ptr<scene::SurfaceObserver> const& observer) override;
52  void remove_observer(std::weak_ptr<scene::SurfaceObserver> const& observer) override;
53  std::shared_ptr<graphics::Buffer>
54  lock_compositor_buffer(void const* user_id) override;
55  geometry::Size stream_size() override;
56  void resize(geometry::Size const& size) override;
57  void allow_framedropping(bool) override;
58  void force_requests_to_complete() override;
59  int buffers_ready_for_compositor(void const* user_id) const override;
60  void drop_old_buffers() override;
61  bool has_submitted_buffer() const override;
62  graphics::BufferID allocate_buffer(graphics::BufferProperties const&) override;
63  void remove_buffer(graphics::BufferID) override;
64  void with_buffer(graphics::BufferID id, std::function<void(graphics::Buffer&)> const& fn) 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> arbiter;
88  MirPixelFormat const pf;
89  bool first_frame_posted;
90 
91  scene::SurfaceObservers observers;
92 };
93 }
94 }
95 
96 #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:40
MirPixelFormat
32-bit pixel formats (8888): The order of components in the enum matches the order of the components ...
Definition: common.h:134
Definition: surface_observers.h:30
Definition: lockable_callback.h:25
Buffer creation properties.
Definition: buffer_properties.h:48
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 Wed Mar 30 00:29:56 UTC 2016