diff options
author | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-04 18:27:04 +0000 |
---|---|---|
committer | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-04 18:27:04 +0000 |
commit | 56403c2267df13e707af931a8aca476806404042 (patch) | |
tree | d2df874c1101b5781b874179f59121a4671fd0dd /content | |
parent | 9d97e4693192ec1985d52cba2fd94eee31189841 (diff) | |
download | chromium_src-56403c2267df13e707af931a8aca476806404042.zip chromium_src-56403c2267df13e707af931a8aca476806404042.tar.gz chromium_src-56403c2267df13e707af931a8aca476806404042.tar.bz2 |
Make about:gpu page reflects the current GPU in real time.
This is for Mac with dual GPUs, dynamic switching enabled.
BUG=
TEST=manually on the affected macs
Review URL: https://codereview.chromium.org/11039033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160170 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/gpu/gpu_data_manager_impl.cc | 32 | ||||
-rw-r--r-- | content/browser/gpu/gpu_data_manager_impl.h | 3 | ||||
-rw-r--r-- | content/gpu/gpu_child_thread.cc | 9 | ||||
-rw-r--r-- | content/gpu/gpu_info_collector.cc | 2 |
4 files changed, 40 insertions, 6 deletions
diff --git a/content/browser/gpu/gpu_data_manager_impl.cc b/content/browser/gpu/gpu_data_manager_impl.cc index 07a5953..41fafda 100644 --- a/content/browser/gpu/gpu_data_manager_impl.cc +++ b/content/browser/gpu/gpu_data_manager_impl.cc @@ -4,6 +4,10 @@ #include "content/browser/gpu/gpu_data_manager_impl.h" +#if defined(OS_MACOSX) +#include <ApplicationServices/ApplicationServices.h> +#endif // OS_MACOSX + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/command_line.h" @@ -56,6 +60,19 @@ std::string ProcessVersionString(const std::string& raw_string) { return version_string; } +#if defined(OS_MACOSX) +void DisplayReconfigCallback(CGDirectDisplayID display, + CGDisplayChangeSummaryFlags flags, + void* gpu_data_manager) { + if (flags & kCGDisplayAddFlag) { + GpuDataManagerImpl* manager = + reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); + DCHECK(manager); + manager->HandleGpuSwitch(); + } +} +#endif // OS_MACOSX + } // namespace anonymous // static @@ -92,6 +109,10 @@ GpuDataManagerImpl::GpuDataManagerImpl() if (option != content::GPU_SWITCHING_OPTION_UNKNOWN) gpu_switching_ = option; } + +#if defined(OS_MACOSX) + CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); +#endif // OS_MACOSX } void GpuDataManagerImpl::Initialize() { @@ -147,6 +168,9 @@ void GpuDataManagerImpl::InitializeImpl( } GpuDataManagerImpl::~GpuDataManagerImpl() { +#if defined(OS_MACOSX) + CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); +#endif } void GpuDataManagerImpl::RequestCompleteGpuInfoIfNeeded() { @@ -277,6 +301,14 @@ bool GpuDataManagerImpl::GpuAccessAllowed() const { return (gpu_feature_type_ & mask) == 0; } +void GpuDataManagerImpl::HandleGpuSwitch() { + if (complete_gpu_info_already_requested_) { + complete_gpu_info_already_requested_ = false; + gpu_info_.finalized = false; + RequestCompleteGpuInfoIfNeeded(); + } +} + void GpuDataManagerImpl::AddObserver(GpuDataManagerObserver* observer) { observer_list_->AddObserver(observer); } diff --git a/content/browser/gpu/gpu_data_manager_impl.h b/content/browser/gpu/gpu_data_manager_impl.h index 118fcb0..16b0399 100644 --- a/content/browser/gpu/gpu_data_manager_impl.h +++ b/content/browser/gpu/gpu_data_manager_impl.h @@ -79,6 +79,9 @@ class CONTENT_EXPORT GpuDataManagerImpl // crashes). void BlacklistCard(); + // Called when switching gpu. + void HandleGpuSwitch(); + #if defined(OS_WIN) // Is the GPU process using the accelerated surface to present, instead of // presenting by itself. diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc index bb69b45..c21b487a 100644 --- a/content/gpu/gpu_child_thread.cc +++ b/content/gpu/gpu_child_thread.cc @@ -180,11 +180,10 @@ void GpuChildThread::StopWatchdog() { } void GpuChildThread::OnCollectGraphicsInfo() { - if (!gpu_info_.finalized && - (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableGpuSandbox) || - CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) || - CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU))) { + CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kDisableGpuSandbox) || + command_line->ForCurrentProcess()->HasSwitch(switches::kSingleProcess) || + command_line->ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) { // GPU full info collection should only happen on un-sandboxed GPU process // or single process/in-process gpu mode. diff --git a/content/gpu/gpu_info_collector.cc b/content/gpu/gpu_info_collector.cc index 86ae2f5..14b1697 100644 --- a/content/gpu/gpu_info_collector.cc +++ b/content/gpu/gpu_info_collector.cc @@ -34,7 +34,7 @@ scoped_refptr<gfx::GLContext> InitializeGLContext(gfx::GLSurface* surface) { scoped_refptr<gfx::GLContext> context( gfx::GLContext::CreateGLContext(NULL, surface, - gfx::PreferDiscreteGpu)); + gfx::PreferIntegratedGpu)); if (!context.get()) { LOG(ERROR) << "gfx::GLContext::CreateGLContext failed"; return NULL; |