Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_MEMORY_PROGRAM_CACHE_H_ | |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_MEMORY_PROGRAM_CACHE_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/hash_tables.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
|
greggman
2012/06/26 23:00:27
style: alphabetize includes
dmurph
2012/07/04 00:01:29
Done.
| |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "gpu/command_buffer/service/program_cache.h" | |
| 15 #include "gpu/command_buffer/service/program_cache_lru_helper.h" | |
| 16 #include "gpu/command_buffer/service/shader_translator.h" | |
| 17 #include "net/disk_cache/disk_cache.h" | |
| 18 | |
| 19 namespace gpu { | |
| 20 namespace gles2 { | |
| 21 | |
| 22 // Program cache that stores binaries completely in-memory | |
| 23 class GPU_EXPORT MemoryProgramCache : public ProgramCache { | |
| 24 public: | |
| 25 static const size_t kMaxProgramCacheMemoryBytes = 6*1024*1024; | |
| 26 MemoryProgramCache() | |
| 27 : max_size_bytes_(kMaxProgramCacheMemoryBytes), | |
| 28 curr_size_bytes_(0) {} | |
| 29 virtual ~MemoryProgramCache(); | |
| 30 | |
| 31 bool LoadLinkedProgram( | |
|
greggman
2012/06/26 23:00:27
style: need 'virtual' in front and OVERRIDE in bac
dmurph
2012/07/04 00:01:29
Done.
| |
| 32 const GLuint program, | |
| 33 ShaderManager::ShaderInfo* shader_a, | |
| 34 ShaderManager::ShaderInfo* shader_b, | |
| 35 const std::map<std::string, GLint>* bind_attrib_location_map) const; | |
| 36 void SaveLinkedProgram( | |
|
greggman
2012/06/26 23:00:27
style: need 'virtual' in front and OVERRIDE in bac
dmurph
2012/07/04 00:01:29
Done.
| |
| 37 const GLuint program, | |
| 38 const ShaderManager::ShaderInfo* shader_a, | |
| 39 const ShaderManager::ShaderInfo* shader_b, | |
| 40 const std::map<std::string, GLint>* bind_attrib_location_map); | |
| 41 | |
| 42 private: | |
| 43 void ClearBackend(); | |
|
greggman
2012/06/26 23:00:27
style: need 'virtual' in front and OVERRIDE in bac
dmurph
2012/07/04 00:01:29
Done.
| |
| 44 | |
| 45 class ProgramCacheValue : public base::RefCounted<ProgramCacheValue> { | |
| 46 public: | |
| 47 ProgramCacheValue(GLsizei _length, | |
| 48 GLenum _format, | |
|
greggman
2012/06/26 23:00:27
style: indenting
dmurph
2012/07/04 00:01:29
Done.
| |
| 49 const char* _data, | |
| 50 const char* _shader_0_hash, | |
| 51 const ShaderTranslator::VariableMap& _attrib_map_0, | |
| 52 const ShaderTranslator::VariableMap& _uniform_map_0, | |
| 53 const char* _shader_1_hash, | |
| 54 const ShaderTranslator::VariableMap& _attrib_map_1, | |
| 55 const ShaderTranslator::VariableMap& _uniform_map_1) | |
| 56 : length(_length), | |
| 57 format(_format), | |
| 58 data(_data), | |
| 59 shader_0_hash(_shader_0_hash, kHashLength), | |
| 60 attrib_map_0(_attrib_map_0), | |
| 61 uniform_map_0(_uniform_map_0), | |
| 62 shader_1_hash(_shader_1_hash, kHashLength), | |
| 63 attrib_map_1(_attrib_map_1), | |
| 64 uniform_map_1(_uniform_map_1) { } | |
| 65 const GLsizei length; | |
|
greggman
2012/06/26 23:00:27
style: public members in classes are not allowed.
dmurph
2012/07/04 00:01:29
Done.
| |
| 66 const GLenum format; | |
| 67 const scoped_array<const char> data; | |
| 68 const std::string shader_0_hash; | |
| 69 const ShaderTranslator::VariableMap attrib_map_0; | |
| 70 const ShaderTranslator::VariableMap uniform_map_0; | |
| 71 const std::string shader_1_hash; | |
| 72 const ShaderTranslator::VariableMap attrib_map_1; | |
| 73 const ShaderTranslator::VariableMap uniform_map_1; | |
| 74 | |
| 75 private: | |
| 76 DISALLOW_COPY_AND_ASSIGN(ProgramCacheValue); | |
| 77 }; | |
| 78 | |
| 79 typedef base::hash_map<const std::string, | |
| 80 scoped_refptr<ProgramCacheValue>, | |
| 81 FastHash> StoreMap; | |
|
greggman
2012/06/26 23:00:27
I don't think you need FashHash. You're hashing st
dmurph
2012/06/27 01:46:22
So SuperFastHash is defined in the disk cache, sho
| |
| 82 | |
| 83 const size_t max_size_bytes_; | |
| 84 size_t curr_size_bytes_; | |
| 85 StoreMap store_; | |
| 86 ProgramCacheLruHelper eviction_helper_; | |
| 87 | |
| 88 DISALLOW_COPY_AND_ASSIGN(MemoryProgramCache); | |
| 89 }; | |
| 90 | |
| 91 } // namespace gles2 | |
| 92 } // namespace gpu | |
| 93 | |
| 94 #endif // GPU_COMMAND_BUFFER_SERVICE_MEMORY_PROGRAM_CACHE_H_ | |
| OLD | NEW |