gpu_data_manager_impl_private.cc revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
1a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// found in the LICENSE file. 4a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 5a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/browser/gpu/gpu_data_manager_impl_private.h" 6a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 7a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/bind.h" 8a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/bind_helpers.h" 9a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/command_line.h" 10a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/debug/trace_event.h" 11a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/metrics/field_trial.h" 12a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/metrics/histogram.h" 13a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/stringprintf.h" 14a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/strings/string_number_conversions.h" 15a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/sys_info.h" 16a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/version.h" 1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "cc/base/switches.h" 18a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/browser/gpu/gpu_process_host.h" 19a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/common/gpu/gpu_messages.h" 20a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/public/browser/browser_thread.h" 21a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/public/browser/gpu_data_manager_observer.h" 22a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/public/common/content_client.h" 23a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/public/common/content_constants.h" 24a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/public/common/content_switches.h" 25a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "gpu/command_buffer/service/gpu_switches.h" 2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "gpu/config/gpu_control_list_jsons.h" 2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "gpu/config/gpu_feature_type.h" 2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "gpu/config/gpu_info_collector.h" 2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "gpu/config/gpu_util.h" 30a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "ui/base/ui_base_switches.h" 31a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "ui/gl/gl_implementation.h" 32a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "ui/gl/gl_switches.h" 33a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "ui/gl/gpu_switching_manager.h" 34a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "webkit/glue/webpreferences.h" 35a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "webkit/plugins/plugin_switches.h" 36a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#if defined(OS_MACOSX) 3890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include <ApplicationServices/ApplicationServices.h> 3990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // OS_MACOSX 40a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_WIN) 41a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/win/windows_version.h" 4290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // OS_WIN 4390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#if defined(OS_ANDROID) 4490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ui/gfx/android/device_display_info.h" 4590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // OS_ANDROID 46a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 47a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)namespace content { 4890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 49a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)namespace { 50a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 5190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)enum GpuFeatureStatus { 5290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kGpuFeatureEnabled = 0, 5390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kGpuFeatureBlacklisted = 1, 5490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kGpuFeatureDisabled = 2, // disabled by user but not blacklisted 5590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kGpuFeatureNumStatus 5690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}; 5790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 5890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#if defined(OS_WIN) 5990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 6090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)enum WinSubVersion { 6190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kWinOthers = 0, 6290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kWinXP, 6390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kWinVista, 6490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kWin7, 6590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kNumWinSubVersions 6690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}; 6790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 6890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)int GetGpuBlacklistHistogramValueWin(GpuFeatureStatus status) { 6990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) static WinSubVersion sub_version = kNumWinSubVersions; 7090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (sub_version == kNumWinSubVersions) { 7190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) sub_version = kWinOthers; 7290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::string version_str = base::SysInfo::OperatingSystemVersion(); 7390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) size_t pos = version_str.find_first_not_of("0123456789."); 7490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (pos != std::string::npos) 7590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) version_str = version_str.substr(0, pos); 7690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) Version os_version(version_str); 7790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (os_version.IsValid() && os_version.components().size() >= 2) { 7890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const std::vector<uint16>& version_numbers = os_version.components(); 7990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (version_numbers[0] == 5) 8090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) sub_version = kWinXP; 8190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) else if (version_numbers[0] == 6 && version_numbers[1] == 0) 8290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) sub_version = kWinVista; 8390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) else if (version_numbers[0] == 6 && version_numbers[1] == 1) 8490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) sub_version = kWin7; 8590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 8690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 8790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int entry_index = static_cast<int>(sub_version) * kGpuFeatureNumStatus; 8890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) switch (status) { 8990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case kGpuFeatureEnabled: 9090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) break; 9190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case kGpuFeatureBlacklisted: 9290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) entry_index++; 9390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) break; 9490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case kGpuFeatureDisabled: 9590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) entry_index += 2; 9690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) break; 9790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 9890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return entry_index; 9990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 10090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // OS_WIN 10190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 10290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Send UMA histograms about the enabled features. 10390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void UpdateStats(const gpu::GpuBlacklist* blacklist, 10490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const std::set<int>& blacklisted_features) { 10590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) uint32 max_entry_id = blacklist->max_entry_id(); 10690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (max_entry_id == 0) { 10790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // GPU Blacklist was not loaded. No need to go further. 10890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return; 10990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 11090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 11190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 11290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool disabled = false; 11390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (blacklisted_features.size() == 0) { 11490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", 11590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 0, max_entry_id + 1); 11690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } else { 11790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::vector<uint32> flag_entries; 11890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) blacklist->GetDecisionEntries(&flag_entries, disabled); 11990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) DCHECK_GT(flag_entries.size(), 0u); 12090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) for (size_t i = 0; i < flag_entries.size(); ++i) { 12190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", 12290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) flag_entries[i], max_entry_id + 1); 12390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 12490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 12590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 12690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // This counts how many users are affected by a disabled entry - this allows 12790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // us to understand the impact of an entry before enable it. 12890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::vector<uint32> flag_disabled_entries; 12990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) disabled = true; 13090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) blacklist->GetDecisionEntries(&flag_disabled_entries, disabled); 13190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) for (size_t i = 0; i < flag_disabled_entries.size(); ++i) { 13290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerDisabledEntry", 13390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) flag_disabled_entries[i], max_entry_id + 1); 13490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 13590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 13690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const gpu::GpuFeatureType kGpuFeatures[] = { 13790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, 13890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING, 13990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GPU_FEATURE_TYPE_WEBGL 14090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) }; 14190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const std::string kGpuBlacklistFeatureHistogramNames[] = { 14290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) "GPU.BlacklistFeatureTestResults.Accelerated2dCanvas", 14390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) "GPU.BlacklistFeatureTestResults.AcceleratedCompositing", 14490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) "GPU.BlacklistFeatureTestResults.Webgl" 14590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) }; 14690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const bool kGpuFeatureUserFlags[] = { 14790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) command_line.HasSwitch(switches::kDisableAccelerated2dCanvas), 14890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) command_line.HasSwitch(switches::kDisableAcceleratedCompositing), 14990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#if defined(OS_ANDROID) 15090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) !command_line.HasSwitch(switches::kEnableExperimentalWebGL) 15190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#else 15290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) command_line.HasSwitch(switches::kDisableExperimentalWebGL) 15390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif 15490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) }; 15590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#if defined(OS_WIN) 15690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const std::string kGpuBlacklistFeatureHistogramNamesWin[] = { 15790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) "GPU.BlacklistFeatureTestResultsWindows.Accelerated2dCanvas", 15890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) "GPU.BlacklistFeatureTestResultsWindows.AcceleratedCompositing", 15990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) "GPU.BlacklistFeatureTestResultsWindows.Webgl" 16090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) }; 16190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif 16290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const size_t kNumFeatures = 16390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) sizeof(kGpuFeatures) / sizeof(gpu::GpuFeatureType); 16490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) for (size_t i = 0; i < kNumFeatures; ++i) { 16590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // We can't use UMA_HISTOGRAM_ENUMERATION here because the same name is 16690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // expected if the macro is used within a loop. 16790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) GpuFeatureStatus value = kGpuFeatureEnabled; 16890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (blacklisted_features.count(kGpuFeatures[i])) 16990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) value = kGpuFeatureBlacklisted; 17090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) else if (kGpuFeatureUserFlags[i]) 17190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) value = kGpuFeatureDisabled; 17290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) base::HistogramBase* histogram_pointer = base::LinearHistogram::FactoryGet( 17390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kGpuBlacklistFeatureHistogramNames[i], 17490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1, kGpuFeatureNumStatus, kGpuFeatureNumStatus + 1, 17590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) base::HistogramBase::kUmaTargetedHistogramFlag); 17690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) histogram_pointer->Add(value); 17790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#if defined(OS_WIN) 17890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) histogram_pointer = base::LinearHistogram::FactoryGet( 17990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kGpuBlacklistFeatureHistogramNamesWin[i], 18090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1, kNumWinSubVersions * kGpuFeatureNumStatus, 18190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) kNumWinSubVersions * kGpuFeatureNumStatus + 1, 18290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) base::HistogramBase::kUmaTargetedHistogramFlag); 18390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); 18490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif 18590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 18690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 18790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 188a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Strip out the non-digital info; if after that, we get an empty string, 189a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// return "0". 190a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)std::string ProcessVersionString(const std::string& raw_string) { 191a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::string valid_set = "0123456789."; 192a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) size_t start_pos = raw_string.find_first_of(valid_set); 193a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (start_pos == std::string::npos) 194a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return "0"; 195a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) size_t end_pos = raw_string.find_first_not_of(raw_string, start_pos); 196a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string version_string = raw_string.substr( 197a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) start_pos, end_pos - start_pos); 198a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (version_string.empty()) 199a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return "0"; 200a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return version_string; 201a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 202a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 203a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Combine the integers into a string, seperated by ','. 204a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)std::string IntSetToString(const std::set<int>& list) { 205a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string rt; 206a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) for (std::set<int>::const_iterator it = list.begin(); 207a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) it != list.end(); ++it) { 208a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!rt.empty()) 209a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) rt += ","; 210a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) rt += base::IntToString(*it); 211a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 212a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return rt; 213a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 214a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 215a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_MACOSX) 216a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void DisplayReconfigCallback(CGDirectDisplayID display, 217a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CGDisplayChangeSummaryFlags flags, 218a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) void* gpu_data_manager) { 219a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (flags & kCGDisplayAddFlag) { 220a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl* manager = 221a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); 222a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DCHECK(manager); 223a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) manager->HandleGpuSwitch(); 224a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 225a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 226a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif // OS_MACOSX 227a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 22890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#if defined(OS_ANDROID) 22990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void ApplyAndroidWorkarounds(const gpu::GPUInfo& gpu_info, 23090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) CommandLine* command_line) { 23190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::string vendor(StringToLowerASCII(gpu_info.gl_vendor)); 23290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::string renderer(StringToLowerASCII(gpu_info.gl_renderer)); 23390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool is_img = 23490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_info.gl_vendor.find("Imagination") != std::string::npos; 23590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool is_arm = 23690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_info.gl_vendor.find("ARM") != std::string::npos; 23790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool is_qualcomm = 23890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_info.gl_vendor.find("Qualcomm") != std::string::npos; 23990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool is_broadcom = 24090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_info.gl_vendor.find("Broadcom") != std::string::npos; 24190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool is_mali_t604 = is_arm && 24290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_info.gl_renderer.find("Mali-T604") != std::string::npos; 24390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 24490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool is_vivante = 24590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_info.gl_extensions.find("GL_VIV_shader_binary") != 24690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::string::npos; 24790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 24890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool is_nexus7 = 24990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_info.machine_model.find("Nexus 7") != std::string::npos; 25090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool is_nexus10 = 25190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_info.machine_model.find("Nexus 10") != std::string::npos; 25290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 25390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // IMG: avoid context switching perf problems, crashes with share groups 25490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Mali-T604: http://crbug.com/154715 25590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // QualComm, NVIDIA: Crashes with share groups 25690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (is_vivante || is_img || is_mali_t604 || is_nexus7 || is_qualcomm || 25790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) is_broadcom) 25890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) command_line->AppendSwitch(switches::kEnableVirtualGLContexts); 25990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 26090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gfx::DeviceDisplayInfo info; 26190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int default_tile_size = 256; 26290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 26390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // For very high resolution displays (eg. Nexus 10), set the default 26490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // tile size to be 512. This should be removed in favour of a generic 26590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // hueristic that works across all platforms and devices, once that 26690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // exists: http://crbug.com/159524. This switches to 512 for screens 26790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // containing 40 or more 256x256 tiles, such that 1080p devices do 26890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // not use 512x512 tiles (eg. 1920x1280 requires 37.5 tiles) 26990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int numTiles = (info.GetDisplayWidth() * 27090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) info.GetDisplayHeight()) / (256 * 256); 27190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (numTiles >= 40) 27290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) default_tile_size = 512; 27390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 27490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // IMG: Fast async texture uploads only work with non-power-of-two, 27590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // but still multiple-of-eight sizes. 27690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // http://crbug.com/168099 27790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (is_img) 27890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) default_tile_size -= 8; 27990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 28090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Set the command line if it isn't already set and we changed 28190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // the default tile size. 28290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (default_tile_size != 256 && 28390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) !command_line->HasSwitch(switches::kDefaultTileWidth) && 28490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) !command_line->HasSwitch(switches::kDefaultTileHeight)) { 28590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::stringstream size; 28690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) size << default_tile_size; 28790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) command_line->AppendSwitchASCII( 28890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) switches::kDefaultTileWidth, size.str()); 28990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) command_line->AppendSwitchASCII( 29090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) switches::kDefaultTileHeight, size.str()); 29190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 29290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 29390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Increase the resolution of low resolution tiles for Nexus tablets. 29490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if ((is_nexus7 || is_nexus10) && 29590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) !command_line->HasSwitch( 29690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) cc::switches::kLowResolutionContentsScaleFactor)) { 29790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) command_line->AppendSwitchASCII( 29890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) cc::switches::kLowResolutionContentsScaleFactor, "0.25"); 29990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 30090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 30190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // OS_ANDROID 30290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 303a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Block all domains' use of 3D APIs for this many milliseconds if 304a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// approaching a threshold where system stability might be compromised. 305a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)const int64 kBlockAllDomainsMs = 10000; 306a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)const int kNumResetsWithinDuration = 1; 307a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 308a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Enums for UMA histograms. 309a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)enum BlockStatusHistogram { 310a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_NOT_BLOCKED, 311a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, 312a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_ALL_DOMAINS_BLOCKED, 313a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_MAX 314a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)}; 315a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 316a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} // namespace anonymous 317a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 318a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::InitializeForTesting( 319a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::string& gpu_blacklist_json, 32090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const gpu::GPUInfo& gpu_info) { 321a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // This function is for testing only, so disable histograms. 322a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) update_histograms_ = false; 323a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 324a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) InitializeImpl(gpu_blacklist_json, std::string(), std::string(), gpu_info); 325a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 326a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 327a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { 328a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (use_swiftshader_) { 329a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Skia's software rendering is probably more efficient than going through 330a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // software emulation of the GPU, so use that. 33190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) 332a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return true; 333a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 334a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 335a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 336a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return (blacklisted_features_.count(feature) == 1); 337a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 338a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 339a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { 340a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (use_swiftshader_) 341a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return 1; 342a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return blacklisted_features_.size(); 343a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 344a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 34590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { 346a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return gpu_info_; 347a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 348a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 349a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::GetGpuProcessHandles( 350a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { 351a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::GetProcessHandles(callback); 352a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 353a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 354a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)bool GpuDataManagerImplPrivate::GpuAccessAllowed( 355a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string* reason) const { 356a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (use_swiftshader_) 357a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return true; 358a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 359a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!gpu_info_.gpu_accessible) { 360a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (reason) { 361a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *reason = "GPU process launch failed."; 362a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 363a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 364a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 365a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 366a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (card_blacklisted_) { 367a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (reason) { 368a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *reason = "GPU access is disabled "; 369a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CommandLine* command_line = CommandLine::ForCurrentProcess(); 370a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (command_line->HasSwitch(switches::kDisableGpu)) 371a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *reason += "through commandline switch --disable-gpu."; 372a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) else 373a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *reason += "in chrome://settings."; 374a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 375a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 376a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 377a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 378a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // We only need to block GPU process if more features are disallowed other 379a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // than those in the preliminary gpu feature flags because the latter work 380a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // through renderer commandline switches. 381a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::set<int> features = preliminary_blacklisted_features_; 38290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::MergeFeatureSets(&features, blacklisted_features_); 383a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (features.size() > preliminary_blacklisted_features_.size()) { 384a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (reason) { 385a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *reason = "Features are disabled upon full but not preliminary GPU info."; 386a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 387a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 388a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 389a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 39090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (blacklisted_features_.size() == gpu::NUMBER_OF_GPU_FEATURE_TYPES) { 391a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // On Linux, we use cached GL strings to make blacklist decsions at browser 392a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // startup time. We need to launch the GPU process to validate these 393a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // strings even if all features are blacklisted. If all GPU features are 394a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // disabled, the GPU process will only initialize GL bindings, create a GL 395a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // context, and collect full GPU info. 396a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if !defined(OS_LINUX) 397a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (reason) { 398a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *reason = "All GPU features are blacklisted."; 399a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 400a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 401a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif 402a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 403a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 404a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return true; 405a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 406a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 407a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::RequestCompleteGpuInfoIfNeeded() { 408a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (complete_gpu_info_already_requested_ || gpu_info_.finalized) 409a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return; 410a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) complete_gpu_info_already_requested_ = true; 411a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 412a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::SendOnIO( 413a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_WIN) 414a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, 415a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#else 416a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, 417a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif 418a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDED, 419a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) new GpuMsg_CollectGraphicsInfo()); 420a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 421a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 422a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)bool GpuDataManagerImplPrivate::IsCompleteGpuInfoAvailable() const { 423a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return gpu_info_.finalized; 424a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 425a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 426a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { 427a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::SendOnIO( 428a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, 429a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, 430a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) new GpuMsg_GetVideoMemoryUsageStats()); 431a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 432a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 433a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { 434a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return use_swiftshader_; 435a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 436a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 437a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::RegisterSwiftShaderPath( 438a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const base::FilePath& path) { 439a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) swiftshader_path_ = path; 440a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EnableSwiftShaderIfNecessary(); 441a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 442a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 443a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::AddObserver(GpuDataManagerObserver* observer) { 444a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::UnlockedSession session(owner_); 445a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_->AddObserver(observer); 446a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 447a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 448a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::RemoveObserver( 449a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerObserver* observer) { 450a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::UnlockedSession session(owner_); 451a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_->RemoveObserver(observer); 452a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 453a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 454a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::UnblockDomainFrom3DAPIs(const GURL& url) { 455a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // This method must do two things: 456a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // 457a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // 1. If the specific domain is blocked, then unblock it. 458a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // 459a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // 2. Reset our notion of how many GPU resets have occurred recently. 460a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // This is necessary even if the specific domain was blocked. 461a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Otherwise, if we call Are3DAPIsBlocked with the same domain right 462a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // after unblocking it, it will probably still be blocked because of 463a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // the recent GPU reset caused by that domain. 464a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // 465a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // These policies could be refined, but at a certain point the behavior 466a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // will become difficult to explain. 467a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string domain = GetDomainFromURL(url); 468a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 469a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) blocked_domains_.erase(domain); 470a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) timestamps_of_gpu_resets_.clear(); 471a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 472a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 473a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::DisableGpuWatchdog() { 474a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::SendOnIO( 475a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, 476a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, 477a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) new GpuMsg_DisableWatchdog); 478a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 479a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 480a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::SetGLStrings(const std::string& gl_vendor, 481a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::string& gl_renderer, 482a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::string& gl_version) { 483a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (gl_vendor.empty() && gl_renderer.empty() && gl_version.empty()) 484a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return; 485a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 486a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // If GPUInfo already got GL strings, do nothing. This is for the rare 487a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // situation where GPU process collected GL strings before this call. 488a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!gpu_info_.gl_vendor.empty() || 489a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) !gpu_info_.gl_renderer.empty() || 490a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) !gpu_info_.gl_version_string.empty()) 491a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return; 492a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 49390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GPUInfo gpu_info = gpu_info_; 494a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 495a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info.gl_vendor = gl_vendor; 496a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info.gl_renderer = gl_renderer; 497a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info.gl_version_string = gl_version; 498a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 49990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::CollectDriverInfoGL(&gpu_info); 500a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 501a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdateGpuInfo(gpu_info); 502a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdateGpuSwitchingManager(gpu_info); 503a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdatePreliminaryBlacklistedFeatures(); 504a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 505a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 506a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::GetGLStrings(std::string* gl_vendor, 507a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string* gl_renderer, 508a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string* gl_version) { 509a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DCHECK(gl_vendor && gl_renderer && gl_version); 510a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 511a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *gl_vendor = gpu_info_.gl_vendor; 512a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *gl_renderer = gpu_info_.gl_renderer; 513a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) *gl_version = gpu_info_.gl_version_string; 514a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 515a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 516a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::Initialize() { 517a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize"); 518a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CommandLine* command_line = CommandLine::ForCurrentProcess(); 519a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) 520a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return; 521a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 52290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GPUInfo gpu_info; 523a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) { 524a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) TRACE_EVENT0("startup", 525a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); 52690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::CollectBasicGraphicsInfo(&gpu_info); 527a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 528a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(ARCH_CPU_X86_FAMILY) 529a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) 530a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info.finalized = true; 531a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif 532a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 533a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string gpu_blacklist_string; 534a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string gpu_switching_list_string; 535a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string gpu_driver_bug_list_string; 536a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist)) { 53790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_blacklist_string = gpu::kSoftwareRenderingListJson; 53890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_switching_list_string = gpu::kGpuSwitchingListJson; 539a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 540a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { 54190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_driver_bug_list_string = gpu::kGpuDriverBugListJson; 542a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 543a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) InitializeImpl(gpu_blacklist_string, 544a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_switching_list_string, 545a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_driver_bug_list_string, 546a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info); 547a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 548a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 54990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { 550a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // No further update of gpu_info if falling back to SwiftShader. 551a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (use_swiftshader_) 552a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return; 553a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 55490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::MergeGPUInfo(&gpu_info_, gpu_info); 555a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) complete_gpu_info_already_requested_ = 556a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) complete_gpu_info_already_requested_ || gpu_info_.finalized; 557a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 558a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GetContentClient()->SetGpuInfo(gpu_info_); 559a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 560a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (gpu_blacklist_) { 561a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::set<int> features = gpu_blacklist_->MakeDecision( 56290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GpuControlList::kOsAny, std::string(), gpu_info_); 563a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (update_histograms_) 564a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdateStats(gpu_blacklist_.get(), features); 565a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 566a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdateBlacklistedFeatures(features); 567a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 568a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (gpu_switching_list_) { 569a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::set<int> option = gpu_switching_list_->MakeDecision( 57090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GpuControlList::kOsAny, std::string(), gpu_info_); 571a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (option.size() == 1) { 572a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Blacklist decision should not overwrite commandline switch from users. 573a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CommandLine* command_line = CommandLine::ForCurrentProcess(); 57490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (!command_line->HasSwitch(switches::kGpuSwitching)) { 57590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_switching_ = static_cast<gpu::GpuSwitchingOption>( 57690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) *(option.begin())); 57790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 578a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 579a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 58090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (gpu_driver_bug_list_) { 581a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_driver_bugs_ = gpu_driver_bug_list_->MakeDecision( 58290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GpuControlList::kOsAny, std::string(), gpu_info_); 58390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 584a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 585a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // We have to update GpuFeatureType before notify all the observers. 586a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) NotifyGpuInfoUpdate(); 587a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 588a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 589a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats( 590a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const GPUVideoMemoryUsageStats& video_memory_usage_stats) { 591a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::UnlockedSession session(owner_); 592a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, 593a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) video_memory_usage_stats); 594a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 595a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 596a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::AppendRendererCommandLine( 597a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CommandLine* command_line) const { 598a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DCHECK(command_line); 599a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 60090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)) { 601a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if !defined(OS_ANDROID) 602a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!command_line->HasSwitch(switches::kDisableExperimentalWebGL)) 603a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kDisableExperimentalWebGL); 604a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif 605a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!command_line->HasSwitch(switches::kDisablePepper3d)) 606a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kDisablePepper3d); 607a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 60890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_MULTISAMPLING) && 609a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) !command_line->HasSwitch(switches::kDisableGLMultisampling)) 610a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kDisableGLMultisampling); 61190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) && 612a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) !command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) 613a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); 61490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) && 615a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) !command_line->HasSwitch(switches::kDisableAccelerated2dCanvas)) 616a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); 61790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) && 618a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) 619a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); 620a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (ShouldUseSwiftShader()) 621a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kDisableFlashFullscreen3d); 622a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 623a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 624a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::AppendGpuCommandLine( 625a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CommandLine* command_line) const { 626a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DCHECK(command_line); 627a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 628a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string use_gl = 629a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL); 630a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::FilePath swiftshader_path = 631a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CommandLine::ForCurrentProcess()->GetSwitchValuePath( 632a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kSwiftShaderPath); 63390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_MULTISAMPLING) && 634a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) !command_line->HasSwitch(switches::kDisableGLMultisampling)) 635a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kDisableGLMultisampling); 63690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_TEXTURE_SHARING)) 637a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kDisableImageTransportSurface); 638a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 639a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (use_swiftshader_) { 640a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kUseGL, "swiftshader"); 641a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (swiftshader_path.empty()) 642a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) swiftshader_path = swiftshader_path_; 64390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } else if ((IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL) || 64490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) IsFeatureBlacklisted( 64590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) || 64690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) IsFeatureBlacklisted( 64790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) && 648a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) (use_gl == "any")) { 649a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII( 650a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kUseGL, gfx::kGLImplementationOSMesaName); 651a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } else if (!use_gl.empty()) { 652a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kUseGL, use_gl); 653a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 654a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { 655a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "true"); 656a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switch (gpu_switching_) { 65790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case gpu::GPU_SWITCHING_OPTION_FORCE_DISCRETE: 658a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kGpuSwitching, 659a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kGpuSwitchingOptionNameForceDiscrete); 660a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) break; 66190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case gpu::GPU_SWITCHING_OPTION_FORCE_INTEGRATED: 662a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kGpuSwitching, 663a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kGpuSwitchingOptionNameForceIntegrated); 664a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) break; 66590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case gpu::GPU_SWITCHING_OPTION_AUTOMATIC: 66690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case gpu::GPU_SWITCHING_OPTION_UNKNOWN: 667a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) break; 668a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 669a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } else { 670a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "false"); 671a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 672a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 673a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!swiftshader_path.empty()) 674a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchPath(switches::kSwiftShaderPath, 675a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) swiftshader_path); 676a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 677a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!gpu_driver_bugs_.empty()) { 678a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds, 679a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) IntSetToString(gpu_driver_bugs_)); 680a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 681a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 682a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_WIN) 683a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // DisplayLink 7.1 and earlier can cause the GPU process to crash on startup. 684a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // http://crbug.com/177611 685a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Thinkpad USB Port Replicator driver causes GPU process to crash when the 686a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // sandbox is enabled. http://crbug.com/181665. 687a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if ((gpu_info_.display_link_version.IsValid() 688a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) && gpu_info_.display_link_version.IsOlderThan("7.2")) || 689a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info_.lenovo_dcute) { 690a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kReduceGpuSandbox); 691a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 692a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif 693a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 694a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (gpu_info_.optimus) 695a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kReduceGpuSandbox); 696a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (gpu_info_.amd_switchable) { 697a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // The image transport surface currently doesn't work with AMD Dynamic 698a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Switchable graphics. 699a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kReduceGpuSandbox); 700a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kDisableImageTransportSurface); 701a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 702a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Pass GPU and driver information to GPU process. We try to avoid full GPU 703a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // info collection at GPU process startup, but we need gpu vendor_id, 704a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // device_id, driver_vendor, driver_version for deciding whether we need to 705a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // collect full info (on Linux) and for crash reporting purpose. 706a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kGpuVendorID, 707a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::StringPrintf("0x%04x", gpu_info_.gpu.vendor_id)); 708a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kGpuDeviceID, 709a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::StringPrintf("0x%04x", gpu_info_.gpu.device_id)); 710a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kGpuDriverVendor, 711a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info_.driver_vendor); 712a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kGpuDriverVersion, 713a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info_.driver_version); 714a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 715a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 716a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::AppendPluginCommandLine( 717a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CommandLine* command_line) const { 718a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DCHECK(command_line); 719a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 720a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_MACOSX) 721a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // TODO(jbauman): Add proper blacklist support for core animation plugins so 722a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // special-casing this video card won't be necessary. See 723a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // http://crbug.com/134015 72490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) || 725a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CommandLine::ForCurrentProcess()->HasSwitch( 726a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kDisableAcceleratedCompositing)) { 727a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!command_line->HasSwitch( 728a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kDisableCoreAnimationPlugins)) 729a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch( 730a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kDisableCoreAnimationPlugins); 731a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 732a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif 733a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 734a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 735a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::UpdateRendererWebPrefs( 736a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) WebPreferences* prefs) const { 737a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DCHECK(prefs); 738a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 73990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING)) 740a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->accelerated_compositing_enabled = false; 74190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)) 742a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->experimental_webgl_enabled = false; 74390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH3D)) 744a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->flash_3d_enabled = false; 74590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D)) { 746a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->flash_stage3d_enabled = false; 747a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->flash_stage3d_baseline_enabled = false; 748a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 74990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) 750a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->flash_stage3d_baseline_enabled = false; 75190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) 752a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->accelerated_2d_canvas_enabled = false; 75390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_MULTISAMPLING)) 754a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->gl_multisampling_enabled = false; 75590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_3D_CSS)) { 756a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->accelerated_compositing_for_3d_transforms_enabled = false; 757a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->accelerated_compositing_for_animation_enabled = false; 758a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 75990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO)) 760a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->accelerated_compositing_for_video_enabled = false; 761a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 762a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Accelerated video and animation are slower than regular when using 763a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // SwiftShader. 3D CSS may also be too slow to be worthwhile. 764a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (ShouldUseSwiftShader()) { 765a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->accelerated_compositing_for_video_enabled = false; 766a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->accelerated_compositing_for_animation_enabled = false; 767a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->accelerated_compositing_for_3d_transforms_enabled = false; 768a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) prefs->accelerated_compositing_for_plugins_enabled = false; 769a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 770a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 771a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 77290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)gpu::GpuSwitchingOption 77390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)GpuDataManagerImplPrivate::GetGpuSwitchingOption() const { 774a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) 77590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return gpu::GPU_SWITCHING_OPTION_UNKNOWN; 776a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return gpu_switching_; 777a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 778a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 779a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::DisableHardwareAcceleration() { 780a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) card_blacklisted_ = true; 781a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 78290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) for (int i = 0; i < gpu::NUMBER_OF_GPU_FEATURE_TYPES; ++i) 783a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) blacklisted_features_.insert(i); 784a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 785a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EnableSwiftShaderIfNecessary(); 786a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) NotifyGpuInfoUpdate(); 787a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 788a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 789a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)std::string GpuDataManagerImplPrivate::GetBlacklistVersion() const { 790a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (gpu_blacklist_) 791a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return gpu_blacklist_->version(); 792a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return "0"; 793a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 794a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 795a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)base::ListValue* GpuDataManagerImplPrivate::GetBlacklistReasons() const { 796a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ListValue* reasons = new ListValue(); 797a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (gpu_blacklist_) 798a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_blacklist_->GetReasons(reasons); 799a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return reasons; 800a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 801a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 802a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::AddLogMessage( 803a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int level, const std::string& header, const std::string& message) { 804a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DictionaryValue* dict = new DictionaryValue(); 805a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) dict->SetInteger("level", level); 806a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) dict->SetString("header", header); 807a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) dict->SetString("message", message); 808a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) log_messages_.Append(dict); 809a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 810a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 811a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::ProcessCrashed( 812a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::TerminationStatus exit_code) { 813a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 814a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Unretained is ok, because it's posted to UI thread, the thread 815a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // where the singleton GpuDataManagerImpl lives until the end. 816a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BrowserThread::PostTask( 817a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BrowserThread::UI, 818a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) FROM_HERE, 819a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::Bind(&GpuDataManagerImpl::ProcessCrashed, 820a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::Unretained(owner_), 821a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) exit_code)); 822a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return; 823a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 824a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) { 825a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::UnlockedSession session(owner_); 826a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_->Notify( 827a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) &GpuDataManagerObserver::OnGpuProcessCrashed, exit_code); 828a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 829a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 830a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 831a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)base::ListValue* GpuDataManagerImplPrivate::GetLogMessages() const { 832a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::ListValue* value; 833a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) value = log_messages_.DeepCopy(); 834a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return value; 835a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 836a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 837a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::HandleGpuSwitch() { 838a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::UnlockedSession session(owner_); 839a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_->Notify(&GpuDataManagerObserver::OnGpuSwitching); 840a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 841a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 842a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_WIN) 843a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)bool GpuDataManagerImplPrivate::IsUsingAcceleratedSurface() const { 844a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (base::win::GetVersion() < base::win::VERSION_VISTA) 845a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 846a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 847a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (gpu_info_.amd_switchable) 848a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 849a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (use_swiftshader_) 850a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 851a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CommandLine* command_line = CommandLine::ForCurrentProcess(); 852a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (command_line->HasSwitch(switches::kDisableImageTransportSurface)) 853a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return false; 85490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return !IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_TEXTURE_SHARING); 855a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 856a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif 857a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 858a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::BlockDomainFrom3DAPIs( 859a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const GURL& url, GpuDataManagerImpl::DomainGuilt guilt) { 860a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BlockDomainFrom3DAPIsAtTime(url, guilt, base::Time::Now()); 861a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 862a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 863a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)bool GpuDataManagerImplPrivate::Are3DAPIsBlocked(const GURL& url, 864a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int render_process_id, 865a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int render_view_id, 866a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ThreeDAPIType requester) { 867a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) bool blocked = Are3DAPIsBlockedAtTime(url, base::Time::Now()) != 868a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_NOT_BLOCKED; 869a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (blocked) { 870a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Unretained is ok, because it's posted to UI thread, the thread 871a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // where the singleton GpuDataManagerImpl lives until the end. 872a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BrowserThread::PostTask( 873a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BrowserThread::UI, FROM_HERE, 874a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::Bind(&GpuDataManagerImpl::Notify3DAPIBlocked, 875a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::Unretained(owner_), url, render_process_id, 876a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) render_view_id, requester)); 877a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 878a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 879a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return blocked; 880a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 881a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 882a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::DisableDomainBlockingFor3DAPIsForTesting() { 883a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) domain_blocking_enabled_ = false; 884a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 885a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 886a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// static 887a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)GpuDataManagerImplPrivate* GpuDataManagerImplPrivate::Create( 888a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl* owner) { 889a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return new GpuDataManagerImplPrivate(owner); 890a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 891a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 892a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)GpuDataManagerImplPrivate::GpuDataManagerImplPrivate( 893a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl* owner) 894a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) : complete_gpu_info_already_requested_(false), 89590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_switching_(gpu::GPU_SWITCHING_OPTION_AUTOMATIC), 896a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_(new GpuDataManagerObserverList), 897a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) use_swiftshader_(false), 898a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) card_blacklisted_(false), 899a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) update_histograms_(true), 900a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) window_count_(0), 901a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) domain_blocking_enabled_(true), 902a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) owner_(owner) { 903a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DCHECK(owner_); 904a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CommandLine* command_line = CommandLine::ForCurrentProcess(); 905a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { 906a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); 907a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->AppendSwitch(switches::kDisableAcceleratedLayers); 908a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 909a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (command_line->HasSwitch(switches::kDisableGpu)) 910a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DisableHardwareAcceleration(); 911a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (command_line->HasSwitch(switches::kGpuSwitching)) { 912a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string option_string = command_line->GetSwitchValueASCII( 913a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kGpuSwitching); 91490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GpuSwitchingOption option = 91590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::StringToGpuSwitchingOption(option_string); 91690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (option != gpu::GPU_SWITCHING_OPTION_UNKNOWN) 917a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_switching_ = option; 918a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 919a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 920a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_MACOSX) 921a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); 922a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif // OS_MACOSX 923a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 924a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 925a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)GpuDataManagerImplPrivate::~GpuDataManagerImplPrivate() { 926a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_MACOSX) 927a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, owner_); 928a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif 929a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 930a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 931a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::InitializeImpl( 932a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::string& gpu_blacklist_json, 933a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::string& gpu_switching_list_json, 934a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::string& gpu_driver_bug_list_json, 93590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const gpu::GPUInfo& gpu_info) { 936a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string browser_version_string = ProcessVersionString( 937a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GetContentClient()->GetProduct()); 938a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CHECK(!browser_version_string.empty()); 939a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 940a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!gpu_blacklist_json.empty()) { 94190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_blacklist_.reset(gpu::GpuBlacklist::Create()); 942a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_blacklist_->LoadList( 943a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) browser_version_string, gpu_blacklist_json, 94490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GpuControlList::kCurrentOsOnly); 945a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 946a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!gpu_switching_list_json.empty()) { 94790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_switching_list_.reset(gpu::GpuSwitchingList::Create()); 948a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_switching_list_->LoadList( 949a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) browser_version_string, gpu_switching_list_json, 95090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GpuControlList::kCurrentOsOnly); 951a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 952a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!gpu_driver_bug_list_json.empty()) { 95390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu_driver_bug_list_.reset(gpu::GpuDriverBugList::Create()); 954a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_driver_bug_list_->LoadList( 955a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) browser_version_string, gpu_driver_bug_list_json, 95690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GpuControlList::kCurrentOsOnly); 957a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 958a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 959a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info_ = gpu_info; 960a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdateGpuInfo(gpu_info); 961a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdateGpuSwitchingManager(gpu_info); 962a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UpdatePreliminaryBlacklistedFeatures(); 96390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 96490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) CommandLine* command_line = CommandLine::ForCurrentProcess(); 96590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // We pass down the list to GPU command buffer through commandline 96690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // switches at GPU process launch. However, in situations where we don't 96790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // have a GPU process, we append the browser process commandline. 96890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (command_line->HasSwitch(switches::kSingleProcess) || 96990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) command_line->HasSwitch(switches::kInProcessGPU)) { 97090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (!gpu_driver_bugs_.empty()) { 97190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds, 97290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) IntSetToString(gpu_driver_bugs_)); 97390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 97490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 97590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#if defined(OS_ANDROID) 97690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) ApplyAndroidWorkarounds(gpu_info, command_line); 97790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // OS_ANDROID 978a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 979a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 980a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures( 981a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const std::set<int>& features) { 982a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) CommandLine* command_line = CommandLine::ForCurrentProcess(); 983a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) blacklisted_features_ = features; 984a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 985a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Force disable using the GPU for these features, even if they would 986a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // otherwise be allowed. 987a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (card_blacklisted_ || 988a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->HasSwitch(switches::kBlacklistAcceleratedCompositing)) { 98990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) blacklisted_features_.insert( 99090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING); 991a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 992a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (card_blacklisted_ || 993a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) command_line->HasSwitch(switches::kBlacklistWebGL)) { 99490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_WEBGL); 995a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 996a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 997a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) EnableSwiftShaderIfNecessary(); 998a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 999a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1000a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::UpdatePreliminaryBlacklistedFeatures() { 1001a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) preliminary_blacklisted_features_ = blacklisted_features_; 1002a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1003a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1004a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager( 100590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const gpu::GPUInfo& gpu_info) { 1006a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ui::GpuSwitchingManager::GetInstance()->SetGpuCount( 1007a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) gpu_info.secondary_gpus.size() + 1); 1008a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1009a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { 1010a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switch (gpu_switching_) { 101190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case gpu::GPU_SWITCHING_OPTION_FORCE_DISCRETE: 1012a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); 1013a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) break; 101490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case gpu::GPU_SWITCHING_OPTION_FORCE_INTEGRATED: 1015a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); 1016a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) break; 101790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case gpu::GPU_SWITCHING_OPTION_AUTOMATIC: 101890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) case gpu::GPU_SWITCHING_OPTION_UNKNOWN: 1019a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) break; 1020a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1021a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1022a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1023a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1024a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() { 1025a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_->Notify(&GpuDataManagerObserver::OnGpuInfoUpdate); 1026a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1027a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1028a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() { 1029a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!GpuAccessAllowed(NULL) || 103090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_WEBGL)) { 1031a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!swiftshader_path_.empty() && 1032a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) !CommandLine::ForCurrentProcess()->HasSwitch( 1033a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) switches::kDisableSoftwareRasterizer)) 1034a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) use_swiftshader_ = true; 1035a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1036a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1037a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1038a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)std::string GpuDataManagerImplPrivate::GetDomainFromURL( 1039a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const GURL& url) const { 1040a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // For the moment, we just use the host, or its IP address, as the 1041a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // entry in the set, rather than trying to figure out the top-level 1042a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // domain. This does mean that a.foo.com and b.foo.com will be 1043a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // treated independently in the blocking of a given domain, but it 1044a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // would require a third-party library to reliably figure out the 1045a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // top-level domain from a URL. 1046a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!url.has_host()) { 1047a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return std::string(); 1048a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1049a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1050a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return url.host(); 1051a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1052a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1053a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::BlockDomainFrom3DAPIsAtTime( 1054a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const GURL& url, 1055a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::DomainGuilt guilt, 1056a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::Time at_time) { 1057a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!domain_blocking_enabled_) 1058a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return; 1059a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1060a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string domain = GetDomainFromURL(url); 1061a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1062a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DomainBlockEntry& entry = blocked_domains_[domain]; 1063a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) entry.last_guilt = guilt; 1064a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) timestamps_of_gpu_resets_.push_back(at_time); 1065a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1066a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1067a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)GpuDataManagerImpl::DomainBlockStatus 1068a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)GpuDataManagerImplPrivate::Are3DAPIsBlockedAtTime( 1069a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const GURL& url, base::Time at_time) const { 1070a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (!domain_blocking_enabled_) 1071a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_NOT_BLOCKED; 1072a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1073a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Note: adjusting the policies in this code will almost certainly 1074a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // require adjusting the associated unit tests. 1075a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::string domain = GetDomainFromURL(url); 1076a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1077a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) DomainBlockMap::const_iterator iter = blocked_domains_.find(domain); 1078a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (iter != blocked_domains_.end()) { 1079a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Err on the side of caution, and assume that if a particular 1080a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // domain shows up in the block map, it's there for a good 1081a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // reason and don't let its presence there automatically expire. 1082a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1083a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UMA_HISTOGRAM_ENUMERATION("GPU.BlockStatusForClient3DAPIs", 1084a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, 1085a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_MAX); 1086a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1087a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_BLOCKED; 1088a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1089a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1090a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Look at the timestamps of the recent GPU resets to see if there are 1091a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // enough within the threshold which would cause us to blacklist all 1092a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // domains. This doesn't need to be overly precise -- if time goes 1093a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // backward due to a system clock adjustment, that's fine. 1094a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // 1095a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // TODO(kbr): make this pay attention to the TDR thresholds in the 1096a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // Windows registry, but make sure it continues to be testable. 1097a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) { 1098a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) std::list<base::Time>::iterator iter = timestamps_of_gpu_resets_.begin(); 1099a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int num_resets_within_timeframe = 0; 1100a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) while (iter != timestamps_of_gpu_resets_.end()) { 1101a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::Time time = *iter; 1102a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::TimeDelta delta_t = at_time - time; 1103a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1104a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // If this entry has "expired", just remove it. 1105a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (delta_t.InMilliseconds() > kBlockAllDomainsMs) { 1106a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) iter = timestamps_of_gpu_resets_.erase(iter); 1107a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) continue; 1108a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1109a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1110a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ++num_resets_within_timeframe; 1111a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ++iter; 1112a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1113a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1114a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if (num_resets_within_timeframe >= kNumResetsWithinDuration) { 1115a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UMA_HISTOGRAM_ENUMERATION("GPU.BlockStatusForClient3DAPIs", 1116a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_ALL_DOMAINS_BLOCKED, 1117a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_MAX); 1118a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1119a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_ALL_DOMAINS_BLOCKED; 1120a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1121a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 1122a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1123a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) UMA_HISTOGRAM_ENUMERATION("GPU.BlockStatusForClient3DAPIs", 1124a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_NOT_BLOCKED, 1125a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BLOCK_STATUS_MAX); 1126a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1127a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_NOT_BLOCKED; 1128a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1129a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1130a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)int64 GpuDataManagerImplPrivate::GetBlockAllDomainsDurationInMs() const { 1131a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return kBlockAllDomainsMs; 1132a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1133a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1134a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void GpuDataManagerImplPrivate::Notify3DAPIBlocked(const GURL& url, 1135a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int render_process_id, 1136a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int render_view_id, 1137a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) ThreeDAPIType requester) { 1138a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) GpuDataManagerImpl::UnlockedSession session(owner_); 1139a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, 1140a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) url, render_process_id, render_view_id, requester); 1141a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 1142a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1143a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} // namespace content 1144a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1145