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

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

Issue 2715563002: Moving SwiftShader from component to bundled library (Closed)
Patch Set: Specify x11 only support on Linux Created 3 years, 10 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_private.h" 5 #include "content/browser/gpu/gpu_data_manager_impl_private.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 25 matching lines...) Expand all
36 #include "gpu/config/gpu_control_list_jsons.h" 36 #include "gpu/config/gpu_control_list_jsons.h"
37 #include "gpu/config/gpu_driver_bug_workaround_type.h" 37 #include "gpu/config/gpu_driver_bug_workaround_type.h"
38 #include "gpu/config/gpu_feature_type.h" 38 #include "gpu/config/gpu_feature_type.h"
39 #include "gpu/config/gpu_info_collector.h" 39 #include "gpu/config/gpu_info_collector.h"
40 #include "gpu/config/gpu_switches.h" 40 #include "gpu/config/gpu_switches.h"
41 #include "gpu/config/gpu_util.h" 41 #include "gpu/config/gpu_util.h"
42 #include "gpu/ipc/common/memory_stats.h" 42 #include "gpu/ipc/common/memory_stats.h"
43 #include "gpu/ipc/service/switches.h" 43 #include "gpu/ipc/service/switches.h"
44 #include "media/media_features.h" 44 #include "media/media_features.h"
45 #include "ui/base/ui_base_switches.h" 45 #include "ui/base/ui_base_switches.h"
46 #include "ui/gl/gl_features.h"
46 #include "ui/gl/gl_implementation.h" 47 #include "ui/gl/gl_implementation.h"
47 #include "ui/gl/gl_switches.h" 48 #include "ui/gl/gl_switches.h"
48 #include "ui/gl/gpu_switching_manager.h" 49 #include "ui/gl/gpu_switching_manager.h"
49 50
50 #if defined(USE_OZONE) 51 #if defined(USE_OZONE)
51 #include "ui/ozone/public/ozone_switches.h" 52 #include "ui/ozone/public/ozone_switches.h"
52 #endif 53 #endif
53 #if defined(OS_MACOSX) 54 #if defined(OS_MACOSX)
54 #include <ApplicationServices/ApplicationServices.h> 55 #include <ApplicationServices/ApplicationServices.h>
55 #endif // OS_MACOSX 56 #endif // OS_MACOSX
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 #if defined(OS_CHROMEOS) 289 #if defined(OS_CHROMEOS)
289 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && 290 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING &&
290 base::CommandLine::ForCurrentProcess()->HasSwitch( 291 base::CommandLine::ForCurrentProcess()->HasSwitch(
291 switches::kDisablePanelFitting)) { 292 switches::kDisablePanelFitting)) {
292 return true; 293 return true;
293 } 294 }
294 #endif // OS_CHROMEOS 295 #endif // OS_CHROMEOS
295 if (use_swiftshader_) { 296 if (use_swiftshader_) {
296 // Skia's software rendering is probably more efficient than going through 297 // Skia's software rendering is probably more efficient than going through
297 // software emulation of the GPU, so use that. 298 // software emulation of the GPU, so use that.
298 if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) 299 if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS ||
300 feature == gpu::GPU_FEATURE_TYPE_WEBGL2)
grt (UTC plus 2) 2017/02/27 09:31:55 nit: add braces since the condition now spans two
sugoi 2017/02/28 16:45:10 Done.
299 return true; 301 return true;
300 return false; 302 return false;
301 } 303 }
302 304
303 return (blacklisted_features_.count(feature) == 1); 305 return (blacklisted_features_.count(feature) == 1);
304 } 306 }
305 307
306 bool GpuDataManagerImplPrivate::IsFeatureEnabled(int feature) const { 308 bool GpuDataManagerImplPrivate::IsFeatureEnabled(int feature) const {
307 DCHECK_EQ(feature, gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); 309 DCHECK_EQ(feature, gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION);
308 return gpu_feature_info_ 310 return gpu_feature_info_
309 .status_values[gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION] == 311 .status_values[gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION] ==
310 gpu::kGpuFeatureStatusEnabled; 312 gpu::kGpuFeatureStatusEnabled;
311 } 313 }
312 314
313 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const { 315 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const {
314 return (gpu_driver_bugs_.count(feature) == 1); 316 return (gpu_driver_bugs_.count(feature) == 1);
315 } 317 }
316 318
317 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { 319 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const {
318 if (use_swiftshader_) 320 if (use_swiftshader_)
319 return 1; 321 return 2; // GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS and
322 // GPU_FEATURE_TYPE_WEBGL2
320 return blacklisted_features_.size(); 323 return blacklisted_features_.size();
321 } 324 }
322 325
323 gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { 326 gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const {
324 return gpu_info_; 327 return gpu_info_;
325 } 328 }
326 329
327 void GpuDataManagerImplPrivate::GetGpuProcessHandles( 330 void GpuDataManagerImplPrivate::GetGpuProcessHandles(
328 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { 331 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const {
329 GpuProcessHost::GetProcessHandles(callback); 332 GpuProcessHost::GetProcessHandles(callback);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { 436 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const {
434 GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, 437 GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
435 false /* force_create */, 438 false /* force_create */,
436 new GpuMsg_GetVideoMemoryUsageStats()); 439 new GpuMsg_GetVideoMemoryUsageStats());
437 } 440 }
438 441
439 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { 442 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const {
440 return use_swiftshader_; 443 return use_swiftshader_;
441 } 444 }
442 445
443 void GpuDataManagerImplPrivate::RegisterSwiftShaderPath(
444 const base::FilePath& path) {
445 swiftshader_path_ = path;
446 EnableSwiftShaderIfNecessary();
447 }
448
449 void GpuDataManagerImplPrivate::AddObserver(GpuDataManagerObserver* observer) { 446 void GpuDataManagerImplPrivate::AddObserver(GpuDataManagerObserver* observer) {
450 GpuDataManagerImpl::UnlockedSession session(owner_); 447 GpuDataManagerImpl::UnlockedSession session(owner_);
451 observer_list_->AddObserver(observer); 448 observer_list_->AddObserver(observer);
452 } 449 }
453 450
454 void GpuDataManagerImplPrivate::RemoveObserver( 451 void GpuDataManagerImplPrivate::RemoveObserver(
455 GpuDataManagerObserver* observer) { 452 GpuDataManagerObserver* observer) {
456 GpuDataManagerImpl::UnlockedSession session(owner_); 453 GpuDataManagerImpl::UnlockedSession session(owner_);
457 observer_list_->RemoveObserver(observer); 454 observer_list_->RemoveObserver(observer);
458 } 455 }
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 " "); 660 " ");
664 661
665 gpu::GpuDriverBugList::AppendWorkaroundsFromCommandLine( 662 gpu::GpuDriverBugList::AppendWorkaroundsFromCommandLine(
666 &gpu_driver_bugs_, *base::CommandLine::ForCurrentProcess()); 663 &gpu_driver_bugs_, *base::CommandLine::ForCurrentProcess());
667 664
668 // We have to update GpuFeatureType before notify all the observers. 665 // We have to update GpuFeatureType before notify all the observers.
669 NotifyGpuInfoUpdate(); 666 NotifyGpuInfoUpdate();
670 } 667 }
671 668
672 void GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { 669 void GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) {
673 // No further update of gpu_info if falling back to SwiftShader.
674 if (use_swiftshader_)
jbauman 2017/02/25 00:30:15 I think we still need this so we don't try to upda
sugoi 2017/02/28 16:45:10 Done.
675 return;
676
677 bool was_info_available = IsCompleteGpuInfoAvailable(); 670 bool was_info_available = IsCompleteGpuInfoAvailable();
678 gpu::MergeGPUInfo(&gpu_info_, gpu_info); 671 gpu::MergeGPUInfo(&gpu_info_, gpu_info);
679 if (IsCompleteGpuInfoAvailable()) { 672 if (IsCompleteGpuInfoAvailable()) {
680 complete_gpu_info_already_requested_ = true; 673 complete_gpu_info_already_requested_ = true;
681 } else if (was_info_available) { 674 } else if (was_info_available) {
682 // Allow future requests to go through properly. 675 // Allow future requests to go through properly.
683 complete_gpu_info_already_requested_ = false; 676 complete_gpu_info_already_requested_ = false;
684 } 677 }
685 678
686 UpdateGpuInfoHelper(); 679 UpdateGpuInfoHelper();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 switches::kUseGL, 740 switches::kUseGL,
748 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation())); 741 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation()));
749 } else if (!use_gl.empty()) { 742 } else if (!use_gl.empty()) {
750 command_line->AppendSwitchASCII(switches::kUseGL, use_gl); 743 command_line->AppendSwitchASCII(switches::kUseGL, use_gl);
751 } 744 }
752 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) 745 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus())
753 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "true"); 746 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "true");
754 else 747 else
755 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "false"); 748 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "false");
756 749
757 if (!swiftshader_path_.empty()) {
758 command_line->AppendSwitchPath(switches::kSwiftShaderPath,
759 swiftshader_path_);
760 }
761
762 if (!gpu_driver_bugs_.empty()) { 750 if (!gpu_driver_bugs_.empty()) {
763 command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds, 751 command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds,
764 IntSetToString(gpu_driver_bugs_)); 752 IntSetToString(gpu_driver_bugs_));
765 } 753 }
766 754
767 if (!disabled_extensions_.empty()) { 755 if (!disabled_extensions_.empty()) {
768 command_line->AppendSwitchASCII(switches::kDisableGLExtensions, 756 command_line->AppendSwitchASCII(switches::kDisableGLExtensions,
769 disabled_extensions_); 757 disabled_extensions_);
770 } 758 }
771 759
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 update_histograms_(true), 1120 update_histograms_(true),
1133 domain_blocking_enabled_(true), 1121 domain_blocking_enabled_(true),
1134 owner_(owner), 1122 owner_(owner),
1135 gpu_process_accessible_(true), 1123 gpu_process_accessible_(true),
1136 is_initialized_(false), 1124 is_initialized_(false),
1137 finalized_(false), 1125 finalized_(false),
1138 in_process_gpu_(false) { 1126 in_process_gpu_(false) {
1139 DCHECK(owner_); 1127 DCHECK(owner_);
1140 const base::CommandLine* command_line = 1128 const base::CommandLine* command_line =
1141 base::CommandLine::ForCurrentProcess(); 1129 base::CommandLine::ForCurrentProcess();
1142 swiftshader_path_ = command_line->GetSwitchValuePath(
1143 switches::kSwiftShaderPath);
1144 if (ShouldDisableHardwareAcceleration()) 1130 if (ShouldDisableHardwareAcceleration())
1145 DisableHardwareAcceleration(); 1131 DisableHardwareAcceleration();
1146 1132
1147 if (command_line->HasSwitch(switches::kSingleProcess) || 1133 if (command_line->HasSwitch(switches::kSingleProcess) ||
1148 command_line->HasSwitch(switches::kInProcessGPU)) { 1134 command_line->HasSwitch(switches::kInProcessGPU)) {
1149 in_process_gpu_ = true; 1135 in_process_gpu_ = true;
1150 } 1136 }
1151 1137
1152 #if defined(OS_MACOSX) 1138 #if defined(OS_MACOSX)
1153 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); 1139 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 } 1222 }
1237 ui::GpuSwitchingManager::GetInstance()->SetGpuVendorIds(vendor_ids); 1223 ui::GpuSwitchingManager::GetInstance()->SetGpuVendorIds(vendor_ids);
1238 gpu::InitializeDualGpusIfSupported(gpu_driver_bugs_); 1224 gpu::InitializeDualGpusIfSupported(gpu_driver_bugs_);
1239 } 1225 }
1240 1226
1241 void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() { 1227 void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() {
1242 observer_list_->Notify(FROM_HERE, &GpuDataManagerObserver::OnGpuInfoUpdate); 1228 observer_list_->Notify(FROM_HERE, &GpuDataManagerObserver::OnGpuInfoUpdate);
1243 } 1229 }
1244 1230
1245 void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() { 1231 void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() {
1246 if (!GpuAccessAllowed(NULL) || 1232 #if BUILDFLAG(ENABLE_SWIFTSHADER)
1247 blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_WEBGL)) { 1233 use_swiftshader_ =
1248 if (!swiftshader_path_.empty() && 1234 (!GpuAccessAllowed(NULL) ||
grt (UTC plus 2) 2017/02/27 09:31:55 nit: NULL -> nullptr
sugoi 2017/02/28 16:45:09 Done.
1249 !base::CommandLine::ForCurrentProcess()->HasSwitch( 1235 blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_WEBGL)) &&
1250 switches::kDisableSoftwareRasterizer)) 1236 !base::CommandLine::ForCurrentProcess()->HasSwitch(
1251 use_swiftshader_ = true; 1237 switches::kDisableSoftwareRasterizer);
1252 } 1238 #endif
1253 } 1239 }
1254 1240
1255 std::string GpuDataManagerImplPrivate::GetDomainFromURL( 1241 std::string GpuDataManagerImplPrivate::GetDomainFromURL(
1256 const GURL& url) const { 1242 const GURL& url) const {
1257 // For the moment, we just use the host, or its IP address, as the 1243 // For the moment, we just use the host, or its IP address, as the
1258 // entry in the set, rather than trying to figure out the top-level 1244 // entry in the set, rather than trying to figure out the top-level
1259 // domain. This does mean that a.foo.com and b.foo.com will be 1245 // domain. This does mean that a.foo.com and b.foo.com will be
1260 // treated independently in the blocking of a given domain, but it 1246 // treated independently in the blocking of a given domain, but it
1261 // would require a third-party library to reliably figure out the 1247 // would require a third-party library to reliably figure out the
1262 // top-level domain from a URL. 1248 // top-level domain from a URL.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; 1344 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure;
1359 #if defined(OS_WIN) 1345 #if defined(OS_WIN)
1360 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; 1346 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure;
1361 #endif 1347 #endif
1362 complete_gpu_info_already_requested_ = true; 1348 complete_gpu_info_already_requested_ = true;
1363 // Some observers might be waiting. 1349 // Some observers might be waiting.
1364 NotifyGpuInfoUpdate(); 1350 NotifyGpuInfoUpdate();
1365 } 1351 }
1366 1352
1367 } // namespace content 1353 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698