Mir
buffer_stream_tracker.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013-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_FRONTEND_BUFFER_STREAM_TRACKER_H_
20 #define MIR_FRONTEND_BUFFER_STREAM_TRACKER_H_
21 
23 #include "mir/graphics/buffer_id.h"
24 
25 #include <unordered_map>
26 #include <memory>
27 #include <mutex>
28 
29 namespace mir
30 {
31 namespace graphics
32 {
33 class Buffer;
34 }
35 namespace frontend
36 {
37 class ClientBufferTracker;
39 {
40 public:
41  BufferStreamTracker(size_t client_cache_size);
44 
45  /* track a buffer as associated with a buffer stream
46  * \warning the buffer must correspond to a single buffer stream id
47  * \param buffer_stream_id id that the the buffer is associated with
48  * \param buffer buffer to be tracked
49  * \returns true if the buffer is already tracked
50  * false if the buffer is not tracked
51  */
52  bool track_buffer(BufferStreamId buffer_stream_id, graphics::Buffer* buffer);
53  /* removes the buffer stream id from all tracking */
55 
56  /* Access the buffer resource that the id corresponds to. */
58 
59 private:
60  size_t const client_cache_size;
61  std::unordered_map<BufferStreamId, std::shared_ptr<ClientBufferTracker>> client_buffer_tracker;
62 
63 public:
64  /* accesses the last buffer given to track_buffer() for the given BufferStreamId */
65  //TODO: once next_buffer rpc call is fully deprecated, this can be removed.
67 private:
68  mutable std::mutex mutex;
69  std::unordered_map<BufferStreamId, graphics::Buffer*> client_buffer_resource;
70 };
71 
72 }
73 }
74 
75 #endif // MIR_FRONTEND_BUFFER_STREAM_TRACKER_H_
All things Mir.
Definition: atomic_callback.h:25
BufferStreamTracker & operator=(BufferStreamTracker const &)=delete
bool track_buffer(BufferStreamId buffer_stream_id, graphics::Buffer *buffer)
Definition: buffer_stream_tracker.cpp:36
graphics::Buffer * buffer_from(graphics::BufferID) const
Definition: buffer_stream_tracker.cpp:85
Definition: buffer_stream_tracker.h:38
BufferStreamTracker(size_t client_cache_size)
Definition: buffer_stream_tracker.cpp:31
Definition: buffer.h:44
graphics::Buffer * last_buffer(BufferStreamId) const
Definition: buffer_stream_tracker.cpp:72
void remove_buffer_stream(BufferStreamId)
Definition: buffer_stream_tracker.cpp:59

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015