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

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

Issue 2737983002: WebGL feature will only enabled when accelerated (Closed)
Patch Set: Added SwiftShader as a GPU feature Created 3 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
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 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 void GpuDataManagerImplPrivate::DisableHardwareAcceleration() { 926 void GpuDataManagerImplPrivate::DisableHardwareAcceleration() {
927 if (!is_initialized_) { 927 if (!is_initialized_) {
928 post_init_tasks_.push_back( 928 post_init_tasks_.push_back(
929 base::Bind(&GpuDataManagerImplPrivate::DisableHardwareAcceleration, 929 base::Bind(&GpuDataManagerImplPrivate::DisableHardwareAcceleration,
930 base::Unretained(this))); 930 base::Unretained(this)));
931 return; 931 return;
932 } 932 }
933 933
934 card_blacklisted_ = true; 934 card_blacklisted_ = true;
935 935
936 for (int i = 0; i < gpu::NUMBER_OF_GPU_FEATURE_TYPES; ++i) 936 for (int i = 0; i < gpu::NUMBER_OF_GPU_FEATURE_TYPES; ++i) {
937 blacklisted_features_.insert(i); 937 if ((i != gpu::GPU_FEATURE_TYPE_SWIFTSHADER) ||
938 base::CommandLine::ForCurrentProcess()->HasSwitch(
939 switches::kDisableSoftwareRasterizer)) {
Zhenyao Mo 2017/03/09 19:18:03 Consider this situation: on a system where kDisabl
sugoi1 2017/03/09 19:24:33 Ok, but this isn't new, I simply moved it from Gpu
sugoi1 2017/03/09 20:07:12 Removed kDisableSoftwareRasterizer check.
sugoi1 2017/03/09 20:17:07 Wait a second, I just looked into it and the kDisa
940 blacklisted_features_.insert(i);
941 }
942 }
938 943
939 EnableSwiftShaderIfNecessary(); 944 EnableSwiftShaderIfNecessary();
940 NotifyGpuInfoUpdate(); 945 NotifyGpuInfoUpdate();
941 } 946 }
942 947
943 void GpuDataManagerImplPrivate::SetGpuInfo(const gpu::GPUInfo& gpu_info) { 948 void GpuDataManagerImplPrivate::SetGpuInfo(const gpu::GPUInfo& gpu_info) {
944 DCHECK(!is_initialized_); 949 DCHECK(!is_initialized_);
945 gpu_info_ = gpu_info; 950 gpu_info_ = gpu_info;
946 DCHECK(IsCompleteGpuInfoAvailable()); 951 DCHECK(IsCompleteGpuInfoAvailable());
947 } 952 }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 const std::set<int>& features) { 1229 const std::set<int>& features) {
1225 blacklisted_features_ = features; 1230 blacklisted_features_ = features;
1226 1231
1227 // Force disable using the GPU for these features, even if they would 1232 // Force disable using the GPU for these features, even if they would
1228 // otherwise be allowed. 1233 // otherwise be allowed.
1229 if (card_blacklisted_) { 1234 if (card_blacklisted_) {
1230 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING); 1235 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING);
1231 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_WEBGL); 1236 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_WEBGL);
1232 } 1237 }
1233 1238
1239 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1240 switches::kDisableSoftwareRasterizer)) {
1241 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_SWIFTSHADER);
Zhenyao Mo 2017/03/09 19:18:03 Same here.
sugoi1 2017/03/09 20:07:12 Removed this change.
1242 }
1243
1234 EnableSwiftShaderIfNecessary(); 1244 EnableSwiftShaderIfNecessary();
1235 } 1245 }
1236 1246
1237 void GpuDataManagerImplPrivate::UpdatePreliminaryBlacklistedFeatures() { 1247 void GpuDataManagerImplPrivate::UpdatePreliminaryBlacklistedFeatures() {
1238 preliminary_blacklisted_features_ = blacklisted_features_; 1248 preliminary_blacklisted_features_ = blacklisted_features_;
1239 preliminary_blacklisted_features_initialized_ = true; 1249 preliminary_blacklisted_features_initialized_ = true;
1240 } 1250 }
1241 1251
1242 void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager( 1252 void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager(
1243 const gpu::GPUInfo& gpu_info) { 1253 const gpu::GPUInfo& gpu_info) {
1244 // The vendor IDs might be 0 on non-PCI devices (like Android), but 1254 // The vendor IDs might be 0 on non-PCI devices (like Android), but
1245 // the length of the vector is all we care about in most cases. 1255 // the length of the vector is all we care about in most cases.
1246 std::vector<uint32_t> vendor_ids; 1256 std::vector<uint32_t> vendor_ids;
1247 vendor_ids.push_back(gpu_info.gpu.vendor_id); 1257 vendor_ids.push_back(gpu_info.gpu.vendor_id);
1248 for (const auto& device : gpu_info.secondary_gpus) { 1258 for (const auto& device : gpu_info.secondary_gpus) {
1249 vendor_ids.push_back(device.vendor_id); 1259 vendor_ids.push_back(device.vendor_id);
1250 } 1260 }
1251 ui::GpuSwitchingManager::GetInstance()->SetGpuVendorIds(vendor_ids); 1261 ui::GpuSwitchingManager::GetInstance()->SetGpuVendorIds(vendor_ids);
1252 gpu::InitializeDualGpusIfSupported(gpu_driver_bugs_); 1262 gpu::InitializeDualGpusIfSupported(gpu_driver_bugs_);
1253 } 1263 }
1254 1264
1255 void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() { 1265 void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() {
1256 observer_list_->Notify(FROM_HERE, &GpuDataManagerObserver::OnGpuInfoUpdate); 1266 observer_list_->Notify(FROM_HERE, &GpuDataManagerObserver::OnGpuInfoUpdate);
1257 } 1267 }
1258 1268
1259 void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() { 1269 void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() {
1260 if (!GpuAccessAllowed(NULL) || 1270 if (!GpuAccessAllowed(nullptr) ||
1261 blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_WEBGL)) { 1271 blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_WEBGL)) {
1262 if (!swiftshader_path_.empty() && 1272 if (!swiftshader_path_.empty() &&
1263 !base::CommandLine::ForCurrentProcess()->HasSwitch( 1273 !blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_SWIFTSHADER))
1264 switches::kDisableSoftwareRasterizer))
1265 use_swiftshader_ = true; 1274 use_swiftshader_ = true;
1266 } 1275 }
1267 } 1276 }
1268 1277
1269 std::string GpuDataManagerImplPrivate::GetDomainFromURL( 1278 std::string GpuDataManagerImplPrivate::GetDomainFromURL(
1270 const GURL& url) const { 1279 const GURL& url) const {
1271 // For the moment, we just use the host, or its IP address, as the 1280 // For the moment, we just use the host, or its IP address, as the
1272 // entry in the set, rather than trying to figure out the top-level 1281 // entry in the set, rather than trying to figure out the top-level
1273 // domain. This does mean that a.foo.com and b.foo.com will be 1282 // domain. This does mean that a.foo.com and b.foo.com will be
1274 // treated independently in the blocking of a given domain, but it 1283 // treated independently in the blocking of a given domain, but it
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; 1381 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure;
1373 #if defined(OS_WIN) 1382 #if defined(OS_WIN)
1374 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; 1383 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure;
1375 #endif 1384 #endif
1376 complete_gpu_info_already_requested_ = true; 1385 complete_gpu_info_already_requested_ = true;
1377 // Some observers might be waiting. 1386 // Some observers might be waiting.
1378 NotifyGpuInfoUpdate(); 1387 NotifyGpuInfoUpdate();
1379 } 1388 }
1380 1389
1381 } // namespace content 1390 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698