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