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(OS_WIN) | 5 #if defined(OS_WIN) |
6 #include <windows.h> | 6 #include <windows.h> |
7 #endif | 7 #endif |
8 | 8 |
9 #include "content/common/gpu/gpu_channel.h" | 9 #include "content/common/gpu/gpu_channel.h" |
10 | 10 |
11 #include <queue> | 11 #include <queue> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/command_line.h" |
15 #include "base/debug/trace_event.h" | 16 #include "base/debug/trace_event.h" |
16 #include "base/message_loop/message_loop_proxy.h" | 17 #include "base/message_loop/message_loop_proxy.h" |
17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
18 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
19 #include "content/common/gpu/devtools_gpu_agent.h" | 20 #include "content/common/gpu/devtools_gpu_agent.h" |
20 #include "content/common/gpu/gpu_channel_manager.h" | 21 #include "content/common/gpu/gpu_channel_manager.h" |
21 #include "content/common/gpu/gpu_messages.h" | 22 #include "content/common/gpu/gpu_messages.h" |
22 #include "content/common/gpu/sync_point_manager.h" | 23 #include "content/common/gpu/sync_point_manager.h" |
| 24 #include "content/public/common/content_switches.h" |
23 #include "gpu/command_buffer/common/mailbox.h" | 25 #include "gpu/command_buffer/common/mailbox.h" |
24 #include "gpu/command_buffer/service/gpu_scheduler.h" | 26 #include "gpu/command_buffer/service/gpu_scheduler.h" |
25 #include "gpu/command_buffer/service/image_manager.h" | 27 #include "gpu/command_buffer/service/image_manager.h" |
26 #include "gpu/command_buffer/service/mailbox_manager.h" | 28 #include "gpu/command_buffer/service/mailbox_manager.h" |
27 #include "ipc/ipc_channel.h" | 29 #include "ipc/ipc_channel.h" |
28 #include "ipc/message_filter.h" | 30 #include "ipc/message_filter.h" |
29 #include "ui/gl/gl_context.h" | 31 #include "ui/gl/gl_context.h" |
30 #include "ui/gl/gl_image.h" | 32 #include "ui/gl/gl_image.h" |
31 #include "ui/gl/gl_surface.h" | 33 #include "ui/gl/gl_surface.h" |
32 | 34 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 watchdog_(watchdog), | 400 watchdog_(watchdog), |
399 software_(software), | 401 software_(software), |
400 handle_messages_scheduled_(false), | 402 handle_messages_scheduled_(false), |
401 currently_processing_message_(NULL), | 403 currently_processing_message_(NULL), |
402 weak_factory_(this), | 404 weak_factory_(this), |
403 num_stubs_descheduled_(0) { | 405 num_stubs_descheduled_(0) { |
404 DCHECK(gpu_channel_manager); | 406 DCHECK(gpu_channel_manager); |
405 DCHECK(client_id); | 407 DCHECK(client_id); |
406 | 408 |
407 channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu"); | 409 channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu"); |
| 410 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 411 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); |
408 } | 412 } |
409 | 413 |
410 | 414 |
411 void GpuChannel::Init(base::MessageLoopProxy* io_message_loop, | 415 void GpuChannel::Init(base::MessageLoopProxy* io_message_loop, |
412 base::WaitableEvent* shutdown_event) { | 416 base::WaitableEvent* shutdown_event) { |
413 DCHECK(!channel_.get()); | 417 DCHECK(!channel_.get()); |
414 | 418 |
415 // Map renderer ID to a (single) channel to that process. | 419 // Map renderer ID to a (single) channel to that process. |
416 channel_.reset(new IPC::SyncChannel( | 420 channel_.reset(new IPC::SyncChannel( |
417 channel_id_, | 421 channel_id_, |
(...skipping 24 matching lines...) Expand all Loading... |
442 int GpuChannel::TakeRendererFileDescriptor() { | 446 int GpuChannel::TakeRendererFileDescriptor() { |
443 if (!channel_) { | 447 if (!channel_) { |
444 NOTREACHED(); | 448 NOTREACHED(); |
445 return -1; | 449 return -1; |
446 } | 450 } |
447 return channel_->TakeClientFileDescriptor(); | 451 return channel_->TakeClientFileDescriptor(); |
448 } | 452 } |
449 #endif // defined(OS_POSIX) | 453 #endif // defined(OS_POSIX) |
450 | 454 |
451 bool GpuChannel::OnMessageReceived(const IPC::Message& message) { | 455 bool GpuChannel::OnMessageReceived(const IPC::Message& message) { |
| 456 if (log_messages_) { |
| 457 DVLOG(1) << "received message @" << &message << " on channel @" << this |
| 458 << " with type " << message.type(); |
| 459 } |
| 460 |
452 if (message.type() == GpuCommandBufferMsg_WaitForTokenInRange::ID || | 461 if (message.type() == GpuCommandBufferMsg_WaitForTokenInRange::ID || |
453 message.type() == GpuCommandBufferMsg_WaitForGetOffsetInRange::ID) { | 462 message.type() == GpuCommandBufferMsg_WaitForGetOffsetInRange::ID) { |
454 // Move Wait commands to the head of the queue, so the renderer | 463 // Move Wait commands to the head of the queue, so the renderer |
455 // doesn't have to wait any longer than necessary. | 464 // doesn't have to wait any longer than necessary. |
456 deferred_messages_.push_front(new IPC::Message(message)); | 465 deferred_messages_.push_front(new IPC::Message(message)); |
457 } else { | 466 } else { |
458 deferred_messages_.push_back(new IPC::Message(message)); | 467 deferred_messages_.push_back(new IPC::Message(message)); |
459 } | 468 } |
460 | 469 |
461 OnScheduled(); | 470 OnScheduled(); |
462 | 471 |
463 return true; | 472 return true; |
464 } | 473 } |
465 | 474 |
466 void GpuChannel::OnChannelError() { | 475 void GpuChannel::OnChannelError() { |
467 gpu_channel_manager_->RemoveChannel(client_id_); | 476 gpu_channel_manager_->RemoveChannel(client_id_); |
468 } | 477 } |
469 | 478 |
470 bool GpuChannel::Send(IPC::Message* message) { | 479 bool GpuChannel::Send(IPC::Message* message) { |
471 // The GPU process must never send a synchronous IPC message to the renderer | 480 // The GPU process must never send a synchronous IPC message to the renderer |
472 // process. This could result in deadlock. | 481 // process. This could result in deadlock. |
473 DCHECK(!message->is_sync()); | 482 DCHECK(!message->is_sync()); |
| 483 if (log_messages_) { |
| 484 DVLOG(1) << "sending message @" << message << " on channel @" << this |
| 485 << " with type " << message->type(); |
| 486 } |
474 | 487 |
475 if (!channel_) { | 488 if (!channel_) { |
476 delete message; | 489 delete message; |
477 return false; | 490 return false; |
478 } | 491 } |
479 | 492 |
480 return channel_->Send(message); | 493 return channel_->Send(message); |
481 } | 494 } |
482 | 495 |
483 void GpuChannel::RequeueMessage() { | 496 void GpuChannel::RequeueMessage() { |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 uint64 GpuChannel::GetMemoryUsage() { | 856 uint64 GpuChannel::GetMemoryUsage() { |
844 uint64 size = 0; | 857 uint64 size = 0; |
845 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); | 858 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); |
846 !it.IsAtEnd(); it.Advance()) { | 859 !it.IsAtEnd(); it.Advance()) { |
847 size += it.GetCurrentValue()->GetMemoryUsage(); | 860 size += it.GetCurrentValue()->GetMemoryUsage(); |
848 } | 861 } |
849 return size; | 862 return size; |
850 } | 863 } |
851 | 864 |
852 } // namespace content | 865 } // namespace content |
OLD | NEW |