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

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: '' 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
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/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/common/child_process_logging.h" 13 #include "chrome/common/child_process_logging.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "chrome/gpu/gpu_info_collector.h"
16 #include "content/browser/gpu_blacklist.h" 17 #include "content/browser/gpu_blacklist.h"
17 #include "grit/browser_resources.h" 18 #include "grit/browser_resources.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 20
20 GpuDataManager::GpuDataManager() 21 GpuDataManager::GpuDataManager()
21 : gpu_feature_flags_set_(false), 22 : gpu_feature_flags_set_(false),
23 gpu_feature_flags_applied_(false),
22 gpu_blacklist_cache_(NULL) { 24 gpu_blacklist_cache_(NULL) {
23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
24 DCHECK(g_browser_process); 26 DCHECK(g_browser_process);
25 PrefService* prefs = g_browser_process->local_state(); 27 PrefService* local_state = g_browser_process->local_state();
26 // If we bring up chrome normally, prefs should never be NULL; however, we 28 // If we bring up chrome normally, prefs should never be NULL; however, we
27 // we handle the case where prefs == NULL for certain tests. 29 // we handle the case where prefs == NULL for certain tests.
28 if (prefs) { 30 if (local_state) {
29 prefs->RegisterDictionaryPref(prefs::kGpuBlacklist); 31 local_state->RegisterDictionaryPref(prefs::kGpuBlacklist);
30 gpu_blacklist_cache_ = prefs->GetMutableDictionary(prefs::kGpuBlacklist); 32 gpu_blacklist_cache_ =
33 local_state->GetMutableDictionary(prefs::kGpuBlacklist);
31 DCHECK(gpu_blacklist_cache_); 34 DCHECK(gpu_blacklist_cache_);
32 35
33 gpu_blacklist_updater_ = new GpuBlacklistUpdater(); 36 gpu_blacklist_updater_ = new GpuBlacklistUpdater();
34 // TODO(zmo): uncomment the following line to turn on auto-updating. 37 // TODO(zmo): uncomment the following line to turn on auto-updating.
35 // gpu_blacklist_updater_->StartAfterDelay(); 38 // gpu_blacklist_updater_->StartAfterDelay();
36 } 39 }
37 40
38 LoadGpuBlacklist(); 41 LoadGpuBlacklist();
39 UpdateGpuBlacklist(); 42 UpdateGpuBlacklist();
43
44 GPUInfo gpu_info;
45 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info);
46 UpdateGpuInfo(gpu_info);
47 UpdateGpuFeatureFlags();
48
49 uint32 flags = gpu_feature_flags_.flags();
apatrick_chromium 2011/03/03 21:09:07 Just to check, the flag being set means the featur
Zhenyao Mo 2011/03/04 00:24:59 Yes and will fix this in another CL after M11.
50 CommandLine* browser_command_line = CommandLine::ForCurrentProcess();
51 DCHECK(browser_command_line);
52 if ((flags & GpuFeatureFlags::kGpuFeatureWebgl) &&
53 !browser_command_line->HasSwitch(switches::kDisableExperimentalWebGL))
54 browser_command_line->AppendSwitch(switches::kDisableExperimentalWebGL);
apatrick_chromium 2011/03/03 21:09:07 It seems strange to modify the browser process com
Zhenyao Mo 2011/03/04 00:24:59 Per our offline discussion, will move this command
55 if ((flags & GpuFeatureFlags::kGpuFeatureMultisampling) &&
56 !browser_command_line->HasSwitch(switches::kDisableGLMultisampling))
57 browser_command_line->AppendSwitch(switches::kDisableGLMultisampling);
58 // If we have kGpuFeatureAcceleratedCompositing, we disable all GPU features.
59 if (flags & GpuFeatureFlags::kGpuFeatureAcceleratedCompositing) {
60 const char* switches[] = {
61 switches::kDisableAcceleratedCompositing,
62 switches::kDisableAcceleratedLayers,
63 switches::kDisableAcceleratedVideo,
64 switches::kDisableExperimentalWebGL
65 };
66 const int switch_count = sizeof(switches) / sizeof(char*);
67 for (int i = 0; i < switch_count; ++i) {
68 if (!browser_command_line->HasSwitch(switches[i]))
69 browser_command_line->AppendSwitch(switches[i]);
70 }
71 }
72 gpu_feature_flags_applied_ = true;
40 } 73 }
41 74
42 GpuDataManager::~GpuDataManager() { } 75 GpuDataManager::~GpuDataManager() { }
43 76
44 GpuDataManager* GpuDataManager::GetInstance() { 77 GpuDataManager* GpuDataManager::GetInstance() {
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
46 return Singleton<GpuDataManager>::get(); 79 return Singleton<GpuDataManager>::get();
47 } 80 }
48 81
49 void GpuDataManager::UpdateGpuInfo(const GPUInfo& gpu_info) { 82 void GpuDataManager::UpdateGpuInfo(const GPUInfo& gpu_info) {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
51 if (gpu_info_.level() >= gpu_info.level()) 84 if (gpu_info_.level() >= gpu_info.level())
52 return; 85 return;
53 gpu_info_ = gpu_info; 86 gpu_info_ = gpu_info;
54 child_process_logging::SetGpuInfo(gpu_info); 87 child_process_logging::SetGpuInfo(gpu_info);
55 // Clear the flag to triger a re-computation of GpuFeatureFlags using the 88 // Clear the flag to triger a re-computation of GpuFeatureFlags using the
56 // updated GPU info. 89 // updated GPU info.
57 gpu_feature_flags_set_ = false; 90 gpu_feature_flags_set_ = false;
58 RunGpuInfoUpdateCallbacks(); 91 RunGpuInfoUpdateCallbacks();
59 } 92 }
60 93
61 const GPUInfo& GpuDataManager::gpu_info() const { 94 const GPUInfo& GpuDataManager::gpu_info() const {
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
63 return gpu_info_; 96 return gpu_info_;
64 } 97 }
65 98
66 GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() { 99 GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() {
apatrick_chromium 2011/03/03 21:09:07 Could this be GetBlacklistedFeatureFlags()? Anothe
Zhenyao Mo 2011/03/04 00:24:59 Will do after M11.
67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
68 UpdateGpuFeatureFlags(); 101 UpdateGpuFeatureFlags();
102 if (gpu_feature_flags_applied_)
103 return GpuFeatureFlags();
apatrick_chromium 2011/03/03 21:09:07 Why does this return that no features are blacklis
Zhenyao Mo 2011/03/04 00:24:59 This is because certain features are already disab
69 return gpu_feature_flags_; 104 return gpu_feature_flags_;
70 } 105 }
71 106
72 void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) { 107 void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) {
73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
74 gpu_info_update_callbacks_.insert(callback); 109 gpu_info_update_callbacks_.insert(callback);
75 } 110 }
76 111
77 bool GpuDataManager::RemoveGpuInfoUpdateCallback(Callback0::Type* callback) { 112 bool GpuDataManager::RemoveGpuInfoUpdateCallback(Callback0::Type* callback) {
78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if (gpu_blacklist == NULL) 183 if (gpu_blacklist == NULL)
149 return; 184 return;
150 185
151 if (gpu_feature_flags_set_) 186 if (gpu_feature_flags_set_)
152 return; 187 return;
153 188
154 gpu_feature_flags_set_ = true; 189 gpu_feature_flags_set_ = true;
155 gpu_feature_flags_.set_flags(0); 190 gpu_feature_flags_.set_flags(0);
156 191
157 if (gpu_blacklist != NULL) { 192 if (gpu_blacklist != NULL) {
158 gpu_feature_flags_ = gpu_blacklist->DetermineGpuFeatureFlags( 193 GpuFeatureFlags flags = gpu_blacklist->DetermineGpuFeatureFlags(
159 GpuBlacklist::kOsAny, NULL, gpu_info_); 194 GpuBlacklist::kOsAny, NULL, gpu_info_);
195 // If any new bit is set, we need to apply flags again.
196 if (gpu_feature_flags_applied_ &&
197 ((~(gpu_feature_flags_.flags())) & flags.flags())) {
198 gpu_feature_flags_applied_ = false;
199 // TODO(zmo): need to ask the user to restart chrome.
apatrick_chromium 2011/03/03 21:09:07 Why can't deal with this by terminating the GPU pr
Zhenyao Mo 2011/03/04 00:24:59 At the moment renderer can't recover and go throug
jamesr 2011/03/04 00:28:14 I thought Alexey fixed this (or possibly is still
200 }
201 gpu_feature_flags_ = flags;
160 uint32 max_entry_id = gpu_blacklist->max_entry_id(); 202 uint32 max_entry_id = gpu_blacklist->max_entry_id();
161 if (gpu_feature_flags_.flags() != 0) { 203 if (gpu_feature_flags_.flags() != 0) {
162 // If gpu is blacklisted, no further GPUInfo will be collected. 204 // If gpu is blacklisted, no further GPUInfo will be collected.
163 gpu_info_.SetLevel(GPUInfo::kComplete); 205 gpu_info_.SetLevel(GPUInfo::kComplete);
164 // TODO(zmo): move histograming to GpuBlacklist::DetermineGpuFeatureFlags. 206 // TODO(zmo): move histograming to GpuBlacklist::DetermineGpuFeatureFlags.
165 std::vector<uint32> flag_entries; 207 std::vector<uint32> flag_entries;
166 gpu_blacklist->GetGpuFeatureFlagEntries( 208 gpu_blacklist->GetGpuFeatureFlagEntries(
167 GpuFeatureFlags::kGpuFeatureAll, flag_entries); 209 GpuFeatureFlags::kGpuFeatureAll, flag_entries);
168 DCHECK_GT(flag_entries.size(), 0u); 210 DCHECK_GT(flag_entries.size(), 0u);
169 for (size_t i = 0; i < flag_entries.size(); ++i) { 211 for (size_t i = 0; i < flag_entries.size(); ++i) {
(...skipping 14 matching lines...) Expand all
184 browser_command_line.GetSwitchValueASCII( 226 browser_command_line.GetSwitchValueASCII(
185 switches::kUseGL) == gfx::kGLImplementationOSMesaName) 227 switches::kUseGL) == gfx::kGLImplementationOSMesaName)
186 return NULL; 228 return NULL;
187 UpdateGpuBlacklist(); 229 UpdateGpuBlacklist();
188 // No need to return an empty blacklist. 230 // No need to return an empty blacklist.
189 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) 231 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0)
190 return NULL; 232 return NULL;
191 return gpu_blacklist_.get(); 233 return gpu_blacklist_.get();
192 } 234 }
193 235
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698