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

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

Issue 15231003: Move code unrelated to info collection from collector to data manager in Android. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/gpu/gpu_info_collector_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/gpu/gpu_data_manager_impl_private.h" 5 #include "content/browser/gpu/gpu_data_manager_impl_private.h"
6 6
7 #if defined(OS_MACOSX)
8 #include <ApplicationServices/ApplicationServices.h>
9 #endif // OS_MACOSX
10
11 #include "base/bind.h" 7 #include "base/bind.h"
12 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 9 #include "base/command_line.h"
14 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
15 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
16 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
17 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
18 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
19 #include "base/sys_info.h" 15 #include "base/sys_info.h"
20 #include "base/version.h" 16 #include "base/version.h"
17 #include "cc/base/switches.h"
21 #include "content/browser/gpu/gpu_control_list_jsons.h" 18 #include "content/browser/gpu/gpu_control_list_jsons.h"
22 #include "content/browser/gpu/gpu_process_host.h" 19 #include "content/browser/gpu/gpu_process_host.h"
23 #include "content/browser/gpu/gpu_util.h" 20 #include "content/browser/gpu/gpu_util.h"
24 #include "content/common/gpu/gpu_messages.h" 21 #include "content/common/gpu/gpu_messages.h"
25 #include "content/gpu/gpu_info_collector.h" 22 #include "content/gpu/gpu_info_collector.h"
26 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/gpu_data_manager_observer.h" 24 #include "content/public/browser/gpu_data_manager_observer.h"
28 #include "content/public/common/content_client.h" 25 #include "content/public/common/content_client.h"
29 #include "content/public/common/content_constants.h" 26 #include "content/public/common/content_constants.h"
30 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
31 #include "content/public/common/gpu_feature_type.h" 28 #include "content/public/common/gpu_feature_type.h"
32 #include "gpu/command_buffer/service/gpu_switches.h" 29 #include "gpu/command_buffer/service/gpu_switches.h"
33 #include "ui/base/ui_base_switches.h" 30 #include "ui/base/ui_base_switches.h"
34 #include "ui/gl/gl_implementation.h" 31 #include "ui/gl/gl_implementation.h"
35 #include "ui/gl/gl_switches.h" 32 #include "ui/gl/gl_switches.h"
36 #include "ui/gl/gpu_switching_manager.h" 33 #include "ui/gl/gpu_switching_manager.h"
37 #include "webkit/glue/webpreferences.h" 34 #include "webkit/glue/webpreferences.h"
38 #include "webkit/plugins/plugin_switches.h" 35 #include "webkit/plugins/plugin_switches.h"
39 36
37 #if defined(OS_MACOSX)
38 #include <ApplicationServices/ApplicationServices.h>
39 #endif // OS_MACOSX
40 #if defined(OS_WIN) 40 #if defined(OS_WIN)
41 #include "base/win/windows_version.h" 41 #include "base/win/windows_version.h"
42 #endif 42 #endif // OS_WIN
43 #if defined(OS_ANDROID)
44 #include "ui/gfx/android/device_display_info.h"
45 #endif // OS_ANDROID
43 46
44 namespace content { 47 namespace content {
45 namespace { 48 namespace {
46 49
47 // Strip out the non-digital info; if after that, we get an empty string, 50 // Strip out the non-digital info; if after that, we get an empty string,
48 // return "0". 51 // return "0".
49 std::string ProcessVersionString(const std::string& raw_string) { 52 std::string ProcessVersionString(const std::string& raw_string) {
50 const std::string valid_set = "0123456789."; 53 const std::string valid_set = "0123456789.";
51 size_t start_pos = raw_string.find_first_of(valid_set); 54 size_t start_pos = raw_string.find_first_of(valid_set);
52 if (start_pos == std::string::npos) 55 if (start_pos == std::string::npos)
(...skipping 24 matching lines...) Expand all
77 void* gpu_data_manager) { 80 void* gpu_data_manager) {
78 if (flags & kCGDisplayAddFlag) { 81 if (flags & kCGDisplayAddFlag) {
79 GpuDataManagerImpl* manager = 82 GpuDataManagerImpl* manager =
80 reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); 83 reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager);
81 DCHECK(manager); 84 DCHECK(manager);
82 manager->HandleGpuSwitch(); 85 manager->HandleGpuSwitch();
83 } 86 }
84 } 87 }
85 #endif // OS_MACOSX 88 #endif // OS_MACOSX
86 89
90 #if defined(OS_ANDROID)
91 void ApplyAndroidWorkarounds(const GPUInfo& gpu_info,
92 CommandLine* command_line) {
93 std::string vendor(StringToLowerASCII(gpu_info.gl_vendor));
94 std::string renderer(StringToLowerASCII(gpu_info.gl_renderer));
95 bool is_img =
96 gpu_info.gl_vendor.find("Imagination") != std::string::npos;
97 bool is_arm =
98 gpu_info.gl_vendor.find("ARM") != std::string::npos;
99 bool is_qualcomm =
100 gpu_info.gl_vendor.find("Qualcomm") != std::string::npos;
101 bool is_mali_t604 = is_arm &&
102 gpu_info.gl_renderer.find("Mali-T604") != std::string::npos;
103
104 bool is_vivante =
105 gpu_info.gl_extensions.find("GL_VIV_shader_binary") !=
106 std::string::npos;
107
108 bool is_nexus7 =
109 gpu_info.machine_model.find("Nexus 7") != std::string::npos;
110 bool is_nexus10 =
111 gpu_info.machine_model.find("Nexus 10") != std::string::npos;
112
113 // IMG: avoid context switching perf problems, crashes with share groups
114 // Mali-T604: http://crbug.com/154715
115 // QualComm, NVIDIA: Crashes with share groups
116 if (is_vivante || is_img || is_mali_t604 || is_nexus7 || is_qualcomm)
117 command_line->AppendSwitch(switches::kEnableVirtualGLContexts);
118
119 gfx::DeviceDisplayInfo info;
120 int default_tile_size = 256;
121
122 // For very high resolution displays (eg. Nexus 10), set the default
123 // tile size to be 512. This should be removed in favour of a generic
124 // hueristic that works across all platforms and devices, once that
125 // exists: http://crbug.com/159524. This switches to 512 for screens
126 // containing 40 or more 256x256 tiles, such that 1080p devices do
127 // not use 512x512 tiles (eg. 1920x1280 requires 37.5 tiles)
128 int numTiles = (info.GetDisplayWidth() *
129 info.GetDisplayHeight()) / (256 * 256);
130 if (numTiles >= 40)
131 default_tile_size = 512;
132
133 // IMG: Fast async texture uploads only work with non-power-of-two,
134 // but still multiple-of-eight sizes.
135 // http://crbug.com/168099
136 if (is_img)
137 default_tile_size -= 8;
138
139 // Set the command line if it isn't already set and we changed
140 // the default tile size.
141 if (default_tile_size != 256 &&
142 !command_line->HasSwitch(switches::kDefaultTileWidth) &&
143 !command_line->HasSwitch(switches::kDefaultTileHeight)) {
144 std::stringstream size;
145 size << default_tile_size;
146 command_line->AppendSwitchASCII(
147 switches::kDefaultTileWidth, size.str());
148 command_line->AppendSwitchASCII(
149 switches::kDefaultTileHeight, size.str());
150 }
151
152 // Increase the resolution of low resolution tiles for Nexus tablets.
153 if ((is_nexus7 || is_nexus10) &&
154 !command_line->HasSwitch(
155 cc::switches::kLowResolutionContentsScaleFactor)) {
156 command_line->AppendSwitchASCII(
157 cc::switches::kLowResolutionContentsScaleFactor, "0.25");
158 }
159 }
160 #endif // OS_ANDROID
161
87 // Block all domains' use of 3D APIs for this many milliseconds if 162 // Block all domains' use of 3D APIs for this many milliseconds if
88 // approaching a threshold where system stability might be compromised. 163 // approaching a threshold where system stability might be compromised.
89 const int64 kBlockAllDomainsMs = 10000; 164 const int64 kBlockAllDomainsMs = 10000;
90 const int kNumResetsWithinDuration = 1; 165 const int kNumResetsWithinDuration = 1;
91 166
92 // Enums for UMA histograms. 167 // Enums for UMA histograms.
93 enum BlockStatusHistogram { 168 enum BlockStatusHistogram {
94 BLOCK_STATUS_NOT_BLOCKED, 169 BLOCK_STATUS_NOT_BLOCKED,
95 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, 170 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED,
96 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, 171 BLOCK_STATUS_ALL_DOMAINS_BLOCKED,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 gpu_blacklist_string = kSoftwareRenderingListJson; 396 gpu_blacklist_string = kSoftwareRenderingListJson;
322 gpu_switching_list_string = kGpuSwitchingListJson; 397 gpu_switching_list_string = kGpuSwitchingListJson;
323 } 398 }
324 if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { 399 if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) {
325 gpu_driver_bug_list_string = kGpuDriverBugListJson; 400 gpu_driver_bug_list_string = kGpuDriverBugListJson;
326 } 401 }
327 InitializeImpl(gpu_blacklist_string, 402 InitializeImpl(gpu_blacklist_string,
328 gpu_switching_list_string, 403 gpu_switching_list_string,
329 gpu_driver_bug_list_string, 404 gpu_driver_bug_list_string,
330 gpu_info); 405 gpu_info);
331 // We pass down the list to GPU command buffer through commandline
332 // switches at GPU process launch. However, in situations where we don't
333 // have a GPU process, we append the browser process commandline.
334 if (command_line->HasSwitch(switches::kSingleProcess) ||
335 command_line->HasSwitch(switches::kInProcessGPU)) {
336 if (!gpu_driver_bugs_.empty()) {
337 command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds,
338 IntSetToString(gpu_driver_bugs_));
339 }
340 }
341 } 406 }
342 407
343 void GpuDataManagerImplPrivate::UpdateGpuInfo(const GPUInfo& gpu_info) { 408 void GpuDataManagerImplPrivate::UpdateGpuInfo(const GPUInfo& gpu_info) {
344 // No further update of gpu_info if falling back to SwiftShader. 409 // No further update of gpu_info if falling back to SwiftShader.
345 if (use_swiftshader_) 410 if (use_swiftshader_)
346 return; 411 return;
347 412
348 gpu_info_collector::MergeGPUInfo(&gpu_info_, gpu_info); 413 gpu_info_collector::MergeGPUInfo(&gpu_info_, gpu_info);
349 complete_gpu_info_already_requested_ = 414 complete_gpu_info_already_requested_ =
350 complete_gpu_info_already_requested_ || gpu_info_.finalized; 415 complete_gpu_info_already_requested_ || gpu_info_.finalized;
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 gpu_driver_bug_list_.reset(GpuDriverBugList::Create()); 805 gpu_driver_bug_list_.reset(GpuDriverBugList::Create());
741 gpu_driver_bug_list_->LoadList( 806 gpu_driver_bug_list_->LoadList(
742 browser_version_string, gpu_driver_bug_list_json, 807 browser_version_string, gpu_driver_bug_list_json,
743 GpuControlList::kCurrentOsOnly); 808 GpuControlList::kCurrentOsOnly);
744 } 809 }
745 810
746 gpu_info_ = gpu_info; 811 gpu_info_ = gpu_info;
747 UpdateGpuInfo(gpu_info); 812 UpdateGpuInfo(gpu_info);
748 UpdateGpuSwitchingManager(gpu_info); 813 UpdateGpuSwitchingManager(gpu_info);
749 UpdatePreliminaryBlacklistedFeatures(); 814 UpdatePreliminaryBlacklistedFeatures();
815
816 CommandLine* command_line = CommandLine::ForCurrentProcess();
817 // We pass down the list to GPU command buffer through commandline
818 // switches at GPU process launch. However, in situations where we don't
819 // have a GPU process, we append the browser process commandline.
820 if (command_line->HasSwitch(switches::kSingleProcess) ||
821 command_line->HasSwitch(switches::kInProcessGPU)) {
822 if (!gpu_driver_bugs_.empty()) {
823 command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds,
824 IntSetToString(gpu_driver_bugs_));
825 }
826 }
827 #if defined(OS_ANDROID)
828 ApplyAndroidWorkarounds(gpu_info, command_line);
829 #endif // OS_ANDROID
750 } 830 }
751 831
752 void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures( 832 void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures(
753 const std::set<int>& features) { 833 const std::set<int>& features) {
754 CommandLine* command_line = CommandLine::ForCurrentProcess(); 834 CommandLine* command_line = CommandLine::ForCurrentProcess();
755 blacklisted_features_ = features; 835 blacklisted_features_ = features;
756 836
757 // Force disable using the GPU for these features, even if they would 837 // Force disable using the GPU for these features, even if they would
758 // otherwise be allowed. 838 // otherwise be allowed.
759 if (card_blacklisted_ || 839 if (card_blacklisted_ ||
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 int render_process_id, 986 int render_process_id,
907 int render_view_id, 987 int render_view_id,
908 ThreeDAPIType requester) { 988 ThreeDAPIType requester) {
909 GpuDataManagerImpl::UnlockedSession session(owner_); 989 GpuDataManagerImpl::UnlockedSession session(owner_);
910 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, 990 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs,
911 url, render_process_id, render_view_id, requester); 991 url, render_process_id, render_view_id, requester);
912 } 992 }
913 993
914 } // namespace content 994 } // namespace content
915 995
OLDNEW
« no previous file with comments | « no previous file | content/gpu/gpu_info_collector_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698