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/public/common/compositor_util.h" | 5 #include "content/public/common/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 "content/public/common/content_constants.h" | 9 #include "content/public/common/content_constants.h" |
10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 bool IsThreadedCompositingEnabled() { | 14 bool IsThreadedCompositingEnabled() { |
15 #if defined(OS_WIN) && defined(USE_AURA) | 15 #if defined(OS_WIN) && defined(USE_AURA) |
16 // We always want compositing on Aura Windows. | 16 // We always want compositing on Aura Windows. |
17 return true; | 17 return true; |
18 #endif | 18 #endif |
19 | 19 |
20 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 20 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
21 if (command_line.HasSwitch(switches::kEnableThreadedCompositing) && | 21 |
22 !command_line.HasSwitch(switches::kDisableThreadedCompositing)) | 22 // Command line switches take precedence over field trials. |
| 23 if (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) || |
| 24 command_line.HasSwitch(switches::kDisableForceCompositingMode) || |
| 25 command_line.HasSwitch(switches::kDisableThreadedCompositing)) |
| 26 return false; |
| 27 |
| 28 if (command_line.HasSwitch(switches::kEnableThreadedCompositing)) |
23 return true; | 29 return true; |
24 | 30 |
25 base::FieldTrial* trial = | 31 base::FieldTrial* trial = |
26 base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); | 32 base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); |
27 return trial && | 33 return trial && |
28 trial->group_name() == | 34 trial->group_name() == |
29 content::kGpuCompositingFieldTrialThreadEnabledName; | 35 content::kGpuCompositingFieldTrialThreadEnabledName; |
30 } | 36 } |
31 | 37 |
32 bool IsForceCompositingModeEnabled() { | 38 bool IsForceCompositingModeEnabled() { |
33 #if defined(OS_WIN) && defined(USE_AURA) | 39 #if defined(OS_WIN) && defined(USE_AURA) |
34 // We always want compositing on Aura Windows. | 40 // We always want compositing on Aura Windows. |
35 return true; | 41 return true; |
36 #endif | 42 #endif |
37 | 43 |
38 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 44 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
39 if (command_line.HasSwitch(switches::kForceCompositingMode) && | 45 |
40 !command_line.HasSwitch(switches::kDisableForceCompositingMode)) | 46 // Command line switches take precedence over field trials. |
| 47 if (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) || |
| 48 command_line.HasSwitch(switches::kDisableForceCompositingMode)) |
| 49 return false; |
| 50 |
| 51 if (command_line.HasSwitch(switches::kForceCompositingMode)) |
41 return true; | 52 return true; |
42 | 53 |
43 base::FieldTrial* trial = | 54 base::FieldTrial* trial = |
44 base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); | 55 base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); |
45 | 56 |
46 // Force compositing is enabled in both the force compositing | 57 // Force compositing is enabled in both the force compositing |
47 // and threaded compositing mode field trials. | 58 // and threaded compositing mode field trials. |
48 return trial && | 59 return trial && |
49 (trial->group_name() == | 60 (trial->group_name() == |
50 content::kGpuCompositingFieldTrialForceCompositingEnabledName || | 61 content::kGpuCompositingFieldTrialForceCompositingEnabledName || |
51 trial->group_name() == | 62 trial->group_name() == |
52 content::kGpuCompositingFieldTrialThreadEnabledName); | 63 content::kGpuCompositingFieldTrialThreadEnabledName); |
53 } | 64 } |
54 | 65 |
55 } // compositor_util | 66 } // compositor_util |
OLD | NEW |