OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/gpu/gpu_info_collector.h" | 5 #include "content/gpu/gpu_info_collector.h" |
6 | 6 |
| 7 #include "base/command_line.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
9 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
10 #include "base/string_split.h" | 11 #include "base/string_split.h" |
| 12 #include "base/string_util.h" |
| 13 #include "content/public/common/content_switches.h" |
11 | 14 |
12 namespace { | 15 namespace { |
13 | 16 |
14 std::string GetDriverVersionFromString(const std::string& version_string) { | 17 std::string GetDriverVersionFromString(const std::string& version_string) { |
15 // Extract driver version from the second number in a string like: | 18 // Extract driver version from the second number in a string like: |
16 // "OpenGL ES 2.0 V@6.0 AU@ (CL@2946718)" | 19 // "OpenGL ES 2.0 V@6.0 AU@ (CL@2946718)" |
17 | 20 |
18 // Exclude first "2.0". | 21 // Exclude first "2.0". |
19 size_t begin = version_string.find_first_of("0123456789"); | 22 size_t begin = version_string.find_first_of("0123456789"); |
20 if (begin == std::string::npos) | 23 if (begin == std::string::npos) |
(...skipping 24 matching lines...) Expand all Loading... |
45 bool CollectGraphicsInfo(content::GPUInfo* gpu_info) { | 48 bool CollectGraphicsInfo(content::GPUInfo* gpu_info) { |
46 // can_lose_context must be false to enable accelerated Canvas2D | 49 // can_lose_context must be false to enable accelerated Canvas2D |
47 gpu_info->can_lose_context = false; | 50 gpu_info->can_lose_context = false; |
48 gpu_info->finalized = true; | 51 gpu_info->finalized = true; |
49 return CollectGraphicsInfoGL(gpu_info); | 52 return CollectGraphicsInfoGL(gpu_info); |
50 } | 53 } |
51 | 54 |
52 bool CollectPreliminaryGraphicsInfo(content::GPUInfo* gpu_info) { | 55 bool CollectPreliminaryGraphicsInfo(content::GPUInfo* gpu_info) { |
53 gpu_info->can_lose_context = false; | 56 gpu_info->can_lose_context = false; |
54 // Create a short-lived context on the UI thread to collect the GL strings. | 57 // Create a short-lived context on the UI thread to collect the GL strings. |
55 return CollectGraphicsInfoGL(gpu_info); | 58 if (!CollectGraphicsInfoGL(gpu_info)) |
| 59 return false; |
| 60 |
| 61 std::string vendor(StringToLowerASCII(gpu_info->gl_vendor)); |
| 62 std::string renderer(StringToLowerASCII(gpu_info->gl_renderer)); |
| 63 bool is_img = vendor.find("imagination") != std::string::npos; |
| 64 bool is_arm = vendor.find("arm") != std::string::npos; |
| 65 bool is_mali_t604 = is_arm && renderer.find("mali-t604") != std::string::npos; |
| 66 |
| 67 // IMG: avoid context switching perf problems, crashes with share groups |
| 68 // Mali-T604: http://crbug.com/154715 |
| 69 if (is_img || is_mali_t604) { |
| 70 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 71 switches::kEnableVirtualGLContexts); |
| 72 } |
| 73 return true; |
56 } | 74 } |
57 | 75 |
58 bool CollectVideoCardInfo(content::GPUInfo* gpu_info) { | 76 bool CollectVideoCardInfo(content::GPUInfo* gpu_info) { |
59 return true; | 77 return true; |
60 } | 78 } |
61 | 79 |
62 bool CollectDriverInfoGL(content::GPUInfo* gpu_info) { | 80 bool CollectDriverInfoGL(content::GPUInfo* gpu_info) { |
63 gpu_info->driver_version = GetDriverVersionFromString( | 81 gpu_info->driver_version = GetDriverVersionFromString( |
64 gpu_info->gl_version_string); | 82 gpu_info->gl_version_string); |
65 return true; | 83 return true; |
66 } | 84 } |
67 | 85 |
68 } // namespace gpu_info_collector | 86 } // namespace gpu_info_collector |
OLD | NEW |