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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 if (trial) | 128 if (trial) |
129 trial->Disable(); | 129 trial->Disable(); |
130 } | 130 } |
131 | 131 |
132 bool ShouldRunCompositingFieldTrial() { | 132 bool ShouldRunCompositingFieldTrial() { |
133 // Enable the field trial only on desktop OS's. | 133 // Enable the field trial only on desktop OS's. |
134 #if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) | 134 #if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) |
135 return false; | 135 return false; |
136 #endif | 136 #endif |
137 | 137 |
| 138 // Necessary for linux_chromeos build since it defines both OS_LINUX |
| 139 // and OS_CHROMEOS. |
| 140 #if defined(OS_CHROMEOS) |
| 141 return false; |
| 142 #endif |
| 143 |
138 #if defined(OS_WIN) | 144 #if defined(OS_WIN) |
139 // Don't run the trial on Windows XP. | 145 // Don't run the trial on Windows XP. |
140 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 146 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
141 return false; | 147 return false; |
142 #endif | 148 #endif |
143 | 149 |
| 150 const GpuDataManager* gpu_data_manager = GpuDataManager::GetInstance(); |
| 151 content::GpuFeatureType blacklisted_features = |
| 152 gpu_data_manager->GetBlacklistedFeatures(); |
| 153 |
| 154 // Don't run the field trial if gpu access has been blocked or |
| 155 // accelerated compositing is blacklisted. |
| 156 if (!gpu_data_manager->GpuAccessAllowed() || |
| 157 blacklisted_features & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) |
| 158 return false; |
| 159 |
144 // The performance of accelerated compositing is too low with software | 160 // The performance of accelerated compositing is too low with software |
145 // rendering. | 161 // rendering. |
146 if (content::GpuDataManager::GetInstance()->ShouldUseSoftwareRendering()) | 162 if (gpu_data_manager->ShouldUseSoftwareRendering()) |
147 return false; | 163 return false; |
148 | 164 |
149 // Don't activate the field trial if force-compositing-mode has been | 165 // Don't activate the field trial if force-compositing-mode has been |
150 // explicitly disabled from the command line. | 166 // explicitly disabled from the command line. |
151 if (CommandLine::ForCurrentProcess()->HasSwitch( | 167 if (CommandLine::ForCurrentProcess()->HasSwitch( |
152 switches::kDisableForceCompositingMode)) | 168 switches::kDisableForceCompositingMode) || |
| 169 CommandLine::ForCurrentProcess()->HasSwitch( |
| 170 switches::kDisableAcceleratedCompositing)) |
153 return false; | 171 return false; |
154 | 172 |
155 return true; | 173 return true; |
156 } | 174 } |
157 | 175 |
158 // Note: The compositing field trial may be created at startup time via the | 176 // Note: The compositing field trial may be created at startup time via the |
159 // Finch framework. In that case, all the Groups and probability values are | 177 // Finch framework. In that case, all the Groups and probability values are |
160 // set before this function is called and any Field Trial setup calls | 178 // set before this function is called and any Field Trial setup calls |
161 // made here are simply ignored. | 179 // made here are simply ignored. |
162 // Early outs from this function intended to bypass activation of the field | 180 // Early outs from this function intended to bypass activation of the field |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 234 |
217 bool force_compositing = (trial->group() == force_compositing_group); | 235 bool force_compositing = (trial->group() == force_compositing_group); |
218 bool thread = (trial->group() == thread_group); | 236 bool thread = (trial->group() == thread_group); |
219 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", | 237 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", |
220 force_compositing); | 238 force_compositing); |
221 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); | 239 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); |
222 } | 240 } |
223 | 241 |
224 } // namespace gpu_util; | 242 } // namespace gpu_util; |
225 | 243 |
OLD | NEW |