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 "base/worker_pool.h" | |
12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
13 #include "chrome/common/child_process.h" | 14 #include "chrome/common/child_process.h" |
14 #include "chrome/common/child_process_logging.h" | 15 #include "chrome/common/child_process_logging.h" |
15 #include "chrome/common/gpu_messages.h" | 16 #include "chrome/common/gpu_messages.h" |
16 #include "chrome/gpu/gpu_info_collector.h" | 17 #include "chrome/gpu/gpu_info_collector.h" |
17 #include "ipc/ipc_channel_handle.h" | 18 #include "ipc/ipc_channel_handle.h" |
18 | 19 |
20 #if defined(OS_WIN) | |
21 #include "app/win_util.h" | |
22 #endif | |
23 | |
19 #if defined(TOOLKIT_USES_GTK) | 24 #if defined(TOOLKIT_USES_GTK) |
20 #include <gtk/gtk.h> | 25 #include <gtk/gtk.h> |
21 #include "app/x11_util.h" | 26 #include "app/x11_util.h" |
22 #include "gfx/gtk_util.h" | 27 #include "gfx/gtk_util.h" |
23 #endif | 28 #endif |
24 | 29 |
25 GpuThread::GpuThread() { | 30 GpuThread::GpuThread() { |
26 #if defined(OS_LINUX) | 31 #if defined(OS_LINUX) |
27 { | 32 { |
28 // The X11 port of the command buffer code assumes it can access the X | 33 // The X11 port of the command buffer code assumes it can access the X |
29 // display via the macro GDK_DISPLAY(), which implies that Gtk has been | 34 // display via the macro GDK_DISPLAY(), which implies that Gtk has been |
30 // initialized. This code was taken from PluginThread. TODO(kbr): | 35 // initialized. This code was taken from PluginThread. TODO(kbr): |
31 // rethink whether initializing Gtk is really necessary or whether we | 36 // rethink whether initializing Gtk is really necessary or whether we |
32 // should just send a raw display connection down to the GPUProcessor. | 37 // should just send a raw display connection down to the GPUProcessor. |
33 g_thread_init(NULL); | 38 g_thread_init(NULL); |
34 gfx::GtkInitFromCommandLine(*CommandLine::ForCurrentProcess()); | 39 gfx::GtkInitFromCommandLine(*CommandLine::ForCurrentProcess()); |
35 x11_util::SetDefaultX11ErrorHandlers(); | 40 x11_util::SetDefaultX11ErrorHandlers(); |
36 } | 41 } |
37 #endif | 42 #endif |
38 } | 43 } |
39 | 44 |
40 GpuThread::~GpuThread() { | 45 GpuThread::~GpuThread() { |
41 } | 46 } |
42 | 47 |
43 void GpuThread::Init(const base::Time& process_start_time) { | 48 void GpuThread::Init(const base::Time& process_start_time) { |
44 gpu_info_collector::CollectGraphicsInfo(&gpu_info_); | 49 gpu_info_collector::CollectGraphicsInfo(&gpu_info_); |
45 child_process_logging::SetGpuInfo(gpu_info_); | 50 child_process_logging::SetGpuInfo(gpu_info_); |
46 | 51 |
52 #if defined(OS_WIN) | |
53 // Asynchronously collect the DirectX diagnostics because this can take a | |
54 // couple of seconds. | |
55 if (!WorkerPool::PostTask( | |
56 FROM_HERE, | |
57 NewRunnableFunction(&GpuThread::CollectDxDiagnostics, | |
58 this), | |
Ken Russell (switch to Gerrit)
2010/11/13 02:34:45
This line break makes this harder to read.
apatrick_chromium
2010/11/15 21:46:25
Done.
| |
59 true)) { | |
Ken Russell (switch to Gerrit)
2010/11/13 02:34:45
CollectDxDiagnostics uses CoCreateInstance. Do we
apatrick_chromium
2010/11/15 21:46:25
That's what win_util::ScopedCOMInitializer in GpuT
| |
60 // Flag GPU info as complete if the DirectX diagnostics cannot be collected. | |
61 gpu_info_.SetProgress(GPUInfo::kComplete); | |
62 } | |
63 #endif | |
64 | |
47 // Record initialization only after collecting the GPU info because that can | 65 // Record initialization only after collecting the GPU info because that can |
48 // take a significant amount of time. | 66 // take a significant amount of time. |
49 gpu_info_.SetInitializationTime(base::Time::Now() - process_start_time); | 67 gpu_info_.SetInitializationTime(base::Time::Now() - process_start_time); |
50 } | 68 } |
51 | 69 |
52 void GpuThread::RemoveChannel(int renderer_id) { | 70 void GpuThread::RemoveChannel(int renderer_id) { |
53 gpu_channels_.erase(renderer_id); | 71 gpu_channels_.erase(renderer_id); |
54 } | 72 } |
55 | 73 |
56 void GpuThread::OnControlMessageReceived(const IPC::Message& msg) { | 74 void GpuThread::OnControlMessageReceived(const IPC::Message& msg) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 void GpuThread::OnCrash() { | 129 void GpuThread::OnCrash() { |
112 // Good bye, cruel world. | 130 // Good bye, cruel world. |
113 volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL; | 131 volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL; |
114 *it_s_the_end_of_the_world_as_we_know_it = 0xdead; | 132 *it_s_the_end_of_the_world_as_we_know_it = 0xdead; |
115 } | 133 } |
116 | 134 |
117 void GpuThread::OnHang() { | 135 void GpuThread::OnHang() { |
118 for (;;) | 136 for (;;) |
119 PlatformThread::Sleep(1000); | 137 PlatformThread::Sleep(1000); |
120 } | 138 } |
139 | |
140 #if defined(OS_WIN) | |
141 | |
142 // Runs on a worker thread. The GpuThread never terminates voluntarily so it is | |
143 // safe to assume that its message loop is valid. | |
144 void GpuThread::CollectDxDiagnostics(GpuThread* thread) { | |
145 win_util::ScopedCOMInitializer com_initializer; | |
146 | |
147 DxDiagNode node; | |
148 gpu_info_collector::GetDxDiagnostics(&node); | |
149 | |
150 thread->message_loop()->PostTask( | |
151 FROM_HERE, | |
152 NewRunnableFunction(&GpuThread::SetDxDiagnostics, | |
153 thread, | |
154 node)); | |
Ken Russell (switch to Gerrit)
2010/11/13 02:34:45
thread and node could be on the previous line.
apatrick_chromium
2010/11/15 21:46:25
Done.
| |
155 } | |
156 | |
157 // Runs on the GPU thread. | |
158 void GpuThread::SetDxDiagnostics(GpuThread* thread, | |
159 const DxDiagNode& node) { | |
Ken Russell (switch to Gerrit)
2010/11/13 02:34:45
Formatting is off.
apatrick_chromium
2010/11/15 21:46:25
Done.
| |
160 thread->gpu_info_.SetDxDiagnostics(node); | |
161 thread->gpu_info_.SetProgress(GPUInfo::kComplete); | |
162 } | |
163 | |
164 #endif | |
OLD | NEW |