From 28638b2ce5ec96bda25fd3583d7902dea0137fb2 Mon Sep 17 00:00:00 2001 From: "kbr@google.com" Date: Wed, 31 Mar 2010 17:55:57 +0000 Subject: Implemented offscreen rendering path for GLES2CmdDecoder on Linux. With these changes, WebGL runs in the sandbox on Linux. BUG=29120 TEST=ran WebGL demos in sandbox on Linux Review URL: http://codereview.chromium.org/1540004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43235 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/gpu/gpu_thread.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'chrome/gpu/gpu_thread.cc') diff --git a/chrome/gpu/gpu_thread.cc b/chrome/gpu/gpu_thread.cc index c2c190e..dcb16e9 100644 --- a/chrome/gpu/gpu_thread.cc +++ b/chrome/gpu/gpu_thread.cc @@ -5,6 +5,8 @@ #include "chrome/gpu/gpu_thread.h" #include "build/build_config.h" + +#include "base/command_line.h" #include "chrome/common/child_process.h" #include "chrome/common/gpu_messages.h" #include "chrome/gpu/gpu_config.h" @@ -18,10 +20,40 @@ #include // Must be last. #endif +#if defined(OS_LINUX) +#include +#endif + GpuThread::GpuThread() { #if defined(GPU_USE_GLX) display_ = ::XOpenDisplay(NULL); #endif +#if defined(OS_LINUX) + { + // The X11 port of the command buffer code assumes it can access the X + // display via the macro GDK_DISPLAY(), which implies that Gtk has been + // initialized. This code was taken from PluginThread. TODO(kbr): + // rethink whether initializing Gtk is really necessary or whether we + // should just send the display connection down to the GPUProcessor. + g_thread_init(NULL); + const std::vector& args = + CommandLine::ForCurrentProcess()->argv(); + int argc = args.size(); + scoped_array argv(new char *[argc + 1]); + for (size_t i = 0; i < args.size(); ++i) { + // TODO(piman@google.com): can gtk_init modify argv? Just being safe + // here. + argv[i] = strdup(args[i].c_str()); + } + argv[argc] = NULL; + char **argv_pointer = argv.get(); + + gtk_init(&argc, &argv_pointer); + for (size_t i = 0; i < args.size(); ++i) { + free(argv[i]); + } + } +#endif } GpuThread::~GpuThread() { -- cgit v1.1