Mir
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
src
server
frontend
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
22
#include "
mir/frontend/buffer_stream_id.h
"
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;
38
class
BufferStreamTracker
39
{
40
public
:
41
BufferStreamTracker
(
size_t
client_cache_size);
42
BufferStreamTracker
(
BufferStreamTracker
const
&) =
delete
;
43
BufferStreamTracker
& operator=(
BufferStreamTracker
const
&) =
delete
;
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 */
54
void
remove_buffer_stream(
BufferStreamId
);
55
56
/* Access the buffer resource that the id corresponds to. */
57
graphics::Buffer
* buffer_from(
graphics::BufferID
)
const
;
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.
66
graphics::Buffer
* last_buffer(
BufferStreamId
)
const
;
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_
buffer_id.h
mir
All things Mir.
Definition:
atomic_callback.h:25
buffer_stream_id.h
mir::frontend::BufferStreamTracker
Definition:
buffer_stream_tracker.h:38
mir::IntWrapper< detail::SessionsBufferStreamIdTag >
mir::graphics::Buffer
Definition:
buffer.h:44
Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016