Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: content/browser/gpu/gpu_data_manager_impl.cc

Issue 12976004: Generalzie GpuBlacklist to GpuControlList. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #if defined(OS_MACOSX) 7 #if defined(OS_MACOSX)
8 #include <ApplicationServices/ApplicationServices.h> 8 #include <ApplicationServices/ApplicationServices.h>
9 #endif // OS_MACOSX 9 #endif // OS_MACOSX
10 10
(...skipping 10 matching lines...) Expand all
21 #include "base/version.h" 21 #include "base/version.h"
22 #include "content/browser/gpu/gpu_process_host.h" 22 #include "content/browser/gpu/gpu_process_host.h"
23 #include "content/browser/gpu/gpu_util.h" 23 #include "content/browser/gpu/gpu_util.h"
24 #include "content/common/gpu/gpu_messages.h" 24 #include "content/common/gpu/gpu_messages.h"
25 #include "content/gpu/gpu_info_collector.h" 25 #include "content/gpu/gpu_info_collector.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/gpu_data_manager_observer.h" 27 #include "content/public/browser/gpu_data_manager_observer.h"
28 #include "content/public/common/content_client.h" 28 #include "content/public/common/content_client.h"
29 #include "content/public/common/content_constants.h" 29 #include "content/public/common/content_constants.h"
30 #include "content/public/common/content_switches.h" 30 #include "content/public/common/content_switches.h"
31 #include "gpu/command_buffer/service/gpu_switches.h"
31 #include "grit/content_resources.h" 32 #include "grit/content_resources.h"
32 #include "ui/base/ui_base_switches.h" 33 #include "ui/base/ui_base_switches.h"
33 #include "ui/gl/gl_implementation.h" 34 #include "ui/gl/gl_implementation.h"
34 #include "ui/gl/gl_switches.h" 35 #include "ui/gl/gl_switches.h"
35 #include "ui/gl/gpu_switching_manager.h" 36 #include "ui/gl/gpu_switching_manager.h"
36 #include "webkit/plugins/plugin_switches.h" 37 #include "webkit/plugins/plugin_switches.h"
37 38
38 #if defined(OS_WIN) 39 #if defined(OS_WIN)
39 #include "base/win/windows_version.h" 40 #include "base/win/windows_version.h"
40 #endif 41 #endif
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() { 95 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() {
95 return Singleton<GpuDataManagerImpl>::get(); 96 return Singleton<GpuDataManagerImpl>::get();
96 } 97 }
97 98
98 void GpuDataManagerImpl::InitializeForTesting( 99 void GpuDataManagerImpl::InitializeForTesting(
99 const std::string& gpu_blacklist_json, 100 const std::string& gpu_blacklist_json,
100 const GPUInfo& gpu_info) { 101 const GPUInfo& gpu_info) {
101 // This function is for testing only, so disable histograms. 102 // This function is for testing only, so disable histograms.
102 update_histograms_ = false; 103 update_histograms_ = false;
103 104
104 InitializeImpl(gpu_blacklist_json, gpu_info); 105 InitializeImpl(gpu_blacklist_json, "", "", gpu_info);
105 } 106 }
106 107
107 GpuFeatureType GpuDataManagerImpl::GetBlacklistedFeatures() const { 108 GpuFeatureType GpuDataManagerImpl::GetBlacklistedFeatures() const {
108 if (software_rendering_) { 109 if (software_rendering_) {
109 GpuFeatureType flags; 110 GpuFeatureType flags;
110 111
111 // Skia's software rendering is probably more efficient than going through 112 // Skia's software rendering is probably more efficient than going through
112 // software emulation of the GPU, so use that. 113 // software emulation of the GPU, so use that.
113 flags = GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; 114 flags = GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS;
114 return flags; 115 return flags;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 return; 281 return;
281 282
282 GPUInfo gpu_info; 283 GPUInfo gpu_info;
283 gpu_info_collector::CollectBasicGraphicsInfo(&gpu_info); 284 gpu_info_collector::CollectBasicGraphicsInfo(&gpu_info);
284 #if defined(ARCH_CPU_X86_FAMILY) 285 #if defined(ARCH_CPU_X86_FAMILY)
285 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) 286 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id)
286 gpu_info.finalized = true; 287 gpu_info.finalized = true;
287 #endif 288 #endif
288 289
289 std::string gpu_blacklist_string; 290 std::string gpu_blacklist_string;
291 std::string gpu_switching_list_string;
292 std::string gpu_driver_bug_list_string;
290 if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist)) { 293 if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist)) {
291 const base::StringPiece gpu_blacklist_json = 294 const base::StringPiece gpu_blacklist_json =
292 GetContentClient()->GetDataResource( 295 GetContentClient()->GetDataResource(
293 IDR_GPU_BLACKLIST, ui::SCALE_FACTOR_NONE); 296 IDR_GPU_BLACKLIST, ui::SCALE_FACTOR_NONE);
294 gpu_blacklist_string = gpu_blacklist_json.as_string(); 297 gpu_blacklist_string = gpu_blacklist_json.as_string();
298 const base::StringPiece gpu_switching_list_json =
299 GetContentClient()->GetDataResource(
300 IDR_GPU_SWITCHING_LIST, ui::SCALE_FACTOR_NONE);
301 gpu_switching_list_string = gpu_switching_list_json.as_string();
295 } 302 }
296 303 if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) {
297 InitializeImpl(gpu_blacklist_string, gpu_info); 304 const base::StringPiece gpu_driver_bug_list_json =
305 GetContentClient()->GetDataResource(
306 IDR_GPU_DRIVER_BUG_LIST, ui::SCALE_FACTOR_NONE);
307 gpu_driver_bug_list_string = gpu_driver_bug_list_json.as_string();
308 }
309 InitializeImpl(gpu_blacklist_string,
310 gpu_switching_list_string,
311 gpu_driver_bug_list_string,
312 gpu_info);
298 } 313 }
299 314
300 void GpuDataManagerImpl::UpdateGpuInfo(const GPUInfo& gpu_info) { 315 void GpuDataManagerImpl::UpdateGpuInfo(const GPUInfo& gpu_info) {
301 // No further update of gpu_info if falling back to software renderer. 316 // No further update of gpu_info if falling back to software renderer.
302 if (software_rendering_) 317 if (software_rendering_)
303 return; 318 return;
304 319
305 GPUInfo my_gpu_info; 320 GPUInfo my_gpu_info;
306 { 321 {
307 base::AutoLock auto_lock(gpu_info_lock_); 322 base::AutoLock auto_lock(gpu_info_lock_);
308 gpu_info_collector::MergeGPUInfo(&gpu_info_, gpu_info); 323 gpu_info_collector::MergeGPUInfo(&gpu_info_, gpu_info);
309 complete_gpu_info_already_requested_ = 324 complete_gpu_info_already_requested_ =
310 complete_gpu_info_already_requested_ || gpu_info_.finalized; 325 complete_gpu_info_already_requested_ || gpu_info_.finalized;
311 my_gpu_info = gpu_info_; 326 my_gpu_info = gpu_info_;
312 } 327 }
313 328
314 GetContentClient()->SetGpuInfo(my_gpu_info); 329 GetContentClient()->SetGpuInfo(my_gpu_info);
315 330
316 if (gpu_blacklist_.get()) { 331 if (gpu_blacklist_.get()) {
317 GpuBlacklist::Decision decision = 332 int features = gpu_blacklist_->MakeDecision(
318 gpu_blacklist_->MakeBlacklistDecision( 333 GpuControlList::kOsAny, "", my_gpu_info);
319 GpuBlacklist::kOsAny, "", my_gpu_info);
320 if (update_histograms_) 334 if (update_histograms_)
321 UpdateStats(gpu_blacklist_.get(), decision.blacklisted_features); 335 UpdateStats(gpu_blacklist_.get(), features);
322 336
323 UpdateBlacklistedFeatures(decision.blacklisted_features); 337 UpdateBlacklistedFeatures(static_cast<GpuFeatureType>(features));
324 if (decision.gpu_switching != GPU_SWITCHING_OPTION_UNKNOWN) { 338 }
339 if (gpu_switching_list_.get()) {
340 int option = gpu_switching_list_->MakeDecision(
341 GpuControlList::kOsAny, "", my_gpu_info);
342 if (option != GPU_SWITCHING_OPTION_UNKNOWN) {
325 // Blacklist decision should not overwrite commandline switch from users. 343 // Blacklist decision should not overwrite commandline switch from users.
326 CommandLine* command_line = CommandLine::ForCurrentProcess(); 344 CommandLine* command_line = CommandLine::ForCurrentProcess();
327 if (!command_line->HasSwitch(switches::kGpuSwitching)) 345 if (!command_line->HasSwitch(switches::kGpuSwitching))
328 gpu_switching_ = decision.gpu_switching; 346 gpu_switching_ = static_cast<GpuSwitchingOption>(option);
329 } 347 }
330 } 348 }
349 if (gpu_driver_bug_list_.get())
350 gpu_driver_bugs_ = gpu_driver_bug_list_->MakeDecision(
351 GpuControlList::kOsAny, "", my_gpu_info);
331 352
332 // We have to update GpuFeatureType before notify all the observers. 353 // We have to update GpuFeatureType before notify all the observers.
333 NotifyGpuInfoUpdate(); 354 NotifyGpuInfoUpdate();
334 } 355 }
335 356
336 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats( 357 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats(
337 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { 358 const GPUVideoMemoryUsageStats& video_memory_usage_stats) {
338 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, 359 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate,
339 video_memory_usage_stats); 360 video_memory_usage_stats);
340 } 361 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 515
495 std::string GpuDataManagerImpl::GetBlacklistVersion() const { 516 std::string GpuDataManagerImpl::GetBlacklistVersion() const {
496 if (gpu_blacklist_.get()) 517 if (gpu_blacklist_.get())
497 return gpu_blacklist_->GetVersion(); 518 return gpu_blacklist_->GetVersion();
498 return "0"; 519 return "0";
499 } 520 }
500 521
501 base::ListValue* GpuDataManagerImpl::GetBlacklistReasons() const { 522 base::ListValue* GpuDataManagerImpl::GetBlacklistReasons() const {
502 ListValue* reasons = new ListValue(); 523 ListValue* reasons = new ListValue();
503 if (gpu_blacklist_.get()) 524 if (gpu_blacklist_.get())
504 gpu_blacklist_->GetBlacklistReasons(reasons); 525 gpu_blacklist_->GetReasons(reasons);
505 return reasons; 526 return reasons;
506 } 527 }
507 528
508 void GpuDataManagerImpl::AddLogMessage( 529 void GpuDataManagerImpl::AddLogMessage(
509 int level, const std::string& header, const std::string& message) { 530 int level, const std::string& header, const std::string& message) {
510 base::AutoLock auto_lock(log_messages_lock_); 531 base::AutoLock auto_lock(log_messages_lock_);
511 DictionaryValue* dict = new DictionaryValue(); 532 DictionaryValue* dict = new DictionaryValue();
512 dict->SetInteger("level", level); 533 dict->SetInteger("level", level);
513 dict->SetString("header", header); 534 dict->SetString("header", header);
514 dict->SetString("message", message); 535 dict->SetString("message", message);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 } 644 }
624 645
625 GpuDataManagerImpl::~GpuDataManagerImpl() { 646 GpuDataManagerImpl::~GpuDataManagerImpl() {
626 #if defined(OS_MACOSX) 647 #if defined(OS_MACOSX)
627 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); 648 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this);
628 #endif 649 #endif
629 } 650 }
630 651
631 void GpuDataManagerImpl::InitializeImpl( 652 void GpuDataManagerImpl::InitializeImpl(
632 const std::string& gpu_blacklist_json, 653 const std::string& gpu_blacklist_json,
654 const std::string& gpu_switching_list_json,
655 const std::string& gpu_driver_bug_list_json,
633 const GPUInfo& gpu_info) { 656 const GPUInfo& gpu_info) {
657 std::string browser_version_string = ProcessVersionString(
658 GetContentClient()->GetProduct());
659 CHECK(!browser_version_string.empty());
660
634 if (!gpu_blacklist_json.empty()) { 661 if (!gpu_blacklist_json.empty()) {
635 std::string browser_version_string = ProcessVersionString( 662 gpu_blacklist_.reset(GpuBlacklist::Create());
636 GetContentClient()->GetProduct()); 663 gpu_blacklist_->LoadList(
637 CHECK(!browser_version_string.empty()); 664 browser_version_string, gpu_blacklist_json,
638 gpu_blacklist_.reset(new GpuBlacklist()); 665 GpuControlList::kCurrentOsOnly);
639 bool succeed = gpu_blacklist_->LoadGpuBlacklist( 666 }
640 browser_version_string, 667 if (!gpu_switching_list_json.empty()) {
641 gpu_blacklist_json, 668 gpu_switching_list_.reset(GpuSwitchingList::Create());
642 GpuBlacklist::kCurrentOsOnly); 669 gpu_switching_list_->LoadList(
643 CHECK(succeed); 670 browser_version_string, gpu_switching_list_json,
671 GpuControlList::kCurrentOsOnly);
672 }
673 if (!gpu_driver_bug_list_json.empty()) {
674 gpu_driver_bug_list_.reset(GpuDriverBugList::Create());
675 gpu_driver_bug_list_->LoadList(
676 browser_version_string, gpu_driver_bug_list_json,
677 GpuControlList::kCurrentOsOnly);
644 } 678 }
645 679
646 { 680 {
647 base::AutoLock auto_lock(gpu_info_lock_); 681 base::AutoLock auto_lock(gpu_info_lock_);
648 gpu_info_ = gpu_info; 682 gpu_info_ = gpu_info;
649 } 683 }
650 UpdateGpuInfo(gpu_info); 684 UpdateGpuInfo(gpu_info);
651 UpdateGpuSwitchingManager(gpu_info); 685 UpdateGpuSwitchingManager(gpu_info);
652 UpdatePreliminaryBlacklistedFeatures(); 686 UpdatePreliminaryBlacklistedFeatures();
653 } 687 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 840
807 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url, 841 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url,
808 int render_process_id, 842 int render_process_id,
809 int render_view_id, 843 int render_view_id,
810 ThreeDAPIType requester) { 844 ThreeDAPIType requester) {
811 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, 845 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs,
812 url, render_process_id, render_view_id, requester); 846 url, render_process_id, render_view_id, requester);
813 } 847 }
814 848
815 } // namespace content 849 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_data_manager_impl.h ('k') | content/browser/gpu/gpu_data_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698