Mir
surface_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_SURFACE_TRACKER_H_
20 #define MIR_FRONTEND_SURFACE_TRACKER_H_
21 
23 #include "mir/graphics/buffer_id.h"
24 
25 #include <unordered_map>
26 #include <tuple>
27 #include <memory>
28 #include <mutex>
29 
30 namespace mir
31 {
32 namespace graphics
33 {
34 class Buffer;
35 }
36 namespace frontend
37 {
38 class ClientBufferTracker;
40 {
41 public:
42  SurfaceTracker(size_t client_cache_size);
43  SurfaceTracker(SurfaceTracker const&) = delete;
44  SurfaceTracker& operator=(SurfaceTracker const&) = delete;
45 
46  /* track a buffer as associated with a surface
47  * \warning the buffer must correspond to a single surface_id
48  * \param surface_id id that the the buffer is associated with
49  * \param buffer buffer to be tracked (TODO: should be a shared_ptr)
50  * \returns true if the buffer is already tracked
51  * false if the buffer is not tracked
52  */
53  bool track_buffer(SurfaceId surface_id, graphics::Buffer* buffer);
54  /* removes the surface id from all tracking */
56 
57  /* Access the buffer resource that the id corresponds to.
58  TODO: should really be a weak or shared ptr */
60 
61 private:
62  size_t const client_cache_size;
63  std::unordered_map<SurfaceId, std::shared_ptr<ClientBufferTracker>> client_buffer_tracker;
64 
65 //TODO: deprecate below this line once exchange_buffer is the normal way to request a new buffer
66 public:
67  /* accesses the last buffer given to track_buffer() for the given SurfaceId */
69 private:
70  mutable std::mutex mutex;
71  std::unordered_map<SurfaceId, graphics::Buffer*> client_buffer_resource;
72 };
73 
74 }
75 }
76 
77 #endif // MIR_FRONTEND_SURFACE_TRACKER_H_
All things Mir.
Definition: buffer_stream.h:37
graphics::Buffer * last_buffer(SurfaceId) const
Definition: surface_tracker.cpp:70
graphics::Buffer * buffer_from(graphics::BufferID) const
Definition: surface_tracker.cpp:81
bool track_buffer(SurfaceId surface_id, graphics::Buffer *buffer)
Definition: surface_tracker.cpp:36
SurfaceTracker(size_t client_cache_size)
Definition: surface_tracker.cpp:31
Definition: surface_tracker.h:39
SurfaceTracker & operator=(SurfaceTracker const &)=delete
Definition: int_wrapper.h:27
Definition: buffer.h:34
void remove_surface(SurfaceId)
Definition: surface_tracker.cpp:58

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Mar 24 16:15:19 UTC 2015