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/command_line.h" |
16 #include "base/debug/trace_event.h" | 16 #include "base/debug/trace_event.h" |
17 #include "base/message_loop/message_loop_proxy.h" | 17 #include "base/message_loop/message_loop_proxy.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
19 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
20 #include "content/common/gpu/devtools_gpu_agent.h" | 20 #include "content/common/gpu/devtools_gpu_agent.h" |
21 #include "content/common/gpu/gpu_channel_manager.h" | 21 #include "content/common/gpu/gpu_channel_manager.h" |
22 #include "content/common/gpu/gpu_messages.h" | 22 #include "content/common/gpu/gpu_messages.h" |
23 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" | |
24 #include "content/common/gpu/sync_point_manager.h" | 23 #include "content/common/gpu/sync_point_manager.h" |
25 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
26 #include "gpu/command_buffer/common/mailbox.h" | 25 #include "gpu/command_buffer/common/mailbox.h" |
27 #include "gpu/command_buffer/service/gpu_scheduler.h" | 26 #include "gpu/command_buffer/service/gpu_scheduler.h" |
28 #include "gpu/command_buffer/service/image_manager.h" | 27 #include "gpu/command_buffer/service/image_manager.h" |
29 #include "gpu/command_buffer/service/mailbox_manager.h" | 28 #include "gpu/command_buffer/service/mailbox_manager.h" |
30 #include "ipc/ipc_channel.h" | 29 #include "ipc/ipc_channel.h" |
31 #include "ipc/ipc_channel_proxy.h" | 30 #include "ipc/ipc_channel_proxy.h" |
32 #include "ui/gl/gl_context.h" | 31 #include "ui/gl/gl_context.h" |
33 #include "ui/gl/gl_image.h" | 32 #include "ui/gl/gl_image.h" |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 gpu_channel_manager_->RemoveChannel(client_id_); | 696 gpu_channel_manager_->RemoveChannel(client_id_); |
698 } | 697 } |
699 | 698 |
700 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { | 699 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { |
701 bool handled = true; | 700 bool handled = true; |
702 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) | 701 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) |
703 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, | 702 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, |
704 OnCreateOffscreenCommandBuffer) | 703 OnCreateOffscreenCommandBuffer) |
705 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, | 704 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, |
706 OnDestroyCommandBuffer) | 705 OnDestroyCommandBuffer) |
707 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateVideoEncoder, OnCreateVideoEncoder) | |
708 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyVideoEncoder, | |
709 OnDestroyVideoEncoder) | |
710 IPC_MESSAGE_HANDLER(GpuChannelMsg_DevToolsStartEventsRecording, | 706 IPC_MESSAGE_HANDLER(GpuChannelMsg_DevToolsStartEventsRecording, |
711 OnDevToolsStartEventsRecording) | 707 OnDevToolsStartEventsRecording) |
712 IPC_MESSAGE_HANDLER(GpuChannelMsg_DevToolsStopEventsRecording, | 708 IPC_MESSAGE_HANDLER(GpuChannelMsg_DevToolsStopEventsRecording, |
713 OnDevToolsStopEventsRecording) | 709 OnDevToolsStopEventsRecording) |
714 IPC_MESSAGE_UNHANDLED(handled = false) | 710 IPC_MESSAGE_UNHANDLED(handled = false) |
715 IPC_END_MESSAGE_MAP() | 711 IPC_END_MESSAGE_MAP() |
716 DCHECK(handled) << msg.type(); | 712 DCHECK(handled) << msg.type(); |
717 return handled; | 713 return handled; |
718 } | 714 } |
719 | 715 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 router_.RemoveRoute(route_id); | 830 router_.RemoveRoute(route_id); |
835 stubs_.Remove(route_id); | 831 stubs_.Remove(route_id); |
836 // In case the renderer is currently blocked waiting for a sync reply from the | 832 // In case the renderer is currently blocked waiting for a sync reply from the |
837 // stub, we need to make sure to reschedule the GpuChannel here. | 833 // stub, we need to make sure to reschedule the GpuChannel here. |
838 if (need_reschedule) { | 834 if (need_reschedule) { |
839 // This stub won't get a chance to reschedule, so update the count now. | 835 // This stub won't get a chance to reschedule, so update the count now. |
840 StubSchedulingChanged(true); | 836 StubSchedulingChanged(true); |
841 } | 837 } |
842 } | 838 } |
843 | 839 |
844 void GpuChannel::OnCreateVideoEncoder(int32* route_id) { | |
845 TRACE_EVENT0("gpu", "GpuChannel::OnCreateVideoEncoder"); | |
846 | |
847 *route_id = GenerateRouteID(); | |
848 GpuVideoEncodeAccelerator* encoder = | |
849 new GpuVideoEncodeAccelerator(this, *route_id); | |
850 router_.AddRoute(*route_id, encoder); | |
851 video_encoders_.AddWithID(encoder, *route_id); | |
852 } | |
853 | |
854 void GpuChannel::OnDestroyVideoEncoder(int32 route_id) { | |
855 TRACE_EVENT1( | |
856 "gpu", "GpuChannel::OnDestroyVideoEncoder", "route_id", route_id); | |
857 GpuVideoEncodeAccelerator* encoder = video_encoders_.Lookup(route_id); | |
858 if (!encoder) | |
859 return; | |
860 router_.RemoveRoute(route_id); | |
861 video_encoders_.Remove(route_id); | |
862 } | |
863 | |
864 void GpuChannel::OnDevToolsStartEventsRecording(int32* route_id) { | 840 void GpuChannel::OnDevToolsStartEventsRecording(int32* route_id) { |
865 devtools_gpu_agent_->StartEventsRecording(route_id); | 841 devtools_gpu_agent_->StartEventsRecording(route_id); |
866 } | 842 } |
867 | 843 |
868 void GpuChannel::OnDevToolsStopEventsRecording() { | 844 void GpuChannel::OnDevToolsStopEventsRecording() { |
869 devtools_gpu_agent_->StopEventsRecording(); | 845 devtools_gpu_agent_->StopEventsRecording(); |
870 } | 846 } |
871 | 847 |
872 void GpuChannel::MessageProcessed() { | 848 void GpuChannel::MessageProcessed() { |
873 messages_processed_++; | 849 messages_processed_++; |
(...skipping 23 matching lines...) Expand all Loading... |
897 uint64 GpuChannel::GetMemoryUsage() { | 873 uint64 GpuChannel::GetMemoryUsage() { |
898 uint64 size = 0; | 874 uint64 size = 0; |
899 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); | 875 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); |
900 !it.IsAtEnd(); it.Advance()) { | 876 !it.IsAtEnd(); it.Advance()) { |
901 size += it.GetCurrentValue()->GetMemoryUsage(); | 877 size += it.GetCurrentValue()->GetMemoryUsage(); |
902 } | 878 } |
903 return size; | 879 return size; |
904 } | 880 } |
905 | 881 |
906 } // namespace content | 882 } // namespace content |
OLD | NEW |