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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/hash.h" | 9 #include "base/hash.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 DevToolsChannelData::CreateForChannel(channel())); | 218 DevToolsChannelData::CreateForChannel(channel())); |
219 // TODO(yurys): remove devtools_gpu_instrumentation call once DevTools | 219 // TODO(yurys): remove devtools_gpu_instrumentation call once DevTools |
220 // Timeline migrates to tracing crbug.com/361045. | 220 // Timeline migrates to tracing crbug.com/361045. |
221 devtools_gpu_instrumentation::ScopedGpuTask task(channel()); | 221 devtools_gpu_instrumentation::ScopedGpuTask task(channel()); |
222 FastSetActiveURL(active_url_, active_url_hash_); | 222 FastSetActiveURL(active_url_, active_url_hash_); |
223 | 223 |
224 bool have_context = false; | 224 bool have_context = false; |
225 // Ensure the appropriate GL context is current before handling any IPC | 225 // Ensure the appropriate GL context is current before handling any IPC |
226 // messages directed at the command buffer. This ensures that the message | 226 // messages directed at the command buffer. This ensures that the message |
227 // handler can assume that the context is current (not necessary for | 227 // handler can assume that the context is current (not necessary for |
228 // Echo, RetireSyncPoint, or WaitSyncPoint). | 228 // RetireSyncPoint or WaitSyncPoint). |
229 if (decoder_.get() && message.type() != GpuCommandBufferMsg_Echo::ID && | 229 if (decoder_.get() && |
230 message.type() != GpuCommandBufferMsg_WaitForTokenInRange::ID && | 230 message.type() != GpuCommandBufferMsg_WaitForTokenInRange::ID && |
231 message.type() != GpuCommandBufferMsg_WaitForGetOffsetInRange::ID && | 231 message.type() != GpuCommandBufferMsg_WaitForGetOffsetInRange::ID && |
232 message.type() != GpuCommandBufferMsg_RetireSyncPoint::ID) { | 232 message.type() != GpuCommandBufferMsg_RetireSyncPoint::ID) { |
233 if (!MakeCurrent()) | 233 if (!MakeCurrent()) |
234 return false; | 234 return false; |
235 have_context = true; | 235 have_context = true; |
236 } | 236 } |
237 | 237 |
238 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers | 238 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers |
239 // here. This is so the reply can be delayed if the scheduler is unscheduled. | 239 // here. This is so the reply can be delayed if the scheduler is unscheduled. |
240 bool handled = true; | 240 bool handled = true; |
241 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) | 241 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) |
242 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, | 242 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, |
243 OnInitialize); | 243 OnInitialize); |
244 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer, | 244 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer, |
245 OnSetGetBuffer); | 245 OnSetGetBuffer); |
246 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ProduceFrontBuffer, | 246 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ProduceFrontBuffer, |
247 OnProduceFrontBuffer); | 247 OnProduceFrontBuffer); |
248 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Echo, OnEcho); | |
249 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForTokenInRange, | 248 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForTokenInRange, |
250 OnWaitForTokenInRange); | 249 OnWaitForTokenInRange); |
251 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForGetOffsetInRange, | 250 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_WaitForGetOffsetInRange, |
252 OnWaitForGetOffsetInRange); | 251 OnWaitForGetOffsetInRange); |
253 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); | 252 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); |
254 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); | 253 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); |
255 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterTransferBuffer, | 254 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterTransferBuffer, |
256 OnRegisterTransferBuffer); | 255 OnRegisterTransferBuffer); |
257 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer, | 256 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer, |
258 OnDestroyTransferBuffer); | 257 OnDestroyTransferBuffer); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 scheduler_->HasMoreIdleWork()) { | 376 scheduler_->HasMoreIdleWork()) { |
378 delay = 0; | 377 delay = 0; |
379 } | 378 } |
380 | 379 |
381 base::MessageLoop::current()->PostDelayedTask( | 380 base::MessageLoop::current()->PostDelayedTask( |
382 FROM_HERE, | 381 FROM_HERE, |
383 base::Bind(&GpuCommandBufferStub::PollWork, AsWeakPtr()), | 382 base::Bind(&GpuCommandBufferStub::PollWork, AsWeakPtr()), |
384 base::TimeDelta::FromMilliseconds(delay)); | 383 base::TimeDelta::FromMilliseconds(delay)); |
385 } | 384 } |
386 | 385 |
387 void GpuCommandBufferStub::OnEcho(const IPC::Message& message) { | |
388 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnEcho"); | |
389 Send(new IPC::Message(message)); | |
390 } | |
391 | |
392 bool GpuCommandBufferStub::MakeCurrent() { | 386 bool GpuCommandBufferStub::MakeCurrent() { |
393 if (decoder_->MakeCurrent()) | 387 if (decoder_->MakeCurrent()) |
394 return true; | 388 return true; |
395 DLOG(ERROR) << "Context lost because MakeCurrent failed."; | 389 DLOG(ERROR) << "Context lost because MakeCurrent failed."; |
396 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); | 390 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); |
397 command_buffer_->SetParseError(gpu::error::kLostContext); | 391 command_buffer_->SetParseError(gpu::error::kLostContext); |
398 CheckContextLost(); | 392 CheckContextLost(); |
399 return false; | 393 return false; |
400 } | 394 } |
401 | 395 |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 if (decoder_) | 1089 if (decoder_) |
1096 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 1090 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); |
1097 command_buffer_->SetParseError(gpu::error::kLostContext); | 1091 command_buffer_->SetParseError(gpu::error::kLostContext); |
1098 } | 1092 } |
1099 | 1093 |
1100 uint64 GpuCommandBufferStub::GetMemoryUsage() const { | 1094 uint64 GpuCommandBufferStub::GetMemoryUsage() const { |
1101 return GetMemoryManager()->GetClientMemoryUsage(this); | 1095 return GetMemoryManager()->GetClientMemoryUsage(this); |
1102 } | 1096 } |
1103 | 1097 |
1104 } // namespace content | 1098 } // namespace content |
OLD | NEW |