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/browser/gpu/compositor_util.h" | 5 #include "content/browser/gpu/compositor_util.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "build/build_config.h" |
9 #include "content/public/browser/gpu_data_manager.h" | 10 #include "content/public/browser/gpu_data_manager.h" |
10 #include "content/public/common/content_constants.h" | 11 #include "content/public/common/content_constants.h" |
11 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
12 #include "gpu/config/gpu_feature_type.h" | 13 #include "gpu/config/gpu_feature_type.h" |
13 | 14 |
| 15 #if defined(OS_WIN) |
| 16 #include "base/win/windows_version.h" |
| 17 #endif |
| 18 |
14 namespace content { | 19 namespace content { |
15 | 20 |
16 namespace { | 21 namespace { |
17 | 22 |
18 bool CanDoAcceleratedCompositing() { | 23 bool CanDoAcceleratedCompositing() { |
19 const GpuDataManager* manager = GpuDataManager::GetInstance(); | 24 const GpuDataManager* manager = GpuDataManager::GetInstance(); |
20 | 25 |
21 // Don't run the field trial if gpu access has been blocked or | 26 // Don't run the field trial if gpu access has been blocked or |
22 // accelerated compositing is blacklisted. | 27 // accelerated compositing is blacklisted. |
23 if (!manager->GpuAccessAllowed(NULL) || | 28 if (!manager->GpuAccessAllowed(NULL) || |
24 manager->IsFeatureBlacklisted( | 29 manager->IsFeatureBlacklisted( |
25 gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING)) | 30 gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING)) |
26 return false; | 31 return false; |
27 | 32 |
28 // Check for SwiftShader. | 33 // Check for SwiftShader. |
29 if (manager->ShouldUseSwiftShader()) | 34 if (manager->ShouldUseSwiftShader()) |
30 return false; | 35 return false; |
31 | 36 |
32 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 37 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
33 if (command_line.HasSwitch(switches::kDisableAcceleratedCompositing)) | 38 if (command_line.HasSwitch(switches::kDisableAcceleratedCompositing)) |
34 return false; | 39 return false; |
35 | 40 |
36 return true; | 41 return true; |
37 } | 42 } |
38 | 43 |
39 bool IsForceCompositingModeBlacklisted() { | |
40 return GpuDataManager::GetInstance()->IsFeatureBlacklisted( | |
41 gpu::GPU_FEATURE_TYPE_FORCE_COMPOSITING_MODE); | |
42 } | |
43 | |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 bool IsThreadedCompositingEnabled() { | 46 bool IsThreadedCompositingEnabled() { |
47 #if defined(USE_AURA) | 47 #if defined(USE_AURA) |
48 // We always want threaded compositing on Aura. | 48 // We always want threaded compositing on Aura. |
49 return true; | 49 return true; |
50 #endif | 50 #endif |
51 | 51 |
52 if (!CanDoAcceleratedCompositing()) | |
53 return false; | |
54 | |
55 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 52 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
56 | 53 |
57 // Command line switches take precedence over blacklist and field trials. | 54 // Command line switches take precedence over blacklist and field trials. |
58 if (command_line.HasSwitch(switches::kDisableForceCompositingMode) || | 55 if (command_line.HasSwitch(switches::kDisableForceCompositingMode) || |
59 command_line.HasSwitch(switches::kDisableThreadedCompositing)) | 56 command_line.HasSwitch(switches::kDisableThreadedCompositing)) { |
60 return false; | 57 return false; |
| 58 } else if (command_line.HasSwitch(switches::kEnableThreadedCompositing)) { |
| 59 return true; |
| 60 } |
61 | 61 |
62 if (command_line.HasSwitch(switches::kEnableThreadedCompositing)) | 62 if (!CanDoAcceleratedCompositing()) |
63 return true; | |
64 | |
65 if (IsForceCompositingModeBlacklisted()) | |
66 return false; | 63 return false; |
67 | 64 |
68 base::FieldTrial* trial = | 65 base::FieldTrial* trial = |
69 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); | 66 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); |
70 return trial && | 67 return trial && |
71 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName; | 68 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName; |
72 } | 69 } |
73 | 70 |
74 bool IsForceCompositingModeEnabled() { | 71 bool IsForceCompositingModeEnabled() { |
75 #if defined(USE_AURA) | 72 #if defined(USE_AURA) |
76 // We always want compositing on Aura. | 73 // We always want compositing on Aura. |
77 return true; | 74 return true; |
78 #endif | 75 #endif |
79 | 76 |
80 if (!CanDoAcceleratedCompositing()) | |
81 return false; | |
82 | |
83 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 77 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
84 | 78 |
85 // Command line switches take precedence over blacklisting and field trials. | 79 // Command line switches take precedence over blacklisting and field trials. |
86 if (command_line.HasSwitch(switches::kDisableForceCompositingMode)) | 80 if (command_line.HasSwitch(switches::kDisableForceCompositingMode)) |
87 return false; | 81 return false; |
88 | 82 else if (command_line.HasSwitch(switches::kForceCompositingMode)) |
89 if (command_line.HasSwitch(switches::kForceCompositingMode)) | |
90 return true; | 83 return true; |
91 | 84 |
92 if (IsForceCompositingModeBlacklisted()) | 85 if (!CanDoAcceleratedCompositing()) |
93 return false; | 86 return false; |
94 | 87 |
| 88 #if defined(OS_WIN) |
| 89 // Windows Vista+ has been shipping with FCM enabled at 100% since M24; skip |
| 90 // the field trial check to ensure this is always enabled on the try bots. |
| 91 // TODO(gab): Do the same thing in IsThreadedCompositingEnabled() once this is |
| 92 // stable. |
| 93 // TODO(gab): Do the same thing for Mac OS (which has been enabled at 100% |
| 94 // since M28) as well and get rid of the field trial code. |
| 95 // TODO(gab): Use the GPU blacklist instead of hardcoding OS version here |
| 96 // https://codereview.chromium.org/23534006. |
| 97 return base::win::GetVersion() >= base::win::VERSION_VISTA; |
| 98 #endif |
| 99 |
95 base::FieldTrial* trial = | 100 base::FieldTrial* trial = |
96 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); | 101 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); |
97 | 102 |
98 // Force compositing is enabled in both the force compositing | 103 // Force compositing is enabled in both the force compositing |
99 // and threaded compositing mode field trials. | 104 // and threaded compositing mode field trials. |
100 return trial && | 105 return trial && |
101 (trial->group_name() == | 106 (trial->group_name() == |
102 kGpuCompositingFieldTrialForceCompositingEnabledName || | 107 kGpuCompositingFieldTrialForceCompositingEnabledName || |
103 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName); | 108 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName); |
104 } | 109 } |
105 | 110 |
106 } // namespace content | 111 } // namespace content |
OLD | NEW |