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 
38 {
39 public:
41  MultiMonitorMode mode,
42  std::shared_ptr<frontend::ClientBuffers> const& map,
43  std::shared_ptr<Schedule> const& schedule);
44 
45  std::shared_ptr<graphics::Buffer> compositor_acquire(compositor::CompositorID id) override;
46  void compositor_release(std::shared_ptr<graphics::Buffer> const&) override;
47  std::shared_ptr<graphics::Buffer> snapshot_acquire() override;
48  void snapshot_release(std::shared_ptr<graphics::Buffer> const&) override;
49  void set_schedule(std::shared_ptr<Schedule> const& schedule);
50  void set_mode(MultiMonitorMode mode) override;
51  bool buffer_ready_for(compositor::CompositorID id);
52  bool has_buffer();
53  void advance_schedule();
54 
55 private:
56  void decrease_refcount_for(graphics::BufferID id, std::lock_guard<std::mutex> const&);
57  void clean_onscreen_buffers(std::lock_guard<std::mutex> const&);
58 
59  std::mutex mutable mutex;
60  MultiMonitorMode mode;
61  std::shared_ptr<frontend::ClientBuffers> const map;
62  struct ScheduleEntry
63  {
64  ScheduleEntry(std::shared_ptr<graphics::Buffer> const& buffer, unsigned int use_count) :
65  buffer(buffer),
66  use_count(use_count)
67  {
68  }
69  std::shared_ptr<graphics::Buffer> buffer;
70  unsigned int use_count;
71  };
72  std::deque<ScheduleEntry> onscreen_buffers;
73  std::set<compositor::CompositorID> current_buffer_users;
74  std::shared_ptr<Schedule> schedule;
75 };
76 
77 }
78 }
79 #endif /* MIR_COMPOSITOR_MULTI_MONITOR_ARBITER_H_ */
All things Mir.
Definition: atomic_callback.h:25
MultiMonitorMode
Definition: buffer_bundle.h:33
Definition: multi_monitor_arbiter.h:37
void const * CompositorID
Definition: compositor_id.h:27
Definition: buffer_bundle.h:39

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