Chromium Code Reviews| 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/browser/compositor_util.h" | 5 #include "content/public/browser/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 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 bool CanDoAcceleratedCompositing() { | 19 bool CanDoAcceleratedCompositing() { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 29 if (manager->ShouldUseSwiftShader()) | 30 if (manager->ShouldUseSwiftShader()) |
| 30 return false; | 31 return false; |
| 31 | 32 |
| 32 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 33 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 33 if (command_line.HasSwitch(switches::kDisableAcceleratedCompositing)) | 34 if (command_line.HasSwitch(switches::kDisableAcceleratedCompositing)) |
| 34 return false; | 35 return false; |
| 35 | 36 |
| 36 return true; | 37 return true; |
| 37 } | 38 } |
| 38 | 39 |
| 39 bool IsForceCompositingModeBlacklisted() { | |
| 40 return GpuDataManager::GetInstance()->IsFeatureBlacklisted( | |
| 41 gpu::GPU_FEATURE_TYPE_FORCE_COMPOSITING_MODE); | |
| 42 } | |
| 43 | |
| 44 } // namespace | 40 } // namespace |
| 45 | 41 |
| 46 bool IsThreadedCompositingEnabled() { | 42 bool IsThreadedCompositingEnabled() { |
| 47 #if defined(OS_WIN) && defined(USE_AURA) | 43 #if defined(OS_WIN) && defined(USE_AURA) |
| 48 // We always want compositing on Aura Windows. | 44 // We always want compositing on Aura Windows. |
| 49 return true; | 45 return true; |
| 50 #endif | 46 #endif |
| 51 | 47 |
| 52 if (!CanDoAcceleratedCompositing()) | |
| 53 return false; | |
| 54 | |
| 55 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 48 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 56 | 49 |
| 57 // Command line switches take precedence over blacklist and field trials. | 50 // Command line switches take precedence over blacklist and field trials. |
| 58 if (command_line.HasSwitch(switches::kDisableForceCompositingMode) || | 51 if (command_line.HasSwitch(switches::kDisableForceCompositingMode) || |
| 59 command_line.HasSwitch(switches::kDisableThreadedCompositing)) | 52 command_line.HasSwitch(switches::kDisableThreadedCompositing)) |
| 60 return false; | 53 return false; |
| 61 | 54 |
| 62 #if defined(OS_CHROMEOS) | 55 #if defined(OS_CHROMEOS) |
| 63 // We always want threaded compositing on ChromeOS unless it's explicitly | 56 // We always want threaded compositing on ChromeOS unless it's explicitly |
| 64 // disabled above. | 57 // disabled above. |
| 65 return true; | 58 return true; |
| 66 #endif | 59 #endif |
| 67 | 60 |
| 68 if (command_line.HasSwitch(switches::kEnableThreadedCompositing)) | 61 if (command_line.HasSwitch(switches::kEnableThreadedCompositing)) |
| 69 return true; | 62 return true; |
| 70 | 63 |
| 71 if (IsForceCompositingModeBlacklisted()) | 64 if (!CanDoAcceleratedCompositing()) |
| 72 return false; | 65 return false; |
| 73 | 66 |
| 74 base::FieldTrial* trial = | 67 base::FieldTrial* trial = |
| 75 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); | 68 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); |
| 76 return trial && | 69 return trial && |
| 77 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName; | 70 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName; |
| 78 } | 71 } |
| 79 | 72 |
| 80 bool IsForceCompositingModeEnabled() { | 73 bool IsForceCompositingModeEnabled() { |
| 81 #if defined(OS_WIN) | 74 #if defined(OS_WIN) && defined(USE_AURA) |
| 82 // We always want compositing on Aura Windows. | 75 // We always want compositing on Aura Windows. |
| 83 return true; | 76 return true; |
| 84 #endif | 77 #endif |
| 85 | 78 |
| 86 if (!CanDoAcceleratedCompositing()) | |
| 87 return false; | |
| 88 | |
| 89 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 79 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 90 | 80 |
| 91 // Command line switches take precedence over blacklisting and field trials. | 81 // Command line switches take precedence over blacklisting and field trials. |
| 92 if (command_line.HasSwitch(switches::kDisableForceCompositingMode)) | 82 if (command_line.HasSwitch(switches::kDisableForceCompositingMode)) |
| 93 return false; | 83 return false; |
| 94 | 84 |
| 95 #if defined(OS_CHROMEOS) | 85 #if defined(OS_CHROMEOS) |
| 96 // We always want compositing ChromeOS unless it's explicitly disabled above. | 86 // We always want compositing ChromeOS unless it's explicitly disabled above. |
| 97 return true; | 87 return true; |
| 98 #endif | 88 #endif |
| 99 | 89 |
| 100 if (command_line.HasSwitch(switches::kForceCompositingMode)) | 90 if (command_line.HasSwitch(switches::kForceCompositingMode)) |
| 101 return true; | 91 return true; |
| 102 | 92 |
| 103 if (IsForceCompositingModeBlacklisted()) | 93 if (!CanDoAcceleratedCompositing()) |
| 104 return false; | 94 return false; |
| 105 | 95 |
| 96 #if defined(OS_WIN) | |
| 97 // Windows Vista+ has been shipping with FCM enabled at 100% since M24; skip | |
| 98 // the field trial check to ensure this is always enabled on the try bots. | |
| 99 // TODO(gab): Do the same thing in IsThreadedCompositingEnabled() once this is | |
| 100 // stable. | |
| 101 // TODO(gab): Do the same thing for Mac OS (which has been enabled at 100% | |
|
wiltzius
2013/08/06 16:58:14
Be careful about the Mac code, since it's only ena
| |
| 102 // since M28) as well and get rid of the field trial code. | |
| 103 return true; | |
| 104 #else | |
| 106 base::FieldTrial* trial = | 105 base::FieldTrial* trial = |
| 107 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); | 106 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); |
| 108 | 107 |
| 109 // Force compositing is enabled in both the force compositing | 108 // Force compositing is enabled in both the force compositing |
| 110 // and threaded compositing mode field trials. | 109 // and threaded compositing mode field trials. |
| 111 return trial && | 110 return trial && |
| 112 (trial->group_name() == | 111 (trial->group_name() == |
| 113 kGpuCompositingFieldTrialForceCompositingEnabledName || | 112 kGpuCompositingFieldTrialForceCompositingEnabledName || |
| 114 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName); | 113 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName); |
| 114 #endif | |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace content | 117 } // namespace content |
| OLD | NEW |