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

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

Issue 10891013: Make GpuDataManager thread safe. (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 26 matching lines...) Expand all
37 return GpuDataManagerImpl::GetInstance(); 37 return GpuDataManagerImpl::GetInstance();
38 } 38 }
39 39
40 // static 40 // static
41 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() { 41 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() {
42 return Singleton<GpuDataManagerImpl>::get(); 42 return Singleton<GpuDataManagerImpl>::get();
43 } 43 }
44 44
45 GpuDataManagerImpl::GpuDataManagerImpl() 45 GpuDataManagerImpl::GpuDataManagerImpl()
46 : complete_gpu_info_already_requested_(false), 46 : complete_gpu_info_already_requested_(false),
47 complete_gpu_info_available_(false),
48 gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN), 47 gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN),
49 preliminary_gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN), 48 preliminary_gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN),
50 observer_list_(new GpuDataManagerObserverList), 49 observer_list_(new GpuDataManagerObserverList),
51 software_rendering_(false), 50 software_rendering_(false),
52 card_blacklisted_(false) { 51 card_blacklisted_(false) {
53 Initialize();
54 }
55
56 void GpuDataManagerImpl::Initialize() {
57 CommandLine* command_line = CommandLine::ForCurrentProcess(); 52 CommandLine* command_line = CommandLine::ForCurrentProcess();
58 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { 53 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) {
59 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); 54 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas);
60 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); 55 command_line->AppendSwitch(switches::kDisableAcceleratedLayers);
61 } 56 }
62
63 if (!command_line->HasSwitch(switches::kSkipGpuDataLoading)) {
64 content::GPUInfo gpu_info;
65 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info);
66 {
67 base::AutoLock auto_lock(gpu_info_lock_);
68 gpu_info_ = gpu_info;
69 }
70 }
71 if (command_line->HasSwitch(switches::kDisableGpu)) 57 if (command_line->HasSwitch(switches::kDisableGpu))
72 BlacklistCard(); 58 BlacklistCard();
73 } 59 }
74 60
61 void GpuDataManagerImpl::InitializeGpuInfo() {
62 content::GPUInfo gpu_info;
63 if (!CommandLine::ForCurrentProcess()->HasSwitch(
64 switches::kSkipGpuDataLoading))
65 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info);
66 else
67 gpu_info.finalized = true;
68 UpdateGpuInfo(gpu_info);
69 }
70
75 GpuDataManagerImpl::~GpuDataManagerImpl() { 71 GpuDataManagerImpl::~GpuDataManagerImpl() {
76 } 72 }
77 73
78 void GpuDataManagerImpl::RequestCompleteGpuInfoIfNeeded() { 74 void GpuDataManagerImpl::RequestCompleteGpuInfoIfNeeded() {
79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 75 if (complete_gpu_info_already_requested_ || gpu_info_.finalized)
80
81 if (complete_gpu_info_already_requested_ || complete_gpu_info_available_)
82 return; 76 return;
83 complete_gpu_info_already_requested_ = true; 77 complete_gpu_info_already_requested_ = true;
84 78
85 GpuProcessHost::SendOnIO( 79 GpuProcessHost::SendOnIO(
86 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, 80 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED,
87 content::CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDE D, 81 content::CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDE D,
88 new GpuMsg_CollectGraphicsInfo()); 82 new GpuMsg_CollectGraphicsInfo());
89 } 83 }
90 84
91 bool GpuDataManagerImpl::IsCompleteGPUInfoAvailable() const { 85 bool GpuDataManagerImpl::IsCompleteGpuInfoAvailable() const {
92 return complete_gpu_info_available_; 86 return gpu_info_.finalized;
93 } 87 }
94 88
95 void GpuDataManagerImpl::UpdateGpuInfo(const content::GPUInfo& gpu_info) { 89 void GpuDataManagerImpl::UpdateGpuInfo(const content::GPUInfo& gpu_info) {
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 90 if (gpu_info_.finalized)
91 return;
92
93 content::GetContentClient()->SetGpuInfo(gpu_info);
97 94
98 { 95 {
99 base::AutoLock auto_lock(gpu_info_lock_); 96 base::AutoLock auto_lock(gpu_info_lock_);
97 gpu_info_ = gpu_info;
100 #if defined(ARCH_CPU_X86_FAMILY) 98 #if defined(ARCH_CPU_X86_FAMILY)
101 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) 99 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id)
102 gpu_info_.finalized = true; 100 gpu_info_.finalized = true;
103 else
104 #endif 101 #endif
105 gpu_info_ = gpu_info;
106 complete_gpu_info_available_ =
107 complete_gpu_info_available_ || gpu_info_.finalized;
108 complete_gpu_info_already_requested_ = 102 complete_gpu_info_already_requested_ =
109 complete_gpu_info_already_requested_ || gpu_info_.finalized; 103 complete_gpu_info_already_requested_ || gpu_info_.finalized;
110 content::GetContentClient()->SetGpuInfo(gpu_info_);
111 } 104 }
112 105
113 // We have to update GpuFeatureType before notify all the observers. 106 // We have to update GpuFeatureType before notify all the observers.
114 NotifyGpuInfoUpdate(); 107 NotifyGpuInfoUpdate();
115 } 108 }
116 109
117 content::GPUInfo GpuDataManagerImpl::GetGPUInfo() const { 110 content::GPUInfo GpuDataManagerImpl::GetGPUInfo() const {
118 return gpu_info_; 111 content::GPUInfo gpu_info;
112 {
113 base::AutoLock auto_lock(gpu_info_lock_);
114 gpu_info = gpu_info_;
115 }
116 return gpu_info;
119 } 117 }
120 118
121 void GpuDataManagerImpl::RequestVideoMemoryUsageStatsUpdate() { 119 void GpuDataManagerImpl::RequestVideoMemoryUsageStatsUpdate() const {
122 GpuProcessHost::SendOnIO( 120 GpuProcessHost::SendOnIO(
123 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, 121 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
124 content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, 122 content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH,
125 new GpuMsg_GetVideoMemoryUsageStats()); 123 new GpuMsg_GetVideoMemoryUsageStats());
126 } 124 }
127 125
128 void GpuDataManagerImpl::AddLogMessage(Value* msg) { 126 void GpuDataManagerImpl::AddLogMessage(
129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 127 int level, const std::string& header, const std::string& message) {
130 log_messages_.Append(msg); 128 base::AutoLock auto_lock(log_messages_lock_);
129 DictionaryValue* dict = new DictionaryValue();
130 dict->SetInteger("level", level);
131 dict->SetString("header", header);
132 dict->SetString("message", message);
133 log_messages_.Append(dict);
131 } 134 }
132 135
133 GpuFeatureType GpuDataManagerImpl::GetGpuFeatureType() { 136 base::ListValue* GpuDataManagerImpl::GetLogMessages() const {
137 base::ListValue* value;
138 {
139 base::AutoLock auto_lock(log_messages_lock_);
140 value = log_messages_.DeepCopy();
141 }
142 return value;
143 }
144
145 GpuFeatureType GpuDataManagerImpl::GetBlacklistedFeatures() const {
134 if (software_rendering_) { 146 if (software_rendering_) {
135 GpuFeatureType flags; 147 GpuFeatureType flags;
136 148
137 // Skia's software rendering is probably more efficient than going through 149 // Skia's software rendering is probably more efficient than going through
138 // software emulation of the GPU, so use that. 150 // software emulation of the GPU, so use that.
139 flags = content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; 151 flags = content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS;
140 return flags; 152 return flags;
141 } 153 }
142 154
143 return gpu_feature_type_; 155 return gpu_feature_type_;
144 } 156 }
145 157
146 bool GpuDataManagerImpl::GpuAccessAllowed() { 158 bool GpuDataManagerImpl::GpuAccessAllowed() const {
147 if (software_rendering_) 159 if (software_rendering_)
148 return true; 160 return true;
149 161
150 if (!gpu_info_.gpu_accessible) 162 if (!gpu_info_.gpu_accessible)
151 return false; 163 return false;
152 164
153 if (card_blacklisted_) 165 if (card_blacklisted_)
154 return false; 166 return false;
155 167
156 // We only need to block GPU process if more features are disallowed other 168 // We only need to block GPU process if more features are disallowed other
157 // than those in the preliminary gpu feature flags because the latter work 169 // than those in the preliminary gpu feature flags because the latter work
158 // through renderer commandline switches. 170 // through renderer commandline switches.
159 uint32 mask = ~(preliminary_gpu_feature_type_); 171 uint32 mask = ~(preliminary_gpu_feature_type_);
160 return (gpu_feature_type_ & mask) == 0; 172 return (gpu_feature_type_ & mask) == 0;
161 } 173 }
162 174
163 void GpuDataManagerImpl::AddObserver(GpuDataManagerObserver* observer) { 175 void GpuDataManagerImpl::AddObserver(GpuDataManagerObserver* observer) {
164 observer_list_->AddObserver(observer); 176 observer_list_->AddObserver(observer);
165 } 177 }
166 178
167 void GpuDataManagerImpl::RemoveObserver(GpuDataManagerObserver* observer) { 179 void GpuDataManagerImpl::RemoveObserver(GpuDataManagerObserver* observer) {
168 observer_list_->RemoveObserver(observer); 180 observer_list_->RemoveObserver(observer);
169 } 181 }
170 182
171 void GpuDataManagerImpl::AppendRendererCommandLine( 183 void GpuDataManagerImpl::AppendRendererCommandLine(
172 CommandLine* command_line) { 184 CommandLine* command_line) const {
173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
174 DCHECK(command_line); 185 DCHECK(command_line);
175 186
176 uint32 flags = GetGpuFeatureType(); 187 uint32 flags = GetBlacklistedFeatures();
177 if ((flags & content::GPU_FEATURE_TYPE_WEBGL)) { 188 if ((flags & content::GPU_FEATURE_TYPE_WEBGL)) {
178 #if !defined(OS_ANDROID) 189 #if !defined(OS_ANDROID)
179 if (!command_line->HasSwitch(switches::kDisableExperimentalWebGL)) 190 if (!command_line->HasSwitch(switches::kDisableExperimentalWebGL))
180 command_line->AppendSwitch(switches::kDisableExperimentalWebGL); 191 command_line->AppendSwitch(switches::kDisableExperimentalWebGL);
181 #endif 192 #endif
182 if (!command_line->HasSwitch(switches::kDisablePepper3dForUntrustedUse)) 193 if (!command_line->HasSwitch(switches::kDisablePepper3dForUntrustedUse))
183 command_line->AppendSwitch(switches::kDisablePepper3dForUntrustedUse); 194 command_line->AppendSwitch(switches::kDisablePepper3dForUntrustedUse);
184 } 195 }
185 if ((flags & content::GPU_FEATURE_TYPE_MULTISAMPLING) && 196 if ((flags & content::GPU_FEATURE_TYPE_MULTISAMPLING) &&
186 !command_line->HasSwitch(switches::kDisableGLMultisampling)) 197 !command_line->HasSwitch(switches::kDisableGLMultisampling))
187 command_line->AppendSwitch(switches::kDisableGLMultisampling); 198 command_line->AppendSwitch(switches::kDisableGLMultisampling);
188 if ((flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) && 199 if ((flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) &&
189 !command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) 200 !command_line->HasSwitch(switches::kDisableAcceleratedCompositing))
190 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); 201 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
191 if ((flags & content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) && 202 if ((flags & content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) &&
192 !command_line->HasSwitch(switches::kDisableAccelerated2dCanvas)) 203 !command_line->HasSwitch(switches::kDisableAccelerated2dCanvas))
193 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); 204 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas);
194 if ((flags & content::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) && 205 if ((flags & content::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) &&
195 !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) 206 !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode))
196 command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); 207 command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
197 if (ShouldUseSoftwareRendering()) 208 if (ShouldUseSoftwareRendering())
198 command_line->AppendSwitch(switches::kDisableFlashFullscreen3d); 209 command_line->AppendSwitch(switches::kDisableFlashFullscreen3d);
199 } 210 }
200 211
201 void GpuDataManagerImpl::AppendGpuCommandLine( 212 void GpuDataManagerImpl::AppendGpuCommandLine(
202 CommandLine* command_line) { 213 CommandLine* command_line) const {
203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
204 DCHECK(command_line); 214 DCHECK(command_line);
205 215
206 std::string use_gl = 216 std::string use_gl =
207 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL); 217 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL);
208 FilePath swiftshader_path = 218 FilePath swiftshader_path =
209 CommandLine::ForCurrentProcess()->GetSwitchValuePath( 219 CommandLine::ForCurrentProcess()->GetSwitchValuePath(
210 switches::kSwiftShaderPath); 220 switches::kSwiftShaderPath);
211 uint32 flags = GetGpuFeatureType(); 221 uint32 flags = GetBlacklistedFeatures();
212 if ((flags & content::GPU_FEATURE_TYPE_MULTISAMPLING) && 222 if ((flags & content::GPU_FEATURE_TYPE_MULTISAMPLING) &&
213 !command_line->HasSwitch(switches::kDisableGLMultisampling)) 223 !command_line->HasSwitch(switches::kDisableGLMultisampling))
214 command_line->AppendSwitch(switches::kDisableGLMultisampling); 224 command_line->AppendSwitch(switches::kDisableGLMultisampling);
215 if (flags & content::GPU_FEATURE_TYPE_TEXTURE_SHARING) 225 if (flags & content::GPU_FEATURE_TYPE_TEXTURE_SHARING)
216 command_line->AppendSwitch(switches::kDisableImageTransportSurface); 226 command_line->AppendSwitch(switches::kDisableImageTransportSurface);
217 227
218 if (software_rendering_) { 228 if (software_rendering_) {
219 command_line->AppendSwitchASCII(switches::kUseGL, "swiftshader"); 229 command_line->AppendSwitchASCII(switches::kUseGL, "swiftshader");
220 if (swiftshader_path.empty()) 230 if (swiftshader_path.empty())
221 swiftshader_path = swiftshader_path_; 231 swiftshader_path = swiftshader_path_;
(...skipping 30 matching lines...) Expand all
252 command_line->AppendSwitchASCII(switches::kGpuDeviceID, 262 command_line->AppendSwitchASCII(switches::kGpuDeviceID,
253 base::StringPrintf("0x%04x", gpu_info_.gpu.device_id)); 263 base::StringPrintf("0x%04x", gpu_info_.gpu.device_id));
254 command_line->AppendSwitchASCII(switches::kGpuDriverVendor, 264 command_line->AppendSwitchASCII(switches::kGpuDriverVendor,
255 gpu_info_.driver_vendor); 265 gpu_info_.driver_vendor);
256 command_line->AppendSwitchASCII(switches::kGpuDriverVersion, 266 command_line->AppendSwitchASCII(switches::kGpuDriverVersion,
257 gpu_info_.driver_version); 267 gpu_info_.driver_version);
258 } 268 }
259 } 269 }
260 270
261 #if defined(OS_WIN) 271 #if defined(OS_WIN)
262 bool GpuDataManagerImpl::IsUsingAcceleratedSurface() { 272 bool GpuDataManagerImpl::IsUsingAcceleratedSurface() const {
263 if (base::win::GetVersion() < base::win::VERSION_VISTA) 273 if (base::win::GetVersion() < base::win::VERSION_VISTA)
264 return false; 274 return false;
265 275
266 base::AutoLock auto_lock(gpu_info_lock_);
267 if (gpu_info_.amd_switchable) 276 if (gpu_info_.amd_switchable)
268 return false; 277 return false;
269 if (software_rendering_) 278 if (software_rendering_)
270 return false; 279 return false;
271 uint32 flags = GetGpuFeatureType(); 280 uint32 flags = GetBlacklistedFeatures();
272 if (flags & content::GPU_FEATURE_TYPE_TEXTURE_SHARING) 281 if (flags & content::GPU_FEATURE_TYPE_TEXTURE_SHARING)
273 return false; 282 return false;
274 283
275 return true; 284 return true;
276 } 285 }
277 #endif 286 #endif
278 287
279 void GpuDataManagerImpl::AppendPluginCommandLine( 288 void GpuDataManagerImpl::AppendPluginCommandLine(
280 CommandLine* command_line) { 289 CommandLine* command_line) const {
281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
282 DCHECK(command_line); 290 DCHECK(command_line);
283 291
284 #if defined(OS_MACOSX) 292 #if defined(OS_MACOSX)
285 uint32 flags = GetGpuFeatureType(); 293 uint32 flags = GetBlacklistedFeatures();
286 // TODO(jbauman): Add proper blacklist support for core animation plugins so 294 // TODO(jbauman): Add proper blacklist support for core animation plugins so
287 // special-casing this video card won't be necessary. See 295 // special-casing this video card won't be necessary. See
288 // http://crbug.com/134015 296 // http://crbug.com/134015
289 if ((flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) || 297 if ((flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) ||
290 CommandLine::ForCurrentProcess()->HasSwitch( 298 CommandLine::ForCurrentProcess()->HasSwitch(
291 switches::kDisableAcceleratedCompositing)) { 299 switches::kDisableAcceleratedCompositing)) {
292 if (!command_line->HasSwitch( 300 if (!command_line->HasSwitch(
293 switches::kDisableCoreAnimationPlugins)) 301 switches::kDisableCoreAnimationPlugins))
294 command_line->AppendSwitch( 302 command_line->AppendSwitch(
295 switches::kDisableCoreAnimationPlugins); 303 switches::kDisableCoreAnimationPlugins);
296 } 304 }
297 #endif 305 #endif
298 } 306 }
299 307
300 void GpuDataManagerImpl::SetGpuFeatureType(GpuFeatureType feature_type) { 308 void GpuDataManagerImpl::SetPreliminaryBlacklistedFeatures(
301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 309 GpuFeatureType feature_type) {
302 UpdateGpuFeatureType(feature_type); 310 UpdateBlacklistedFeatures(feature_type);
303 preliminary_gpu_feature_type_ = gpu_feature_type_; 311 preliminary_gpu_feature_type_ = gpu_feature_type_;
304 } 312 }
305 313
306 void GpuDataManagerImpl::NotifyGpuInfoUpdate() { 314 void GpuDataManagerImpl::NotifyGpuInfoUpdate() {
307 observer_list_->Notify(&GpuDataManagerObserver::OnGpuInfoUpdate); 315 observer_list_->Notify(&GpuDataManagerObserver::OnGpuInfoUpdate);
308 } 316 }
309 317
310 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats( 318 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats(
311 const content::GPUVideoMemoryUsageStats& video_memory_usage_stats) { 319 const content::GPUVideoMemoryUsageStats& video_memory_usage_stats) {
312 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, 320 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate,
313 video_memory_usage_stats); 321 video_memory_usage_stats);
314 } 322 }
315 323
316 void GpuDataManagerImpl::UpdateGpuFeatureType( 324 void GpuDataManagerImpl::UpdateBlacklistedFeatures(
317 GpuFeatureType embedder_feature_type) { 325 GpuFeatureType features) {
318 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
319
320 CommandLine* command_line = CommandLine::ForCurrentProcess(); 326 CommandLine* command_line = CommandLine::ForCurrentProcess();
321 int flags = embedder_feature_type; 327 int flags = features;
322 328
323 // Force disable using the GPU for these features, even if they would 329 // Force disable using the GPU for these features, even if they would
324 // otherwise be allowed. 330 // otherwise be allowed.
325 if (card_blacklisted_ || 331 if (card_blacklisted_ ||
326 command_line->HasSwitch(switches::kBlacklistAcceleratedCompositing)) { 332 command_line->HasSwitch(switches::kBlacklistAcceleratedCompositing)) {
327 flags |= content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING; 333 flags |= content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING;
328 } 334 }
329 if (card_blacklisted_ || 335 if (card_blacklisted_ ||
330 command_line->HasSwitch(switches::kBlacklistWebGL)) { 336 command_line->HasSwitch(switches::kBlacklistWebGL)) {
331 flags |= content::GPU_FEATURE_TYPE_WEBGL; 337 flags |= content::GPU_FEATURE_TYPE_WEBGL;
332 } 338 }
333 gpu_feature_type_ = static_cast<GpuFeatureType>(flags); 339 gpu_feature_type_ = static_cast<GpuFeatureType>(flags);
334 340
335 EnableSoftwareRenderingIfNecessary(); 341 EnableSoftwareRenderingIfNecessary();
336 } 342 }
337 343
338 void GpuDataManagerImpl::RegisterSwiftShaderPath(const FilePath& path) { 344 void GpuDataManagerImpl::RegisterSwiftShaderPath(const FilePath& path) {
339 swiftshader_path_ = path; 345 swiftshader_path_ = path;
340 EnableSoftwareRenderingIfNecessary(); 346 EnableSoftwareRenderingIfNecessary();
341 } 347 }
342 348
343 const base::ListValue& GpuDataManagerImpl::GetLogMessages() const {
344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
345 return log_messages_;
346 }
347
348 void GpuDataManagerImpl::EnableSoftwareRenderingIfNecessary() { 349 void GpuDataManagerImpl::EnableSoftwareRenderingIfNecessary() {
349 if (!GpuAccessAllowed() || 350 if (!GpuAccessAllowed() ||
350 (gpu_feature_type_ & content::GPU_FEATURE_TYPE_WEBGL)) { 351 (gpu_feature_type_ & content::GPU_FEATURE_TYPE_WEBGL)) {
351 #if defined(ENABLE_SWIFTSHADER) 352 #if defined(ENABLE_SWIFTSHADER)
352 if (!swiftshader_path_.empty() && 353 if (!swiftshader_path_.empty() &&
353 !CommandLine::ForCurrentProcess()->HasSwitch( 354 !CommandLine::ForCurrentProcess()->HasSwitch(
354 switches::kDisableSoftwareRasterizer)) 355 switches::kDisableSoftwareRasterizer))
355 software_rendering_ = true; 356 software_rendering_ = true;
356 #endif 357 #endif
357 } 358 }
358 } 359 }
359 360
360 bool GpuDataManagerImpl::ShouldUseSoftwareRendering() { 361 bool GpuDataManagerImpl::ShouldUseSoftwareRendering() const {
361 return software_rendering_; 362 return software_rendering_;
362 } 363 }
363 364
364 void GpuDataManagerImpl::BlacklistCard() { 365 void GpuDataManagerImpl::BlacklistCard() {
365 card_blacklisted_ = true; 366 card_blacklisted_ = true;
366 367
367 gpu_feature_type_ = content::GPU_FEATURE_TYPE_ALL; 368 gpu_feature_type_ = content::GPU_FEATURE_TYPE_ALL;
368 369
369 EnableSoftwareRenderingIfNecessary(); 370 EnableSoftwareRenderingIfNecessary();
370 NotifyGpuInfoUpdate(); 371 NotifyGpuInfoUpdate();
371 } 372 }
372 373
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698