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

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014