diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-05 02:54:42 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-05 02:54:42 +0000 |
commit | cb632c310910db456fbc3083fcad1fce0e1a2197 (patch) | |
tree | 73892688ceae64bf6b01f25c721a04f06e285a72 /chrome/plugin | |
parent | 5d682cb2177736c065b7ff271c6151c73fdc8caf (diff) | |
download | chromium_src-cb632c310910db456fbc3083fcad1fce0e1a2197.zip chromium_src-cb632c310910db456fbc3083fcad1fce0e1a2197.tar.gz chromium_src-cb632c310910db456fbc3083fcad1fce0e1a2197.tar.bz2 |
If SHM pixmaps support is available, for example, Intel drivers now support that
(http://cgit.freedesktop.org/xorg/driver/xf86-video-intel/commit/?id=4b7142baa0b3bf6f38843d06aadc579d8624cefc),
use SHM pixmaps support to accelerate windowless plugin painting.
Modify WindowlessPaint to directly use Xlib interfaces for SHM pixmaps support,
similarly to the way how backing_store_x handles different SHM support levels provided by X server.
BUG=50912
TEST=Open the page "http://disney.go.com/official-sites/demi-lovato/albums" using Chromium browser,
compare the CPU usage of browser and X server before and after the change, and confirm CPU usage
is reduced with this change (for example, on an Atom N450 Netbook with MeeGo 1.0 and Chromium browser
6.0.417.0 there's >30% CPU usage reduction, especially X server CPU usage is reduced by half).
Review URL: http://codereview.chromium.org/3052039
Patch from Yuqiang Xian <yuqiang.xian@intel.com>.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r-- | chrome/plugin/webplugin_proxy.cc | 49 | ||||
-rw-r--r-- | chrome/plugin/webplugin_proxy.h | 7 |
2 files changed, 56 insertions, 0 deletions
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index 66f65fc..5441dc8 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -32,6 +32,10 @@ #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" #include "webkit/glue/plugins/webplugin_delegate_impl.h" +#if defined(USE_X11) +#include "app/x11_util_internal.h" +#endif + using WebKit::WebBindings; using webkit_glue::WebPluginResourceClient; @@ -58,11 +62,36 @@ WebPluginProxy::WebPluginProxy( transparent_(false), host_render_view_routing_id_(host_render_view_routing_id), ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)) { +#if defined(USE_X11) + windowless_shm_pixmap_ = None; + use_shm_pixmap_ = false; + + // If the X server supports SHM pixmaps + // and the color depth and masks match, + // then consider using SHM pixmaps for windowless plugin painting. + Display* display = x11_util::GetXDisplay(); + if (x11_util::QuerySharedMemorySupport(display) == + x11_util::SHARED_MEMORY_PIXMAP && + x11_util::BitsPerPixelForPixmapDepth( + display, DefaultDepth(display, 0)) == 32) { + Visual* vis = DefaultVisual(display, 0); + + if (vis->red_mask == 0xff0000 && + vis->green_mask == 0xff00 && + vis->blue_mask == 0xff) + use_shm_pixmap_ = true; + } +#endif } WebPluginProxy::~WebPluginProxy() { if (cp_browsing_context_) GetContextMap().erase(cp_browsing_context_); + +#if defined(USE_X11) + if (windowless_shm_pixmap_ != None) + XFreePixmap(x11_util::GetXDisplay(), windowless_shm_pixmap_); +#endif } bool WebPluginProxy::Send(IPC::Message* msg) { @@ -567,6 +596,26 @@ void WebPluginProxy::SetWindowlessBuffer( } else { background_canvas_.reset(); } + + // If SHM pixmaps support is available, create a SHM pixmap and + // pass it to the delegate for windowless plugin painting. + if (delegate_->IsWindowless() && use_shm_pixmap_ && windowless_dib_.get()) { + Display* display = x11_util::GetXDisplay(); + XID root_window = x11_util::GetX11RootWindow(); + XShmSegmentInfo shminfo = {0}; + + if (windowless_shm_pixmap_ != None) + XFreePixmap(display, windowless_shm_pixmap_); + + shminfo.shmseg = windowless_dib_->MapToX(display); + // Create a shared memory pixmap based on the image buffer. + windowless_shm_pixmap_ = XShmCreatePixmap(display, root_window, + NULL, &shminfo, + width, height, + DefaultDepth(display, 0)); + + delegate_->SetWindowlessShmPixmap(windowless_shm_pixmap_); + } } #endif diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h index 1fb72c4..b390261 100644 --- a/chrome/plugin/webplugin_proxy.h +++ b/chrome/plugin/webplugin_proxy.h @@ -8,6 +8,9 @@ #include <string> +#if defined(USE_X11) +#include "app/x11_util.h" +#endif #include "app/surface/transport_dib.h" #include "base/hash_tables.h" #include "base/ref_counted.h" @@ -185,6 +188,10 @@ class WebPluginProxy : public webkit_glue::WebPlugin { #if defined(USE_X11) scoped_ptr<TransportDIB> windowless_dib_; scoped_ptr<TransportDIB> background_dib_; + // If we can use SHM pixmaps for windowless plugin painting or not. + bool use_shm_pixmap_; + // The SHM pixmap for windowless plugin painting. + XID windowless_shm_pixmap_; #endif #endif |