| 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_channel.h" | 5 #include "chrome/gpu/gpu_channel.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 int GpuChannel::GenerateRouteID() { | 112 int GpuChannel::GenerateRouteID() { |
| 113 static int last_id = 0; | 113 static int last_id = 0; |
| 114 return ++last_id; | 114 return ++last_id; |
| 115 } | 115 } |
| 116 | 116 |
| 117 void GpuChannel::OnCreateViewCommandBuffer( | 117 void GpuChannel::OnCreateViewCommandBuffer( |
| 118 gfx::NativeViewId view_id, | 118 gfx::NativeViewId view_id, |
| 119 int32 render_view_id, | 119 int32 render_view_id, |
| 120 const GPUCreateCommandBufferConfig& init_params, | 120 const GPUCreateCommandBufferConfig& init_params, |
| 121 int32* route_id) { | 121 int32* route_id) { |
| 122 *route_id = 0; | 122 *route_id = MSG_ROUTING_NONE; |
| 123 | 123 |
| 124 #if defined(ENABLE_GPU) | 124 #if defined(ENABLE_GPU) |
| 125 | 125 |
| 126 gfx::PluginWindowHandle handle = gfx::kNullPluginWindow; | 126 gfx::PluginWindowHandle handle = gfx::kNullPluginWindow; |
| 127 #if defined(OS_WIN) | 127 #if defined(OS_WIN) |
| 128 gfx::NativeView view = gfx::NativeViewFromId(view_id); | 128 // TODO(apatrick): We don't actually need the window handle on the Windows |
| 129 | 129 // platform. At this point, it only indicates to the GpuCommandBufferStub |
| 130 // Check that the calling renderer is allowed to render to this window. | 130 // whether onscreen or offscreen rendering is requested. The window handle |
| 131 // TODO(apatrick): consider killing the renderer process rather than failing. | 131 // that will be rendered to is the child compositor window and that window |
| 132 int view_renderer_id = reinterpret_cast<int>( | 132 // handle is provided by the browser process. Looking at what we are doing on |
| 133 GetProp(view, chrome::kChromiumRendererIdProperty)); | 133 // this and other platforms, I think a redesign is in order here. Perhaps |
| 134 if (view_renderer_id != renderer_id_) | 134 // on all platforms the renderer just indicates whether it wants onscreen or |
| 135 return; | 135 // offscreen rendering and the browser provides whichever platform specific |
| 136 | 136 // "render target" the GpuCommandBufferStub targets. |
| 137 // Note, we don't actually render into the view HWND. Instead, inside | 137 handle = gfx::NativeViewFromId(view_id); |
| 138 // the GpuCommandBufferStub, we will create a child window within the view | |
| 139 // HWND into which we will render. | |
| 140 handle = view; | |
| 141 #elif defined(OS_LINUX) | 138 #elif defined(OS_LINUX) |
| 142 ChildThread* gpu_thread = ChildThread::current(); | 139 ChildThread* gpu_thread = ChildThread::current(); |
| 143 // Ask the browser for the view's XID. | 140 // Ask the browser for the view's XID. |
| 144 // TODO(piman): This assumes that it doesn't change. It can change however | 141 // TODO(piman): This assumes that it doesn't change. It can change however |
| 145 // when tearing off tabs. This needs a fix in the browser UI code. A possible | 142 // when tearing off tabs. This needs a fix in the browser UI code. A possible |
| 146 // alternative would be to add a socket/plug pair like with plugins but that | 143 // alternative would be to add a socket/plug pair like with plugins but that |
| 147 // has issues with events and focus. | 144 // has issues with events and focus. |
| 148 gpu_thread->Send(new GpuHostMsg_GetViewXID(view_id, &handle)); | 145 gpu_thread->Send(new GpuHostMsg_GetViewXID(view_id, &handle)); |
| 149 #elif defined(OS_MACOSX) | 146 #elif defined(OS_MACOSX) |
| 150 // On Mac OS X we currently pass a (fake) PluginWindowHandle for the | 147 // On Mac OS X we currently pass a (fake) PluginWindowHandle for the |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 parent_stub, | 184 parent_stub, |
| 188 size, | 185 size, |
| 189 init_params.allowed_extensions, | 186 init_params.allowed_extensions, |
| 190 init_params.attribs, | 187 init_params.attribs, |
| 191 parent_texture_id, | 188 parent_texture_id, |
| 192 *route_id, | 189 *route_id, |
| 193 0, 0)); | 190 0, 0)); |
| 194 router_.AddRoute(*route_id, stub.get()); | 191 router_.AddRoute(*route_id, stub.get()); |
| 195 stubs_.AddWithID(stub.release(), *route_id); | 192 stubs_.AddWithID(stub.release(), *route_id); |
| 196 #else | 193 #else |
| 197 *route_id = 0; | 194 *route_id = MSG_ROUTING_NONE; |
| 198 #endif | 195 #endif |
| 199 } | 196 } |
| 200 | 197 |
| 201 void GpuChannel::OnDestroyCommandBuffer(int32 route_id) { | 198 void GpuChannel::OnDestroyCommandBuffer(int32 route_id) { |
| 202 #if defined(ENABLE_GPU) | 199 #if defined(ENABLE_GPU) |
| 203 router_.RemoveRoute(route_id); | 200 router_.RemoveRoute(route_id); |
| 204 stubs_.Remove(route_id); | 201 stubs_.Remove(route_id); |
| 205 #endif | 202 #endif |
| 206 } | 203 } |
| 207 | 204 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 channel_name, IPC::Channel::MODE_SERVER, this, NULL, | 255 channel_name, IPC::Channel::MODE_SERVER, this, NULL, |
| 259 ChildProcess::current()->io_message_loop(), false, | 256 ChildProcess::current()->io_message_loop(), false, |
| 260 ChildProcess::current()->GetShutDownEvent())); | 257 ChildProcess::current()->GetShutDownEvent())); |
| 261 | 258 |
| 262 return true; | 259 return true; |
| 263 } | 260 } |
| 264 | 261 |
| 265 std::string GpuChannel::GetChannelName() { | 262 std::string GpuChannel::GetChannelName() { |
| 266 return StringPrintf("%d.r%d", base::GetCurrentProcId(), renderer_id_); | 263 return StringPrintf("%d.r%d", base::GetCurrentProcId(), renderer_id_); |
| 267 } | 264 } |
| OLD | NEW |