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

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

Issue 10915219: Add capability for GPU blacklist to manage GPU switching. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 14 matching lines...) Expand all
25 #include "ui/gl/gl_switches.h" 25 #include "ui/gl/gl_switches.h"
26 #include "webkit/plugins/plugin_switches.h" 26 #include "webkit/plugins/plugin_switches.h"
27 27
28 #if defined(OS_WIN) 28 #if defined(OS_WIN)
29 #include "base/win/windows_version.h" 29 #include "base/win/windows_version.h"
30 #endif 30 #endif
31 31
32 using content::BrowserThread; 32 using content::BrowserThread;
33 using content::GpuDataManagerObserver; 33 using content::GpuDataManagerObserver;
34 using content::GpuFeatureType; 34 using content::GpuFeatureType;
35 using content::GpuSwitchingOption;
35 36
36 // static 37 // static
37 content::GpuDataManager* content::GpuDataManager::GetInstance() { 38 content::GpuDataManager* content::GpuDataManager::GetInstance() {
38 return GpuDataManagerImpl::GetInstance(); 39 return GpuDataManagerImpl::GetInstance();
39 } 40 }
40 41
41 // static 42 // static
42 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() { 43 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() {
43 return Singleton<GpuDataManagerImpl>::get(); 44 return Singleton<GpuDataManagerImpl>::get();
44 } 45 }
45 46
46 GpuDataManagerImpl::GpuDataManagerImpl() 47 GpuDataManagerImpl::GpuDataManagerImpl()
47 : complete_gpu_info_already_requested_(false), 48 : complete_gpu_info_already_requested_(false),
48 gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN), 49 gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN),
49 preliminary_gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN), 50 preliminary_gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN),
51 gpu_switching_(content::GPU_SWITCHING_AUTOMATIC),
50 observer_list_(new GpuDataManagerObserverList), 52 observer_list_(new GpuDataManagerObserverList),
51 software_rendering_(false), 53 software_rendering_(false),
52 card_blacklisted_(false), 54 card_blacklisted_(false),
53 update_histograms_(true) { 55 update_histograms_(true) {
54 CommandLine* command_line = CommandLine::ForCurrentProcess(); 56 CommandLine* command_line = CommandLine::ForCurrentProcess();
55 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { 57 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) {
56 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); 58 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas);
57 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); 59 command_line->AppendSwitch(switches::kDisableAcceleratedLayers);
58 } 60 }
59 if (command_line->HasSwitch(switches::kDisableGpu)) 61 if (command_line->HasSwitch(switches::kDisableGpu))
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return gpu_info_.finalized; 122 return gpu_info_.finalized;
121 } 123 }
122 124
123 void GpuDataManagerImpl::UpdateGpuInfo(const content::GPUInfo& gpu_info) { 125 void GpuDataManagerImpl::UpdateGpuInfo(const content::GPUInfo& gpu_info) {
124 if (gpu_info_.finalized) 126 if (gpu_info_.finalized)
125 return; 127 return;
126 128
127 content::GetContentClient()->SetGpuInfo(gpu_info); 129 content::GetContentClient()->SetGpuInfo(gpu_info);
128 130
129 if (gpu_blacklist_.get()) { 131 if (gpu_blacklist_.get()) {
130 GpuFeatureType feature_type = gpu_blacklist_->DetermineGpuFeatureType( 132 GpuBlacklist::Decision decision =
131 GpuBlacklist::kOsAny, NULL, gpu_info); 133 gpu_blacklist_->MakeBlacklistDecision(
132 if (update_histograms_) 134 GpuBlacklist::kOsAny, NULL, gpu_info);
133 gpu_util::UpdateStats(gpu_blacklist_.get(), feature_type); 135 if (update_histograms_) {
134 UpdateBlacklistedFeatures(feature_type); 136 gpu_util::UpdateStats(gpu_blacklist_.get(),
137 decision.blacklisted_features);
138 }
139 UpdateBlacklistedFeatures(decision.blacklisted_features);
140 gpu_switching_ = decision.gpu_switching;
135 } 141 }
136 142
137 { 143 {
138 base::AutoLock auto_lock(gpu_info_lock_); 144 base::AutoLock auto_lock(gpu_info_lock_);
139 gpu_info_ = gpu_info; 145 gpu_info_ = gpu_info;
140 complete_gpu_info_already_requested_ = 146 complete_gpu_info_already_requested_ =
141 complete_gpu_info_already_requested_ || gpu_info_.finalized; 147 complete_gpu_info_already_requested_ || gpu_info_.finalized;
142 } 148 }
143 149
144 // We have to update GpuFeatureType before notify all the observers. 150 // We have to update GpuFeatureType before notify all the observers.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 198
193 // Skia's software rendering is probably more efficient than going through 199 // Skia's software rendering is probably more efficient than going through
194 // software emulation of the GPU, so use that. 200 // software emulation of the GPU, so use that.
195 flags = content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; 201 flags = content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS;
196 return flags; 202 return flags;
197 } 203 }
198 204
199 return gpu_feature_type_; 205 return gpu_feature_type_;
200 } 206 }
201 207
208 GpuSwitchingOption GpuDataManagerImpl::GetGpuSwitchingOption() const {
209 return gpu_switching_;
210 }
211
202 base::ListValue* GpuDataManagerImpl::GetBlacklistReasons() const { 212 base::ListValue* GpuDataManagerImpl::GetBlacklistReasons() const {
203 ListValue* reasons = new ListValue(); 213 ListValue* reasons = new ListValue();
204 if (gpu_blacklist_.get()) 214 if (gpu_blacklist_.get())
205 gpu_blacklist_->GetBlacklistReasons(reasons); 215 gpu_blacklist_->GetBlacklistReasons(reasons);
206 return reasons; 216 return reasons;
207 } 217 }
208 218
209 bool GpuDataManagerImpl::GpuAccessAllowed() const { 219 bool GpuDataManagerImpl::GpuAccessAllowed() const {
210 if (software_rendering_) 220 if (software_rendering_)
211 return true; 221 return true;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 426
417 void GpuDataManagerImpl::BlacklistCard() { 427 void GpuDataManagerImpl::BlacklistCard() {
418 card_blacklisted_ = true; 428 card_blacklisted_ = true;
419 429
420 gpu_feature_type_ = content::GPU_FEATURE_TYPE_ALL; 430 gpu_feature_type_ = content::GPU_FEATURE_TYPE_ALL;
421 431
422 EnableSoftwareRenderingIfNecessary(); 432 EnableSoftwareRenderingIfNecessary();
423 NotifyGpuInfoUpdate(); 433 NotifyGpuInfoUpdate();
424 } 434 }
425 435
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698