diff options
author | alecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-21 20:56:00 +0000 |
---|---|---|
committer | alecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-21 20:56:00 +0000 |
commit | f22a2b6a7f496b5ce33d2091dd4b6b2b6620f5bf (patch) | |
tree | d051eeb01c1eebb6b2bc1cc6de66e92f384ac0f7 /chrome/browser/gpu | |
parent | ce7b9ac85035b9b57610166fd220c69b55cb0c10 (diff) | |
download | chromium_src-f22a2b6a7f496b5ce33d2091dd4b6b2b6620f5bf.zip chromium_src-f22a2b6a7f496b5ce33d2091dd4b6b2b6620f5bf.tar.gz chromium_src-f22a2b6a7f496b5ce33d2091dd4b6b2b6620f5bf.tar.bz2 |
Revert 229806 "Statically enable TCM and get rid of compositing-..."
> Statically enable TCM and get rid of compositing-mode-field-trials.
>
> This is based on top of https://codereview.chromium.org/27197009/
>
> TBR=joi
> BUG=302738, 233830, 306557
>
> Review URL: https://codereview.chromium.org/26389003
TBR=gab@chromium.org
Review URL: https://codereview.chromium.org/33663002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229907 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gpu')
-rw-r--r-- | chrome/browser/gpu/chrome_gpu_util.cc | 112 | ||||
-rw-r--r-- | chrome/browser/gpu/chrome_gpu_util.h | 16 |
2 files changed, 128 insertions, 0 deletions
diff --git a/chrome/browser/gpu/chrome_gpu_util.cc b/chrome/browser/gpu/chrome_gpu_util.cc new file mode 100644 index 0000000..5904713 --- /dev/null +++ b/chrome/browser/gpu/chrome_gpu_util.cc @@ -0,0 +1,112 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/gpu/chrome_gpu_util.h" + +#include "base/command_line.h" +#if defined(OS_MACOSX) +#include "base/mac/mac_util.h" +#endif +#include "base/metrics/field_trial.h" +#include "base/metrics/histogram.h" +#include "base/version.h" +#if defined(OS_WIN) +#include "base/win/windows_version.h" +#endif +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_observer.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/common/chrome_version_info.h" +#include "content/public/browser/gpu_data_manager.h" +#include "content/public/common/content_constants.h" +#include "content/public/common/content_switches.h" + +using content::GpuDataManager; + +namespace gpu_util { + +void DisableCompositingFieldTrial() { + base::FieldTrial* trial = + base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); + if (trial) + trial->Disable(); +} + +bool ShouldRunCompositingFieldTrial() { +// Enable the field trial only on desktop OS's. +#if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) + return false; +#endif + +// Necessary for linux_chromeos build since it defines both OS_LINUX +// and OS_CHROMEOS. +#if defined(OS_CHROMEOS) + return false; +#endif + + // Don't activate the field trial if force-compositing-mode has been + // explicitly disabled from the command line. + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableForceCompositingMode) || + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableAcceleratedCompositing)) + return false; + + return true; +} + +// Note 1: The compositing field trial may be created at startup time via the +// Finch framework. In that case, all the Groups and probability values are +// set before this function is called and any Field Trial setup calls +// made here are simply ignored. +// Note 2: Compositing field trials will be overwritten if accelerated +// compositing is blacklisted. That check takes place in +// IsThreadedCompositingEnabled() and IsForceCompositingModeEnabled() as +// the blacklist information isn't available at the time the field trials +// are initialized. +// Early outs from this function intended to bypass activation of the field +// trial must call DisableCompositingFieldTrial() before returning. +void InitializeCompositingFieldTrial() { + // Early out in configurations that should not run the compositing + // field trial. + if (!ShouldRunCompositingFieldTrial()) { + DisableCompositingFieldTrial(); + return; + } + + const base::FieldTrial::Probability kDivisor = 3; + scoped_refptr<base::FieldTrial> trial( + base::FieldTrialList::FactoryGetFieldTrial( + content::kGpuCompositingFieldTrialName, kDivisor, "disable", + 2013, 12, 31, base::FieldTrial::ONE_TIME_RANDOMIZED, NULL)); + + base::FieldTrial::Probability force_compositing_mode_probability = 0; + base::FieldTrial::Probability threaded_compositing_probability = 0; + + // Note: Threaded compositing mode isn't feature complete on mac or linux yet: + // http://crbug.com/133602 for mac + // http://crbug.com/140866 for linux + +#if defined(OS_WIN) || defined(OS_MACOSX) + // Enable threaded compositing on Windows and Mac. + threaded_compositing_probability = kDivisor; +#endif + + int force_compositing_group = trial->AppendGroup( + content::kGpuCompositingFieldTrialForceCompositingEnabledName, + force_compositing_mode_probability); + int thread_group = trial->AppendGroup( + content::kGpuCompositingFieldTrialThreadEnabledName, + threaded_compositing_probability); + + bool force_compositing = (trial->group() == force_compositing_group); + bool thread = (trial->group() == thread_group); + UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", + force_compositing); + UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); +} + +} // namespace gpu_util + diff --git a/chrome/browser/gpu/chrome_gpu_util.h b/chrome/browser/gpu/chrome_gpu_util.h new file mode 100644 index 0000000..1edff61 --- /dev/null +++ b/chrome/browser/gpu/chrome_gpu_util.h @@ -0,0 +1,16 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_GPU_CHROME_GPU_UTIL_H_ +#define CHROME_BROWSER_GPU_CHROME_GPU_UTIL_H_ + +namespace gpu_util { + +// Sets up force-compositing-mode and threaded compositing field trials. +void InitializeCompositingFieldTrial(); + +} // namespace gpu_util + +#endif // CHROME_BROWSER_GPU_CHROME_GPU_UTIL_H_ + |