Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1253)

Side by Side Diff: chrome/browser/gpu_util.cc

Issue 10541019: Adding a field trial for testing --force-compositing-mode on 50% of (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/gpu_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/gpu_util.h" 5 #include "chrome/browser/gpu_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
11 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
12 #include "base/string_util.h" 13 #include "base/string_util.h"
13 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
14 #include "base/sys_info.h" 15 #include "base/sys_info.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "base/version.h" 17 #include "base/version.h"
17 #include "chrome/browser/gpu_blacklist.h" 18 #include "chrome/browser/gpu_blacklist.h"
19 #include "chrome/common/chrome_version_info.h"
18 #include "content/public/browser/gpu_data_manager.h" 20 #include "content/public/browser/gpu_data_manager.h"
19 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
20 #include "content/public/common/gpu_info.h" 22 #include "content/public/common/gpu_info.h"
21 23
24 #if defined(OS_WIN)
25 #include "base/win/windows_version.h"
26 #elif defined(OS_MAC)
27 #include "base/mac/mac_util.h"
28 #endif
29
22 using content::GpuDataManager; 30 using content::GpuDataManager;
23 using content::GpuFeatureType; 31 using content::GpuFeatureType;
24 32
25 namespace { 33 namespace {
26 34
27 const char kGpuFeatureNameAccelerated2dCanvas[] = "accelerated_2d_canvas"; 35 const char kGpuFeatureNameAccelerated2dCanvas[] = "accelerated_2d_canvas";
28 const char kGpuFeatureNameAcceleratedCompositing[] = "accelerated_compositing"; 36 const char kGpuFeatureNameAcceleratedCompositing[] = "accelerated_compositing";
29 const char kGpuFeatureNameWebgl[] = "webgl"; 37 const char kGpuFeatureNameWebgl[] = "webgl";
30 const char kGpuFeatureNameMultisampling[] = "multisampling"; 38 const char kGpuFeatureNameMultisampling[] = "multisampling";
31 const char kGpuFeatureNameFlash3d[] = "flash_3d"; 39 const char kGpuFeatureNameFlash3d[] = "flash_3d";
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 break; 163 break;
156 } 164 }
157 return entry_index; 165 return entry_index;
158 } 166 }
159 #endif // OS_WIN 167 #endif // OS_WIN
160 168
161 } // namespace 169 } // namespace
162 170
163 namespace gpu_util { 171 namespace gpu_util {
164 172
173 const char kForceCompositingModeFieldTrialName[] = "ForceCompositingMode";
174 const char kFieldTrialEnabledName[] = "enabled";
175
176 void InitializeForceCompositingModeFieldTrial() {
177 // Enable the field trial only on desktop OS's.
178 #if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX))
179 return;
180 #endif
181 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
182 // Only run the trial on the Canary channel.
183 if (channel != chrome::VersionInfo::CHANNEL_CANARY)
184 return;
185 #if defined(OS_WIN)
186 // Don't run the trial on Windows XP.
187 if (base::win::GetVersion() < base::win::VERSION_VISTA)
188 return;
189 #elif defined(OS_MACOSX)
190 // Accelerated compositing is only implemented on Mac OSX 10.6 or later.
191 if (base::mac::IsOSLeopardOrEarlier())
192 return;
193 #endif
194
195 const base::FieldTrial::Probability kDivisor = 100;
196 scoped_refptr<base::FieldTrial> trial(
197 base::FieldTrialList::FactoryGetFieldTrial(
198 kForceCompositingModeFieldTrialName, kDivisor,
199 "disable", 2012, 12, 31, NULL));
200
201 // Produce the same result on every run of this client.
202 trial->UseOneTimeRandomization();
203 // 50% probability of being in the enabled group.
204 const base::FieldTrial::Probability kEnableProbability = 50;
205 int enable_group = trial->AppendGroup(
206 kFieldTrialEnabledName, kEnableProbability);
207
208 bool enabled = (trial->group() == enable_group);
209 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", enabled);
210 }
211
212 bool InForceCompositingModeTrial() {
213 base::FieldTrial* trial =
214 base::FieldTrialList::Find(kForceCompositingModeFieldTrialName);
215 if (!trial)
216 return false;
217 return trial->group_name() == kFieldTrialEnabledName;
218 }
219
165 GpuFeatureType StringToGpuFeatureType(const std::string& feature_string) { 220 GpuFeatureType StringToGpuFeatureType(const std::string& feature_string) {
166 if (feature_string == kGpuFeatureNameAccelerated2dCanvas) 221 if (feature_string == kGpuFeatureNameAccelerated2dCanvas)
167 return content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; 222 return content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS;
168 else if (feature_string == kGpuFeatureNameAcceleratedCompositing) 223 else if (feature_string == kGpuFeatureNameAcceleratedCompositing)
169 return content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING; 224 return content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING;
170 else if (feature_string == kGpuFeatureNameWebgl) 225 else if (feature_string == kGpuFeatureNameWebgl)
171 return content::GPU_FEATURE_TYPE_WEBGL; 226 return content::GPU_FEATURE_TYPE_WEBGL;
172 else if (feature_string == kGpuFeatureNameMultisampling) 227 else if (feature_string == kGpuFeatureNameMultisampling)
173 return content::GPU_FEATURE_TYPE_MULTISAMPLING; 228 return content::GPU_FEATURE_TYPE_MULTISAMPLING;
174 else if (feature_string == kGpuFeatureNameFlash3d) 229 else if (feature_string == kGpuFeatureNameFlash3d)
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 { 337 {
283 ListValue* feature_status_list = new ListValue(); 338 ListValue* feature_status_list = new ListValue();
284 339
285 for (size_t i = 0; i < kNumFeatures; ++i) { 340 for (size_t i = 0; i < kNumFeatures; ++i) {
286 std::string status; 341 std::string status;
287 if (kGpuFeatureInfo[i].disabled) { 342 if (kGpuFeatureInfo[i].disabled) {
288 status = "disabled"; 343 status = "disabled";
289 if (kGpuFeatureInfo[i].name == "css_animation") { 344 if (kGpuFeatureInfo[i].name == "css_animation") {
290 status += "_software_animated"; 345 status += "_software_animated";
291 } else { 346 } else {
292 if (kGpuFeatureInfo[i].fallback_to_software) 347 if (kGpuFeatureInfo[i].fallback_to_software)
jar (doing other things) 2012/06/08 00:03:25 nit: you could have made this an else if on line 3
293 status += "_software"; 348 status += "_software";
294 else 349 else
295 status += "_off"; 350 status += "_off";
296 } 351 }
297 } else if (GpuDataManager::GetInstance()->ShouldUseSoftwareRendering()) { 352 } else if (GpuDataManager::GetInstance()->ShouldUseSoftwareRendering()) {
298 status = "unavailable_software"; 353 status = "unavailable_software";
299 } else if (kGpuFeatureInfo[i].blocked || 354 } else if (kGpuFeatureInfo[i].blocked ||
300 gpu_access_blocked) { 355 gpu_access_blocked) {
jar (doing other things) 2012/06/08 00:03:25 nit: unwrap this line
301 status = "unavailable"; 356 status = "unavailable";
302 if (kGpuFeatureInfo[i].fallback_to_software) 357 if (kGpuFeatureInfo[i].fallback_to_software)
303 status += "_software"; 358 status += "_software";
304 else 359 else
305 status += "_off"; 360 status += "_off";
306 } else { 361 } else {
307 status = "enabled"; 362 status = "enabled";
308 if (kGpuFeatureInfo[i].name == "webgl" && 363 if (kGpuFeatureInfo[i].name == "webgl" &&
309 (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) || 364 (command_line.HasSwitch(switches::kDisableAcceleratedCompositing) ||
310 (flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))) 365 (flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING)))
311 status += "_readback"; 366 status += "_readback";
312 bool has_thread = CommandLine::ForCurrentProcess()->HasSwitch( 367 bool has_thread = CommandLine::ForCurrentProcess()->HasSwitch(
313 switches::kEnableThreadedCompositing) && 368 switches::kEnableThreadedCompositing) &&
314 (!CommandLine::ForCurrentProcess()->HasSwitch( 369 (!CommandLine::ForCurrentProcess()->HasSwitch(
315 switches::kDisableThreadedCompositing)); 370 switches::kDisableThreadedCompositing));
316 if (kGpuFeatureInfo[i].name == "compositing" && 371 if (kGpuFeatureInfo[i].name == "compositing" &&
317 CommandLine::ForCurrentProcess()->HasSwitch( 372 (CommandLine::ForCurrentProcess()->HasSwitch(
318 switches::kForceCompositingMode)) 373 switches::kForceCompositingMode) ||
374 InForceCompositingModeTrial()))
jar (doing other things) 2012/06/08 00:03:25 nit: indent: It is hard to say how to fix this up.
319 status += "_force"; 375 status += "_force";
320 if (kGpuFeatureInfo[i].name == "compositing" && 376 if (kGpuFeatureInfo[i].name == "compositing" &&
321 has_thread) 377 has_thread)
322 status += "_threaded"; 378 status += "_threaded";
323 if (kGpuFeatureInfo[i].name == "css_animation") { 379 if (kGpuFeatureInfo[i].name == "css_animation") {
324 if (has_thread) 380 if (has_thread)
325 status = "accelerated_threaded"; 381 status = "accelerated_threaded";
326 else 382 else
327 status = "accelerated"; 383 status = "accelerated";
328 } 384 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 kGpuBlacklistFeatureHistogramNamesWin[i], 565 kGpuBlacklistFeatureHistogramNamesWin[i],
510 1, kNumWinSubVersions * kGpuFeatureNumStatus, 566 1, kNumWinSubVersions * kGpuFeatureNumStatus,
511 kNumWinSubVersions * kGpuFeatureNumStatus + 1, 567 kNumWinSubVersions * kGpuFeatureNumStatus + 1,
512 base::Histogram::kUmaTargetedHistogramFlag); 568 base::Histogram::kUmaTargetedHistogramFlag);
513 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); 569 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value));
514 #endif 570 #endif
515 } 571 }
516 } 572 }
517 573
518 } // namespace gpu_util; 574 } // namespace gpu_util;
OLDNEW
« no previous file with comments | « chrome/browser/gpu_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698