| 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" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 void GpuDataManagerImpl::UpdateGpuInfo(const content::GPUInfo& gpu_info) { | 88 void GpuDataManagerImpl::UpdateGpuInfo(const content::GPUInfo& gpu_info) { |
| 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 90 | 90 |
| 91 complete_gpu_info_available_ = | 91 complete_gpu_info_available_ = |
| 92 complete_gpu_info_available_ || gpu_info.finalized; | 92 complete_gpu_info_available_ || gpu_info.finalized; |
| 93 complete_gpu_info_already_requested_ = | 93 complete_gpu_info_already_requested_ = |
| 94 complete_gpu_info_already_requested_ || gpu_info.finalized; | 94 complete_gpu_info_already_requested_ || gpu_info.finalized; |
| 95 { | 95 { |
| 96 base::AutoLock auto_lock(gpu_info_lock_); | 96 base::AutoLock auto_lock(gpu_info_lock_); |
| 97 if (!Merge(&gpu_info_, gpu_info)) | 97 gpu_info_ = gpu_info; |
| 98 return; | |
| 99 content::GetContentClient()->SetGpuInfo(gpu_info_); | 98 content::GetContentClient()->SetGpuInfo(gpu_info_); |
| 100 } | 99 } |
| 101 | 100 |
| 102 // We have to update GpuFeatureType before notify all the observers. | 101 // We have to update GpuFeatureType before notify all the observers. |
| 103 NotifyGpuInfoUpdate(); | 102 NotifyGpuInfoUpdate(); |
| 104 } | 103 } |
| 105 | 104 |
| 106 content::GPUInfo GpuDataManagerImpl::GetGPUInfo() const { | 105 content::GPUInfo GpuDataManagerImpl::GetGPUInfo() const { |
| 107 return gpu_info_; | 106 return gpu_info_; |
| 108 } | 107 } |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 int flags = gpu_feature_type_; | 281 int flags = gpu_feature_type_; |
| 283 flags |= content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING | | 282 flags |= content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING | |
| 284 content::GPU_FEATURE_TYPE_WEBGL; | 283 content::GPU_FEATURE_TYPE_WEBGL; |
| 285 gpu_feature_type_ = static_cast<GpuFeatureType>(flags); | 284 gpu_feature_type_ = static_cast<GpuFeatureType>(flags); |
| 286 } | 285 } |
| 287 | 286 |
| 288 EnableSoftwareRenderingIfNecessary(); | 287 EnableSoftwareRenderingIfNecessary(); |
| 289 NotifyGpuInfoUpdate(); | 288 NotifyGpuInfoUpdate(); |
| 290 } | 289 } |
| 291 | 290 |
| 292 bool GpuDataManagerImpl::Merge(content::GPUInfo* object, | |
| 293 const content::GPUInfo& other) { | |
| 294 if (object->device_id != other.device_id || | |
| 295 object->vendor_id != other.vendor_id) { | |
| 296 *object = other; | |
| 297 return true; | |
| 298 } | |
| 299 | |
| 300 bool changed = false; | |
| 301 if (!object->finalized) { | |
| 302 object->finalized = other.finalized; | |
| 303 object->initialization_time = other.initialization_time; | |
| 304 object->optimus |= other.optimus; | |
| 305 object->amd_switchable |= other.amd_switchable; | |
| 306 | |
| 307 if (object->driver_vendor.empty()) { | |
| 308 changed |= object->driver_vendor != other.driver_vendor; | |
| 309 object->driver_vendor = other.driver_vendor; | |
| 310 } | |
| 311 if (object->driver_version.empty()) { | |
| 312 changed |= object->driver_version != other.driver_version; | |
| 313 object->driver_version = other.driver_version; | |
| 314 } | |
| 315 if (object->driver_date.empty()) { | |
| 316 changed |= object->driver_date != other.driver_date; | |
| 317 object->driver_date = other.driver_date; | |
| 318 } | |
| 319 if (object->pixel_shader_version.empty()) { | |
| 320 changed |= object->pixel_shader_version != other.pixel_shader_version; | |
| 321 object->pixel_shader_version = other.pixel_shader_version; | |
| 322 } | |
| 323 if (object->vertex_shader_version.empty()) { | |
| 324 changed |= object->vertex_shader_version != other.vertex_shader_version; | |
| 325 object->vertex_shader_version = other.vertex_shader_version; | |
| 326 } | |
| 327 if (object->gl_version.empty()) { | |
| 328 changed |= object->gl_version != other.gl_version; | |
| 329 object->gl_version = other.gl_version; | |
| 330 } | |
| 331 if (object->gl_version_string.empty()) { | |
| 332 changed |= object->gl_version_string != other.gl_version_string; | |
| 333 object->gl_version_string = other.gl_version_string; | |
| 334 } | |
| 335 if (object->gl_vendor.empty()) { | |
| 336 changed |= object->gl_vendor != other.gl_vendor; | |
| 337 object->gl_vendor = other.gl_vendor; | |
| 338 } | |
| 339 if (object->gl_renderer.empty()) { | |
| 340 changed |= object->gl_renderer != other.gl_renderer; | |
| 341 object->gl_renderer = other.gl_renderer; | |
| 342 } | |
| 343 if (object->gl_extensions.empty()) { | |
| 344 changed |= object->gl_extensions != other.gl_extensions; | |
| 345 object->gl_extensions = other.gl_extensions; | |
| 346 } | |
| 347 object->can_lose_context = other.can_lose_context; | |
| 348 object->software_rendering = other.software_rendering; | |
| 349 object->gpu_accessible = other.gpu_accessible; | |
| 350 #if defined(OS_WIN) | |
| 351 if (object->dx_diagnostics.values.size() == 0 && | |
| 352 object->dx_diagnostics.children.size() == 0) { | |
| 353 object->dx_diagnostics = other.dx_diagnostics; | |
| 354 changed = true; | |
| 355 } | |
| 356 #endif | |
| 357 } | |
| 358 return changed; | |
| 359 } | |
| OLD | NEW |