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 "content/browser/gpu/gpu_data_manager_impl.h" | 5 #include "content/browser/gpu/gpu_data_manager_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/string_piece.h" |
11 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
12 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "base/version.h" | 15 #include "base/version.h" |
15 #include "content/browser/gpu/gpu_process_host.h" | 16 #include "content/browser/gpu/gpu_process_host.h" |
16 #include "content/browser/gpu/gpu_util.h" | 17 #include "content/browser/gpu/gpu_util.h" |
17 #include "content/common/gpu/gpu_messages.h" | 18 #include "content/common/gpu/gpu_messages.h" |
18 #include "content/gpu/gpu_info_collector.h" | 19 #include "content/gpu/gpu_info_collector.h" |
19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/gpu_data_manager_observer.h" | 21 #include "content/public/browser/gpu_data_manager_observer.h" |
21 #include "content/public/common/content_client.h" | 22 #include "content/public/common/content_client.h" |
22 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 24 #include "grit/content_resources.h" |
23 #include "ui/base/ui_base_switches.h" | 25 #include "ui/base/ui_base_switches.h" |
24 #include "ui/gl/gl_implementation.h" | 26 #include "ui/gl/gl_implementation.h" |
25 #include "ui/gl/gl_switches.h" | 27 #include "ui/gl/gl_switches.h" |
26 #include "webkit/plugins/plugin_switches.h" | 28 #include "webkit/plugins/plugin_switches.h" |
27 | 29 |
28 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
29 #include "base/win/windows_version.h" | 31 #include "base/win/windows_version.h" |
30 #endif | 32 #endif |
31 | 33 |
32 using content::BrowserThread; | 34 using content::BrowserThread; |
(...skipping 22 matching lines...) Expand all Loading... |
55 update_histograms_(true) { | 57 update_histograms_(true) { |
56 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 58 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
57 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { | 59 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { |
58 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); | 60 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); |
59 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); | 61 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); |
60 } | 62 } |
61 if (command_line->HasSwitch(switches::kDisableGpu)) | 63 if (command_line->HasSwitch(switches::kDisableGpu)) |
62 BlacklistCard(); | 64 BlacklistCard(); |
63 } | 65 } |
64 | 66 |
65 void GpuDataManagerImpl::Initialize( | 67 void GpuDataManagerImpl::Initialize(const std::string& browser_version_string) { |
66 const std::string& browser_version_string, | 68 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
67 const std::string& gpu_blacklist_json) { | 69 if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) |
| 70 return; |
| 71 |
68 content::GPUInfo gpu_info; | 72 content::GPUInfo gpu_info; |
69 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); | 73 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); |
70 #if defined(ARCH_CPU_X86_FAMILY) | 74 #if defined(ARCH_CPU_X86_FAMILY) |
71 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) | 75 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) |
72 gpu_info.finalized = true; | 76 gpu_info.finalized = true; |
73 #endif | 77 #endif |
74 | 78 |
75 Initialize(browser_version_string, gpu_blacklist_json, gpu_info); | 79 std::string gpu_blacklist_string; |
| 80 if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist)) { |
| 81 const base::StringPiece gpu_blacklist_json = |
| 82 content::GetContentClient()->GetDataResource( |
| 83 IDR_GPU_BLACKLIST, ui::SCALE_FACTOR_NONE); |
| 84 gpu_blacklist_string = gpu_blacklist_json.as_string(); |
| 85 } |
| 86 Initialize(browser_version_string, gpu_blacklist_string, gpu_info); |
| 87 } |
| 88 |
| 89 void GpuDataManagerImpl::Initialize( |
| 90 const std::string& gpu_blacklist_json, |
| 91 const content::GPUInfo& gpu_info) { |
| 92 // This function is for testing only, so disable histograms. |
| 93 update_histograms_ = false; |
| 94 |
| 95 Initialize("0", gpu_blacklist_json, gpu_info); |
76 } | 96 } |
77 | 97 |
78 void GpuDataManagerImpl::Initialize( | 98 void GpuDataManagerImpl::Initialize( |
79 const std::string& browser_version_string, | 99 const std::string& browser_version_string, |
80 const std::string& gpu_blacklist_json, | 100 const std::string& gpu_blacklist_json, |
81 const content::GPUInfo& gpu_info) { | 101 const content::GPUInfo& gpu_info) { |
82 { | 102 { |
83 // This function should only be called in testing. | 103 // This function should only be called in testing. |
84 // We need clean up the gpu_info_ for a clean initialization. | 104 // We need clean up the gpu_info_ for a clean initialization. |
85 const content::GPUInfo empty_gpu_info; | 105 const content::GPUInfo empty_gpu_info; |
86 base::AutoLock auto_lock(gpu_info_lock_); | 106 base::AutoLock auto_lock(gpu_info_lock_); |
87 gpu_info_ = empty_gpu_info; | 107 gpu_info_ = empty_gpu_info; |
88 } | 108 } |
89 | 109 |
90 // This function is for testing only, so disable histograms. | |
91 update_histograms_ = false; | |
92 | |
93 if (!gpu_blacklist_json.empty()) { | 110 if (!gpu_blacklist_json.empty()) { |
94 CHECK(!browser_version_string.empty()); | 111 CHECK(!browser_version_string.empty()); |
95 gpu_blacklist_.reset(new GpuBlacklist()); | 112 gpu_blacklist_.reset(new GpuBlacklist()); |
96 bool succeed = gpu_blacklist_->LoadGpuBlacklist( | 113 bool succeed = gpu_blacklist_->LoadGpuBlacklist( |
97 browser_version_string, | 114 browser_version_string, |
98 gpu_blacklist_json, | 115 gpu_blacklist_json, |
99 GpuBlacklist::kCurrentOsOnly); | 116 GpuBlacklist::kCurrentOsOnly); |
100 CHECK(succeed); | 117 CHECK(succeed); |
101 } | 118 } |
102 | 119 |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 443 |
427 void GpuDataManagerImpl::BlacklistCard() { | 444 void GpuDataManagerImpl::BlacklistCard() { |
428 card_blacklisted_ = true; | 445 card_blacklisted_ = true; |
429 | 446 |
430 gpu_feature_type_ = content::GPU_FEATURE_TYPE_ALL; | 447 gpu_feature_type_ = content::GPU_FEATURE_TYPE_ALL; |
431 | 448 |
432 EnableSoftwareRenderingIfNecessary(); | 449 EnableSoftwareRenderingIfNecessary(); |
433 NotifyGpuInfoUpdate(); | 450 NotifyGpuInfoUpdate(); |
434 } | 451 } |
435 | 452 |
OLD | NEW |