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 #include "gpu/command_buffer/service/memory_program_cache.h" | 5 #include "gpu/command_buffer/service/memory_program_cache.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/sha1.h" | 10 #include "base/sha1.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 const std::string* program = eviction_helper_.PeekKey(); | 172 const std::string* program = eviction_helper_.PeekKey(); |
173 const StoreMap::iterator found = store_.find(*program); | 173 const StoreMap::iterator found = store_.find(*program); |
174 const ProgramCacheValue* evicting = found->second.get(); | 174 const ProgramCacheValue* evicting = found->second.get(); |
175 curr_size_bytes_ -= evicting->length; | 175 curr_size_bytes_ -= evicting->length; |
176 Evict(*program, evicting->shader_0_hash, evicting->shader_1_hash); | 176 Evict(*program, evicting->shader_0_hash, evicting->shader_1_hash); |
177 store_.erase(found); | 177 store_.erase(found); |
178 eviction_helper_.PopKey(); | 178 eviction_helper_.PopKey(); |
179 } | 179 } |
180 | 180 |
181 if (!shader_callback.is_null() && | 181 if (!shader_callback.is_null() && |
182 !CommandLine::ForCurrentProcess()->HasSwitch( | 182 CommandLine::ForCurrentProcess()->HasSwitch( |
183 switches::kDisableGpuShaderDiskCache)) { | 183 switches::kEnableGpuShaderDiskCache)) { |
184 std::string key; | 184 std::string key; |
185 base::Base64Encode(sha_string, &key); | 185 base::Base64Encode(sha_string, &key); |
186 | 186 |
187 GpuProgramProto* proto = GpuProgramProto::default_instance().New(); | 187 GpuProgramProto* proto = GpuProgramProto::default_instance().New(); |
188 proto->set_sha(sha, kHashLength); | 188 proto->set_sha(sha, kHashLength); |
189 proto->set_format(format); | 189 proto->set_format(format); |
190 proto->set_program(binary.get(), length); | 190 proto->set_program(binary.get(), length); |
191 | 191 |
192 ShaderProto* vertex_shader = proto->mutable_vertex_shader(); | 192 ShaderProto* vertex_shader = proto->mutable_vertex_shader(); |
193 vertex_shader->set_sha(a_sha, kHashLength); | 193 vertex_shader->set_sha(a_sha, kHashLength); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 attrib_map_0(_attrib_map_0), | 296 attrib_map_0(_attrib_map_0), |
297 uniform_map_0(_uniform_map_0), | 297 uniform_map_0(_uniform_map_0), |
298 shader_1_hash(_shader_1_hash, kHashLength), | 298 shader_1_hash(_shader_1_hash, kHashLength), |
299 attrib_map_1(_attrib_map_1), | 299 attrib_map_1(_attrib_map_1), |
300 uniform_map_1(_uniform_map_1) {} | 300 uniform_map_1(_uniform_map_1) {} |
301 | 301 |
302 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() {} | 302 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() {} |
303 | 303 |
304 } // namespace gles2 | 304 } // namespace gles2 |
305 } // namespace gpu | 305 } // namespace gpu |
OLD | NEW |