Mir
multi_monitor_arbiter.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  */
17 
18 #ifndef MIR_COMPOSITOR_MULTI_MONITOR_ARBITER_H_
19 #define MIR_COMPOSITOR_MULTI_MONITOR_ARBITER_H_
20 
22 #include "mir/graphics/buffer_id.h"
23 #include "buffer_bundle.h"
24 #include <memory>
25 #include <mutex>
26 #include <deque>
27 #include <set>
28 
29 namespace mir
30 {
31 namespace graphics { class Buffer; }
32 namespace frontend { class ClientBuffers; }
33 namespace compositor
34 {
35 class Schedule;
36 
37 enum class MultiMonitorMode
38 {
41 };
42 
44 {
45 public:
47  MultiMonitorMode mode,
48  std::shared_ptr<frontend::ClientBuffers> const& map,
49  std::shared_ptr<Schedule> const& schedule);
50 
51  std::shared_ptr<graphics::Buffer> compositor_acquire(compositor::CompositorID id) override;
52  void compositor_release(std::shared_ptr<graphics::Buffer> const&) override;
53  std::shared_ptr<graphics::Buffer> snapshot_acquire() override;
54  void snapshot_release(std::shared_ptr<graphics::Buffer> const&) override;
55  void set_schedule(std::shared_ptr<Schedule> const& schedule);
56  void set_mode(MultiMonitorMode mode);
57  bool buffer_ready_for(compositor::CompositorID id);
58  bool has_buffer();
59  void advance_schedule();
60 
61 private:
62  void decrease_refcount_for(graphics::BufferID id, std::lock_guard<std::mutex> const&);
63  void clean_onscreen_buffers(std::lock_guard<std::mutex> const&);
64 
65  std::mutex mutable mutex;
66  MultiMonitorMode mode;
67  std::shared_ptr<frontend::ClientBuffers> const map;
68  struct ScheduleEntry
69  {
70  ScheduleEntry(std::shared_ptr<graphics::Buffer> const& buffer, unsigned int use_count) :
71  buffer(buffer),
72  use_count(use_count)
73  {
74  }
75  std::shared_ptr<graphics::Buffer> buffer;
76  unsigned int use_count;
77  };
78  std::deque<ScheduleEntry> onscreen_buffers;
79  std::set<compositor::CompositorID> current_buffer_users;
80  std::shared_ptr<Schedule> schedule;
81 };
82 
83 }
84 }
85 #endif /* MIR_COMPOSITOR_MULTI_MONITOR_ARBITER_H_ */
All things Mir.
Definition: atomic_callback.h:25
MultiMonitorMode
Definition: multi_monitor_arbiter.h:37
Definition: multi_monitor_arbiter.h:43
void const * CompositorID
Definition: compositor_id.h:27
Definition: buffer_bundle.h:33

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016