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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { | 154 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { |
155 FastSetActiveURL(active_url_, active_url_hash_); | 155 FastSetActiveURL(active_url_, active_url_hash_); |
156 | 156 |
157 // Ensure the appropriate GL context is current before handling any IPC | 157 // Ensure the appropriate GL context is current before handling any IPC |
158 // messages directed at the command buffer. This ensures that the message | 158 // messages directed at the command buffer. This ensures that the message |
159 // handler can assume that the context is current (not necessary for | 159 // handler can assume that the context is current (not necessary for |
160 // Echo, RetireSyncPoint, or WaitSyncPoint). | 160 // Echo, RetireSyncPoint, or WaitSyncPoint). |
161 if (decoder_.get() && | 161 if (decoder_.get() && |
162 message.type() != GpuCommandBufferMsg_Echo::ID && | 162 message.type() != GpuCommandBufferMsg_Echo::ID && |
163 message.type() != GpuCommandBufferMsg_RetireSyncPoint::ID && | 163 message.type() != GpuCommandBufferMsg_RetireSyncPoint::ID && |
164 message.type() != GpuCommandBufferMsg_WaitSyncPoint::ID) { | 164 message.type() != GpuCommandBufferMsg_WaitSyncPoint::ID && |
| 165 message.type() != GpuCommandBufferMsg_SetLatencyInfo::ID) { |
165 if (!MakeCurrent()) | 166 if (!MakeCurrent()) |
166 return false; | 167 return false; |
167 } | 168 } |
168 | 169 |
169 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers | 170 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers |
170 // here. This is so the reply can be delayed if the scheduler is unscheduled. | 171 // here. This is so the reply can be delayed if the scheduler is unscheduled. |
171 bool handled = true; | 172 bool handled = true; |
172 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) | 173 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) |
173 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, | 174 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, |
174 OnInitialize); | 175 OnInitialize); |
175 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer, | 176 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer, |
176 OnSetGetBuffer); | 177 OnSetGetBuffer); |
177 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetSharedStateBuffer, | 178 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetSharedStateBuffer, |
178 OnSetSharedStateBuffer); | 179 OnSetSharedStateBuffer); |
179 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent, | 180 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent, |
180 OnSetParent); | 181 OnSetParent); |
181 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Echo, OnEcho); | 182 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Echo, OnEcho); |
182 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState); | 183 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState); |
183 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetStateFast, | 184 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetStateFast, |
184 OnGetStateFast); | 185 OnGetStateFast); |
185 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); | 186 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); |
| 187 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetLatencyInfo, OnSetLatencyInfo); |
186 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); | 188 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); |
187 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateTransferBuffer, | 189 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateTransferBuffer, |
188 OnCreateTransferBuffer); | 190 OnCreateTransferBuffer); |
189 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_RegisterTransferBuffer, | 191 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_RegisterTransferBuffer, |
190 OnRegisterTransferBuffer); | 192 OnRegisterTransferBuffer); |
191 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_DestroyTransferBuffer, | 193 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_DestroyTransferBuffer, |
192 OnDestroyTransferBuffer); | 194 OnDestroyTransferBuffer); |
193 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetTransferBuffer, | 195 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetTransferBuffer, |
194 OnGetTransferBuffer); | 196 OnGetTransferBuffer); |
195 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder, | 197 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder, |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true); | 518 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true); |
517 Send(reply_message); | 519 Send(reply_message); |
518 | 520 |
519 if (handle_.is_null() && !active_url_.is_empty()) { | 521 if (handle_.is_null() && !active_url_.is_empty()) { |
520 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 522 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
521 gpu_channel_manager->Send(new GpuHostMsg_DidCreateOffscreenContext( | 523 gpu_channel_manager->Send(new GpuHostMsg_DidCreateOffscreenContext( |
522 active_url_)); | 524 active_url_)); |
523 } | 525 } |
524 } | 526 } |
525 | 527 |
| 528 void GpuCommandBufferStub::OnSetLatencyInfo( |
| 529 const WebKit::WebLatencyInfoImpl& latency_info) { |
| 530 if (!latency_info_callback_.is_null()) |
| 531 latency_info_callback_.Run(latency_info); |
| 532 } |
| 533 |
| 534 void GpuCommandBufferStub::SetLatencyInfoCallback( |
| 535 const LatencyInfoCallback& callback) { |
| 536 latency_info_callback_ = callback; |
| 537 } |
| 538 |
| 539 void GpuCommandBufferStub::SetLatencyInfo( |
| 540 const WebKit::WebLatencyInfoImpl& latency_info) { |
| 541 Send(new GpuCommandBufferMsg_SetLatencyInfo(route_id_, latency_info)); |
| 542 } |
| 543 |
526 void GpuCommandBufferStub::OnSetGetBuffer( | 544 void GpuCommandBufferStub::OnSetGetBuffer( |
527 int32 shm_id, IPC::Message* reply_message) { | 545 int32 shm_id, IPC::Message* reply_message) { |
528 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSetGetBuffer"); | 546 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSetGetBuffer"); |
529 if (command_buffer_.get()) { | 547 if (command_buffer_.get()) { |
530 command_buffer_->SetGetBuffer(shm_id); | 548 command_buffer_->SetGetBuffer(shm_id); |
531 } else { | 549 } else { |
532 DLOG(ERROR) << "no command_buffer."; | 550 DLOG(ERROR) << "no command_buffer."; |
533 reply_message->set_reply_error(); | 551 reply_message->set_reply_error(); |
534 } | 552 } |
535 Send(reply_message); | 553 Send(reply_message); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 // made current before calling methods on the surface. | 933 // made current before calling methods on the surface. |
916 if (!surface_ || !MakeCurrent()) | 934 if (!surface_ || !MakeCurrent()) |
917 return; | 935 return; |
918 surface_->SetFrontbufferAllocation( | 936 surface_->SetFrontbufferAllocation( |
919 allocation.browser_allocation.suggest_have_frontbuffer); | 937 allocation.browser_allocation.suggest_have_frontbuffer); |
920 } | 938 } |
921 | 939 |
922 } // namespace content | 940 } // namespace content |
923 | 941 |
924 #endif // defined(ENABLE_GPU) | 942 #endif // defined(ENABLE_GPU) |
OLD | NEW |