Commit 5b51f339 authored by backer@chromium.org's avatar backer@chromium.org

The GPU process cannot be placed on a UI thread in --single-process mode...

The GPU process cannot be placed on a UI thread in --single-process mode because glib is not thread safe. This patch moves it onto a IO thread instead.

Connections to the X server are not thread safe. I've made changes so that each thread gets it's own connection.

Finally, GpuHostMsg_GetViewXID needed to be needed to be sent from the thread added to GpuChannel instead of ChildThread::current().

BUG=69674
TEST=try --single-process with --enable-accelerated-layers on http://webkit.org/blog/386/3d-transforms/

Review URL: http://codereview.chromium.org/6340004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71655 0039d316-1c4b-4281-b951-d872f2087c98
parent b160d7ed
...@@ -4,11 +4,14 @@ ...@@ -4,11 +4,14 @@
#include <EGL/egl.h> #include <EGL/egl.h>
#include "build/build_config.h"
#if defined(OS_LINUX) #if defined(OS_LINUX)
#include "app/x11_util.h" extern "C" {
#include <X11/Xlib.h>
}
#define EGL_HAS_PBUFFERS 1 #define EGL_HAS_PBUFFERS 1
#endif #endif
#include "build/build_config.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/scoped_ptr.h" #include "base/scoped_ptr.h"
#include "app/gfx/gl/gl_bindings.h" #include "app/gfx/gl/gl_bindings.h"
...@@ -80,7 +83,7 @@ bool BaseEGLContext::InitializeOneOff() { ...@@ -80,7 +83,7 @@ bool BaseEGLContext::InitializeOneOff() {
return true; return true;
#ifdef OS_LINUX #ifdef OS_LINUX
EGLNativeDisplayType native_display = x11_util::GetXDisplay(); EGLNativeDisplayType native_display = XOpenDisplay(NULL);
#else #else
EGLNativeDisplayType native_display = EGL_DEFAULT_DISPLAY; EGLNativeDisplayType native_display = EGL_DEFAULT_DISPLAY;
#endif #endif
......
...@@ -28,16 +28,14 @@ Display* GetXDisplayHelper() { ...@@ -28,16 +28,14 @@ Display* GetXDisplayHelper() {
static Display* display = NULL; static Display* display = NULL;
if (!display) { if (!display) {
if (x11_util::XDisplayExists()) { display = XOpenDisplay(NULL);
display = x11_util::GetXDisplay(); CHECK(display);
} else {
display = XOpenDisplay(NULL);
}
} }
return display; return display;
} }
} } // namespace
namespace gfx { namespace gfx {
......
...@@ -574,26 +574,23 @@ bool GpuProcessHost::CanLaunchGpuProcess() const { ...@@ -574,26 +574,23 @@ bool GpuProcessHost::CanLaunchGpuProcess() const {
bool GpuProcessHost::LaunchGpuProcess() { bool GpuProcessHost::LaunchGpuProcess() {
const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
// TODO(apatrick): This cannot be a UI message pump on Linux because glib is
// not thread safe. Changing this to an IO message pump does not completely
// resolve the problem, most likely because we're sharing a connection to the
// X server with the browser.
#if !defined(OS_LINUX)
// If the single-process switch is present, just launch the GPU service in a // If the single-process switch is present, just launch the GPU service in a
// new thread in the browser process. // new thread in the browser process.
if (browser_command_line.HasSwitch(switches::kSingleProcess)) { if (browser_command_line.HasSwitch(switches::kSingleProcess)) {
GpuMainThread* thread = new GpuMainThread(channel_id()); GpuMainThread* thread = new GpuMainThread(channel_id());
base::Thread::Options options; base::Thread::Options options;
#if defined(OS_LINUX)
options.message_loop_type = MessageLoop::TYPE_IO;
#else
options.message_loop_type = MessageLoop::TYPE_UI; options.message_loop_type = MessageLoop::TYPE_UI;
#endif
if (!thread->StartWithOptions(options)) if (!thread->StartWithOptions(options))
return false; return false;
return true; return true;
} }
#endif
CommandLine::StringType gpu_launcher = CommandLine::StringType gpu_launcher =
browser_command_line.GetSwitchValueNative(switches::kGpuLauncher); browser_command_line.GetSwitchValueNative(switches::kGpuLauncher);
......
...@@ -141,13 +141,8 @@ void GpuChannel::OnCreateViewCommandBuffer( ...@@ -141,13 +141,8 @@ void GpuChannel::OnCreateViewCommandBuffer(
// "render target" the GpuCommandBufferStub targets. // "render target" the GpuCommandBufferStub targets.
handle = gfx::NativeViewFromId(view_id); handle = gfx::NativeViewFromId(view_id);
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
ChildThread* gpu_thread = ChildThread::current();
// Ask the browser for the view's XID. // Ask the browser for the view's XID.
// TODO(piman): This assumes that it doesn't change. It can change however gpu_thread_->Send(new GpuHostMsg_GetViewXID(view_id, &handle));
// when tearing off tabs. This needs a fix in the browser UI code. A possible
// alternative would be to add a socket/plug pair like with plugins but that
// has issues with events and focus.
gpu_thread->Send(new GpuHostMsg_GetViewXID(view_id, &handle));
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
// On Mac OS X we currently pass a (fake) PluginWindowHandle for the // On Mac OS X we currently pass a (fake) PluginWindowHandle for the
// NativeViewId. We could allocate fake NativeViewIds on the browser // NativeViewId. We could allocate fake NativeViewIds on the browser
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment