diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 21:10:17 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 21:10:17 +0000 |
commit | a5342268dbffa499e6e17e5bbda2bc2ab34aa8f2 (patch) | |
tree | 593d9e813fdf37fea603c30b76df1c0933d4ccdb /chrome | |
parent | da5b6de33c18e49a8c1f3fb3c05f779e07a2240d (diff) | |
download | chromium_src-a5342268dbffa499e6e17e5bbda2bc2ab34aa8f2.zip chromium_src-a5342268dbffa499e6e17e5bbda2bc2ab34aa8f2.tar.gz chromium_src-a5342268dbffa499e6e17e5bbda2bc2ab34aa8f2.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.
Review URL: http://codereview.chromium.org/3509004
Patch from Jonathan Backer <backer@google.com>.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61561 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/gpu_process_host.cc | 34 | ||||
-rw-r--r-- | chrome/browser/gpu_process_host.h | 2 |
2 files changed, 31 insertions, 5 deletions
diff --git a/chrome/browser/gpu_process_host.cc b/chrome/browser/gpu_process_host.cc index f4c6164..8e2242e 100644 --- a/chrome/browser/gpu_process_host.cc +++ b/chrome/browser/gpu_process_host.cc @@ -177,7 +177,7 @@ void GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, OnGraphicsInfoCollected) #if defined(OS_LINUX) - IPC_MESSAGE_HANDLER(GpuHostMsg_GetViewXID, OnGetViewXID) + IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_GetViewXID, OnGetViewXID) #elif defined(OS_MACOSX) IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, OnAcceleratedSurfaceSetIOSurface) @@ -210,12 +210,38 @@ void GpuProcessHost::OnGraphicsInfoCollected(const GPUInfo& gpu_info) { } #if defined(OS_LINUX) -void GpuProcessHost::OnGetViewXID(gfx::NativeViewId id, unsigned long* xid) { + +namespace { + +void SendDelayedReply(IPC::Message* reply_msg) { + GpuProcessHost::Get()->Send(reply_msg); +} + +void GetViewXIDDispatcher(gfx::NativeViewId id, IPC::Message* reply_msg) { + unsigned long xid; + GtkNativeViewManager* manager = Singleton<GtkNativeViewManager>::get(); - if (!manager->GetXIDForId(xid, id)) { + if (!manager->GetPermanentXIDForId(&xid, id)) { DLOG(ERROR) << "Can't find XID for view id " << id; - *xid = 0; + xid = 0; } + + GpuHostMsg_GetViewXID::WriteReplyParams(reply_msg, xid); + + // Have to reply from IO thread. + ChromeThread::PostTask( + ChromeThread::IO, FROM_HERE, + NewRunnableFunction(&SendDelayedReply, reply_msg)); +} + +} + +void GpuProcessHost::OnGetViewXID(gfx::NativeViewId id, + IPC::Message *reply_msg) { + // Have to request a permanent overlay from UI thread. + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableFunction(&GetViewXIDDispatcher, id, reply_msg)); } #elif defined(OS_MACOSX) diff --git a/chrome/browser/gpu_process_host.h b/chrome/browser/gpu_process_host.h index e4d4559..a5268ba 100644 --- a/chrome/browser/gpu_process_host.h +++ b/chrome/browser/gpu_process_host.h @@ -95,7 +95,7 @@ class GpuProcessHost : public BrowserChildProcessHost { void OnSynchronizeReply(); void OnGraphicsInfoCollected(const GPUInfo& gpu_info); #if defined(OS_LINUX) - void OnGetViewXID(gfx::NativeViewId id, unsigned long* xid); + void OnGetViewXID(gfx::NativeViewId id, IPC::Message* reply_msg); #elif defined(OS_MACOSX) void OnAcceleratedSurfaceSetIOSurface( const GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params& params); |