diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-06 19:59:53 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-06 19:59:53 +0000 |
commit | eae61a6fc6e0e68b3da1d68b50b1f0c359682cc1 (patch) | |
tree | ec63565f0a3022359400e6189e5bd118f6647bc4 /gfx/gtk_native_view_id_manager.h | |
parent | cbe4cb648cd71ac0dab89050f75eff44530d1894 (diff) | |
download | chromium_src-eae61a6fc6e0e68b3da1d68b50b1f0c359682cc1.zip chromium_src-eae61a6fc6e0e68b3da1d68b50b1f0c359682cc1.tar.gz chromium_src-eae61a6fc6e0e68b3da1d68b50b1f0c359682cc1.tar.bz2 |
Create an X window overlay with static ID for GL contexts.
This code creates an X window that overlays where tab contents are drawn. The handle associated with this window never changes (unlike the X window associated with a GTK widget that is created and destroyed whenever the widget is realized and unrealized respectively). This is helpful when creating a GL context associated with an X window. Also, having a floating overlay allows us to handle detaching GPU accelerated tabs.
This code seems to have uncovered a race condition within the GPU process. When a tab that uses accelerated compositing is detached (e.g. http://webkit.org/blog/386/3d-transforms/), the tab contents often don't get displayed even though the tab is redrawn. A slight delay of about 100ms in the GPU process on the call to glXSwapBuffers (in gl_context_linux.cc) fixes this. To witness that GL can draw to the overlay after delay, try it with a tab with constant animation (e.g. http://webkit.org/blog-files/3d-transforms/poster-circle.html).
I've written a bare bones test (about 150 lines of C) of the overlay technique, and it requires no such delay b/w reparenting the glXSwapBuffers. I've also confirmed that there is no synchronization issues w.r.t. the X server between my patch and GL draw commands. I propose filing a new bug for the race, if this patch gets accepted.
BUG=53345,56419
TEST=Open two tabs, one with GPU rendered content (http://webkit.org/blog/386/3d-transforms/). Detach the tab with GPU rendered content. GPU process shouldn't crash.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=61561
Review URL: http://codereview.chromium.org/3509004
Patch from Jonathan Backer <backer@google.com>.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61695 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx/gtk_native_view_id_manager.h')
-rw-r--r-- | gfx/gtk_native_view_id_manager.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/gfx/gtk_native_view_id_manager.h b/gfx/gtk_native_view_id_manager.h index 0a90e2f..439d843 100644 --- a/gfx/gtk_native_view_id_manager.h +++ b/gfx/gtk_native_view_id_manager.h @@ -6,6 +6,7 @@ #define GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_ #pragma once +#include <gtk/gtk.h> #include <map> #include "base/singleton.h" @@ -59,10 +60,27 @@ class GtkNativeViewManager { // |*xid| is set to 0. bool GetXIDForId(XID* xid, gfx::NativeViewId id); + // Generate an XID that doesn't change. + // + // The GPU process assumes that the XID associated with a GL context + // does not change. To maintain this invariant we create and overlay + // whose XID is static. This requires reparenting as the underlying + // window comes and goes. It incurs a bit of overhead, so a permanent + // XID must be requested. + // + // Must be called from the UI thread so that the widget that we + // overlay does not change while we construct the overlay. + // + // xid: (output) the resulting X window + // id: a value previously returned from GetIdForWidget + // returns: true if |id| is a valid id, false otherwise. + bool GetPermanentXIDForId(XID* xid, gfx::NativeViewId id); + // These are actually private functions, but need to be called from statics. void OnRealize(gfx::NativeView widget); void OnUnrealize(gfx::NativeView widget); void OnDestroy(gfx::NativeView widget); + void OnSizeAllocate(gfx::NativeView widget, GtkAllocation *alloc); Lock& unrealize_lock() { return unrealize_lock_; } @@ -73,11 +91,11 @@ class GtkNativeViewManager { friend struct DefaultSingletonTraits<GtkNativeViewManager>; struct NativeViewInfo { - NativeViewInfo() - : x_window_id(0) { - } - + NativeViewInfo() : x_window_id(0), permanent_window_id(0) { } + // XID associated with GTK widget. XID x_window_id; + // Permanent overlay (0 if not requested yet). + XID permanent_window_id; }; gfx::NativeViewId GetWidgetId(gfx::NativeView id); |