OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "content/browser/gpu/gpu_data_manager.h" |
6 | 6 |
7 #if defined(OS_MACOSX) | 7 #if defined(OS_MACOSX) |
8 #include <CoreGraphics/CGDisplayConfiguration.h> | 8 #include <CoreGraphics/CGDisplayConfiguration.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 void GpuDataManager::UserFlags::ApplyPolicies() { | 190 void GpuDataManager::UserFlags::ApplyPolicies() { |
191 if (disable_accelerated_compositing_) { | 191 if (disable_accelerated_compositing_) { |
192 disable_accelerated_2d_canvas_ = true; | 192 disable_accelerated_2d_canvas_ = true; |
193 disable_accelerated_layers_ = true; | 193 disable_accelerated_layers_ = true; |
194 } | 194 } |
195 } | 195 } |
196 | 196 |
197 GpuDataManager::GpuDataManager() | 197 GpuDataManager::GpuDataManager() |
198 : complete_gpu_info_already_requested_(false), | 198 : complete_gpu_info_already_requested_(false), |
| 199 complete_gpu_info_available_(false), |
199 observer_list_(new GpuDataManagerObserverList), | 200 observer_list_(new GpuDataManagerObserverList), |
200 software_rendering_(false) { | 201 software_rendering_(false) { |
201 Initialize(); | 202 Initialize(); |
202 } | 203 } |
203 | 204 |
204 void GpuDataManager::Initialize() { | 205 void GpuDataManager::Initialize() { |
205 // User flags need to be collected before any further initialization. | 206 // User flags need to be collected before any further initialization. |
206 user_flags_.Initialize(); | 207 user_flags_.Initialize(); |
207 | 208 |
208 if (!user_flags_.skip_gpu_data_loading()) { | 209 if (!user_flags_.skip_gpu_data_loading()) { |
209 content::GPUInfo gpu_info; | 210 content::GPUInfo gpu_info; |
210 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); | 211 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); |
211 UpdateGpuInfo(gpu_info); | 212 { |
| 213 base::AutoLock auto_lock(gpu_info_lock_); |
| 214 gpu_info_ = gpu_info; |
| 215 } |
212 } | 216 } |
213 | 217 |
214 #if defined(OS_MACOSX) | 218 #if defined(OS_MACOSX) |
215 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); | 219 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); |
216 #endif | 220 #endif |
217 } | 221 } |
218 | 222 |
219 GpuDataManager::~GpuDataManager() { | 223 GpuDataManager::~GpuDataManager() { |
220 #if defined(OS_MACOSX) | 224 #if defined(OS_MACOSX) |
221 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); | 225 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); |
222 #endif | 226 #endif |
223 } | 227 } |
224 | 228 |
225 // static | 229 // static |
226 GpuDataManager* GpuDataManager::GetInstance() { | 230 GpuDataManager* GpuDataManager::GetInstance() { |
227 return Singleton<GpuDataManager>::get(); | 231 return Singleton<GpuDataManager>::get(); |
228 } | 232 } |
229 | 233 |
230 void GpuDataManager::RequestCompleteGpuInfoIfNeeded() { | 234 void GpuDataManager::RequestCompleteGpuInfoIfNeeded() { |
231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
232 if (complete_gpu_info_already_requested_) | 236 if (complete_gpu_info_already_requested_ || complete_gpu_info_available_) |
233 return; | 237 return; |
234 complete_gpu_info_already_requested_ = true; | 238 complete_gpu_info_already_requested_ = true; |
235 | 239 |
236 GpuProcessHost::SendOnIO( | 240 GpuProcessHost::SendOnIO( |
237 0, | 241 0, |
238 content::CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDE
D, | 242 content::CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDE
D, |
239 new GpuMsg_CollectGraphicsInfo()); | 243 new GpuMsg_CollectGraphicsInfo()); |
240 } | 244 } |
241 | 245 |
242 void GpuDataManager::UpdateGpuInfo(const content::GPUInfo& gpu_info) { | 246 void GpuDataManager::UpdateGpuInfo(const content::GPUInfo& gpu_info) { |
| 247 complete_gpu_info_available_ = true; |
| 248 complete_gpu_info_already_requested_ = true; |
243 { | 249 { |
244 base::AutoLock auto_lock(gpu_info_lock_); | 250 base::AutoLock auto_lock(gpu_info_lock_); |
245 if (!Merge(&gpu_info_, gpu_info)) | 251 if (!Merge(&gpu_info_, gpu_info)) |
246 return; | 252 return; |
247 } | |
248 | |
249 NotifyGpuInfoUpdate(); | |
250 | |
251 { | |
252 base::AutoLock auto_lock(gpu_info_lock_); | |
253 content::GetContentClient()->SetGpuInfo(gpu_info_); | 253 content::GetContentClient()->SetGpuInfo(gpu_info_); |
254 } | 254 } |
255 | 255 |
256 UpdateGpuFeatureFlags(); | 256 UpdateGpuFeatureFlags(); |
| 257 // We have to update GpuFeatureFlags before notify all the observers. |
| 258 NotifyGpuInfoUpdate(); |
257 } | 259 } |
258 | 260 |
259 const content::GPUInfo& GpuDataManager::gpu_info() const { | 261 const content::GPUInfo& GpuDataManager::gpu_info() const { |
260 base::AutoLock auto_lock(gpu_info_lock_); | 262 base::AutoLock auto_lock(gpu_info_lock_); |
261 return gpu_info_; | 263 return gpu_info_; |
262 } | 264 } |
263 | 265 |
264 Value* GpuDataManager::GetFeatureStatus() { | 266 Value* GpuDataManager::GetFeatureStatus() { |
265 bool gpu_access_blocked = !GpuAccessAllowed(); | 267 bool gpu_access_blocked = !GpuAccessAllowed(); |
266 | 268 |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 bool GpuDataManager::supportsAccelerated2dCanvas() const { | 792 bool GpuDataManager::supportsAccelerated2dCanvas() const { |
791 if (gpu_info_.can_lose_context) | 793 if (gpu_info_.can_lose_context) |
792 return false; | 794 return false; |
793 #if defined(USE_SKIA) | 795 #if defined(USE_SKIA) |
794 return true; | 796 return true; |
795 #else | 797 #else |
796 return false; | 798 return false; |
797 #endif | 799 #endif |
798 } | 800 } |
799 | 801 |
OLD | NEW |