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