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_GL_RECENTLY_USED_CACHE_H_
21 #define MIR_GL_RECENTLY_USED_CACHE_H_
22 
23 #include "mir/gl/texture_cache.h"
24 #include "mir/gl/texture.h"
25 #include "mir/graphics/buffer_id.h"
27 #include <unordered_map>
28 
29 namespace mir
30 {
31 namespace graphics { class Buffer; }
32 namespace gl
33 {
35 {
36 public:
37  std::shared_ptr<Texture> load(graphics::Renderable const& renderable) override;
38  void invalidate() override;
39  void drop_unused() override;
40 
41 private:
42  struct Entry
43  {
44  Entry()
45  : texture(std::make_shared<Texture>())
46  {}
47  std::shared_ptr<Texture> texture;
48  graphics::BufferID last_bound_buffer;
49  bool used{true};
50  bool valid_binding{false};
51  std::shared_ptr<graphics::Buffer> resource;
52  };
53 
54  std::unordered_map<graphics::Renderable::ID, Entry> textures;
55 };
56 }
57 }
58 
59 #endif /* MIR_GL_RECENTLY_USED_CACHE_H_ */
All things Mir.
Definition: atomic_callback.h:25
Definition: texture_cache.h:31
Definition: recently_used_cache.h:34
Definition: renderable.h:33
Definition: buffer.h:44

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016