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/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "base/version.h" | 14 #include "base/version.h" |
15 #include "content/browser/gpu/gpu_process_host.h" | 15 #include "content/browser/gpu/gpu_process_host.h" |
| 16 #include "content/browser/gpu/gpu_util.h" |
16 #include "content/common/gpu/gpu_messages.h" | 17 #include "content/common/gpu/gpu_messages.h" |
17 #include "content/gpu/gpu_info_collector.h" | 18 #include "content/gpu/gpu_info_collector.h" |
18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/browser/gpu_data_manager_observer.h" | 20 #include "content/public/browser/gpu_data_manager_observer.h" |
20 #include "content/public/common/content_client.h" | 21 #include "content/public/common/content_client.h" |
21 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
22 #include "ui/base/ui_base_switches.h" | 23 #include "ui/base/ui_base_switches.h" |
23 #include "ui/gl/gl_implementation.h" | 24 #include "ui/gl/gl_implementation.h" |
24 #include "ui/gl/gl_switches.h" | 25 #include "ui/gl/gl_switches.h" |
25 #include "webkit/plugins/plugin_switches.h" | 26 #include "webkit/plugins/plugin_switches.h" |
(...skipping 25 matching lines...) Expand all Loading... |
51 card_blacklisted_(false) { | 52 card_blacklisted_(false) { |
52 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 53 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
53 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { | 54 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { |
54 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); | 55 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); |
55 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); | 56 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); |
56 } | 57 } |
57 if (command_line->HasSwitch(switches::kDisableGpu)) | 58 if (command_line->HasSwitch(switches::kDisableGpu)) |
58 BlacklistCard(); | 59 BlacklistCard(); |
59 } | 60 } |
60 | 61 |
61 void GpuDataManagerImpl::InitializeGpuInfo() { | 62 void GpuDataManagerImpl::Initialize( |
| 63 const std::string& browser_version_string, |
| 64 const std::string& gpu_blacklist_json) { |
62 content::GPUInfo gpu_info; | 65 content::GPUInfo gpu_info; |
63 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 66 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); |
64 switches::kSkipGpuDataLoading)) | 67 |
65 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); | 68 if (!gpu_blacklist_json.empty()) { |
66 else | 69 CHECK(!browser_version_string.empty()); |
67 gpu_info.finalized = true; | 70 gpu_blacklist_.reset(new GpuBlacklist()); |
| 71 bool succeed = gpu_blacklist_->LoadGpuBlacklist( |
| 72 browser_version_string, |
| 73 gpu_blacklist_json, |
| 74 GpuBlacklist::kCurrentOsOnly); |
| 75 CHECK(succeed); |
| 76 } |
| 77 |
68 UpdateGpuInfo(gpu_info); | 78 UpdateGpuInfo(gpu_info); |
| 79 UpdatePreliminaryBlacklistedFeatures(); |
69 } | 80 } |
70 | 81 |
71 GpuDataManagerImpl::~GpuDataManagerImpl() { | 82 GpuDataManagerImpl::~GpuDataManagerImpl() { |
72 } | 83 } |
73 | 84 |
74 void GpuDataManagerImpl::RequestCompleteGpuInfoIfNeeded() { | 85 void GpuDataManagerImpl::RequestCompleteGpuInfoIfNeeded() { |
75 if (complete_gpu_info_already_requested_ || gpu_info_.finalized) | 86 if (complete_gpu_info_already_requested_ || gpu_info_.finalized) |
76 return; | 87 return; |
77 complete_gpu_info_already_requested_ = true; | 88 complete_gpu_info_already_requested_ = true; |
78 | 89 |
79 GpuProcessHost::SendOnIO( | 90 GpuProcessHost::SendOnIO( |
80 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, | 91 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, |
81 content::CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDE
D, | 92 content::CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDE
D, |
82 new GpuMsg_CollectGraphicsInfo()); | 93 new GpuMsg_CollectGraphicsInfo()); |
83 } | 94 } |
84 | 95 |
85 bool GpuDataManagerImpl::IsCompleteGpuInfoAvailable() const { | 96 bool GpuDataManagerImpl::IsCompleteGpuInfoAvailable() const { |
86 return gpu_info_.finalized; | 97 return gpu_info_.finalized; |
87 } | 98 } |
88 | 99 |
89 void GpuDataManagerImpl::UpdateGpuInfo(const content::GPUInfo& gpu_info) { | 100 void GpuDataManagerImpl::UpdateGpuInfo(const content::GPUInfo& gpu_info) { |
90 if (gpu_info_.finalized) | 101 if (gpu_info_.finalized) |
91 return; | 102 return; |
92 | 103 |
93 content::GetContentClient()->SetGpuInfo(gpu_info); | 104 content::GetContentClient()->SetGpuInfo(gpu_info); |
94 | 105 |
| 106 if (gpu_blacklist_.get()) { |
| 107 GpuFeatureType feature_type = gpu_blacklist_->DetermineGpuFeatureType( |
| 108 GpuBlacklist::kOsAny, |
| 109 NULL, |
| 110 GpuDataManager::GetInstance()->GetGPUInfo()); |
| 111 gpu_util::UpdateStats(gpu_blacklist_.get(), feature_type); |
| 112 UpdateBlacklistedFeatures(feature_type); |
| 113 } |
| 114 |
95 { | 115 { |
96 base::AutoLock auto_lock(gpu_info_lock_); | 116 base::AutoLock auto_lock(gpu_info_lock_); |
97 gpu_info_ = gpu_info; | 117 gpu_info_ = gpu_info; |
98 #if defined(ARCH_CPU_X86_FAMILY) | 118 #if defined(ARCH_CPU_X86_FAMILY) |
99 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) | 119 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) |
100 gpu_info_.finalized = true; | 120 gpu_info_.finalized = true; |
101 #endif | 121 #endif |
102 complete_gpu_info_already_requested_ = | 122 complete_gpu_info_already_requested_ = |
103 complete_gpu_info_already_requested_ || gpu_info_.finalized; | 123 complete_gpu_info_already_requested_ || gpu_info_.finalized; |
104 } | 124 } |
(...skipping 30 matching lines...) Expand all Loading... |
135 | 155 |
136 base::ListValue* GpuDataManagerImpl::GetLogMessages() const { | 156 base::ListValue* GpuDataManagerImpl::GetLogMessages() const { |
137 base::ListValue* value; | 157 base::ListValue* value; |
138 { | 158 { |
139 base::AutoLock auto_lock(log_messages_lock_); | 159 base::AutoLock auto_lock(log_messages_lock_); |
140 value = log_messages_.DeepCopy(); | 160 value = log_messages_.DeepCopy(); |
141 } | 161 } |
142 return value; | 162 return value; |
143 } | 163 } |
144 | 164 |
| 165 std::string GpuDataManagerImpl::GetBlacklistVersion() const { |
| 166 if (gpu_blacklist_.get()) |
| 167 return gpu_blacklist_->GetVersion(); |
| 168 return "0"; |
| 169 } |
| 170 |
145 GpuFeatureType GpuDataManagerImpl::GetBlacklistedFeatures() const { | 171 GpuFeatureType GpuDataManagerImpl::GetBlacklistedFeatures() const { |
146 if (software_rendering_) { | 172 if (software_rendering_) { |
147 GpuFeatureType flags; | 173 GpuFeatureType flags; |
148 | 174 |
149 // Skia's software rendering is probably more efficient than going through | 175 // Skia's software rendering is probably more efficient than going through |
150 // software emulation of the GPU, so use that. | 176 // software emulation of the GPU, so use that. |
151 flags = content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; | 177 flags = content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; |
152 return flags; | 178 return flags; |
153 } | 179 } |
154 | 180 |
155 return gpu_feature_type_; | 181 return gpu_feature_type_; |
156 } | 182 } |
157 | 183 |
| 184 base::ListValue* GpuDataManagerImpl::GetBlacklistReasons() const { |
| 185 ListValue* reasons = new ListValue(); |
| 186 if (gpu_blacklist_.get()) |
| 187 gpu_blacklist_->GetBlacklistReasons(reasons); |
| 188 return reasons; |
| 189 } |
| 190 |
158 bool GpuDataManagerImpl::GpuAccessAllowed() const { | 191 bool GpuDataManagerImpl::GpuAccessAllowed() const { |
159 if (software_rendering_) | 192 if (software_rendering_) |
160 return true; | 193 return true; |
161 | 194 |
162 if (!gpu_info_.gpu_accessible) | 195 if (!gpu_info_.gpu_accessible) |
163 return false; | 196 return false; |
164 | 197 |
165 if (card_blacklisted_) | 198 if (card_blacklisted_) |
166 return false; | 199 return false; |
167 | 200 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 CommandLine::ForCurrentProcess()->HasSwitch( | 331 CommandLine::ForCurrentProcess()->HasSwitch( |
299 switches::kDisableAcceleratedCompositing)) { | 332 switches::kDisableAcceleratedCompositing)) { |
300 if (!command_line->HasSwitch( | 333 if (!command_line->HasSwitch( |
301 switches::kDisableCoreAnimationPlugins)) | 334 switches::kDisableCoreAnimationPlugins)) |
302 command_line->AppendSwitch( | 335 command_line->AppendSwitch( |
303 switches::kDisableCoreAnimationPlugins); | 336 switches::kDisableCoreAnimationPlugins); |
304 } | 337 } |
305 #endif | 338 #endif |
306 } | 339 } |
307 | 340 |
308 void GpuDataManagerImpl::SetPreliminaryBlacklistedFeatures( | 341 void GpuDataManagerImpl::UpdatePreliminaryBlacklistedFeatures() { |
309 GpuFeatureType feature_type) { | |
310 UpdateBlacklistedFeatures(feature_type); | |
311 preliminary_gpu_feature_type_ = gpu_feature_type_; | 342 preliminary_gpu_feature_type_ = gpu_feature_type_; |
312 } | 343 } |
313 | 344 |
314 void GpuDataManagerImpl::NotifyGpuInfoUpdate() { | 345 void GpuDataManagerImpl::NotifyGpuInfoUpdate() { |
315 observer_list_->Notify(&GpuDataManagerObserver::OnGpuInfoUpdate); | 346 observer_list_->Notify(&GpuDataManagerObserver::OnGpuInfoUpdate); |
316 } | 347 } |
317 | 348 |
318 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats( | 349 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats( |
319 const content::GPUVideoMemoryUsageStats& video_memory_usage_stats) { | 350 const content::GPUVideoMemoryUsageStats& video_memory_usage_stats) { |
320 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, | 351 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 395 |
365 void GpuDataManagerImpl::BlacklistCard() { | 396 void GpuDataManagerImpl::BlacklistCard() { |
366 card_blacklisted_ = true; | 397 card_blacklisted_ = true; |
367 | 398 |
368 gpu_feature_type_ = content::GPU_FEATURE_TYPE_ALL; | 399 gpu_feature_type_ = content::GPU_FEATURE_TYPE_ALL; |
369 | 400 |
370 EnableSoftwareRenderingIfNecessary(); | 401 EnableSoftwareRenderingIfNecessary(); |
371 NotifyGpuInfoUpdate(); | 402 NotifyGpuInfoUpdate(); |
372 } | 403 } |
373 | 404 |
OLD | NEW |