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