OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/gpu/gpu_thread.h" | 5 #include "chrome/gpu/gpu_thread.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "app/gfx/gl/gl_context.h" | 10 #include "app/gfx/gl/gl_context.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "chrome/common/child_process.h" | 13 #include "chrome/common/child_process.h" |
14 #include "chrome/common/child_process_logging.h" | 14 #include "chrome/common/child_process_logging.h" |
15 #include "chrome/common/gpu_info.h" | 15 #include "chrome/common/gpu_info.h" |
16 #include "chrome/common/gpu_messages.h" | 16 #include "chrome/common/gpu_messages.h" |
17 #include "chrome/gpu/gpu_info_collector.h" | 17 #include "chrome/gpu/gpu_info_collector.h" |
| 18 #include "gfx/gtk_util.h" |
18 #include "ipc/ipc_channel_handle.h" | 19 #include "ipc/ipc_channel_handle.h" |
19 | 20 |
20 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
21 #include "chrome/gpu/gpu_view_win.h" | 22 #include "chrome/gpu/gpu_view_win.h" |
22 #elif defined(GPU_USE_GLX) | 23 #elif defined(GPU_USE_GLX) |
23 #include "chrome/gpu/gpu_backing_store_glx_context.h" | 24 #include "chrome/gpu/gpu_backing_store_glx_context.h" |
24 #include "chrome/gpu/gpu_view_x.h" | 25 #include "chrome/gpu/gpu_view_x.h" |
25 | 26 |
26 #include <X11/Xutil.h> // Must be last. | 27 #include <X11/Xutil.h> // Must be last. |
27 #endif | 28 #endif |
28 | 29 |
29 #if defined(OS_LINUX) | 30 #if defined(OS_LINUX) |
30 #include "app/x11_util.h" | 31 #include "app/x11_util.h" |
31 #include <gtk/gtk.h> | 32 #include <gtk/gtk.h> |
32 #endif | 33 #endif |
33 | 34 |
34 GpuThread::GpuThread() { | 35 GpuThread::GpuThread() { |
35 #if defined(GPU_USE_GLX) | 36 #if defined(GPU_USE_GLX) |
36 display_ = ::XOpenDisplay(NULL); | 37 display_ = ::XOpenDisplay(NULL); |
37 #endif | 38 #endif |
38 #if defined(OS_LINUX) | 39 #if defined(OS_LINUX) |
39 { | 40 { |
40 // The X11 port of the command buffer code assumes it can access the X | 41 // The X11 port of the command buffer code assumes it can access the X |
41 // display via the macro GDK_DISPLAY(), which implies that Gtk has been | 42 // display via the macro GDK_DISPLAY(), which implies that Gtk has been |
42 // initialized. This code was taken from PluginThread. TODO(kbr): | 43 // initialized. This code was taken from PluginThread. TODO(kbr): |
43 // rethink whether initializing Gtk is really necessary or whether we | 44 // rethink whether initializing Gtk is really necessary or whether we |
44 // should just send the display connection down to the GPUProcessor. | 45 // should just send the display connection down to the GPUProcessor. |
45 g_thread_init(NULL); | 46 g_thread_init(NULL); |
46 const std::vector<std::string>& args = | 47 gfx::GtkInitFromCommandLine(*CommandLine::ForCurrentProcess()); |
47 CommandLine::ForCurrentProcess()->argv(); | |
48 int argc = args.size(); | |
49 scoped_array<char *> argv(new char *[argc + 1]); | |
50 for (size_t i = 0; i < args.size(); ++i) { | |
51 // TODO(piman@google.com): can gtk_init modify argv? Just being safe | |
52 // here. | |
53 argv[i] = strdup(args[i].c_str()); | |
54 } | |
55 argv[argc] = NULL; | |
56 char **argv_pointer = argv.get(); | |
57 | |
58 gtk_init(&argc, &argv_pointer); | |
59 for (size_t i = 0; i < args.size(); ++i) { | |
60 free(argv[i]); | |
61 } | |
62 x11_util::SetDefaultX11ErrorHandlers(); | 48 x11_util::SetDefaultX11ErrorHandlers(); |
63 } | 49 } |
64 #endif | 50 #endif |
65 } | 51 } |
66 | 52 |
67 GpuThread::~GpuThread() { | 53 GpuThread::~GpuThread() { |
68 } | 54 } |
69 | 55 |
70 #if defined(GPU_USE_GLX) | 56 #if defined(GPU_USE_GLX) |
71 GpuBackingStoreGLXContext* GpuThread::GetGLXContext() { | 57 GpuBackingStoreGLXContext* GpuThread::GetGLXContext() { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 void GpuThread::OnCrash() { | 156 void GpuThread::OnCrash() { |
171 // Good bye, cruel world. | 157 // Good bye, cruel world. |
172 volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL; | 158 volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL; |
173 *it_s_the_end_of_the_world_as_we_know_it = 0xdead; | 159 *it_s_the_end_of_the_world_as_we_know_it = 0xdead; |
174 } | 160 } |
175 | 161 |
176 void GpuThread::OnHang() { | 162 void GpuThread::OnHang() { |
177 for (;;) | 163 for (;;) |
178 PlatformThread::Sleep(1000); | 164 PlatformThread::Sleep(1000); |
179 } | 165 } |
OLD | NEW |