| 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 #if defined(OS_MACOSX) | 7 #if defined(OS_MACOSX) |
| 8 #include <CoreGraphics/CGDisplayConfiguration.h> | 8 #include <CoreGraphics/CGDisplayConfiguration.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 } // namespace anonymous | 43 } // namespace anonymous |
| 44 | 44 |
| 45 GpuDataManager::GpuDataManager() | 45 GpuDataManager::GpuDataManager() |
| 46 : complete_gpu_info_already_requested_(false) { | 46 : complete_gpu_info_already_requested_(false) { |
| 47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 48 | 48 |
| 49 GPUInfo gpu_info; | 49 GPUInfo gpu_info; |
| 50 allows_gpu_access_ = | 50 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); |
| 51 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); | |
| 52 UpdateGpuInfo(gpu_info); | 51 UpdateGpuInfo(gpu_info); |
| 53 | 52 |
| 54 #if defined(OS_MACOSX) | 53 #if defined(OS_MACOSX) |
| 55 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); | 54 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); |
| 56 #endif | 55 #endif |
| 57 } | 56 } |
| 58 | 57 |
| 59 GpuDataManager::~GpuDataManager() { | 58 GpuDataManager::~GpuDataManager() { |
| 60 #if defined(OS_MACOSX) | 59 #if defined(OS_MACOSX) |
| 61 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); | 60 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 const ListValue& GpuDataManager::log_messages() const { | 135 const ListValue& GpuDataManager::log_messages() const { |
| 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 138 return log_messages_; | 137 return log_messages_; |
| 139 } | 138 } |
| 140 | 139 |
| 141 GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() { | 140 GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() { |
| 142 return gpu_feature_flags_; | 141 return gpu_feature_flags_; |
| 143 } | 142 } |
| 144 | 143 |
| 145 bool GpuDataManager::GpuAccessAllowed() { | 144 bool GpuDataManager::GpuAccessAllowed() { |
| 146 if (!allows_gpu_access_) | |
| 147 return false; | |
| 148 // We only need to block GPU process if more features are disallowed other | 145 // We only need to block GPU process if more features are disallowed other |
| 149 // than those in the preliminary gpu feature flags because the latter work | 146 // than those in the preliminary gpu feature flags because the latter work |
| 150 // through renderer commandline switches. | 147 // through renderer commandline switches. |
| 151 uint32 mask = (~(preliminary_gpu_feature_flags_.flags())); | 148 uint32 mask = (~(preliminary_gpu_feature_flags_.flags())); |
| 152 return (gpu_feature_flags_.flags() & mask) == 0; | 149 return (gpu_feature_flags_.flags() & mask) == 0; |
| 153 } | 150 } |
| 154 | 151 |
| 155 void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) { | 152 void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) { |
| 156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 157 gpu_info_update_callbacks_.insert(callback); | 154 gpu_info_update_callbacks_.insert(callback); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 297 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 301 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || | 298 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || |
| 302 browser_command_line.GetSwitchValueASCII( | 299 browser_command_line.GetSwitchValueASCII( |
| 303 switches::kUseGL) == gfx::kGLImplementationOSMesaName) | 300 switches::kUseGL) == gfx::kGLImplementationOSMesaName) |
| 304 return NULL; | 301 return NULL; |
| 305 // No need to return an empty blacklist. | 302 // No need to return an empty blacklist. |
| 306 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) | 303 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) |
| 307 return NULL; | 304 return NULL; |
| 308 return gpu_blacklist_.get(); | 305 return gpu_blacklist_.get(); |
| 309 } | 306 } |
| OLD | NEW |