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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
6 | 6 |
7 #include "base/process_util.h" | 7 #include "base/process_util.h" |
8 #include "base/shared_memory.h" | 8 #include "base/shared_memory.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/common/child_thread.h" | 10 #include "chrome/common/child_thread.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { | 163 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { |
164 bool handled = true; | 164 bool handled = true; |
165 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) | 165 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) |
166 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Initialize, OnInitialize); | 166 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Initialize, OnInitialize); |
167 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetState, OnGetState); | 167 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetState, OnGetState); |
168 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncGetState, OnAsyncGetState); | 168 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncGetState, OnAsyncGetState); |
169 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Flush, OnFlush); | 169 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Flush, OnFlush); |
170 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); | 170 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); |
171 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateTransferBuffer, | 171 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateTransferBuffer, |
172 OnCreateTransferBuffer); | 172 OnCreateTransferBuffer); |
| 173 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterTransferBuffer, |
| 174 OnRegisterTransferBuffer); |
173 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer, | 175 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer, |
174 OnDestroyTransferBuffer); | 176 OnDestroyTransferBuffer); |
175 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetTransferBuffer, | 177 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetTransferBuffer, |
176 OnGetTransferBuffer); | 178 OnGetTransferBuffer); |
177 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ResizeOffscreenFrameBuffer, | 179 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ResizeOffscreenFrameBuffer, |
178 OnResizeOffscreenFrameBuffer); | 180 OnResizeOffscreenFrameBuffer); |
179 #if defined(OS_MACOSX) | 181 #if defined(OS_MACOSX) |
180 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetWindowSize, OnSetWindowSize); | 182 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetWindowSize, OnSetWindowSize); |
181 #endif // defined(OS_MACOSX) | 183 #endif // defined(OS_MACOSX) |
182 IPC_MESSAGE_UNHANDLED(handled = false) | 184 IPC_MESSAGE_UNHANDLED(handled = false) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 parent_processor, | 230 parent_processor, |
229 parent_texture_id_)) { | 231 parent_texture_id_)) { |
230 command_buffer_->SetPutOffsetChangeCallback( | 232 command_buffer_->SetPutOffsetChangeCallback( |
231 NewCallback(processor_.get(), | 233 NewCallback(processor_.get(), |
232 &gpu::GPUProcessor::ProcessCommands)); | 234 &gpu::GPUProcessor::ProcessCommands)); |
233 processor_->SetSwapBuffersCallback( | 235 processor_->SetSwapBuffersCallback( |
234 NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers)); | 236 NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers)); |
235 | 237 |
236 // Assume service is responsible for duplicating the handle from the | 238 // Assume service is responsible for duplicating the handle from the |
237 // calling process. | 239 // calling process. |
238 buffer.shared_memory->ShareToProcess(channel_->renderer_handle(), | 240 buffer.shared_memory->ShareToProcess(channel_->renderer_process(), |
239 ring_buffer); | 241 ring_buffer); |
240 #if defined(OS_MACOSX) | 242 #if defined(OS_MACOSX) |
241 if (handle_) { | 243 if (handle_) { |
242 // This context conceptually puts its output directly on the | 244 // This context conceptually puts its output directly on the |
243 // screen, rendered by the accelerated plugin layer in | 245 // screen, rendered by the accelerated plugin layer in |
244 // RenderWidgetHostViewMac. Set up a pathway to notify the | 246 // RenderWidgetHostViewMac. Set up a pathway to notify the |
245 // browser process when its contents change. | 247 // browser process when its contents change. |
246 processor_->SetSwapBuffersCallback( | 248 processor_->SetSwapBuffersCallback( |
247 NewCallback(this, | 249 NewCallback(this, |
248 &GpuCommandBufferStub::SwapBuffersCallback)); | 250 &GpuCommandBufferStub::SwapBuffersCallback)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 284 |
283 void GpuCommandBufferStub::OnAsyncFlush(int32 put_offset) { | 285 void GpuCommandBufferStub::OnAsyncFlush(int32 put_offset) { |
284 gpu::CommandBuffer::State state = command_buffer_->FlushSync(put_offset); | 286 gpu::CommandBuffer::State state = command_buffer_->FlushSync(put_offset); |
285 Send(new GpuCommandBufferMsg_UpdateState(route_id_, state)); | 287 Send(new GpuCommandBufferMsg_UpdateState(route_id_, state)); |
286 } | 288 } |
287 | 289 |
288 void GpuCommandBufferStub::OnCreateTransferBuffer(int32 size, int32* id) { | 290 void GpuCommandBufferStub::OnCreateTransferBuffer(int32 size, int32* id) { |
289 *id = command_buffer_->CreateTransferBuffer(size); | 291 *id = command_buffer_->CreateTransferBuffer(size); |
290 } | 292 } |
291 | 293 |
| 294 void GpuCommandBufferStub::OnRegisterTransferBuffer( |
| 295 base::SharedMemoryHandle transfer_buffer, |
| 296 size_t size, |
| 297 int32* id) { |
| 298 #if defined(OS_WIN) |
| 299 base::SharedMemory shared_memory(transfer_buffer, |
| 300 false, |
| 301 channel_->renderer_process()); |
| 302 #else |
| 303 base::SharedMemory shared_memory(transfer_buffer, false); |
| 304 #endif |
| 305 *id = command_buffer_->RegisterTransferBuffer(&shared_memory, size); |
| 306 } |
| 307 |
292 void GpuCommandBufferStub::OnDestroyTransferBuffer(int32 id) { | 308 void GpuCommandBufferStub::OnDestroyTransferBuffer(int32 id) { |
293 command_buffer_->DestroyTransferBuffer(id); | 309 command_buffer_->DestroyTransferBuffer(id); |
294 } | 310 } |
295 | 311 |
296 void GpuCommandBufferStub::OnGetTransferBuffer( | 312 void GpuCommandBufferStub::OnGetTransferBuffer( |
297 int32 id, | 313 int32 id, |
298 base::SharedMemoryHandle* transfer_buffer, | 314 base::SharedMemoryHandle* transfer_buffer, |
299 uint32* size) { | 315 uint32* size) { |
300 *transfer_buffer = base::SharedMemoryHandle(); | 316 *transfer_buffer = base::SharedMemoryHandle(); |
301 *size = 0; | 317 *size = 0; |
302 | 318 |
| 319 // Fail if the renderer process has not provided its process handle. |
| 320 if (!channel_->renderer_process()) |
| 321 return; |
| 322 |
303 Buffer buffer = command_buffer_->GetTransferBuffer(id); | 323 Buffer buffer = command_buffer_->GetTransferBuffer(id); |
304 if (buffer.shared_memory) { | 324 if (buffer.shared_memory) { |
305 // Assume service is responsible for duplicating the handle to the calling | 325 // Assume service is responsible for duplicating the handle to the calling |
306 // process. | 326 // process. |
307 buffer.shared_memory->ShareToProcess(channel_->renderer_handle(), | 327 buffer.shared_memory->ShareToProcess(channel_->renderer_process(), |
308 transfer_buffer); | 328 transfer_buffer); |
309 *size = buffer.shared_memory->created_size(); | 329 *size = buffer.size; |
310 } | 330 } |
311 } | 331 } |
312 | 332 |
313 void GpuCommandBufferStub::OnResizeOffscreenFrameBuffer(const gfx::Size& size) { | 333 void GpuCommandBufferStub::OnResizeOffscreenFrameBuffer(const gfx::Size& size) { |
314 processor_->ResizeOffscreenFrameBuffer(size); | 334 processor_->ResizeOffscreenFrameBuffer(size); |
315 } | 335 } |
316 | 336 |
317 void GpuCommandBufferStub::OnSwapBuffers() { | 337 void GpuCommandBufferStub::OnSwapBuffers() { |
318 Send(new GpuCommandBufferMsg_SwapBuffers(route_id_)); | 338 Send(new GpuCommandBufferMsg_SwapBuffers(route_id_)); |
319 } | 339 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 #elif defined(OS_WIN) | 394 #elif defined(OS_WIN) |
375 HWND hwnd = static_cast<HWND>(compositor_window_); | 395 HWND hwnd = static_cast<HWND>(compositor_window_); |
376 UINT swp_flags = SWP_NOSENDCHANGING | SWP_NOOWNERZORDER | SWP_NOCOPYBITS | | 396 UINT swp_flags = SWP_NOSENDCHANGING | SWP_NOOWNERZORDER | SWP_NOCOPYBITS | |
377 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE; | 397 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE; |
378 SetWindowPos(hwnd, NULL, 0, 0, size.width(), size.height(), swp_flags); | 398 SetWindowPos(hwnd, NULL, 0, 0, size.width(), size.height(), swp_flags); |
379 #endif // defined(OS_LINUX) | 399 #endif // defined(OS_LINUX) |
380 } | 400 } |
381 } | 401 } |
382 | 402 |
383 #endif // defined(ENABLE_GPU) | 403 #endif // defined(ENABLE_GPU) |
OLD | NEW |