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" | |
10 #include "content/public/browser/gpu_data_manager.h" | 9 #include "content/public/browser/gpu_data_manager.h" |
11 #include "content/public/common/content_constants.h" | 10 #include "content/public/common/content_constants.h" |
12 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
13 #include "gpu/config/gpu_feature_type.h" | 12 #include "gpu/config/gpu_feature_type.h" |
14 | 13 |
15 namespace content { | 14 namespace content { |
16 | 15 |
17 namespace { | 16 namespace { |
18 | 17 |
19 bool CanDoAcceleratedCompositing() { | 18 bool CanDoAcceleratedCompositing() { |
(...skipping 10 matching lines...) Expand all Loading... |
30 if (manager->ShouldUseSwiftShader()) | 29 if (manager->ShouldUseSwiftShader()) |
31 return false; | 30 return false; |
32 | 31 |
33 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 32 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
34 if (command_line.HasSwitch(switches::kDisableAcceleratedCompositing)) | 33 if (command_line.HasSwitch(switches::kDisableAcceleratedCompositing)) |
35 return false; | 34 return false; |
36 | 35 |
37 return true; | 36 return true; |
38 } | 37 } |
39 | 38 |
| 39 bool IsForceCompositingModeBlacklisted() { |
| 40 return GpuDataManager::GetInstance()->IsFeatureBlacklisted( |
| 41 gpu::GPU_FEATURE_TYPE_FORCE_COMPOSITING_MODE); |
| 42 } |
| 43 |
40 } // namespace | 44 } // namespace |
41 | 45 |
42 bool IsThreadedCompositingEnabled() { | 46 bool IsThreadedCompositingEnabled() { |
43 #if defined(USE_AURA) | 47 #if defined(USE_AURA) |
44 // We always want threaded compositing on Aura. | 48 // We always want threaded compositing on Aura. |
45 return true; | 49 return true; |
46 #endif | 50 #endif |
47 | 51 |
| 52 if (!CanDoAcceleratedCompositing()) |
| 53 return false; |
| 54 |
48 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 55 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
49 | 56 |
50 // Command line switches take precedence over blacklist and field trials. | 57 // Command line switches take precedence over blacklist and field trials. |
51 if (command_line.HasSwitch(switches::kDisableForceCompositingMode) || | 58 if (command_line.HasSwitch(switches::kDisableForceCompositingMode) || |
52 command_line.HasSwitch(switches::kDisableThreadedCompositing)) { | 59 command_line.HasSwitch(switches::kDisableThreadedCompositing)) |
53 return false; | 60 return false; |
54 } else if (command_line.HasSwitch(switches::kEnableThreadedCompositing)) { | 61 |
| 62 if (command_line.HasSwitch(switches::kEnableThreadedCompositing)) |
55 return true; | 63 return true; |
56 } | |
57 | 64 |
58 if (!CanDoAcceleratedCompositing()) | 65 if (IsForceCompositingModeBlacklisted()) |
59 return false; | 66 return false; |
60 | 67 |
61 base::FieldTrial* trial = | 68 base::FieldTrial* trial = |
62 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); | 69 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); |
63 return trial && | 70 return trial && |
64 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName; | 71 trial->group_name() == kGpuCompositingFieldTrialThreadEnabledName; |
65 } | 72 } |
66 | 73 |
67 bool IsForceCompositingModeEnabled() { | 74 bool IsForceCompositingModeEnabled() { |
68 #if defined(USE_AURA) | 75 #if defined(USE_AURA) |
69 // We always want compositing on Aura. | 76 // We always want compositing on Aura. |
70 return true; | 77 return true; |
71 #endif | 78 #endif |
72 | 79 |
| 80 if (!CanDoAcceleratedCompositing()) |
| 81 return false; |
| 82 |
73 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 83 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
74 | 84 |
75 // Command line switches take precedence over blacklisting and field trials. | 85 // Command line switches take precedence over blacklisting and field trials. |
76 if (command_line.HasSwitch(switches::kDisableForceCompositingMode)) | 86 if (command_line.HasSwitch(switches::kDisableForceCompositingMode)) |
77 return false; | 87 return false; |
78 else if (command_line.HasSwitch(switches::kForceCompositingMode)) | 88 |
| 89 if (command_line.HasSwitch(switches::kForceCompositingMode)) |
79 return true; | 90 return true; |
80 | 91 |
81 if (!CanDoAcceleratedCompositing()) | 92 if (IsForceCompositingModeBlacklisted()) |
82 return false; | 93 return false; |
83 | 94 |
84 base::FieldTrial* trial = | 95 base::FieldTrial* trial = |
85 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); | 96 base::FieldTrialList::Find(kGpuCompositingFieldTrialName); |
86 | 97 |
87 // Force compositing is enabled in both the force compositing | 98 // Force compositing is enabled in both the force compositing |
88 // and threaded compositing mode field trials. | 99 // and threaded compositing mode field trials. |
89 return trial && | 100 return trial && |
90 (trial->group_name() == | 101 (trial->group_name() == |
91 kGpuCompositingFieldTrialForceCompositingEnabledName || | 102 kGpuCompositingFieldTrialForceCompositingEnabledName || |
(...skipping 18 matching lines...) Expand all Loading... |
110 (!IsForceCompositingModeEnabled() || !IsThreadedCompositingEnabled())) { | 121 (!IsForceCompositingModeEnabled() || !IsThreadedCompositingEnabled())) { |
111 enabled = false; | 122 enabled = false; |
112 LOG(ERROR) << "Disabling delegated-rendering because it needs " | 123 LOG(ERROR) << "Disabling delegated-rendering because it needs " |
113 << "force-compositing-mode and threaded-compositing."; | 124 << "force-compositing-mode and threaded-compositing."; |
114 } | 125 } |
115 | 126 |
116 return enabled; | 127 return enabled; |
117 } | 128 } |
118 | 129 |
119 } // namespace content | 130 } // namespace content |
OLD | NEW |