Chromium Code Reviews| 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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 static bool IsGpuRasterizationBlacklisted() { | 23 static bool IsGpuRasterizationBlacklisted() { |
| 24 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); | 24 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); |
| 25 return manager->IsFeatureBlacklisted( | 25 return manager->IsFeatureBlacklisted( |
| 26 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); | 26 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); |
| 27 } | 27 } |
| 28 | 28 |
| 29 const char* kGpuCompositingFeatureName = "gpu_compositing"; | 29 const char* kGpuCompositingFeatureName = "gpu_compositing"; |
| 30 const char* kWebGLFeatureName = "webgl"; | 30 const char* kWebGLFeatureName = "webgl"; |
| 31 const char* kRasterizationFeatureName = "rasterization"; | 31 const char* kRasterizationFeatureName = "rasterization"; |
| 32 const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; | 32 const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; |
| 33 const char* kNativeGpuMemoryBufferFeatureName = "native_gpu_memory_buffers"; | |
|
reveman
2015/10/16 18:37:43
s/GpuMemoryBuffer/GpuMemoryBuffers/
| |
| 33 | 34 |
| 34 const int kMinRasterThreads = 1; | 35 const int kMinRasterThreads = 1; |
| 35 const int kMaxRasterThreads = 4; | 36 const int kMaxRasterThreads = 4; |
| 36 | 37 |
| 37 const int kMinMSAASampleCount = 0; | 38 const int kMinMSAASampleCount = 0; |
| 38 | 39 |
| 39 struct GpuFeatureInfo { | 40 struct GpuFeatureInfo { |
| 40 std::string name; | 41 std::string name; |
| 41 bool blocked; | 42 bool blocked; |
| 42 bool disabled; | 43 bool disabled; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 NumberOfRendererRasterThreads() == 1, | 150 NumberOfRendererRasterThreads() == 1, |
| 150 "Raster is using a single thread.", | 151 "Raster is using a single thread.", |
| 151 false | 152 false |
| 152 }, | 153 }, |
| 153 }; | 154 }; |
| 154 DCHECK(index < arraysize(kGpuFeatureInfo)); | 155 DCHECK(index < arraysize(kGpuFeatureInfo)); |
| 155 *eof = (index == arraysize(kGpuFeatureInfo) - 1); | 156 *eof = (index == arraysize(kGpuFeatureInfo) - 1); |
| 156 return kGpuFeatureInfo[index]; | 157 return kGpuFeatureInfo[index]; |
| 157 } | 158 } |
| 158 | 159 |
| 160 const GpuFeatureInfo GetGpuGmbInfo(size_t index, bool* eof) { | |
| 161 const GpuFeatureInfo kGpuGmbInfo[] = { | |
| 162 { | |
| 163 kNativeGpuMemoryBufferFeatureName, | |
| 164 false, | |
| 165 !IsNativeGpuMemoryBufferEnabled(), | |
| 166 "GpuMemoryBuffers are using the fall back path through shared memory" | |
| 167 " instead the hardware backed one.", | |
| 168 true | |
| 169 }, | |
| 170 }; | |
| 171 DCHECK(index < arraysize(kGpuGmbInfo)); | |
| 172 *eof = (index == arraysize(kGpuGmbInfo) - 1); | |
| 173 return kGpuGmbInfo[index]; | |
| 174 } | |
| 175 | |
| 159 } // namespace | 176 } // namespace |
| 160 | 177 |
| 161 bool IsPropertyTreeVerificationEnabled() { | 178 bool IsPropertyTreeVerificationEnabled() { |
| 162 const base::CommandLine& command_line = | 179 const base::CommandLine& command_line = |
| 163 *base::CommandLine::ForCurrentProcess(); | 180 *base::CommandLine::ForCurrentProcess(); |
| 164 return command_line.HasSwitch(cc::switches::kEnablePropertyTreeVerification); | 181 return command_line.HasSwitch(cc::switches::kEnablePropertyTreeVerification); |
| 165 } | 182 } |
| 166 | 183 |
| 167 int NumberOfRendererRasterThreads() { | 184 int NumberOfRendererRasterThreads() { |
| 168 int num_processors = base::SysInfo::NumberOfProcessors(); | 185 int num_processors = base::SysInfo::NumberOfProcessors(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 bool IsZeroCopyUploadEnabled() { | 218 bool IsZeroCopyUploadEnabled() { |
| 202 const base::CommandLine& command_line = | 219 const base::CommandLine& command_line = |
| 203 *base::CommandLine::ForCurrentProcess(); | 220 *base::CommandLine::ForCurrentProcess(); |
| 204 #if defined(OS_MACOSX) | 221 #if defined(OS_MACOSX) |
| 205 return !command_line.HasSwitch(switches::kDisableZeroCopy); | 222 return !command_line.HasSwitch(switches::kDisableZeroCopy); |
| 206 #else | 223 #else |
| 207 return command_line.HasSwitch(switches::kEnableZeroCopy); | 224 return command_line.HasSwitch(switches::kEnableZeroCopy); |
| 208 #endif | 225 #endif |
| 209 } | 226 } |
| 210 | 227 |
| 228 bool IsNativeGpuMemoryBufferEnabled() { | |
|
reveman
2015/10/16 18:37:43
The logic used to determine if enable_native_gpu_m
| |
| 229 const auto& command_line = *base::CommandLine::ForCurrentProcess(); | |
| 230 return command_line.HasSwitch(switches::kEnableNativeGpuMemoryBuffers); | |
| 231 } | |
| 232 | |
| 211 bool IsPersistentGpuMemoryBufferEnabled() { | 233 bool IsPersistentGpuMemoryBufferEnabled() { |
| 212 // Zero copy currently doesn't take advantage of persistent buffers. | 234 // Zero copy currently doesn't take advantage of persistent buffers. |
| 213 if (IsZeroCopyUploadEnabled()) | 235 if (IsZeroCopyUploadEnabled()) |
| 214 return false; | 236 return false; |
| 215 const auto& command_line = *base::CommandLine::ForCurrentProcess(); | 237 const auto& command_line = *base::CommandLine::ForCurrentProcess(); |
| 216 return command_line.HasSwitch(switches::kEnablePersistentGpuMemoryBuffer); | 238 return command_line.HasSwitch(switches::kEnablePersistentGpuMemoryBuffer); |
| 217 } | 239 } |
| 218 | 240 |
| 219 bool IsGpuRasterizationEnabled() { | 241 bool IsGpuRasterizationEnabled() { |
| 220 const base::CommandLine& command_line = | 242 const base::CommandLine& command_line = |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 manager->ShouldUseSwiftShader()) { | 357 manager->ShouldUseSwiftShader()) { |
| 336 status = "unavailable_software"; | 358 status = "unavailable_software"; |
| 337 } | 359 } |
| 338 | 360 |
| 339 feature_status_dict->SetString( | 361 feature_status_dict->SetString( |
| 340 gpu_feature_info.name.c_str(), status.c_str()); | 362 gpu_feature_info.name.c_str(), status.c_str()); |
| 341 } | 363 } |
| 342 return feature_status_dict; | 364 return feature_status_dict; |
| 343 } | 365 } |
| 344 | 366 |
| 367 base::DictionaryValue* GetGmbStatus() { | |
| 368 base::DictionaryValue* feature_status_dict = new base::DictionaryValue(); | |
| 369 | |
| 370 bool eof = false; | |
| 371 for (size_t i = 0; !eof; ++i) { | |
| 372 const GpuFeatureInfo gpu_gmb_info = GetGpuGmbInfo(i, &eof); | |
| 373 std::string status; | |
| 374 if (gpu_gmb_info.disabled) { | |
| 375 status = "disabled_software"; | |
| 376 } else { | |
| 377 status = "enabled_on"; | |
| 378 } | |
| 379 | |
| 380 feature_status_dict->SetString( | |
| 381 gpu_gmb_info.name.c_str(), status.c_str()); | |
| 382 } | |
| 383 return feature_status_dict; | |
| 384 } | |
| 385 | |
| 345 base::Value* GetProblems() { | 386 base::Value* GetProblems() { |
| 346 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); | 387 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); |
| 347 std::string gpu_access_blocked_reason; | 388 std::string gpu_access_blocked_reason; |
| 348 bool gpu_access_blocked = | 389 bool gpu_access_blocked = |
| 349 !manager->GpuAccessAllowed(&gpu_access_blocked_reason); | 390 !manager->GpuAccessAllowed(&gpu_access_blocked_reason); |
| 350 | 391 |
| 351 base::ListValue* problem_list = new base::ListValue(); | 392 base::ListValue* problem_list = new base::ListValue(); |
| 352 manager->GetBlacklistReasons(problem_list); | 393 manager->GetBlacklistReasons(problem_list); |
| 353 | 394 |
| 354 if (gpu_access_blocked) { | 395 if (gpu_access_blocked) { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 381 } | 422 } |
| 382 } | 423 } |
| 383 return problem_list; | 424 return problem_list; |
| 384 } | 425 } |
| 385 | 426 |
| 386 std::vector<std::string> GetDriverBugWorkarounds() { | 427 std::vector<std::string> GetDriverBugWorkarounds() { |
| 387 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); | 428 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); |
| 388 } | 429 } |
| 389 | 430 |
| 390 } // namespace content | 431 } // namespace content |
| OLD | NEW |