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" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "gpu/command_buffer/common/constants.h" | 12 #include "gpu/command_buffer/common/constants.h" |
13 #include "gpu/command_buffer/service/disk_cache_proto.pb.h" | 13 #include "gpu/command_buffer/service/disk_cache_proto.pb.h" |
14 #include "gpu/command_buffer/service/gl_utils.h" | 14 #include "gpu/command_buffer/service/gl_utils.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/gpu_switches.h" | 16 #include "gpu/command_buffer/service/gpu_switches.h" |
17 #include "gpu/command_buffer/service/shader_manager.h" | 17 #include "gpu/command_buffer/service/shader_manager.h" |
18 #include "gpu/command_buffer/service/shader_translator.h" | 18 #include "gpu/command_buffer/service/shader_translator.h" |
19 #include "ui/gl/gl_bindings.h" | 19 #include "ui/gl/gl_bindings.h" |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 size_t GetCacheSizeBytes() { | 23 size_t GetCacheSizeBytes() { |
24 size_t size; | |
25 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 24 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
26 if (command_line->HasSwitch(switches::kGpuProgramCacheSizeKb) && | 25 if (command_line->HasSwitch(switches::kGpuProgramCacheSizeKb)) { |
27 base::StringToSizeT(command_line->GetSwitchValueNative( | 26 size_t size; |
28 switches::kGpuProgramCacheSizeKb), | 27 if (base::StringToSizeT( |
29 &size)) { | 28 command_line->GetSwitchValueNative(switches::kGpuProgramCacheSizeKb), |
| 29 &size)) |
30 return size * 1024; | 30 return size * 1024; |
31 } | 31 } |
32 return gpu::kDefaultMaxProgramCacheMemoryBytes; | 32 return gpu::kDefaultMaxProgramCacheMemoryBytes; |
33 } | 33 } |
34 | 34 |
35 } // anonymous namespace | 35 } // anonymous namespace |
36 | 36 |
37 namespace gpu { | 37 namespace gpu { |
38 namespace gles2 { | 38 namespace gles2 { |
39 | 39 |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 program_cache_->LinkedProgramCacheSuccess(program_hash); | 361 program_cache_->LinkedProgramCacheSuccess(program_hash); |
362 } | 362 } |
363 | 363 |
364 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() { | 364 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() { |
365 program_cache_->curr_size_bytes_ -= length_; | 365 program_cache_->curr_size_bytes_ -= length_; |
366 program_cache_->Evict(program_hash_); | 366 program_cache_->Evict(program_hash_); |
367 } | 367 } |
368 | 368 |
369 } // namespace gles2 | 369 } // namespace gles2 |
370 } // namespace gpu | 370 } // namespace gpu |
OLD | NEW |