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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { | 151 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { |
152 FastSetActiveURL(active_url_, active_url_hash_); | 152 FastSetActiveURL(active_url_, active_url_hash_); |
153 | 153 |
154 // Ensure the appropriate GL context is current before handling any IPC | 154 // Ensure the appropriate GL context is current before handling any IPC |
155 // messages directed at the command buffer. This ensures that the message | 155 // messages directed at the command buffer. This ensures that the message |
156 // handler can assume that the context is current (not necessary for | 156 // handler can assume that the context is current (not necessary for |
157 // Echo, RetireSyncPoint, or WaitSyncPoint). | 157 // Echo, RetireSyncPoint, or WaitSyncPoint). |
158 if (decoder_.get() && | 158 if (decoder_.get() && |
159 message.type() != GpuCommandBufferMsg_Echo::ID && | 159 message.type() != GpuCommandBufferMsg_Echo::ID && |
160 message.type() != GpuCommandBufferMsg_RetireSyncPoint::ID && | 160 message.type() != GpuCommandBufferMsg_RetireSyncPoint::ID && |
161 message.type() != GpuCommandBufferMsg_WaitSyncPoint::ID) { | 161 message.type() != GpuCommandBufferMsg_WaitSyncPoint::ID && |
| 162 message.type() != GpuCommandBufferMsg_SetLatencyInfo::ID) { |
162 if (!MakeCurrent()) | 163 if (!MakeCurrent()) |
163 return false; | 164 return false; |
164 } | 165 } |
165 | 166 |
166 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers | 167 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers |
167 // here. This is so the reply can be delayed if the scheduler is unscheduled. | 168 // here. This is so the reply can be delayed if the scheduler is unscheduled. |
168 bool handled = true; | 169 bool handled = true; |
169 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) | 170 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) |
170 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, | 171 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, |
171 OnInitialize); | 172 OnInitialize); |
172 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer, | 173 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer, |
173 OnSetGetBuffer); | 174 OnSetGetBuffer); |
174 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent, | 175 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent, |
175 OnSetParent); | 176 OnSetParent); |
176 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Echo, OnEcho); | 177 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Echo, OnEcho); |
177 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState); | 178 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState); |
178 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetStateFast, | 179 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetStateFast, |
179 OnGetStateFast); | 180 OnGetStateFast); |
180 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); | 181 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); |
| 182 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetLatencyInfo, OnSetLatencyInfo); |
181 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); | 183 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); |
182 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterTransferBuffer, | 184 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterTransferBuffer, |
183 OnRegisterTransferBuffer); | 185 OnRegisterTransferBuffer); |
184 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer, | 186 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer, |
185 OnDestroyTransferBuffer); | 187 OnDestroyTransferBuffer); |
186 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetTransferBuffer, | 188 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetTransferBuffer, |
187 OnGetTransferBuffer); | 189 OnGetTransferBuffer); |
188 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder, | 190 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder, |
189 OnCreateVideoDecoder) | 191 OnCreateVideoDecoder) |
190 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyVideoDecoder, | 192 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyVideoDecoder, |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true); | 519 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true); |
518 Send(reply_message); | 520 Send(reply_message); |
519 | 521 |
520 if (handle_.is_null() && !active_url_.is_empty()) { | 522 if (handle_.is_null() && !active_url_.is_empty()) { |
521 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 523 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
522 gpu_channel_manager->Send(new GpuHostMsg_DidCreateOffscreenContext( | 524 gpu_channel_manager->Send(new GpuHostMsg_DidCreateOffscreenContext( |
523 active_url_)); | 525 active_url_)); |
524 } | 526 } |
525 } | 527 } |
526 | 528 |
| 529 void GpuCommandBufferStub::OnSetLatencyInfo( |
| 530 const cc::LatencyInfo& latency_info) { |
| 531 if (!latency_info_callback_.is_null()) |
| 532 latency_info_callback_.Run(latency_info); |
| 533 } |
| 534 |
| 535 void GpuCommandBufferStub::SetLatencyInfoCallback( |
| 536 const LatencyInfoCallback& callback) { |
| 537 latency_info_callback_ = callback; |
| 538 } |
| 539 |
| 540 void GpuCommandBufferStub::SetLatencyInfo( |
| 541 const cc::LatencyInfo& latency_info) { |
| 542 Send(new GpuCommandBufferMsg_SetLatencyInfo(route_id_, latency_info)); |
| 543 } |
| 544 |
527 void GpuCommandBufferStub::OnSetGetBuffer(int32 shm_id, | 545 void GpuCommandBufferStub::OnSetGetBuffer(int32 shm_id, |
528 IPC::Message* reply_message) { | 546 IPC::Message* reply_message) { |
529 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSetGetBuffer"); | 547 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSetGetBuffer"); |
530 if (command_buffer_.get()) | 548 if (command_buffer_.get()) |
531 command_buffer_->SetGetBuffer(shm_id); | 549 command_buffer_->SetGetBuffer(shm_id); |
532 Send(reply_message); | 550 Send(reply_message); |
533 } | 551 } |
534 | 552 |
535 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, | 553 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, |
536 uint32 parent_texture_id, | 554 uint32 parent_texture_id, |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 // made current before calling methods on the surface. | 887 // made current before calling methods on the surface. |
870 if (!surface_ || !MakeCurrent()) | 888 if (!surface_ || !MakeCurrent()) |
871 return; | 889 return; |
872 surface_->SetFrontbufferAllocation( | 890 surface_->SetFrontbufferAllocation( |
873 allocation.browser_allocation.suggest_have_frontbuffer); | 891 allocation.browser_allocation.suggest_have_frontbuffer); |
874 } | 892 } |
875 | 893 |
876 } // namespace content | 894 } // namespace content |
877 | 895 |
878 #endif // defined(ENABLE_GPU) | 896 #endif // defined(ENABLE_GPU) |
OLD | NEW |