Mir
buffer_map.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
5  * it under the terms of the GNU General Public License version 3 as
6  * 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: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 #ifndef MIR_COMPOSITOR_BUFFER_MAP_H_
20 #define MIR_COMPOSITOR_BUFFER_MAP_H_
21 
23 #include <mutex>
24 #include <map>
25 
26 namespace mir
27 {
28 namespace graphics { class GraphicBufferAllocator; }
29 namespace frontend { class BufferSink; }
30 namespace compositor
31 {
33 {
34 public:
35  BufferMap(
36  std::shared_ptr<frontend::BufferSink> const& sink,
37  std::shared_ptr<graphics::GraphicBufferAllocator> const& allocator);
38 
39  graphics::BufferID add_buffer(graphics::BufferProperties const& properties) override;
40  void remove_buffer(graphics::BufferID id) override;
41 
42  void receive_buffer(graphics::BufferID id) override;
43  void send_buffer(graphics::BufferID id) override;
44 
45  std::shared_ptr<graphics::Buffer>& operator[](graphics::BufferID) override;
46 
47 private:
48  std::mutex mutable mutex;
49 
50  enum class Owner;
51  struct MapEntry
52  {
53  std::shared_ptr<graphics::Buffer> buffer;
54  Owner owner;
55  };
56  typedef std::map<graphics::BufferID, MapEntry> Map;
57  //used to keep strong reference
58  Map buffers;
59  Map::iterator checked_buffers_find(graphics::BufferID, std::unique_lock<std::mutex> const&);
60 
61  std::shared_ptr<frontend::BufferSink> const sink;
62  std::shared_ptr<graphics::GraphicBufferAllocator> const allocator;
63 };
64 }
65 }
66 #endif /* MIR_COMPOSITOR_BUFFER_MAP_H_ */
All things Mir.
Definition: atomic_callback.h:25
Definition: client_buffers.h:30
Owner
Definition: buffer_map.cpp:33
Definition: buffer_map.h:32
Buffer creation properties.
Definition: buffer_properties.h:48

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