| 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 "chrome/browser/chrome_gpu_util.h" | 5 #include "chrome/browser/chrome_gpu_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 "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/version.h" | 10 #include "base/version.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 if (trial) | 64 if (trial) |
| 65 trial->Disable(); | 65 trial->Disable(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool ShouldRunCompositingFieldTrial() { | 68 bool ShouldRunCompositingFieldTrial() { |
| 69 // Enable the field trial only on desktop OS's. | 69 // Enable the field trial only on desktop OS's. |
| 70 #if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) | 70 #if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) |
| 71 return false; | 71 return false; |
| 72 #endif | 72 #endif |
| 73 | 73 |
| 74 // Necessary for linux_chromeos build since it defines both OS_LINUX |
| 75 // and OS_CHROMEOS . |
| 76 #if defined(OS_CHROMEOS) |
| 77 return false; |
| 78 #endif |
| 79 |
| 74 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
| 75 // Don't run the trial on Windows XP. | 81 // Don't run the trial on Windows XP. |
| 76 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 82 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
| 77 return false; | 83 return false; |
| 78 #endif | 84 #endif |
| 79 | 85 |
| 80 // The performance of accelerated compositing is too low with software | 86 // The performance of accelerated compositing is too low with software |
| 81 // rendering. | 87 // rendering. |
| 82 if (content::GpuDataManager::GetInstance()->ShouldUseSoftwareRendering()) | 88 if (content::GpuDataManager::GetInstance()->ShouldUseSoftwareRendering()) |
| 83 return false; | 89 return false; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 99 // trial must call DisableCompositingFieldTrial() before returning. | 105 // trial must call DisableCompositingFieldTrial() before returning. |
| 100 void InitializeCompositingFieldTrial() { | 106 void InitializeCompositingFieldTrial() { |
| 101 // Early out in configurations that should not run the compositing | 107 // Early out in configurations that should not run the compositing |
| 102 // field trial. | 108 // field trial. |
| 103 if (!ShouldRunCompositingFieldTrial()) { | 109 if (!ShouldRunCompositingFieldTrial()) { |
| 104 DisableCompositingFieldTrial(); | 110 DisableCompositingFieldTrial(); |
| 105 return; | 111 return; |
| 106 } | 112 } |
| 107 | 113 |
| 108 const base::FieldTrial::Probability kDivisor = 3; | 114 const base::FieldTrial::Probability kDivisor = 3; |
| 115 // Note: This field trial should be removed once we're comfortable with |
| 116 // turning force compositing mode and threaded compositing on all relevant |
| 117 // platforms (see crbug.com/149991). |
| 109 scoped_refptr<base::FieldTrial> trial( | 118 scoped_refptr<base::FieldTrial> trial( |
| 110 base::FieldTrialList::FactoryGetFieldTrial( | 119 base::FieldTrialList::FactoryGetFieldTrial( |
| 111 content::kGpuCompositingFieldTrialName, kDivisor, | 120 content::kGpuCompositingFieldTrialName, kDivisor, |
| 112 "disable", 2012, 12, 31, NULL)); | 121 "disable", 2013, 12, 31, NULL)); |
| 113 | 122 |
| 114 // Produce the same result on every run of this client. | 123 // Produce the same result on every run of this client. |
| 115 trial->UseOneTimeRandomization(); | 124 trial->UseOneTimeRandomization(); |
| 116 | 125 |
| 126 // Note: The static field trial probabilities set here can be overwritten |
| 127 // at runtime by Finch. Changing these static values won't have an effect |
| 128 // if a Finch study is active. |
| 117 base::FieldTrial::Probability force_compositing_mode_probability = 0; | 129 base::FieldTrial::Probability force_compositing_mode_probability = 0; |
| 118 base::FieldTrial::Probability threaded_compositing_probability = 0; | 130 base::FieldTrial::Probability threaded_compositing_probability = 0; |
| 119 | 131 |
| 132 // Threaded compositing mode isn't feature complete on mac or linux yet: |
| 133 // http://crbug.com/133602 for mac |
| 134 // http://crbug.com/140866 for linux |
| 135 |
| 136 #if defined(OS_WIN) |
| 137 // threaded-compositing turned on by default on Windows. |
| 138 // (Windows XP is excluded explicitly in ShouldRunCompositingFieldTrial) |
| 139 threaded_compositing_probability = 3; |
| 140 #elif defined(OS_LINUX) || defined(OS_MACOSX) |
| 120 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 141 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 121 if (channel == chrome::VersionInfo::CHANNEL_STABLE || | 142 if (channel != chrome::VersionInfo::CHANNEL_STABLE && |
| 122 channel == chrome::VersionInfo::CHANNEL_BETA) { | 143 channel != chrome::VersionInfo::CHANNEL_BETA) { |
| 123 // Stable and Beta channels: Non-threaded force-compositing-mode on by | 144 // On channels < beta, force-compositing-mode on |
| 124 // default (mac and windows only). | 145 // with 33% probability. |
| 125 #if defined(OS_WIN) || defined(OS_MACOSX) | 146 force_compositing_mode_probability = 1; |
| 126 force_compositing_mode_probability = 3; | 147 } |
| 127 #endif | 148 #endif |
| 128 } else if (channel == chrome::VersionInfo::CHANNEL_DEV || | |
| 129 channel == chrome::VersionInfo::CHANNEL_CANARY) { | |
| 130 // Dev and Canary channels: force-compositing-mode and | |
| 131 // threaded-compositing on with 1/3 probability each. | |
| 132 force_compositing_mode_probability = 1; | |
| 133 | |
| 134 #if defined(OS_MACOSX) || defined(OS_LINUX) | |
| 135 // Threaded compositing mode isn't feature complete on mac or linux yet: | |
| 136 // http://crbug.com/133602 for mac | |
| 137 // http://crbug.com/140866 for linux | |
| 138 threaded_compositing_probability = 0; | |
| 139 #else | |
| 140 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
| 141 switches::kDisableThreadedCompositing)) | |
| 142 threaded_compositing_probability = 1; | |
| 143 #endif | |
| 144 } | |
| 145 | 149 |
| 146 int force_compositing_group = trial->AppendGroup( | 150 int force_compositing_group = trial->AppendGroup( |
| 147 content::kGpuCompositingFieldTrialForceCompositingEnabledName, | 151 content::kGpuCompositingFieldTrialForceCompositingEnabledName, |
| 148 force_compositing_mode_probability); | 152 force_compositing_mode_probability); |
| 149 int thread_group = trial->AppendGroup( | 153 int thread_group = trial->AppendGroup( |
| 150 content::kGpuCompositingFieldTrialThreadEnabledName, | 154 content::kGpuCompositingFieldTrialThreadEnabledName, |
| 151 threaded_compositing_probability); | 155 threaded_compositing_probability); |
| 152 | 156 |
| 153 bool force_compositing = (trial->group() == force_compositing_group); | 157 bool force_compositing = (trial->group() == force_compositing_group); |
| 154 bool thread = (trial->group() == thread_group); | 158 bool thread = (trial->group() == thread_group); |
| 155 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", | 159 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", |
| 156 force_compositing); | 160 force_compositing); |
| 157 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); | 161 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); |
| 158 } | 162 } |
| 159 | 163 |
| 160 } // namespace gpu_util; | 164 } // namespace gpu_util; |
| 161 | 165 |
| OLD | NEW |