diff options
author | kbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-13 22:55:50 +0000 |
---|---|---|
committer | kbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-13 22:55:50 +0000 |
commit | 276f89060fa4b38582dcd76ebdf9454bb7d42c8e (patch) | |
tree | 0ff1c47fed812c196ae491a6c7295164d557e813 /content/plugin | |
parent | 91701aec11f289e96ce92b588b858b26179cb89c (diff) | |
download | chromium_src-276f89060fa4b38582dcd76ebdf9454bb7d42c8e.zip chromium_src-276f89060fa4b38582dcd76ebdf9454bb7d42c8e.tar.gz chromium_src-276f89060fa4b38582dcd76ebdf9454bb7d42c8e.tar.bz2 |
Support dynamic switching between integrated and discrete GPUs on Mac OS X.
Change Chrome to allocate most OpenGL contexts with the
kCGLPFAAllowOfflineRenderers flag, and specify
NSSupportsAutomaticGraphicsSwitching in the Info.plist for the main
executable and helper apps. This keeps Chrome on the integrated GPU
except when using WebGL, accelerated 2D Canvas, Pepper 3D, and Core
Animation-based plugins (except Flash).
Chrome shares resources between OpenGL contexts in order to display WebGL
and other content in the compositor, and resource sharing doesn't work
between contexts allocated on different GPUs. Therefore, when the first
context for a given renderer requests the discrete GPU, the channel is
dropped and all contexts are reallocated on the discrete GPU. Similarly,
when the last context requesting the discrete GPU for a given renderer is
shut down, all contexts are dropped and reallocated on the integrated GPU.
Currently dynamic GPU switching is only supported on the latest Mac OS X
10.7 update and MacBook Pros with dual AMD / Intel GPUs, though this will
improve in future OS updates.
Tested with WebGL, CSS 3D, Flash and Unity3D content and observed desired
GPU switching behavior. Also added a layout test to WebKit under
https://bugs.webkit.org/show_bug.cgi?id=69776 which when run in Chrome
catches an assertion failure related to the destruction of contexts. The
intent is to add it as a UI layout test on the GPU bots.
BUG=88788
TEST=none
Review URL: http://codereview.chromium.org/8233027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105399 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/plugin')
-rw-r--r-- | content/plugin/webplugin_accelerated_surface_proxy_mac.cc | 5 | ||||
-rw-r--r-- | content/plugin/webplugin_accelerated_surface_proxy_mac.h | 6 | ||||
-rw-r--r-- | content/plugin/webplugin_proxy.cc | 6 | ||||
-rw-r--r-- | content/plugin/webplugin_proxy.h | 4 |
4 files changed, 14 insertions, 7 deletions
diff --git a/content/plugin/webplugin_accelerated_surface_proxy_mac.cc b/content/plugin/webplugin_accelerated_surface_proxy_mac.cc index 77f76c5..c00fa41 100644 --- a/content/plugin/webplugin_accelerated_surface_proxy_mac.cc +++ b/content/plugin/webplugin_accelerated_surface_proxy_mac.cc @@ -12,13 +12,14 @@ #include "ui/gfx/surface/transport_dib.h" WebPluginAcceleratedSurfaceProxy::WebPluginAcceleratedSurfaceProxy( - WebPluginProxy* plugin_proxy) + WebPluginProxy* plugin_proxy, + gfx::GpuPreference gpu_preference) : plugin_proxy_(plugin_proxy), window_handle_(NULL) { surface_ = new AcceleratedSurface; // It's possible for OpenGL to fail to initialze (e.g., if an incompatible // mode is forced via flags), so handle that gracefully. - if (!surface_->Initialize(NULL, true)) { + if (!surface_->Initialize(NULL, true, gpu_preference)) { delete surface_; surface_ = NULL; return; diff --git a/content/plugin/webplugin_accelerated_surface_proxy_mac.h b/content/plugin/webplugin_accelerated_surface_proxy_mac.h index b41239f..d3ad9ec 100644 --- a/content/plugin/webplugin_accelerated_surface_proxy_mac.h +++ b/content/plugin/webplugin_accelerated_surface_proxy_mac.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,6 +6,7 @@ #define CONTENT_PLUGIN_WEBPLUGIN_ACCELERATED_SURFACE_PROXY_H_ #pragma once +#include "ui/gfx/gl/gpu_preference.h" #include "webkit/plugins/npapi/webplugin_accelerated_surface_mac.h" class WebPluginProxy; @@ -18,7 +19,8 @@ class WebPluginAcceleratedSurfaceProxy public: // Creates a new WebPluginAcceleratedSurfaceProxy that uses plugin_proxy // to proxy calls. plugin_proxy must outlive this object. - WebPluginAcceleratedSurfaceProxy(WebPluginProxy* plugin_proxy); + WebPluginAcceleratedSurfaceProxy(WebPluginProxy* plugin_proxy, + gfx::GpuPreference gpu_preference); virtual ~WebPluginAcceleratedSurfaceProxy(); // WebPluginAcceleratedSurface implementation. diff --git a/content/plugin/webplugin_proxy.cc b/content/plugin/webplugin_proxy.cc index c60c136..643d445 100644 --- a/content/plugin/webplugin_proxy.cc +++ b/content/plugin/webplugin_proxy.cc @@ -673,9 +673,11 @@ void WebPluginProxy::BindFakePluginWindowHandle(bool opaque) { Send(new PluginHostMsg_BindFakePluginWindowHandle(route_id_, opaque)); } -WebPluginAcceleratedSurface* WebPluginProxy::GetAcceleratedSurface() { +WebPluginAcceleratedSurface* WebPluginProxy::GetAcceleratedSurface( + gfx::GpuPreference gpu_preference) { if (!accelerated_surface_.get()) - accelerated_surface_.reset(new WebPluginAcceleratedSurfaceProxy(this)); + accelerated_surface_.reset(new WebPluginAcceleratedSurfaceProxy( + this, gpu_preference)); return accelerated_surface_.get(); } diff --git a/content/plugin/webplugin_proxy.h b/content/plugin/webplugin_proxy.h index 100c767..dbc33b0 100644 --- a/content/plugin/webplugin_proxy.h +++ b/content/plugin/webplugin_proxy.h @@ -22,6 +22,7 @@ #if defined(USE_X11) #include "ui/base/x/x11_util.h" #endif +#include "ui/gfx/gl/gpu_preference.h" #include "ui/gfx/surface/transport_dib.h" #include "webkit/plugins/npapi/webplugin.h" @@ -135,7 +136,8 @@ class WebPluginProxy : public webkit::npapi::WebPlugin { virtual void BindFakePluginWindowHandle(bool opaque); - virtual webkit::npapi::WebPluginAcceleratedSurface* GetAcceleratedSurface(); + virtual webkit::npapi::WebPluginAcceleratedSurface* + GetAcceleratedSurface(gfx::GpuPreference gpu_preference); // Tell the browser (via the renderer) to invalidate because the // accelerated buffers have changed. |