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 
24 #include <mutex>
25 #include <map>
26 
27 namespace mir
28 {
29 namespace graphics { class GraphicBufferAllocator; }
30 namespace frontend { class BufferSink; }
31 namespace compositor
32 {
34 {
35 public:
36  BufferMap(
38  std::shared_ptr<frontend::BufferSink> const& sink,
39  std::shared_ptr<graphics::GraphicBufferAllocator> const& allocator);
40 
41  graphics::BufferID add_buffer(graphics::BufferProperties const& properties) override;
42  void remove_buffer(graphics::BufferID id) override;
43 
44  void receive_buffer(graphics::BufferID id) override;
45  void send_buffer(graphics::BufferID id) override;
46  size_t client_owned_buffer_count() const override;
47 
48  std::shared_ptr<graphics::Buffer>& operator[](graphics::BufferID) override;
49 
50 private:
51  std::mutex mutable mutex;
52 
53  enum class Owner;
54  struct MapEntry
55  {
56  std::shared_ptr<graphics::Buffer> buffer;
57  Owner owner;
58  };
59  typedef std::map<graphics::BufferID, MapEntry> Map;
60  //used to keep strong reference
61  Map buffers;
62  Map::iterator checked_buffers_find(graphics::BufferID, std::unique_lock<std::mutex> const&);
63 
64  frontend::BufferStreamId const stream_id;
65  std::shared_ptr<frontend::BufferSink> const sink;
66  std::shared_ptr<graphics::GraphicBufferAllocator> const allocator;
67 };
68 }
69 }
70 #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:33
Buffer creation properties.
Definition: buffer_properties.h:48

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