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" | |
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 "crypto/hmac.h" | 25 #include "crypto/hmac.h" |
27 #include "gpu/command_buffer/common/mailbox.h" | 26 #include "gpu/command_buffer/common/mailbox.h" |
28 #include "gpu/command_buffer/service/gpu_scheduler.h" | 27 #include "gpu/command_buffer/service/gpu_scheduler.h" |
29 #include "gpu/command_buffer/service/image_manager.h" | 28 #include "gpu/command_buffer/service/image_manager.h" |
30 #include "gpu/command_buffer/service/mailbox_manager.h" | 29 #include "gpu/command_buffer/service/mailbox_manager.h" |
31 #include "ipc/ipc_channel.h" | 30 #include "ipc/ipc_channel.h" |
32 #include "ipc/ipc_channel_proxy.h" | 31 #include "ipc/ipc_channel_proxy.h" |
33 #include "ui/gl/gl_context.h" | 32 #include "ui/gl/gl_context.h" |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 | 747 |
749 void GpuChannel::OnDestroy() { | 748 void GpuChannel::OnDestroy() { |
750 TRACE_EVENT0("gpu", "GpuChannel::OnDestroy"); | 749 TRACE_EVENT0("gpu", "GpuChannel::OnDestroy"); |
751 gpu_channel_manager_->RemoveChannel(client_id_); | 750 gpu_channel_manager_->RemoveChannel(client_id_); |
752 } | 751 } |
753 | 752 |
754 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { | 753 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { |
755 bool handled = true; | 754 bool handled = true; |
756 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) | 755 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) |
757 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, | 756 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, |
758 OnCreateOffscreenCommandBuffer) | 757 OnCreateOffscreenCommandBuffer) |
759 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, | 758 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, |
760 OnDestroyCommandBuffer) | 759 OnDestroyCommandBuffer) |
761 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateVideoEncoder, OnCreateVideoEncoder) | |
762 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyVideoEncoder, | |
763 OnDestroyVideoEncoder) | |
764 #if defined(OS_ANDROID) | 760 #if defined(OS_ANDROID) |
765 IPC_MESSAGE_HANDLER(GpuChannelMsg_RegisterStreamTextureProxy, | 761 IPC_MESSAGE_HANDLER(GpuChannelMsg_RegisterStreamTextureProxy, |
766 OnRegisterStreamTextureProxy) | 762 OnRegisterStreamTextureProxy) |
767 IPC_MESSAGE_HANDLER(GpuChannelMsg_EstablishStreamTexture, | 763 IPC_MESSAGE_HANDLER(GpuChannelMsg_EstablishStreamTexture, |
768 OnEstablishStreamTexture) | 764 OnEstablishStreamTexture) |
769 IPC_MESSAGE_HANDLER(GpuChannelMsg_SetStreamTextureSize, | 765 IPC_MESSAGE_HANDLER(GpuChannelMsg_SetStreamTextureSize, |
770 OnSetStreamTextureSize) | 766 OnSetStreamTextureSize) |
771 #endif | 767 #endif |
772 IPC_MESSAGE_HANDLER( | 768 IPC_MESSAGE_HANDLER( |
773 GpuChannelMsg_CollectRenderingStatsForSurface, | 769 GpuChannelMsg_CollectRenderingStatsForSurface, |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 router_.RemoveRoute(route_id); | 892 router_.RemoveRoute(route_id); |
897 stubs_.Remove(route_id); | 893 stubs_.Remove(route_id); |
898 // In case the renderer is currently blocked waiting for a sync reply from the | 894 // In case the renderer is currently blocked waiting for a sync reply from the |
899 // stub, we need to make sure to reschedule the GpuChannel here. | 895 // stub, we need to make sure to reschedule the GpuChannel here. |
900 if (need_reschedule) { | 896 if (need_reschedule) { |
901 // This stub won't get a chance to reschedule, so update the count now. | 897 // This stub won't get a chance to reschedule, so update the count now. |
902 StubSchedulingChanged(true); | 898 StubSchedulingChanged(true); |
903 } | 899 } |
904 } | 900 } |
905 | 901 |
906 void GpuChannel::OnCreateVideoEncoder(int32* route_id) { | |
907 TRACE_EVENT0("gpu", "GpuChannel::OnCreateVideoEncoder"); | |
908 | |
909 *route_id = GenerateRouteID(); | |
910 GpuVideoEncodeAccelerator* encoder = | |
911 new GpuVideoEncodeAccelerator(this, *route_id); | |
912 router_.AddRoute(*route_id, encoder); | |
913 video_encoders_.AddWithID(encoder, *route_id); | |
914 } | |
915 | |
916 void GpuChannel::OnDestroyVideoEncoder(int32 route_id) { | |
917 TRACE_EVENT1( | |
918 "gpu", "GpuChannel::OnDestroyVideoEncoder", "route_id", route_id); | |
919 GpuVideoEncodeAccelerator* encoder = video_encoders_.Lookup(route_id); | |
920 if (!encoder) | |
921 return; | |
922 router_.RemoveRoute(route_id); | |
923 video_encoders_.Remove(route_id); | |
924 } | |
925 | |
926 #if defined(OS_ANDROID) | 902 #if defined(OS_ANDROID) |
927 void GpuChannel::OnRegisterStreamTextureProxy( | 903 void GpuChannel::OnRegisterStreamTextureProxy( |
928 int32 stream_id, int32* route_id) { | 904 int32 stream_id, int32* route_id) { |
929 // Note that route_id is only used for notifications sent out from here. | 905 // Note that route_id is only used for notifications sent out from here. |
930 // StreamTextureManager owns all texture objects and for incoming messages | 906 // StreamTextureManager owns all texture objects and for incoming messages |
931 // it finds the correct object based on stream_id. | 907 // it finds the correct object based on stream_id. |
932 *route_id = GenerateRouteID(); | 908 *route_id = GenerateRouteID(); |
933 stream_texture_manager_->RegisterStreamTextureProxy(stream_id, *route_id); | 909 stream_texture_manager_->RegisterStreamTextureProxy(stream_id, *route_id); |
934 } | 910 } |
935 | 911 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 } | 955 } |
980 } | 956 } |
981 | 957 |
982 void GpuChannel::CacheShader(const std::string& key, | 958 void GpuChannel::CacheShader(const std::string& key, |
983 const std::string& shader) { | 959 const std::string& shader) { |
984 gpu_channel_manager_->Send( | 960 gpu_channel_manager_->Send( |
985 new GpuHostMsg_CacheShader(client_id_, key, shader)); | 961 new GpuHostMsg_CacheShader(client_id_, key, shader)); |
986 } | 962 } |
987 | 963 |
988 } // namespace content | 964 } // namespace content |
OLD | NEW |