Chromium Code Reviews| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 #endif // OS_WIN | 146 #endif // OS_WIN |
| 147 | 147 |
| 148 } // namespace anonymous | 148 } // namespace anonymous |
| 149 | 149 |
| 150 GpuDataManager::UserFlags::UserFlags() | 150 GpuDataManager::UserFlags::UserFlags() |
| 151 : disable_accelerated_2d_canvas_(false), | 151 : disable_accelerated_2d_canvas_(false), |
| 152 disable_accelerated_compositing_(false), | 152 disable_accelerated_compositing_(false), |
| 153 disable_accelerated_layers_(false), | 153 disable_accelerated_layers_(false), |
| 154 disable_experimental_webgl_(false), | 154 disable_experimental_webgl_(false), |
| 155 disable_gl_multisampling_(false), | 155 disable_gl_multisampling_(false), |
| 156 ignore_gpu_blacklist_(false) { | 156 ignore_gpu_blacklist_(false), |
| 157 skip_gpu_data_loading_(false) { | |
| 157 } | 158 } |
| 158 | 159 |
| 159 void GpuDataManager::UserFlags::Initialize() { | 160 void GpuDataManager::UserFlags::Initialize() { |
| 160 const CommandLine& browser_command_line = | 161 const CommandLine& browser_command_line = |
| 161 *CommandLine::ForCurrentProcess(); | 162 *CommandLine::ForCurrentProcess(); |
| 162 | 163 |
| 163 disable_accelerated_2d_canvas_ = browser_command_line.HasSwitch( | 164 disable_accelerated_2d_canvas_ = browser_command_line.HasSwitch( |
| 164 switches::kDisableAccelerated2dCanvas); | 165 switches::kDisableAccelerated2dCanvas); |
| 165 disable_accelerated_compositing_ = browser_command_line.HasSwitch( | 166 disable_accelerated_compositing_ = browser_command_line.HasSwitch( |
| 166 switches::kDisableAcceleratedCompositing); | 167 switches::kDisableAcceleratedCompositing); |
| 167 disable_accelerated_layers_ = browser_command_line.HasSwitch( | 168 disable_accelerated_layers_ = browser_command_line.HasSwitch( |
| 168 switches::kDisableAcceleratedLayers); | 169 switches::kDisableAcceleratedLayers); |
| 169 disable_experimental_webgl_ = browser_command_line.HasSwitch( | 170 disable_experimental_webgl_ = browser_command_line.HasSwitch( |
| 170 switches::kDisableExperimentalWebGL); | 171 switches::kDisableExperimentalWebGL); |
| 171 disable_gl_multisampling_ = browser_command_line.HasSwitch( | 172 disable_gl_multisampling_ = browser_command_line.HasSwitch( |
| 172 switches::kDisableGLMultisampling); | 173 switches::kDisableGLMultisampling); |
| 173 | 174 |
| 174 ignore_gpu_blacklist_ = browser_command_line.HasSwitch( | 175 ignore_gpu_blacklist_ = browser_command_line.HasSwitch( |
| 175 switches::kIgnoreGpuBlacklist); | 176 switches::kIgnoreGpuBlacklist); |
| 177 skip_gpu_data_loading_ = browser_command_line.HasSwitch( | |
| 178 switches::kSkipGpuDataLoading); | |
| 176 | 179 |
| 177 use_gl_ = browser_command_line.GetSwitchValueASCII(switches::kUseGL); | 180 use_gl_ = browser_command_line.GetSwitchValueASCII(switches::kUseGL); |
| 178 | 181 |
| 179 ApplyPolicies(); | 182 ApplyPolicies(); |
| 180 } | 183 } |
| 181 | 184 |
| 182 void GpuDataManager::UserFlags::ApplyPolicies() { | 185 void GpuDataManager::UserFlags::ApplyPolicies() { |
| 183 if (disable_accelerated_compositing_) { | 186 if (disable_accelerated_compositing_) { |
| 184 disable_accelerated_2d_canvas_ = true; | 187 disable_accelerated_2d_canvas_ = true; |
| 185 disable_accelerated_layers_ = true; | 188 disable_accelerated_layers_ = true; |
| 186 } | 189 } |
| 187 } | 190 } |
| 188 | 191 |
| 189 GpuDataManager::GpuDataManager() | 192 GpuDataManager::GpuDataManager() |
| 190 : complete_gpu_info_already_requested_(false) { | 193 : complete_gpu_info_already_requested_(false) { |
| 191 Initialize(); | 194 Initialize(); |
| 192 } | 195 } |
| 193 | 196 |
| 194 void GpuDataManager::Initialize() { | 197 void GpuDataManager::Initialize() { |
| 198 // User flags need to be collected before any further initialization. | |
| 199 user_flags_.Initialize(); | |
| 200 | |
| 195 // Certain tests doesn't go through the browser startup path that | 201 // Certain tests doesn't go through the browser startup path that |
| 196 // initializes GpuDataManager on FILE thread; therefore, it is initialized | 202 // initializes GpuDataManager on FILE thread; therefore, it is initialized |
| 197 // on UI thread later, and we skip the preliminary gpu info collection | 203 // on UI thread later, and we skip the preliminary gpu info collection |
| 198 // in such situation. | 204 // in such situation. |
| 199 if (BrowserThread::CurrentlyOn(BrowserThread::FILE)) { | 205 if (!user_flags_.skip_gpu_data_loading() && |
| 206 BrowserThread::CurrentlyOn(BrowserThread::FILE)) { | |
| 200 content::GPUInfo gpu_info; | 207 content::GPUInfo gpu_info; |
| 201 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); | 208 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); |
| 202 UpdateGpuInfo(gpu_info); | 209 UpdateGpuInfo(gpu_info); |
| 203 } | 210 } |
| 204 | 211 |
| 205 user_flags_.Initialize(); | |
| 206 | |
| 207 #if defined(OS_MACOSX) | 212 #if defined(OS_MACOSX) |
| 208 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); | 213 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); |
| 209 #endif | 214 #endif |
| 210 } | 215 } |
| 211 | 216 |
| 212 GpuDataManager::~GpuDataManager() { | 217 GpuDataManager::~GpuDataManager() { |
| 213 #if defined(OS_MACOSX) | 218 #if defined(OS_MACOSX) |
| 214 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); | 219 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); |
| 215 #endif | 220 #endif |
| 216 } | 221 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 DictionaryValue* problem = new DictionaryValue(); | 357 DictionaryValue* problem = new DictionaryValue(); |
| 353 problem->SetString( | 358 problem->SetString( |
| 354 "description", kGpuFeatureInfo[i].disabled_description); | 359 "description", kGpuFeatureInfo[i].disabled_description); |
| 355 problem->Set("crBugs", new ListValue()); | 360 problem->Set("crBugs", new ListValue()); |
| 356 problem->Set("webkitBugs", new ListValue()); | 361 problem->Set("webkitBugs", new ListValue()); |
| 357 problem_list->Append(problem); | 362 problem_list->Append(problem); |
| 358 } | 363 } |
| 359 } | 364 } |
| 360 | 365 |
| 361 GpuBlacklist* blacklist = GetGpuBlacklist(); | 366 GpuBlacklist* blacklist = GetGpuBlacklist(); |
| 362 if (blacklist && (!UseGLIsOSMesaOrAny())) | 367 if (blacklist) |
| 363 blacklist->GetBlacklistReasons(problem_list); | 368 blacklist->GetBlacklistReasons(problem_list); |
| 364 | 369 |
| 365 status->Set("problems", problem_list); | 370 status->Set("problems", problem_list); |
| 366 } | 371 } |
| 367 | 372 |
| 368 return status; | 373 return status; |
| 369 } | 374 } |
| 370 | 375 |
| 371 std::string GpuDataManager::GetBlacklistVersion() const { | 376 std::string GpuDataManager::GetBlacklistVersion() const { |
| 372 GpuBlacklist* blacklist = GetGpuBlacklist(); | 377 GpuBlacklist* blacklist = GetGpuBlacklist(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 387 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 392 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 388 log_messages_.Append(msg); | 393 log_messages_.Append(msg); |
| 389 } | 394 } |
| 390 | 395 |
| 391 const ListValue& GpuDataManager::log_messages() const { | 396 const ListValue& GpuDataManager::log_messages() const { |
| 392 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 397 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 393 return log_messages_; | 398 return log_messages_; |
| 394 } | 399 } |
| 395 | 400 |
| 396 GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() { | 401 GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() { |
| 397 if (UseGLIsOSMesaOrAny()) | |
| 398 return GpuFeatureFlags(); | |
| 399 return gpu_feature_flags_; | 402 return gpu_feature_flags_; |
| 400 } | 403 } |
| 401 | 404 |
| 402 bool GpuDataManager::GpuAccessAllowed() { | 405 bool GpuDataManager::GpuAccessAllowed() { |
| 403 if (UseGLIsOSMesaOrAny()) | |
| 404 return true; | |
| 405 | |
| 406 // We only need to block GPU process if more features are disallowed other | 406 // We only need to block GPU process if more features are disallowed other |
| 407 // than those in the preliminary gpu feature flags because the latter work | 407 // than those in the preliminary gpu feature flags because the latter work |
| 408 // through renderer commandline switches. | 408 // through renderer commandline switches. |
| 409 uint32 mask = (~(preliminary_gpu_feature_flags_.flags())); | 409 uint32 mask = (~(preliminary_gpu_feature_flags_.flags())); |
| 410 return (gpu_feature_flags_.flags() & mask) == 0; | 410 return (gpu_feature_flags_.flags() & mask) == 0; |
| 411 } | 411 } |
| 412 | 412 |
| 413 void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) { | 413 void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) { |
| 414 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 414 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 415 gpu_info_update_callbacks_.insert(callback); | 415 gpu_info_update_callbacks_.insert(callback); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 #endif | 682 #endif |
| 683 } | 683 } |
| 684 } | 684 } |
| 685 | 685 |
| 686 GpuBlacklist* GpuDataManager::GetGpuBlacklist() const { | 686 GpuBlacklist* GpuDataManager::GetGpuBlacklist() const { |
| 687 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 687 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 688 if (user_flags_.ignore_gpu_blacklist()) | 688 if (user_flags_.ignore_gpu_blacklist()) |
| 689 return NULL; | 689 return NULL; |
| 690 // No need to return an empty blacklist. | 690 // No need to return an empty blacklist. |
| 691 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) | 691 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) |
| 692 return NULL; | 692 return NULL; |
|
Ken Russell (switch to Gerrit)
2011/10/24 21:04:41
Does this test handle the case where --skip-gpu-da
Zhenyao Mo
2011/10/24 21:42:19
if --skip-gpu-data-loading is passed, gpu_blacklis
| |
| 693 return gpu_blacklist_.get(); | 693 return gpu_blacklist_.get(); |
| 694 } | 694 } |
| 695 | 695 |
| 696 bool GpuDataManager::UseGLIsOSMesaOrAny() { | |
| 697 return (user_flags_.use_gl() == "any" || | |
| 698 user_flags_.use_gl() == gfx::kGLImplementationOSMesaName); | |
| 699 } | |
| 700 | |
| 701 bool GpuDataManager::Merge(content::GPUInfo* object, | 696 bool GpuDataManager::Merge(content::GPUInfo* object, |
| 702 const content::GPUInfo& other) { | 697 const content::GPUInfo& other) { |
| 703 if (object->device_id != other.device_id || | 698 if (object->device_id != other.device_id || |
| 704 object->vendor_id != other.vendor_id) { | 699 object->vendor_id != other.vendor_id) { |
| 705 *object = other; | 700 *object = other; |
| 706 return true; | 701 return true; |
| 707 } | 702 } |
| 708 | 703 |
| 709 bool changed = false; | 704 bool changed = false; |
| 710 if (!object->finalized) { | 705 if (!object->finalized) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 #if defined(OS_WIN) | 750 #if defined(OS_WIN) |
| 756 if (object->dx_diagnostics.values.size() == 0 && | 751 if (object->dx_diagnostics.values.size() == 0 && |
| 757 object->dx_diagnostics.children.size() == 0) { | 752 object->dx_diagnostics.children.size() == 0) { |
| 758 object->dx_diagnostics = other.dx_diagnostics; | 753 object->dx_diagnostics = other.dx_diagnostics; |
| 759 changed = true; | 754 changed = true; |
| 760 } | 755 } |
| 761 #endif | 756 #endif |
| 762 } | 757 } |
| 763 return changed; | 758 return changed; |
| 764 } | 759 } |
| OLD | NEW |