OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_MEMORY_PROGRAM_CACHE_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_MEMORY_PROGRAM_CACHE_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_MEMORY_PROGRAM_CACHE_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_MEMORY_PROGRAM_CACHE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/containers/mru_cache.h" | 12 #include "base/containers/mru_cache.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
16 #include "gpu/command_buffer/service/program_cache.h" | 16 #include "gpu/command_buffer/service/program_cache.h" |
17 #include "gpu/command_buffer/service/shader_translator.h" | |
18 | 17 |
19 namespace gpu { | 18 namespace gpu { |
20 namespace gles2 { | 19 namespace gles2 { |
21 | 20 |
22 // Program cache that stores binaries completely in-memory | 21 // Program cache that stores binaries completely in-memory |
23 class GPU_EXPORT MemoryProgramCache : public ProgramCache { | 22 class GPU_EXPORT MemoryProgramCache : public ProgramCache { |
24 public: | 23 public: |
25 MemoryProgramCache(); | 24 MemoryProgramCache(); |
26 explicit MemoryProgramCache(const size_t max_cache_size_bytes); | 25 explicit MemoryProgramCache(const size_t max_cache_size_bytes); |
27 ~MemoryProgramCache() override; | 26 ~MemoryProgramCache() override; |
28 | 27 |
29 ProgramLoadResult LoadLinkedProgram( | 28 ProgramLoadResult LoadLinkedProgram( |
30 GLuint program, | 29 GLuint program, |
31 Shader* shader_a, | 30 Shader* shader_a, |
32 const ShaderTranslatorInterface* translator_a, | |
33 Shader* shader_b, | 31 Shader* shader_b, |
34 const ShaderTranslatorInterface* translator_b, | |
35 const LocationMap* bind_attrib_location_map, | 32 const LocationMap* bind_attrib_location_map, |
36 const ShaderCacheCallback& shader_callback) override; | 33 const ShaderCacheCallback& shader_callback) override; |
37 void SaveLinkedProgram(GLuint program, | 34 void SaveLinkedProgram(GLuint program, |
38 const Shader* shader_a, | 35 const Shader* shader_a, |
39 const ShaderTranslatorInterface* translator_a, | |
40 const Shader* shader_b, | 36 const Shader* shader_b, |
41 const ShaderTranslatorInterface* translator_b, | |
42 const LocationMap* bind_attrib_location_map, | 37 const LocationMap* bind_attrib_location_map, |
43 const ShaderCacheCallback& shader_callback) override; | 38 const ShaderCacheCallback& shader_callback) override; |
44 | 39 |
45 void LoadProgram(const std::string& program) override; | 40 void LoadProgram(const std::string& program) override; |
46 | 41 |
47 private: | 42 private: |
48 void ClearBackend() override; | 43 void ClearBackend() override; |
49 | 44 |
50 class ProgramCacheValue : public base::RefCounted<ProgramCacheValue> { | 45 class ProgramCacheValue : public base::RefCounted<ProgramCacheValue> { |
51 public: | 46 public: |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 size_t curr_size_bytes_; | 133 size_t curr_size_bytes_; |
139 ProgramMRUCache store_; | 134 ProgramMRUCache store_; |
140 | 135 |
141 DISALLOW_COPY_AND_ASSIGN(MemoryProgramCache); | 136 DISALLOW_COPY_AND_ASSIGN(MemoryProgramCache); |
142 }; | 137 }; |
143 | 138 |
144 } // namespace gles2 | 139 } // namespace gles2 |
145 } // namespace gpu | 140 } // namespace gpu |
146 | 141 |
147 #endif // GPU_COMMAND_BUFFER_SERVICE_MEMORY_PROGRAM_CACHE_H_ | 142 #endif // GPU_COMMAND_BUFFER_SERVICE_MEMORY_PROGRAM_CACHE_H_ |
OLD | NEW |