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 "content/browser/gpu/compositor_util.h" | 5 #include "content/browser/gpu/compositor_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 "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "content/public/browser/gpu_data_manager.h" | 10 #include "content/public/browser/gpu_data_manager.h" |
11 #include "content/public/common/content_constants.h" | 11 #include "content/public/common/content_constants.h" |
12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
13 #include "gpu/config/gpu_feature_type.h" | 13 #include "gpu/config/gpu_feature_type.h" |
14 | 14 |
15 #if defined(OS_WIN) | 15 #if defined(OS_MACOSX) |
16 #include "base/mac/mac_util.h" | |
17 #elif defined(OS_WIN) | |
16 #include "base/win/windows_version.h" | 18 #include "base/win/windows_version.h" |
17 #endif | 19 #endif |
18 | 20 |
19 namespace content { | 21 namespace content { |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
23 bool CanDoAcceleratedCompositing() { | 25 bool CanDoAcceleratedCompositing() { |
24 const GpuDataManager* manager = GpuDataManager::GetInstance(); | 26 const GpuDataManager* manager = GpuDataManager::GetInstance(); |
25 | 27 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 | 80 |
79 // Command line switches take precedence over blacklisting and field trials. | 81 // Command line switches take precedence over blacklisting and field trials. |
80 if (command_line.HasSwitch(switches::kDisableForceCompositingMode)) | 82 if (command_line.HasSwitch(switches::kDisableForceCompositingMode)) |
81 return false; | 83 return false; |
82 else if (command_line.HasSwitch(switches::kForceCompositingMode)) | 84 else if (command_line.HasSwitch(switches::kForceCompositingMode)) |
83 return true; | 85 return true; |
84 | 86 |
85 if (!CanDoAcceleratedCompositing()) | 87 if (!CanDoAcceleratedCompositing()) |
86 return false; | 88 return false; |
87 | 89 |
88 #if defined(OS_WIN) | 90 // TODO(gab): Do the same thing in IsThreadedCompositingEnabled() once this is |
91 // stable. | |
92 // TODO(gab): Use the GPU blacklist instead of hardcoding OS versions here | |
93 // https://codereview.chromium.org/23534006. | |
94 #if defined(OS_MACOSX) | |
95 // Mac OSX 10.8+ has been shipping with FCM enabled at 100% since M28; skip | |
96 // the field trial check to ensure this is always enabled on the try bots. | |
Zhenyao Mo
2013/09/18 20:43:59
Shouldn't this field trial check comment be more g
gab
2013/09/18 21:00:21
Done.
| |
97 return base::mac::IsOSMountainLionOrLater(); | |
98 #elif defined(OS_WIN) | |
89 // Windows Vista+ has been shipping with FCM enabled at 100% since M24; skip | 99 // Windows Vista+ has been shipping with FCM enabled at 100% since M24; skip |
90 // the field trial check to ensure this is always enabled on the try bots. | 100 // the field trial check to ensure this is always enabled on the try bots. |
91 // TODO(gab): Do the same thing in IsThreadedCompositingEnabled() once this is | |
92 // stable. | |
93 // TODO(gab): Do the same thing for Mac OS (which has been enabled at 100% | |
94 // since M28) as well and get rid of the field trial code. | |
95 // TODO(gab): Use the GPU blacklist instead of hardcoding OS version here | |
96 // https://codereview.chromium.org/23534006. | |
97 return base::win::GetVersion() >= base::win::VERSION_VISTA; | 101 return base::win::GetVersion() >= base::win::VERSION_VISTA; |
98 #endif | 102 #endif |
99 | 103 |
100 base::FieldTrial* trial = | 104 return false; |
101 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); | |
102 | |
103 // Force compositing is enabled in both the force compositing | |
104 // and threaded compositing mode field trials. | |
105 return trial && | |
106 (trial->group_name() == | |
107 kGpuCompositingFieldTrialForceCompositingEnabledName || | |
108 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName); | |
109 } | 105 } |
110 | 106 |
111 bool IsDelegatedRendererEnabled() { | 107 bool IsDelegatedRendererEnabled() { |
112 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 108 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
113 bool enabled = false; | 109 bool enabled = false; |
114 | 110 |
115 #if defined(USE_AURA) | 111 #if defined(USE_AURA) |
116 // Default to true on Aura, but allow override via flags. | 112 // Default to true on Aura, but allow override via flags. |
117 enabled = true; | 113 enabled = true; |
118 #endif | 114 #endif |
119 | 115 |
120 // Flags override. | 116 // Flags override. |
121 enabled |= command_line.HasSwitch(switches::kEnableDelegatedRenderer); | 117 enabled |= command_line.HasSwitch(switches::kEnableDelegatedRenderer); |
122 enabled &= !command_line.HasSwitch(switches::kDisableDelegatedRenderer); | 118 enabled &= !command_line.HasSwitch(switches::kDisableDelegatedRenderer); |
123 | 119 |
124 // Needs compositing, and thread. | 120 // Needs compositing, and thread. |
125 if (enabled && | 121 if (enabled && |
126 (!IsForceCompositingModeEnabled() || !IsThreadedCompositingEnabled())) { | 122 (!IsForceCompositingModeEnabled() || !IsThreadedCompositingEnabled())) { |
127 enabled = false; | 123 enabled = false; |
128 LOG(ERROR) << "Disabling delegated-rendering because it needs " | 124 LOG(ERROR) << "Disabling delegated-rendering because it needs " |
129 << "force-compositing-mode and threaded-compositing."; | 125 << "force-compositing-mode and threaded-compositing."; |
130 } | 126 } |
131 | 127 |
132 return enabled; | 128 return enabled; |
133 } | 129 } |
134 | 130 |
135 } // namespace content | 131 } // namespace content |
OLD | NEW |