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/rand_util.h" | 18 #include "base/rand_util.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/timer/timer.h" | 20 #include "base/timer/timer.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" |
23 #include "content/common/gpu/sync_point_manager.h" | 24 #include "content/common/gpu/sync_point_manager.h" |
24 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
25 #include "crypto/hmac.h" | 26 #include "crypto/hmac.h" |
26 #include "gpu/command_buffer/common/mailbox.h" | 27 #include "gpu/command_buffer/common/mailbox.h" |
27 #include "gpu/command_buffer/service/gpu_scheduler.h" | 28 #include "gpu/command_buffer/service/gpu_scheduler.h" |
28 #include "gpu/command_buffer/service/image_manager.h" | 29 #include "gpu/command_buffer/service/image_manager.h" |
29 #include "gpu/command_buffer/service/mailbox_manager.h" | 30 #include "gpu/command_buffer/service/mailbox_manager.h" |
30 #include "ipc/ipc_channel.h" | 31 #include "ipc/ipc_channel.h" |
31 #include "ipc/ipc_channel_proxy.h" | 32 #include "ipc/ipc_channel_proxy.h" |
32 #include "ui/gl/gl_context.h" | 33 #include "ui/gl/gl_context.h" |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 | 755 |
755 void GpuChannel::OnDestroy() { | 756 void GpuChannel::OnDestroy() { |
756 TRACE_EVENT0("gpu", "GpuChannel::OnDestroy"); | 757 TRACE_EVENT0("gpu", "GpuChannel::OnDestroy"); |
757 gpu_channel_manager_->RemoveChannel(client_id_); | 758 gpu_channel_manager_->RemoveChannel(client_id_); |
758 } | 759 } |
759 | 760 |
760 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { | 761 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { |
761 bool handled = true; | 762 bool handled = true; |
762 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) | 763 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) |
763 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, | 764 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, |
764 OnCreateOffscreenCommandBuffer) | 765 OnCreateOffscreenCommandBuffer) |
765 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, | 766 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, |
766 OnDestroyCommandBuffer) | 767 OnDestroyCommandBuffer) |
| 768 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateVideoEncoder, OnCreateVideoEncoder) |
| 769 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyVideoEncoder, |
| 770 OnDestroyVideoEncoder) |
767 #if defined(OS_ANDROID) | 771 #if defined(OS_ANDROID) |
768 IPC_MESSAGE_HANDLER(GpuChannelMsg_RegisterStreamTextureProxy, | 772 IPC_MESSAGE_HANDLER(GpuChannelMsg_RegisterStreamTextureProxy, |
769 OnRegisterStreamTextureProxy) | 773 OnRegisterStreamTextureProxy) |
770 IPC_MESSAGE_HANDLER(GpuChannelMsg_EstablishStreamTexture, | 774 IPC_MESSAGE_HANDLER(GpuChannelMsg_EstablishStreamTexture, |
771 OnEstablishStreamTexture) | 775 OnEstablishStreamTexture) |
772 IPC_MESSAGE_HANDLER(GpuChannelMsg_SetStreamTextureSize, | 776 IPC_MESSAGE_HANDLER(GpuChannelMsg_SetStreamTextureSize, |
773 OnSetStreamTextureSize) | 777 OnSetStreamTextureSize) |
774 #endif | 778 #endif |
775 IPC_MESSAGE_HANDLER( | 779 IPC_MESSAGE_HANDLER( |
776 GpuChannelMsg_CollectRenderingStatsForSurface, | 780 GpuChannelMsg_CollectRenderingStatsForSurface, |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 router_.RemoveRoute(route_id); | 903 router_.RemoveRoute(route_id); |
900 stubs_.Remove(route_id); | 904 stubs_.Remove(route_id); |
901 // In case the renderer is currently blocked waiting for a sync reply from the | 905 // In case the renderer is currently blocked waiting for a sync reply from the |
902 // stub, we need to make sure to reschedule the GpuChannel here. | 906 // stub, we need to make sure to reschedule the GpuChannel here. |
903 if (need_reschedule) { | 907 if (need_reschedule) { |
904 // This stub won't get a chance to reschedule, so update the count now. | 908 // This stub won't get a chance to reschedule, so update the count now. |
905 StubSchedulingChanged(true); | 909 StubSchedulingChanged(true); |
906 } | 910 } |
907 } | 911 } |
908 | 912 |
| 913 void GpuChannel::OnCreateVideoEncoder(int32* route_id) { |
| 914 TRACE_EVENT0("gpu", "GpuChannel::OnCreateVideoEncoder"); |
| 915 |
| 916 *route_id = GenerateRouteID(); |
| 917 GpuVideoEncodeAccelerator* encoder = |
| 918 new GpuVideoEncodeAccelerator(this, *route_id); |
| 919 router_.AddRoute(*route_id, encoder); |
| 920 video_encoders_.AddWithID(encoder, *route_id); |
| 921 } |
| 922 |
| 923 void GpuChannel::OnDestroyVideoEncoder(int32 route_id) { |
| 924 TRACE_EVENT1( |
| 925 "gpu", "GpuChannel::OnDestroyVideoEncoder", "route_id", route_id); |
| 926 GpuVideoEncodeAccelerator* encoder = video_encoders_.Lookup(route_id); |
| 927 if (!encoder) |
| 928 return; |
| 929 router_.RemoveRoute(route_id); |
| 930 delete encoder; |
| 931 } |
| 932 |
909 #if defined(OS_ANDROID) | 933 #if defined(OS_ANDROID) |
910 void GpuChannel::OnRegisterStreamTextureProxy( | 934 void GpuChannel::OnRegisterStreamTextureProxy( |
911 int32 stream_id, int32* route_id) { | 935 int32 stream_id, int32* route_id) { |
912 // Note that route_id is only used for notifications sent out from here. | 936 // Note that route_id is only used for notifications sent out from here. |
913 // StreamTextureManager owns all texture objects and for incoming messages | 937 // StreamTextureManager owns all texture objects and for incoming messages |
914 // it finds the correct object based on stream_id. | 938 // it finds the correct object based on stream_id. |
915 *route_id = GenerateRouteID(); | 939 *route_id = GenerateRouteID(); |
916 stream_texture_manager_->RegisterStreamTextureProxy(stream_id, *route_id); | 940 stream_texture_manager_->RegisterStreamTextureProxy(stream_id, *route_id); |
917 } | 941 } |
918 | 942 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 } | 986 } |
963 } | 987 } |
964 | 988 |
965 void GpuChannel::CacheShader(const std::string& key, | 989 void GpuChannel::CacheShader(const std::string& key, |
966 const std::string& shader) { | 990 const std::string& shader) { |
967 gpu_channel_manager_->Send( | 991 gpu_channel_manager_->Send( |
968 new GpuHostMsg_CacheShader(client_id_, key, shader)); | 992 new GpuHostMsg_CacheShader(client_id_, key, shader)); |
969 } | 993 } |
970 | 994 |
971 } // namespace content | 995 } // namespace content |
OLD | NEW |