OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gpu_data_manager.h" | 5 #include "content/browser/gpu/gpu_data_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 105 } |
106 | 106 |
107 GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() { | 107 GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() { |
108 return gpu_feature_flags_; | 108 return gpu_feature_flags_; |
109 } | 109 } |
110 | 110 |
111 bool GpuDataManager::GpuAccessAllowed() { | 111 bool GpuDataManager::GpuAccessAllowed() { |
112 // We only need to block GPU process if more features are disallowed other | 112 // We only need to block GPU process if more features are disallowed other |
113 // than those in the preliminary gpu feature flags because the latter work | 113 // than those in the preliminary gpu feature flags because the latter work |
114 // through renderer commandline switches. | 114 // through renderer commandline switches. |
115 // However, if accelerated_compositing is not allowed, then we should always | 115 uint32 mask = (~(preliminary_gpu_feature_flags_.flags())); |
116 // deny gpu access. | |
117 uint32 mask = (~(preliminary_gpu_feature_flags_.flags())) | | |
118 GpuFeatureFlags::kGpuFeatureAcceleratedCompositing; | |
119 return (gpu_feature_flags_.flags() & mask) == 0; | 116 return (gpu_feature_flags_.flags() & mask) == 0; |
120 } | 117 } |
121 | 118 |
122 void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) { | 119 void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) { |
123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
124 gpu_info_update_callbacks_.insert(callback); | 121 gpu_info_update_callbacks_.insert(callback); |
125 } | 122 } |
126 | 123 |
127 bool GpuDataManager::RemoveGpuInfoUpdateCallback(Callback0::Type* callback) { | 124 bool GpuDataManager::RemoveGpuInfoUpdateCallback(Callback0::Type* callback) { |
128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 11 matching lines...) Expand all Loading... |
140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
141 DCHECK(command_line); | 138 DCHECK(command_line); |
142 | 139 |
143 uint32 flags = gpu_feature_flags_.flags(); | 140 uint32 flags = gpu_feature_flags_.flags(); |
144 if ((flags & GpuFeatureFlags::kGpuFeatureWebgl) && | 141 if ((flags & GpuFeatureFlags::kGpuFeatureWebgl) && |
145 !command_line->HasSwitch(switches::kDisableExperimentalWebGL)) | 142 !command_line->HasSwitch(switches::kDisableExperimentalWebGL)) |
146 command_line->AppendSwitch(switches::kDisableExperimentalWebGL); | 143 command_line->AppendSwitch(switches::kDisableExperimentalWebGL); |
147 if ((flags & GpuFeatureFlags::kGpuFeatureMultisampling) && | 144 if ((flags & GpuFeatureFlags::kGpuFeatureMultisampling) && |
148 !command_line->HasSwitch(switches::kDisableGLMultisampling)) | 145 !command_line->HasSwitch(switches::kDisableGLMultisampling)) |
149 command_line->AppendSwitch(switches::kDisableGLMultisampling); | 146 command_line->AppendSwitch(switches::kDisableGLMultisampling); |
150 // If we have kGpuFeatureAcceleratedCompositing, we disable all GPU features. | 147 if ((flags & GpuFeatureFlags::kGpuFeatureAcceleratedCompositing) && |
151 if (flags & GpuFeatureFlags::kGpuFeatureAcceleratedCompositing) { | 148 !command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) |
152 const char* switches[] = { | 149 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); |
153 switches::kDisableAcceleratedCompositing, | |
154 switches::kDisableExperimentalWebGL, | |
155 switches::kDisableAccelerated2dCanvas | |
156 }; | |
157 const int switch_count = sizeof(switches) / sizeof(char*); | |
158 for (int i = 0; i < switch_count; ++i) { | |
159 if (!command_line->HasSwitch(switches[i])) | |
160 command_line->AppendSwitch(switches[i]); | |
161 } | |
162 } | |
163 } | 150 } |
164 | 151 |
165 void GpuDataManager::SetBuiltInGpuBlacklist(GpuBlacklist* built_in_list) { | 152 void GpuDataManager::SetBuiltInGpuBlacklist(GpuBlacklist* built_in_list) { |
166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
167 DCHECK(built_in_list); | 154 DCHECK(built_in_list); |
168 uint16 version_major, version_minor; | 155 uint16 version_major, version_minor; |
169 bool succeed = built_in_list->GetVersion( | 156 bool succeed = built_in_list->GetVersion( |
170 &version_major, &version_minor); | 157 &version_major, &version_minor); |
171 DCHECK(succeed); | 158 DCHECK(succeed); |
172 gpu_blacklist_.reset(built_in_list); | 159 gpu_blacklist_.reset(built_in_list); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 252 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
266 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || | 253 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || |
267 browser_command_line.GetSwitchValueASCII( | 254 browser_command_line.GetSwitchValueASCII( |
268 switches::kUseGL) == gfx::kGLImplementationOSMesaName) | 255 switches::kUseGL) == gfx::kGLImplementationOSMesaName) |
269 return NULL; | 256 return NULL; |
270 // No need to return an empty blacklist. | 257 // No need to return an empty blacklist. |
271 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) | 258 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) |
272 return NULL; | 259 return NULL; |
273 return gpu_blacklist_.get(); | 260 return gpu_blacklist_.get(); |
274 } | 261 } |
OLD | NEW |