| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers | 93 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers |
| 94 // here. This is so the reply can be delayed if the scheduler is unscheduled. | 94 // here. This is so the reply can be delayed if the scheduler is unscheduled. |
| 95 bool handled = true; | 95 bool handled = true; |
| 96 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) | 96 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) |
| 97 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, | 97 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, |
| 98 OnInitialize); | 98 OnInitialize); |
| 99 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer, | 99 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer, |
| 100 OnSetGetBuffer); | 100 OnSetGetBuffer); |
| 101 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetSharedStateBuffer, |
| 102 OnSetSharedStateBuffer); |
| 101 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent, | 103 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent, |
| 102 OnSetParent); | 104 OnSetParent); |
| 103 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState); | 105 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState); |
| 104 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetStateFast, | 106 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetStateFast, |
| 105 OnGetStateFast); | 107 OnGetStateFast); |
| 106 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); | 108 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); |
| 107 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); | 109 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); |
| 108 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateTransferBuffer, | 110 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateTransferBuffer, |
| 109 OnCreateTransferBuffer); | 111 OnCreateTransferBuffer); |
| 110 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_RegisterTransferBuffer, | 112 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_RegisterTransferBuffer, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 int32 shm_id, IPC::Message* reply_message) { | 289 int32 shm_id, IPC::Message* reply_message) { |
| 288 if (command_buffer_.get()) { | 290 if (command_buffer_.get()) { |
| 289 command_buffer_->SetGetBuffer(shm_id); | 291 command_buffer_->SetGetBuffer(shm_id); |
| 290 } else { | 292 } else { |
| 291 DLOG(ERROR) << "no command_buffer."; | 293 DLOG(ERROR) << "no command_buffer."; |
| 292 reply_message->set_reply_error(); | 294 reply_message->set_reply_error(); |
| 293 } | 295 } |
| 294 Send(reply_message); | 296 Send(reply_message); |
| 295 } | 297 } |
| 296 | 298 |
| 299 void GpuCommandBufferStub::OnSetSharedStateBuffer( |
| 300 int32 shm_id, IPC::Message* reply_message) { |
| 301 if (command_buffer_.get()) { |
| 302 command_buffer_->SetSharedStateBuffer(shm_id); |
| 303 } else { |
| 304 DLOG(ERROR) << "no command_buffer."; |
| 305 reply_message->set_reply_error(); |
| 306 } |
| 307 Send(reply_message); |
| 308 } |
| 309 |
| 297 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, | 310 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, |
| 298 uint32 parent_texture_id, | 311 uint32 parent_texture_id, |
| 299 IPC::Message* reply_message) { | 312 IPC::Message* reply_message) { |
| 300 GpuCommandBufferStub* parent_stub = NULL; | 313 GpuCommandBufferStub* parent_stub = NULL; |
| 301 if (parent_route_id != MSG_ROUTING_NONE) { | 314 if (parent_route_id != MSG_ROUTING_NONE) { |
| 302 parent_stub = channel_->LookupCommandBuffer(parent_route_id); | 315 parent_stub = channel_->LookupCommandBuffer(parent_route_id); |
| 303 } | 316 } |
| 304 | 317 |
| 305 bool result = true; | 318 bool result = true; |
| 306 if (scheduler_.get()) { | 319 if (scheduler_.get()) { |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 if (watchdog_) | 482 if (watchdog_) |
| 470 watchdog_->CheckArmed(); | 483 watchdog_->CheckArmed(); |
| 471 } | 484 } |
| 472 | 485 |
| 473 void GpuCommandBufferStub::ReportState() { | 486 void GpuCommandBufferStub::ReportState() { |
| 474 gpu::CommandBuffer::State state = command_buffer_->GetState(); | 487 gpu::CommandBuffer::State state = command_buffer_->GetState(); |
| 475 if (state.error == gpu::error::kLostContext && | 488 if (state.error == gpu::error::kLostContext && |
| 476 gfx::GLContext::LosesAllContextsOnContextLost()) { | 489 gfx::GLContext::LosesAllContextsOnContextLost()) { |
| 477 channel_->LoseAllContexts(); | 490 channel_->LoseAllContexts(); |
| 478 } else { | 491 } else { |
| 479 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state); | 492 command_buffer_->UpdateState(); |
| 480 msg->set_unblock(true); | |
| 481 Send(msg); | |
| 482 } | 493 } |
| 483 } | 494 } |
| 484 | 495 |
| 485 void GpuCommandBufferStub::OnCreateVideoDecoder( | 496 void GpuCommandBufferStub::OnCreateVideoDecoder( |
| 486 media::VideoDecodeAccelerator::Profile profile, | 497 media::VideoDecodeAccelerator::Profile profile, |
| 487 IPC::Message* reply_message) { | 498 IPC::Message* reply_message) { |
| 488 int decoder_route_id = channel_->GenerateRouteID(); | 499 int decoder_route_id = channel_->GenerateRouteID(); |
| 489 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams( | 500 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams( |
| 490 reply_message, decoder_route_id); | 501 reply_message, decoder_route_id); |
| 491 GpuVideoDecodeAccelerator* decoder = | 502 GpuVideoDecodeAccelerator* decoder = |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 return; | 570 return; |
| 560 if (allocation.has_frontbuffer && allocation.has_backbuffer) | 571 if (allocation.has_frontbuffer && allocation.has_backbuffer) |
| 561 surface_->SetVisibility(gfx::GLSurface::VISIBILITY_STATE_FOREGROUND); | 572 surface_->SetVisibility(gfx::GLSurface::VISIBILITY_STATE_FOREGROUND); |
| 562 else if (allocation.has_frontbuffer) | 573 else if (allocation.has_frontbuffer) |
| 563 surface_->SetVisibility(gfx::GLSurface::VISIBILITY_STATE_BACKGROUND); | 574 surface_->SetVisibility(gfx::GLSurface::VISIBILITY_STATE_BACKGROUND); |
| 564 else | 575 else |
| 565 surface_->SetVisibility(gfx::GLSurface::VISIBILITY_STATE_HIBERNATED); | 576 surface_->SetVisibility(gfx::GLSurface::VISIBILITY_STATE_HIBERNATED); |
| 566 } | 577 } |
| 567 | 578 |
| 568 #endif // defined(ENABLE_GPU) | 579 #endif // defined(ENABLE_GPU) |
| OLD | NEW |