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