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