| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 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 | 
|  | 3 // found in the LICENSE file. | 
|  | 4 | 
|  | 5 #include "chrome/browser/chrome_gpu_util.h" | 
|  | 6 | 
|  | 7 #include "base/command_line.h" | 
|  | 8 #include "base/metrics/field_trial.h" | 
|  | 9 #include "base/metrics/histogram.h" | 
|  | 10 #include "base/version.h" | 
|  | 11 #if defined(OS_WIN) | 
|  | 12 #include "base/win/windows_version.h" | 
|  | 13 #endif | 
|  | 14 #include "chrome/common/chrome_switches.h" | 
|  | 15 #include "chrome/common/chrome_version_info.h" | 
|  | 16 #include "content/public/browser/gpu_data_manager.h" | 
|  | 17 #include "content/public/common/content_constants.h" | 
|  | 18 #include "content/public/common/content_switches.h" | 
|  | 19 #include "grit/browser_resources.h" | 
|  | 20 #include "ui/base/resource/resource_bundle.h" | 
|  | 21 | 
|  | 22 using content::GpuDataManager; | 
|  | 23 | 
|  | 24 namespace gpu_util { | 
|  | 25 | 
|  | 26 void InitializeCompositingFieldTrial() { | 
|  | 27 // Enable the field trial only on desktop OS's. | 
|  | 28 #if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)) | 
|  | 29   return; | 
|  | 30 #endif | 
|  | 31 #if defined(OS_WIN) | 
|  | 32   // Don't run the trial on Windows XP. | 
|  | 33   if (base::win::GetVersion() < base::win::VERSION_VISTA) | 
|  | 34     return; | 
|  | 35 #endif | 
|  | 36 | 
|  | 37   // The performance of accelerated compositing is too low with software | 
|  | 38   // rendering. | 
|  | 39   if (content::GpuDataManager::GetInstance()->ShouldUseSoftwareRendering()) | 
|  | 40     return; | 
|  | 41 | 
|  | 42   // Don't activate the field trial if force-compositing-mode has been | 
|  | 43   // explicitly disabled from the command line. | 
|  | 44   if (CommandLine::ForCurrentProcess()->HasSwitch( | 
|  | 45           switches::kDisableForceCompositingMode)) | 
|  | 46     return; | 
|  | 47 | 
|  | 48   const base::FieldTrial::Probability kDivisor = 3; | 
|  | 49   scoped_refptr<base::FieldTrial> trial( | 
|  | 50     base::FieldTrialList::FactoryGetFieldTrial( | 
|  | 51         content::kGpuCompositingFieldTrialName, kDivisor, | 
|  | 52         "disable", 2012, 12, 31, NULL)); | 
|  | 53 | 
|  | 54   // Produce the same result on every run of this client. | 
|  | 55   trial->UseOneTimeRandomization(); | 
|  | 56 | 
|  | 57   base::FieldTrial::Probability force_compositing_mode_probability = 0; | 
|  | 58   base::FieldTrial::Probability threaded_compositing_probability = 0; | 
|  | 59 | 
|  | 60   chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 
|  | 61   if (channel == chrome::VersionInfo::CHANNEL_STABLE || | 
|  | 62       channel == chrome::VersionInfo::CHANNEL_BETA) { | 
|  | 63     // Stable and Beta channels: Non-threaded force-compositing-mode on by | 
|  | 64     // default (mac and windows only). | 
|  | 65 #if defined(OS_WIN) || defined(OS_MACOSX) | 
|  | 66     force_compositing_mode_probability = 3; | 
|  | 67 #endif | 
|  | 68   } else if (channel == chrome::VersionInfo::CHANNEL_DEV || | 
|  | 69              channel == chrome::VersionInfo::CHANNEL_CANARY) { | 
|  | 70     // Dev and Canary channels: force-compositing-mode and | 
|  | 71     // threaded-compositing on with 1/3 probability each. | 
|  | 72     force_compositing_mode_probability = 1; | 
|  | 73 | 
|  | 74 #if defined(OS_MACOSX) || defined(OS_LINUX) | 
|  | 75     // Threaded compositing mode isn't feature complete on mac or linux yet: | 
|  | 76     // http://crbug.com/133602 for mac | 
|  | 77     // http://crbug.com/140866 for linux | 
|  | 78     threaded_compositing_probability = 0; | 
|  | 79 #else | 
|  | 80     if (!CommandLine::ForCurrentProcess()->HasSwitch( | 
|  | 81             switches::kDisableThreadedCompositing)) | 
|  | 82         threaded_compositing_probability = 1; | 
|  | 83 #endif | 
|  | 84   } | 
|  | 85 | 
|  | 86   int force_compositing_group = trial->AppendGroup( | 
|  | 87       content::kGpuCompositingFieldTrialForceCompositingEnabledName, | 
|  | 88       force_compositing_mode_probability); | 
|  | 89   int thread_group = trial->AppendGroup( | 
|  | 90       content::kGpuCompositingFieldTrialThreadEnabledName, | 
|  | 91       threaded_compositing_probability); | 
|  | 92 | 
|  | 93   bool force_compositing = (trial->group() == force_compositing_group); | 
|  | 94   bool thread = (trial->group() == thread_group); | 
|  | 95   UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", | 
|  | 96                         force_compositing); | 
|  | 97   UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); | 
|  | 98 } | 
|  | 99 | 
|  | 100 // Load GPU Blacklist, collect preliminary gpu info, and compute preliminary | 
|  | 101 // gpu feature flags. | 
|  | 102 void InitializeGpuDataManager(const CommandLine& command_line) { | 
|  | 103   if (command_line.HasSwitch(switches::kSkipGpuDataLoading)) | 
|  | 104     return; | 
|  | 105 | 
|  | 106   std::string chrome_version_string = "0"; | 
|  | 107   std::string gpu_blacklist_json_string; | 
|  | 108   if (!command_line.HasSwitch(switches::kIgnoreGpuBlacklist)) { | 
|  | 109     chrome::VersionInfo chrome_version_info; | 
|  | 110     if (chrome_version_info.is_valid()) | 
|  | 111         chrome_version_string = chrome_version_info.Version(); | 
|  | 112 | 
|  | 113     const base::StringPiece gpu_blacklist_json( | 
|  | 114         ResourceBundle::GetSharedInstance().GetRawDataResource( | 
|  | 115             IDR_GPU_BLACKLIST, ui::SCALE_FACTOR_NONE)); | 
|  | 116     gpu_blacklist_json_string = gpu_blacklist_json.as_string(); | 
|  | 117   } | 
|  | 118   content::GpuDataManager::GetInstance()->Initialize( | 
|  | 119       chrome_version_string, gpu_blacklist_json_string); | 
|  | 120 } | 
|  | 121 | 
|  | 122 }  // namespace gpu_util; | 
|  | 123 | 
| OLD | NEW | 
|---|