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

Side by Side Diff: chrome/browser/gpu_data_manager.cc

Issue 6588138: Implemented multisampling control in software rendering list. Move prelimina... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: For the records: landing patch Created 9 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
« no previous file with comments | « chrome/browser/gpu_data_manager.h ('k') | chrome/browser/gpu_process_host_ui_shim.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/gpu_data_manager.h" 5 #include "chrome/browser/gpu_data_manager.h"
6 6
7 #include "app/app_switches.h" 7 #include "app/app_switches.h"
8 #include "app/gfx/gl/gl_implementation.h" 8 #include "app/gfx/gl/gl_implementation.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/gpu_process_host_ui_shim.h" 13 #include "chrome/browser/gpu_process_host_ui_shim.h"
14 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/common/child_process_logging.h" 15 #include "chrome/common/child_process_logging.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "chrome/gpu/gpu_info_collector.h"
18 #include "content/browser/gpu_blacklist.h" 19 #include "content/browser/gpu_blacklist.h"
19 #include "grit/browser_resources.h" 20 #include "grit/browser_resources.h"
20 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
21 22
22 GpuDataManager::GpuDataManager() 23 GpuDataManager::GpuDataManager()
23 : complete_gpu_info_already_requested_(false) 24 : complete_gpu_info_already_requested_(false),
24 , gpu_feature_flags_set_(false) 25 gpu_feature_flags_set_(false),
25 , gpu_blacklist_cache_(NULL) { 26 gpu_blacklist_cache_(NULL) {
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
27 DCHECK(g_browser_process); 28 DCHECK(g_browser_process);
28 PrefService* prefs = g_browser_process->local_state(); 29 PrefService* local_state = g_browser_process->local_state();
29 // If we bring up chrome normally, prefs should never be NULL; however, we 30 // If we bring up chrome normally, prefs should never be NULL; however, we
30 // we handle the case where prefs == NULL for certain tests. 31 // we handle the case where local_state == NULL for certain tests.
31 if (prefs) { 32 if (local_state) {
32 prefs->RegisterDictionaryPref(prefs::kGpuBlacklist); 33 local_state->RegisterDictionaryPref(prefs::kGpuBlacklist);
33 gpu_blacklist_cache_ = prefs->GetMutableDictionary(prefs::kGpuBlacklist); 34 gpu_blacklist_cache_ =
35 local_state->GetMutableDictionary(prefs::kGpuBlacklist);
34 DCHECK(gpu_blacklist_cache_); 36 DCHECK(gpu_blacklist_cache_);
35 37
36 gpu_blacklist_updater_ = new GpuBlacklistUpdater(); 38 gpu_blacklist_updater_ = new GpuBlacklistUpdater();
37 // TODO(zmo): uncomment the following line to turn on auto-updating. 39 // TODO(zmo): uncomment the following line to turn on auto-updating.
38 // gpu_blacklist_updater_->StartAfterDelay(); 40 // gpu_blacklist_updater_->StartAfterDelay();
39 } 41 }
40 42
41 LoadGpuBlacklist(); 43 LoadGpuBlacklist();
42 UpdateGpuBlacklist(); 44 UpdateGpuBlacklist();
45
46 GPUInfo gpu_info;
47 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info);
48 UpdateGpuInfo(gpu_info);
49 UpdateGpuFeatureFlags();
50
51 preliminary_gpu_feature_flags_ = gpu_feature_flags_;
43 } 52 }
44 53
45 GpuDataManager::~GpuDataManager() { } 54 GpuDataManager::~GpuDataManager() { }
46 55
47 GpuDataManager* GpuDataManager::GetInstance() { 56 GpuDataManager* GpuDataManager::GetInstance() {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
49 return Singleton<GpuDataManager>::get(); 58 return Singleton<GpuDataManager>::get();
50 } 59 }
51 60
52 void GpuDataManager::RequestCompleteGpuInfoIfNeeded() { 61 void GpuDataManager::RequestCompleteGpuInfoIfNeeded() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 98 }
90 99
91 const ListValue& GpuDataManager::log_messages() const { 100 const ListValue& GpuDataManager::log_messages() const {
92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
93 return log_messages_; 102 return log_messages_;
94 } 103 }
95 104
96 GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() { 105 GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() {
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
98 UpdateGpuFeatureFlags(); 107 UpdateGpuFeatureFlags();
99 return gpu_feature_flags_; 108 // We only need to return the bits that are not in the preliminary
109 // gpu feature flags because the latter work through renderer
110 // commandline switches.
111 uint32 mask = ~(preliminary_gpu_feature_flags_.flags());
112 GpuFeatureFlags masked_flags;
113 masked_flags.set_flags(gpu_feature_flags_.flags() & mask);
114 return masked_flags;
100 } 115 }
101 116
102 void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) { 117 void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) {
103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
104 gpu_info_update_callbacks_.insert(callback); 119 gpu_info_update_callbacks_.insert(callback);
105 } 120 }
106 121
107 bool GpuDataManager::RemoveGpuInfoUpdateCallback(Callback0::Type* callback) { 122 bool GpuDataManager::RemoveGpuInfoUpdateCallback(Callback0::Type* callback) {
108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
109 std::set<Callback0::Type*>::iterator i = 124 std::set<Callback0::Type*>::iterator i =
110 gpu_info_update_callbacks_.find(callback); 125 gpu_info_update_callbacks_.find(callback);
111 if (i != gpu_info_update_callbacks_.end()) { 126 if (i != gpu_info_update_callbacks_.end()) {
112 gpu_info_update_callbacks_.erase(i); 127 gpu_info_update_callbacks_.erase(i);
113 return true; 128 return true;
114 } 129 }
115 return false; 130 return false;
116 } 131 }
117 132
133 void GpuDataManager::AppendRendererCommandLine(
134 CommandLine* command_line) {
135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
136 DCHECK(command_line);
137
138 uint32 flags = preliminary_gpu_feature_flags_.flags();
139 if ((flags & GpuFeatureFlags::kGpuFeatureWebgl) &&
140 !command_line->HasSwitch(switches::kDisableExperimentalWebGL))
141 command_line->AppendSwitch(switches::kDisableExperimentalWebGL);
142 if ((flags & GpuFeatureFlags::kGpuFeatureMultisampling) &&
143 !command_line->HasSwitch(switches::kDisableGLMultisampling))
144 command_line->AppendSwitch(switches::kDisableGLMultisampling);
145 // If we have kGpuFeatureAcceleratedCompositing, we disable all GPU features.
146 if (flags & GpuFeatureFlags::kGpuFeatureAcceleratedCompositing) {
147 const char* switches[] = {
148 switches::kDisableAcceleratedCompositing,
149 switches::kDisableExperimentalWebGL
150 };
151 const int switch_count = sizeof(switches) / sizeof(char*);
152 for (int i = 0; i < switch_count; ++i) {
153 if (!command_line->HasSwitch(switches[i]))
154 command_line->AppendSwitch(switches[i]);
155 }
156 }
157 }
158
118 void GpuDataManager::RunGpuInfoUpdateCallbacks() { 159 void GpuDataManager::RunGpuInfoUpdateCallbacks() {
119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
120 std::set<Callback0::Type*>::iterator i = gpu_info_update_callbacks_.begin(); 161 std::set<Callback0::Type*>::iterator i = gpu_info_update_callbacks_.begin();
121 for (; i != gpu_info_update_callbacks_.end(); ++i) { 162 for (; i != gpu_info_update_callbacks_.end(); ++i) {
122 (*i)->Run(); 163 (*i)->Run();
123 } 164 }
124 } 165 }
125 166
126 bool GpuDataManager::LoadGpuBlacklist() { 167 bool GpuDataManager::LoadGpuBlacklist() {
127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 browser_command_line.GetSwitchValueASCII( 268 browser_command_line.GetSwitchValueASCII(
228 switches::kUseGL) == gfx::kGLImplementationOSMesaName) 269 switches::kUseGL) == gfx::kGLImplementationOSMesaName)
229 return NULL; 270 return NULL;
230 UpdateGpuBlacklist(); 271 UpdateGpuBlacklist();
231 // No need to return an empty blacklist. 272 // No need to return an empty blacklist.
232 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) 273 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0)
233 return NULL; 274 return NULL;
234 return gpu_blacklist_.get(); 275 return gpu_blacklist_.get();
235 } 276 }
236 277
OLDNEW
« no previous file with comments | « chrome/browser/gpu_data_manager.h ('k') | chrome/browser/gpu_process_host_ui_shim.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698