Mir
recently_used_cache.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013-2014 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as 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: Daniel van Vugt <daniel.van.vugt@canonical.com>
17  * Kevin DuBois <kevin.dubois@canonical.com>
18  */
19 
20 #ifndef MIR_COMPOSITOR_RECENTLY_USED_CACHE_H_
21 #define MIR_COMPOSITOR_RECENTLY_USED_CACHE_H_
22 
25 #include "mir/graphics/buffer_id.h"
26 #include <unordered_map>
27 
28 namespace mir
29 {
30 namespace compositor
31 {
33 {
34 public:
35  std::shared_ptr<graphics::GLTexture> load(graphics::Renderable const& renderable) override;
36  void invalidate() override;
37  void drop_unused() override;
38 
39 private:
40  struct Entry
41  {
42  Entry()
43  : texture(std::make_shared<graphics::GLTexture>())
44  {}
45  std::shared_ptr<graphics::GLTexture> texture;
46  graphics::BufferID last_bound_buffer;
47  bool used{true};
48  bool valid_binding{false};
49  std::shared_ptr<graphics::Buffer> resource;
50  };
51 
52  std::unordered_map<graphics::Renderable::ID, Entry> textures;
53 };
54 }
55 }
56 
57 #endif /* MIR_COMPOSITOR_RECENTLY_USED_CACHE_H_ */
std::shared_ptr< graphics::GLTexture > load(graphics::Renderable const &renderable) override
Loads texture from the renderable.
Definition: recently_used_cache.cpp:28
All things Mir.
Definition: buffer_stream.h:37
void invalidate() override
Mark all entries in the cache as out-of-date to ensure fresh textures are loaded next time...
Definition: recently_used_cache.cpp:47
Definition: renderable.h:33
Definition: recently_used_cache.h:32
Definition: gl_texture_cache.h:30
void drop_unused() override
Free textures that were not used (loaded) since the last drop/invalidate.
Definition: recently_used_cache.cpp:53

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