Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: content/common/gpu/gpu_channel.cc

Issue 1736643005: Decouple Media Service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nit + fixed compile issue Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/gpu/gpu_channel.h ('k') | content/common/gpu/gpu_channel_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/common/gpu/gpu_channel.h" 5 #include "content/common/gpu/gpu_channel.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 16 matching lines...) Expand all
27 #include "base/thread_task_runner_handle.h" 27 #include "base/thread_task_runner_handle.h"
28 #include "base/timer/timer.h" 28 #include "base/timer/timer.h"
29 #include "base/trace_event/memory_dump_manager.h" 29 #include "base/trace_event/memory_dump_manager.h"
30 #include "base/trace_event/process_memory_dump.h" 30 #include "base/trace_event/process_memory_dump.h"
31 #include "base/trace_event/trace_event.h" 31 #include "base/trace_event/trace_event.h"
32 #include "build/build_config.h" 32 #include "build/build_config.h"
33 #include "content/common/gpu/gpu_channel_manager.h" 33 #include "content/common/gpu/gpu_channel_manager.h"
34 #include "content/common/gpu/gpu_channel_manager_delegate.h" 34 #include "content/common/gpu/gpu_channel_manager_delegate.h"
35 #include "content/common/gpu/gpu_memory_buffer_factory.h" 35 #include "content/common/gpu/gpu_memory_buffer_factory.h"
36 #include "content/common/gpu/gpu_messages.h" 36 #include "content/common/gpu/gpu_messages.h"
37 #include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h"
38 #include "content/public/common/content_switches.h" 37 #include "content/public/common/content_switches.h"
39 #include "gpu/command_buffer/common/mailbox.h" 38 #include "gpu/command_buffer/common/mailbox.h"
40 #include "gpu/command_buffer/common/value_state.h" 39 #include "gpu/command_buffer/common/value_state.h"
41 #include "gpu/command_buffer/service/gpu_scheduler.h" 40 #include "gpu/command_buffer/service/gpu_scheduler.h"
42 #include "gpu/command_buffer/service/image_factory.h" 41 #include "gpu/command_buffer/service/image_factory.h"
43 #include "gpu/command_buffer/service/mailbox_manager.h" 42 #include "gpu/command_buffer/service/mailbox_manager.h"
44 #include "gpu/command_buffer/service/sync_point_manager.h" 43 #include "gpu/command_buffer/service/sync_point_manager.h"
45 #include "gpu/command_buffer/service/valuebuffer_manager.h" 44 #include "gpu/command_buffer/service/valuebuffer_manager.h"
46 #include "ipc/ipc_channel.h" 45 #include "ipc/ipc_channel.h"
47 #include "ipc/message_filter.h" 46 #include "ipc/message_filter.h"
(...skipping 18 matching lines...) Expand all
66 const int64_t kPreemptWaitTimeMs = 2 * kVsyncIntervalMs; 65 const int64_t kPreemptWaitTimeMs = 2 * kVsyncIntervalMs;
67 66
68 // Once we trigger a preemption, the maximum duration that we will wait 67 // Once we trigger a preemption, the maximum duration that we will wait
69 // before clearing the preemption. 68 // before clearing the preemption.
70 const int64_t kMaxPreemptTimeMs = kVsyncIntervalMs; 69 const int64_t kMaxPreemptTimeMs = kVsyncIntervalMs;
71 70
72 // Stop the preemption once the time for the longest pending IPC drops 71 // Stop the preemption once the time for the longest pending IPC drops
73 // below this threshold. 72 // below this threshold.
74 const int64_t kStopPreemptThresholdMs = kVsyncIntervalMs; 73 const int64_t kStopPreemptThresholdMs = kVsyncIntervalMs;
75 74
76 void SendCreateJpegDecoderResult(
77 scoped_ptr<IPC::Message> reply_message,
78 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
79 base::WeakPtr<GpuChannel> channel,
80 scoped_refptr<GpuChannelMessageFilter> filter,
81 bool result) {
82 GpuChannelMsg_CreateJpegDecoder::WriteReplyParams(reply_message.get(),
83 result);
84 if (io_task_runner->BelongsToCurrentThread()) {
85 filter->Send(reply_message.release());
86 } else {
87 channel->Send(reply_message.release());
88 }
89 }
90
91 } // anonymous namespace 75 } // anonymous namespace
92 76
93 scoped_refptr<GpuChannelMessageQueue> GpuChannelMessageQueue::Create( 77 scoped_refptr<GpuChannelMessageQueue> GpuChannelMessageQueue::Create(
94 int32_t stream_id, 78 int32_t stream_id,
95 GpuStreamPriority stream_priority, 79 GpuStreamPriority stream_priority,
96 GpuChannel* channel, 80 GpuChannel* channel,
97 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, 81 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
98 const scoped_refptr<gpu::PreemptionFlag>& preempting_flag, 82 const scoped_refptr<gpu::PreemptionFlag>& preempting_flag,
99 const scoped_refptr<gpu::PreemptionFlag>& preempted_flag, 83 const scoped_refptr<gpu::PreemptionFlag>& preempted_flag,
100 gpu::SyncPointManager* sync_point_manager) { 84 gpu::SyncPointManager* sync_point_manager) {
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 gpu::PreemptionFlag* preempting_flag, 582 gpu::PreemptionFlag* preempting_flag,
599 gpu::PreemptionFlag* preempted_flag, 583 gpu::PreemptionFlag* preempted_flag,
600 base::SingleThreadTaskRunner* task_runner, 584 base::SingleThreadTaskRunner* task_runner,
601 base::SingleThreadTaskRunner* io_task_runner, 585 base::SingleThreadTaskRunner* io_task_runner,
602 int32_t client_id, 586 int32_t client_id,
603 uint64_t client_tracing_id, 587 uint64_t client_tracing_id,
604 bool allow_view_command_buffers, 588 bool allow_view_command_buffers,
605 bool allow_real_time_streams) 589 bool allow_real_time_streams)
606 : gpu_channel_manager_(gpu_channel_manager), 590 : gpu_channel_manager_(gpu_channel_manager),
607 sync_point_manager_(sync_point_manager), 591 sync_point_manager_(sync_point_manager),
592 unhandled_message_listener_(nullptr),
608 channel_id_(IPC::Channel::GenerateVerifiedChannelID("gpu")), 593 channel_id_(IPC::Channel::GenerateVerifiedChannelID("gpu")),
609 preempting_flag_(preempting_flag), 594 preempting_flag_(preempting_flag),
610 preempted_flag_(preempted_flag), 595 preempted_flag_(preempted_flag),
611 client_id_(client_id), 596 client_id_(client_id),
612 client_tracing_id_(client_tracing_id), 597 client_tracing_id_(client_tracing_id),
613 task_runner_(task_runner), 598 task_runner_(task_runner),
614 io_task_runner_(io_task_runner), 599 io_task_runner_(io_task_runner),
615 share_group_(share_group), 600 share_group_(share_group),
616 mailbox_manager_(mailbox), 601 mailbox_manager_(mailbox),
617 subscription_ref_set_(new gpu::gles2::SubscriptionRefSet), 602 subscription_ref_set_(new gpu::gles2::SubscriptionRefSet),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 base::ScopedFD renderer_fd = channel_->TakeClientFileDescriptor(); 645 base::ScopedFD renderer_fd = channel_->TakeClientFileDescriptor();
661 DCHECK(renderer_fd.is_valid()); 646 DCHECK(renderer_fd.is_valid());
662 channel_handle.socket = base::FileDescriptor(std::move(renderer_fd)); 647 channel_handle.socket = base::FileDescriptor(std::move(renderer_fd));
663 #endif 648 #endif
664 649
665 channel_->AddFilter(filter_.get()); 650 channel_->AddFilter(filter_.get());
666 651
667 return channel_handle; 652 return channel_handle;
668 } 653 }
669 654
655 void GpuChannel::SetUnhandledMessageListener(IPC::Listener* listener) {
656 unhandled_message_listener_ = listener;
657 }
658
659 base::WeakPtr<GpuChannel> GpuChannel::AsWeakPtr() {
660 return weak_factory_.GetWeakPtr();
661 }
662
670 base::ProcessId GpuChannel::GetClientPID() const { 663 base::ProcessId GpuChannel::GetClientPID() const {
671 return channel_->GetPeerPID(); 664 return channel_->GetPeerPID();
672 } 665 }
673 666
674 uint32_t GpuChannel::GetProcessedOrderNum() const { 667 uint32_t GpuChannel::GetProcessedOrderNum() const {
675 uint32_t processed_order_num = 0; 668 uint32_t processed_order_num = 0;
676 for (auto& kv : streams_) { 669 for (auto& kv : streams_) {
677 processed_order_num = 670 processed_order_num =
678 std::max(processed_order_num, kv.second->GetProcessedOrderNum()); 671 std::max(processed_order_num, kv.second->GetProcessedOrderNum());
679 } 672 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 752
760 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { 753 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) {
761 bool handled = true; 754 bool handled = true;
762 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) 755 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg)
763 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateViewCommandBuffer, 756 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateViewCommandBuffer,
764 OnCreateViewCommandBuffer) 757 OnCreateViewCommandBuffer)
765 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, 758 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer,
766 OnCreateOffscreenCommandBuffer) 759 OnCreateOffscreenCommandBuffer)
767 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, 760 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer,
768 OnDestroyCommandBuffer) 761 OnDestroyCommandBuffer)
769 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuChannelMsg_CreateJpegDecoder,
770 OnCreateJpegDecoder)
771 IPC_MESSAGE_UNHANDLED(handled = false) 762 IPC_MESSAGE_UNHANDLED(handled = false)
772 IPC_END_MESSAGE_MAP() 763 IPC_END_MESSAGE_MAP()
773 DCHECK(handled) << msg.type();
774 return handled; 764 return handled;
775 } 765 }
776 766
777 scoped_refptr<gpu::SyncPointOrderData> GpuChannel::GetSyncPointOrderData( 767 scoped_refptr<gpu::SyncPointOrderData> GpuChannel::GetSyncPointOrderData(
778 int32_t stream_id) { 768 int32_t stream_id) {
779 auto it = streams_.find(stream_id); 769 auto it = streams_.find(stream_id);
780 DCHECK(it != streams_.end()); 770 DCHECK(it != streams_.end());
781 DCHECK(it->second); 771 DCHECK(it->second);
782 return it->second->GetSyncPointOrderData(); 772 return it->second->GetSyncPointOrderData();
783 } 773 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 void GpuChannel::HandleMessageHelper(const IPC::Message& msg) { 815 void GpuChannel::HandleMessageHelper(const IPC::Message& msg) {
826 int32_t routing_id = msg.routing_id(); 816 int32_t routing_id = msg.routing_id();
827 817
828 bool handled = false; 818 bool handled = false;
829 if (routing_id == MSG_ROUTING_CONTROL) { 819 if (routing_id == MSG_ROUTING_CONTROL) {
830 handled = OnControlMessageReceived(msg); 820 handled = OnControlMessageReceived(msg);
831 } else { 821 } else {
832 handled = router_.RouteMessage(msg); 822 handled = router_.RouteMessage(msg);
833 } 823 }
834 824
825 if (!handled && unhandled_message_listener_)
826 handled = unhandled_message_listener_->OnMessageReceived(msg);
827
835 // Respond to sync messages even if router failed to route. 828 // Respond to sync messages even if router failed to route.
836 if (!handled && msg.is_sync()) { 829 if (!handled && msg.is_sync()) {
837 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); 830 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg);
838 reply->set_reply_error(); 831 reply->set_reply_error();
839 Send(reply); 832 Send(reply);
840 } 833 }
841 } 834 }
842 835
843 void GpuChannel::HandleOutOfOrderMessage(const IPC::Message& msg) { 836 void GpuChannel::HandleOutOfOrderMessage(const IPC::Message& msg) {
844 HandleMessageHelper(msg); 837 HandleMessageHelper(msg);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 // In case the renderer is currently blocked waiting for a sync reply from the 985 // In case the renderer is currently blocked waiting for a sync reply from the
993 // stub, we need to make sure to reschedule the correct stream here. 986 // stub, we need to make sure to reschedule the correct stream here.
994 if (stub && !stub->IsScheduled()) { 987 if (stub && !stub->IsScheduled()) {
995 // This stub won't get a chance to reschedule the stream so do that now. 988 // This stub won't get a chance to reschedule the stream so do that now.
996 OnStreamRescheduled(stub->stream_id(), true); 989 OnStreamRescheduled(stub->stream_id(), true);
997 } 990 }
998 991
999 RemoveRoute(route_id); 992 RemoveRoute(route_id);
1000 } 993 }
1001 994
1002 void GpuChannel::OnCreateJpegDecoder(int32_t route_id,
1003 IPC::Message* reply_msg) {
1004 scoped_ptr<IPC::Message> msg(reply_msg);
1005 if (!jpeg_decoder_) {
1006 jpeg_decoder_.reset(new GpuJpegDecodeAccelerator(this, io_task_runner_));
1007 }
1008 jpeg_decoder_->AddClient(
1009 route_id,
1010 base::Bind(&SendCreateJpegDecoderResult, base::Passed(&msg),
1011 io_task_runner_, weak_factory_.GetWeakPtr(), filter_));
1012 }
1013
1014 void GpuChannel::CacheShader(const std::string& key, 995 void GpuChannel::CacheShader(const std::string& key,
1015 const std::string& shader) { 996 const std::string& shader) {
1016 gpu_channel_manager_->delegate()->StoreShaderToDisk(client_id_, key, shader); 997 gpu_channel_manager_->delegate()->StoreShaderToDisk(client_id_, key, shader);
1017 } 998 }
1018 999
1019 void GpuChannel::AddFilter(IPC::MessageFilter* filter) { 1000 void GpuChannel::AddFilter(IPC::MessageFilter* filter) {
1020 io_task_runner_->PostTask( 1001 io_task_runner_->PostTask(
1021 FROM_HERE, base::Bind(&GpuChannelMessageFilter::AddChannelFilter, 1002 FROM_HERE, base::Bind(&GpuChannelMessageFilter::AddChannelFilter,
1022 filter_, make_scoped_refptr(filter))); 1003 filter_, make_scoped_refptr(filter)));
1023 } 1004 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 } 1058 }
1078 } 1059 }
1079 } 1060 }
1080 1061
1081 void GpuChannel::HandleUpdateValueState( 1062 void GpuChannel::HandleUpdateValueState(
1082 unsigned int target, const gpu::ValueState& state) { 1063 unsigned int target, const gpu::ValueState& state) {
1083 pending_valuebuffer_state_->UpdateState(target, state); 1064 pending_valuebuffer_state_->UpdateState(target, state);
1084 } 1065 }
1085 1066
1086 } // namespace content 1067 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel.h ('k') | content/common/gpu/gpu_channel_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698