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/public/browser/compositor_util.h" | 5 #include "content/public/browser/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 "content/public/browser/gpu_data_manager.h" | 9 #include "content/public/browser/gpu_data_manager.h" |
10 #include "content/public/common/content_constants.h" | 10 #include "content/public/common/content_constants.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 if (gpu_data_manager->ShouldUseSoftwareRendering()) | 29 if (gpu_data_manager->ShouldUseSoftwareRendering()) |
30 return false; | 30 return false; |
31 | 31 |
32 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 32 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
33 if (command_line.HasSwitch(switches::kDisableAcceleratedCompositing)) | 33 if (command_line.HasSwitch(switches::kDisableAcceleratedCompositing)) |
34 return false; | 34 return false; |
35 | 35 |
36 return true; | 36 return true; |
37 } | 37 } |
38 | 38 |
| 39 bool IsForceCompositingModeBlacklisted() { |
| 40 GpuFeatureType blacklisted_features = |
| 41 GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| 42 return GPU_FEATURE_TYPE_FORCE_COMPOSITING_MODE == |
| 43 (blacklisted_features & GPU_FEATURE_TYPE_FORCE_COMPOSITING_MODE); |
| 44 } |
| 45 |
39 } // namespace | 46 } // namespace |
40 | 47 |
41 bool IsThreadedCompositingEnabled() { | 48 bool IsThreadedCompositingEnabled() { |
42 #if defined(OS_WIN) && defined(USE_AURA) | 49 #if defined(OS_WIN) && defined(USE_AURA) |
43 // We always want compositing on Aura Windows. | 50 // We always want compositing on Aura Windows. |
44 return true; | 51 return true; |
45 #endif | 52 #endif |
46 | 53 |
47 if (!CanDoAcceleratedCompositing()) | 54 if (!CanDoAcceleratedCompositing()) |
48 return false; | 55 return false; |
49 | 56 |
50 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 57 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
51 | 58 |
52 // Command line switches take precedence over field trials. | 59 // Command line switches take precedence over blacklist and field trials. |
53 if (command_line.HasSwitch(switches::kDisableForceCompositingMode) || | 60 if (command_line.HasSwitch(switches::kDisableForceCompositingMode) || |
54 command_line.HasSwitch(switches::kDisableThreadedCompositing)) | 61 command_line.HasSwitch(switches::kDisableThreadedCompositing)) |
55 return false; | 62 return false; |
56 | 63 |
57 if (command_line.HasSwitch(switches::kEnableThreadedCompositing)) | 64 if (command_line.HasSwitch(switches::kEnableThreadedCompositing)) |
58 return true; | 65 return true; |
59 | 66 |
| 67 if (IsForceCompositingModeBlacklisted()) |
| 68 return false; |
| 69 |
60 base::FieldTrial* trial = | 70 base::FieldTrial* trial = |
61 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); | 71 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); |
62 return trial && | 72 return trial && |
63 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName; | 73 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName; |
64 } | 74 } |
65 | 75 |
66 bool IsForceCompositingModeEnabled() { | 76 bool IsForceCompositingModeEnabled() { |
67 #if defined(OS_WIN) && defined(USE_AURA) | 77 #if defined(OS_WIN) && defined(USE_AURA) |
68 // We always want compositing on Aura Windows. | 78 // We always want compositing on Aura Windows. |
69 return true; | 79 return true; |
70 #endif | 80 #endif |
71 | 81 |
72 if (!CanDoAcceleratedCompositing()) | 82 if (!CanDoAcceleratedCompositing()) |
73 return false; | 83 return false; |
74 | 84 |
75 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 85 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
76 | 86 |
77 // Command line switches take precedence over field trials. | 87 // Command line switches take precedence over blacklisting and field trials. |
78 if (command_line.HasSwitch(switches::kDisableForceCompositingMode)) | 88 if (command_line.HasSwitch(switches::kDisableForceCompositingMode)) |
79 return false; | 89 return false; |
80 | 90 |
81 if (command_line.HasSwitch(switches::kForceCompositingMode)) | 91 if (command_line.HasSwitch(switches::kForceCompositingMode)) |
82 return true; | 92 return true; |
83 | 93 |
| 94 if (IsForceCompositingModeBlacklisted()) |
| 95 return false; |
| 96 |
84 base::FieldTrial* trial = | 97 base::FieldTrial* trial = |
85 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); | 98 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); |
86 | 99 |
87 // Force compositing is enabled in both the force compositing | 100 // Force compositing is enabled in both the force compositing |
88 // and threaded compositing mode field trials. | 101 // and threaded compositing mode field trials. |
89 return trial && | 102 return trial && |
90 (trial->group_name() == | 103 (trial->group_name() == |
91 kGpuCompositingFieldTrialForceCompositingEnabledName || | 104 kGpuCompositingFieldTrialForceCompositingEnabledName || |
92 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName); | 105 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName); |
93 } | 106 } |
94 | 107 |
95 } // namespace content | 108 } // namespace content |
OLD | NEW |