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 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE { | 97 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE { |
98 DCHECK(!channel_); | 98 DCHECK(!channel_); |
99 channel_ = channel; | 99 channel_ = channel; |
100 } | 100 } |
101 | 101 |
102 virtual void OnFilterRemoved() OVERRIDE { | 102 virtual void OnFilterRemoved() OVERRIDE { |
103 DCHECK(channel_); | 103 DCHECK(channel_); |
104 channel_ = NULL; | 104 channel_ = NULL; |
105 } | 105 } |
106 | 106 |
| 107 void AddRoute(int32 route_id, IPC::Listener* listener) { |
| 108 router_.AddRoute(route_id, listener); |
| 109 } |
| 110 |
| 111 void RemoveRoute(int32 route_id) { |
| 112 router_.RemoveRoute(route_id); |
| 113 } |
| 114 |
107 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { | 115 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { |
108 DCHECK(channel_); | 116 DCHECK(channel_); |
109 | 117 |
110 bool handled = true; | 118 bool handled = true; |
111 IPC_BEGIN_MESSAGE_MAP(GpuChannelMessageFilter, message) | 119 IPC_BEGIN_MESSAGE_MAP(GpuChannelMessageFilter, message) |
112 IPC_MESSAGE_HANDLER(GpuChannelMsg_GenerateMailboxNames, | 120 IPC_MESSAGE_HANDLER(GpuChannelMsg_GenerateMailboxNames, |
113 OnGenerateMailboxNames) | 121 OnGenerateMailboxNames) |
114 IPC_MESSAGE_HANDLER(GpuChannelMsg_GenerateMailboxNamesAsync, | 122 IPC_MESSAGE_HANDLER(GpuChannelMsg_GenerateMailboxNamesAsync, |
115 OnGenerateMailboxNamesAsync) | 123 OnGenerateMailboxNamesAsync) |
116 IPC_MESSAGE_UNHANDLED(handled = false) | 124 IPC_MESSAGE_UNHANDLED(handled = false) |
117 IPC_END_MESSAGE_MAP() | 125 IPC_END_MESSAGE_MAP() |
118 | 126 |
119 if (message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) { | 127 if (message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) { |
120 // This message should not be sent explicitly by the renderer. | 128 // This message should not be sent explicitly by the renderer. |
121 NOTREACHED(); | 129 NOTREACHED(); |
122 handled = true; | 130 handled = true; |
123 } | 131 } |
124 | 132 |
| 133 if (message.type() == AcceleratedVideoDecoderMsg_Decode::ID) { |
| 134 handled = router_.RouteMessage(message); |
| 135 } |
| 136 |
125 // All other messages get processed by the GpuChannel. | 137 // All other messages get processed by the GpuChannel. |
126 if (!handled) { | 138 if (!handled) { |
127 messages_forwarded_to_channel_++; | 139 messages_forwarded_to_channel_++; |
128 if (preempting_flag_.get()) | 140 if (preempting_flag_.get()) |
129 pending_messages_.push(PendingMessage(messages_forwarded_to_channel_)); | 141 pending_messages_.push(PendingMessage(messages_forwarded_to_channel_)); |
130 UpdatePreemptionState(); | 142 UpdatePreemptionState(); |
131 } | 143 } |
132 | 144 |
133 if (message.type() == GpuCommandBufferMsg_InsertSyncPoint::ID) { | 145 if (message.type() == GpuCommandBufferMsg_InsertSyncPoint::ID) { |
134 uint32 sync_point = sync_point_manager_->GenerateSyncPoint(); | 146 uint32 sync_point = sync_point_manager_->GenerateSyncPoint(); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 std::queue<PendingMessage> pending_messages_; | 433 std::queue<PendingMessage> pending_messages_; |
422 | 434 |
423 // Count of the number of IPCs forwarded to the GpuChannel. | 435 // Count of the number of IPCs forwarded to the GpuChannel. |
424 uint64 messages_forwarded_to_channel_; | 436 uint64 messages_forwarded_to_channel_; |
425 | 437 |
426 base::OneShotTimer<GpuChannelMessageFilter> timer_; | 438 base::OneShotTimer<GpuChannelMessageFilter> timer_; |
427 | 439 |
428 bool a_stub_is_descheduled_; | 440 bool a_stub_is_descheduled_; |
429 | 441 |
430 crypto::HMAC hmac_; | 442 crypto::HMAC hmac_; |
| 443 |
| 444 // Used to implement message routing functionality running on IO thread. |
| 445 MessageRouter router_; |
431 }; | 446 }; |
432 | 447 |
433 GpuChannel::GpuChannel(GpuChannelManager* gpu_channel_manager, | 448 GpuChannel::GpuChannel(GpuChannelManager* gpu_channel_manager, |
434 GpuWatchdog* watchdog, | 449 GpuWatchdog* watchdog, |
435 gfx::GLShareGroup* share_group, | 450 gfx::GLShareGroup* share_group, |
436 gpu::gles2::MailboxManager* mailbox, | 451 gpu::gles2::MailboxManager* mailbox, |
437 int client_id, | 452 int client_id, |
438 bool software) | 453 bool software) |
439 : gpu_channel_manager_(gpu_channel_manager), | 454 : gpu_channel_manager_(gpu_channel_manager), |
440 messages_processed_(0), | 455 messages_processed_(0), |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 } | 728 } |
714 | 729 |
715 void GpuChannel::AddRoute(int32 route_id, IPC::Listener* listener) { | 730 void GpuChannel::AddRoute(int32 route_id, IPC::Listener* listener) { |
716 router_.AddRoute(route_id, listener); | 731 router_.AddRoute(route_id, listener); |
717 } | 732 } |
718 | 733 |
719 void GpuChannel::RemoveRoute(int32 route_id) { | 734 void GpuChannel::RemoveRoute(int32 route_id) { |
720 router_.RemoveRoute(route_id); | 735 router_.RemoveRoute(route_id); |
721 } | 736 } |
722 | 737 |
| 738 void GpuChannel::AddMessageFilterRoute(int32 route_id, |
| 739 IPC::Listener* listener) { |
| 740 filter_->AddRoute(route_id, listener); |
| 741 } |
| 742 |
| 743 void GpuChannel::RemoveMessageFilterRoute(int32 route_id) { |
| 744 filter_->RemoveRoute(route_id); |
| 745 } |
| 746 |
723 gpu::PreemptionFlag* GpuChannel::GetPreemptionFlag() { | 747 gpu::PreemptionFlag* GpuChannel::GetPreemptionFlag() { |
724 if (!preempting_flag_.get()) { | 748 if (!preempting_flag_.get()) { |
725 preempting_flag_ = new gpu::PreemptionFlag; | 749 preempting_flag_ = new gpu::PreemptionFlag; |
726 io_message_loop_->PostTask( | 750 io_message_loop_->PostTask( |
727 FROM_HERE, base::Bind( | 751 FROM_HERE, base::Bind( |
728 &GpuChannelMessageFilter::SetPreemptingFlagAndSchedulingState, | 752 &GpuChannelMessageFilter::SetPreemptingFlagAndSchedulingState, |
729 filter_, preempting_flag_, num_stubs_descheduled_ > 0)); | 753 filter_, preempting_flag_, num_stubs_descheduled_ > 0)); |
730 } | 754 } |
731 return preempting_flag_.get(); | 755 return preempting_flag_.get(); |
732 } | 756 } |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 } | 1003 } |
980 } | 1004 } |
981 | 1005 |
982 void GpuChannel::CacheShader(const std::string& key, | 1006 void GpuChannel::CacheShader(const std::string& key, |
983 const std::string& shader) { | 1007 const std::string& shader) { |
984 gpu_channel_manager_->Send( | 1008 gpu_channel_manager_->Send( |
985 new GpuHostMsg_CacheShader(client_id_, key, shader)); | 1009 new GpuHostMsg_CacheShader(client_id_, key, shader)); |
986 } | 1010 } |
987 | 1011 |
988 } // namespace content | 1012 } // namespace content |
OLD | NEW |