| 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" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 | 99 |
| 100 void GpuThread::OnEstablishChannel(int renderer_id) { | 100 void GpuThread::OnEstablishChannel(int renderer_id) { |
| 101 scoped_refptr<GpuChannel> channel; | 101 scoped_refptr<GpuChannel> channel; |
| 102 IPC::ChannelHandle channel_handle; | 102 IPC::ChannelHandle channel_handle; |
| 103 GPUInfo gpu_info; | 103 GPUInfo gpu_info; |
| 104 | 104 |
| 105 // Fail to establish a channel if some implementation of GL cannot be | 105 // Fail to establish a channel if some implementation of GL cannot be |
| 106 // initialized. | 106 // initialized. |
| 107 if (gfx::GLContext::InitializeOneOff()) { | 107 if (gfx::GLContext::InitializeOneOff()) { |
| 108 // Fail to establish channel if GPU stats cannot be retreived. | 108 if (!gpu_info_collector::CollectGraphicsInfo(&gpu_info)) |
| 109 if (gpu_info_collector::CollectGraphicsInfo(&gpu_info)) { | 109 LOG(WARNING) << "Could not collect GPU info."; |
| 110 child_process_logging::SetGpuInfo(gpu_info); | |
| 111 GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); | |
| 112 if (iter == gpu_channels_.end()) { | |
| 113 channel = new GpuChannel(renderer_id); | |
| 114 } else { | |
| 115 channel = iter->second; | |
| 116 } | |
| 117 | 110 |
| 118 DCHECK(channel != NULL); | 111 child_process_logging::SetGpuInfo(gpu_info); |
| 112 GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); |
| 119 | 113 |
| 120 if (channel->Init()) { | 114 if (iter == gpu_channels_.end()) |
| 121 gpu_channels_[renderer_id] = channel; | 115 channel = new GpuChannel(renderer_id); |
| 122 } else { | 116 else |
| 123 channel = NULL; | 117 channel = iter->second; |
| 124 } | |
| 125 | 118 |
| 126 if (channel.get()) { | 119 DCHECK(channel != NULL); |
| 127 channel_handle.name = channel->GetChannelName(); | 120 |
| 121 if (channel->Init()) |
| 122 gpu_channels_[renderer_id] = channel; |
| 123 else |
| 124 channel = NULL; |
| 125 |
| 126 if (channel.get()) { |
| 127 channel_handle.name = channel->GetChannelName(); |
| 128 #if defined(OS_POSIX) | 128 #if defined(OS_POSIX) |
| 129 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so | 129 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so |
| 130 // that it gets closed after it has been sent. | 130 // that it gets closed after it has been sent. |
| 131 int renderer_fd = channel->DisownRendererFd(); | 131 int renderer_fd = channel->DisownRendererFd(); |
| 132 channel_handle.socket = base::FileDescriptor(renderer_fd, true); | 132 channel_handle.socket = base::FileDescriptor(renderer_fd, true); |
| 133 #endif | 133 #endif |
| 134 } | |
| 135 } | 134 } |
| 136 } | 135 } |
| 137 | 136 |
| 138 Send(new GpuHostMsg_ChannelEstablished(channel_handle, gpu_info)); | 137 Send(new GpuHostMsg_ChannelEstablished(channel_handle, gpu_info)); |
| 139 } | 138 } |
| 140 | 139 |
| 141 void GpuThread::OnSynchronize() { | 140 void GpuThread::OnSynchronize() { |
| 142 Send(new GpuHostMsg_SynchronizeReply()); | 141 Send(new GpuHostMsg_SynchronizeReply()); |
| 143 } | 142 } |
| 144 | 143 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 170 void GpuThread::OnCrash() { | 169 void GpuThread::OnCrash() { |
| 171 // Good bye, cruel world. | 170 // Good bye, cruel world. |
| 172 volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL; | 171 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; | 172 *it_s_the_end_of_the_world_as_we_know_it = 0xdead; |
| 174 } | 173 } |
| 175 | 174 |
| 176 void GpuThread::OnHang() { | 175 void GpuThread::OnHang() { |
| 177 for (;;) | 176 for (;;) |
| 178 PlatformThread::Sleep(1000); | 177 PlatformThread::Sleep(1000); |
| 179 } | 178 } |
| OLD | NEW |