| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 DictionaryValue* problem = new DictionaryValue(); | 359 DictionaryValue* problem = new DictionaryValue(); |
| 355 problem->SetString( | 360 problem->SetString( |
| 356 "description", kGpuFeatureInfo[i].disabled_description); | 361 "description", kGpuFeatureInfo[i].disabled_description); |
| 357 problem->Set("crBugs", new ListValue()); | 362 problem->Set("crBugs", new ListValue()); |
| 358 problem->Set("webkitBugs", new ListValue()); | 363 problem->Set("webkitBugs", new ListValue()); |
| 359 problem_list->Append(problem); | 364 problem_list->Append(problem); |
| 360 } | 365 } |
| 361 } | 366 } |
| 362 | 367 |
| 363 GpuBlacklist* blacklist = GetGpuBlacklist(); | 368 GpuBlacklist* blacklist = GetGpuBlacklist(); |
| 364 if (blacklist && (!UseGLIsOSMesaOrAny())) | 369 if (blacklist) |
| 365 blacklist->GetBlacklistReasons(problem_list); | 370 blacklist->GetBlacklistReasons(problem_list); |
| 366 | 371 |
| 367 status->Set("problems", problem_list); | 372 status->Set("problems", problem_list); |
| 368 } | 373 } |
| 369 | 374 |
| 370 return status; | 375 return status; |
| 371 } | 376 } |
| 372 | 377 |
| 373 std::string GpuDataManager::GetBlacklistVersion() const { | 378 std::string GpuDataManager::GetBlacklistVersion() const { |
| 374 GpuBlacklist* blacklist = GetGpuBlacklist(); | 379 GpuBlacklist* blacklist = GetGpuBlacklist(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 389 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 390 log_messages_.Append(msg); | 395 log_messages_.Append(msg); |
| 391 } | 396 } |
| 392 | 397 |
| 393 const ListValue& GpuDataManager::log_messages() const { | 398 const ListValue& GpuDataManager::log_messages() const { |
| 394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 399 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 395 return log_messages_; | 400 return log_messages_; |
| 396 } | 401 } |
| 397 | 402 |
| 398 GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() { | 403 GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() { |
| 399 if (UseGLIsOSMesaOrAny()) | |
| 400 return GpuFeatureFlags(); | |
| 401 return gpu_feature_flags_; | 404 return gpu_feature_flags_; |
| 402 } | 405 } |
| 403 | 406 |
| 404 bool GpuDataManager::GpuAccessAllowed() { | 407 bool GpuDataManager::GpuAccessAllowed() { |
| 405 if (UseGLIsOSMesaOrAny()) | |
| 406 return true; | |
| 407 | |
| 408 // We only need to block GPU process if more features are disallowed other | 408 // We only need to block GPU process if more features are disallowed other |
| 409 // than those in the preliminary gpu feature flags because the latter work | 409 // than those in the preliminary gpu feature flags because the latter work |
| 410 // through renderer commandline switches. | 410 // through renderer commandline switches. |
| 411 uint32 mask = (~(preliminary_gpu_feature_flags_.flags())); | 411 uint32 mask = (~(preliminary_gpu_feature_flags_.flags())); |
| 412 return (gpu_feature_flags_.flags() & mask) == 0; | 412 return (gpu_feature_flags_.flags() & mask) == 0; |
| 413 } | 413 } |
| 414 | 414 |
| 415 void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) { | 415 void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) { |
| 416 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 416 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 417 gpu_info_update_callbacks_.insert(callback); | 417 gpu_info_update_callbacks_.insert(callback); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 GpuBlacklist* GpuDataManager::GetGpuBlacklist() const { | 688 GpuBlacklist* GpuDataManager::GetGpuBlacklist() const { |
| 689 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 689 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 690 if (user_flags_.ignore_gpu_blacklist()) | 690 if (user_flags_.ignore_gpu_blacklist()) |
| 691 return NULL; | 691 return NULL; |
| 692 // No need to return an empty blacklist. | 692 // No need to return an empty blacklist. |
| 693 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) | 693 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) |
| 694 return NULL; | 694 return NULL; |
| 695 return gpu_blacklist_.get(); | 695 return gpu_blacklist_.get(); |
| 696 } | 696 } |
| 697 | 697 |
| 698 bool GpuDataManager::UseGLIsOSMesaOrAny() { | |
| 699 return (user_flags_.use_gl() == "any" || | |
| 700 user_flags_.use_gl() == gfx::kGLImplementationOSMesaName); | |
| 701 } | |
| 702 | |
| 703 bool GpuDataManager::Merge(content::GPUInfo* object, | 698 bool GpuDataManager::Merge(content::GPUInfo* object, |
| 704 const content::GPUInfo& other) { | 699 const content::GPUInfo& other) { |
| 705 if (object->device_id != other.device_id || | 700 if (object->device_id != other.device_id || |
| 706 object->vendor_id != other.vendor_id) { | 701 object->vendor_id != other.vendor_id) { |
| 707 *object = other; | 702 *object = other; |
| 708 return true; | 703 return true; |
| 709 } | 704 } |
| 710 | 705 |
| 711 bool changed = false; | 706 bool changed = false; |
| 712 if (!object->finalized) { | 707 if (!object->finalized) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 bool GpuDataManager::supportsAccelerated2dCanvas() const { | 763 bool GpuDataManager::supportsAccelerated2dCanvas() const { |
| 769 if (gpu_info_.can_lose_context) | 764 if (gpu_info_.can_lose_context) |
| 770 return false; | 765 return false; |
| 771 #if defined(USE_SKIA) | 766 #if defined(USE_SKIA) |
| 772 return true; | 767 return true; |
| 773 #else | 768 #else |
| 774 return false; | 769 return false; |
| 775 #endif | 770 #endif |
| 776 } | 771 } |
| 777 | 772 |
| OLD | NEW |