| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_GPU_GPU_CHANNEL_H_ | |
| 6 #define CHROME_GPU_GPU_CHANNEL_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <set> | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/id_map.h" | |
| 14 #include "base/process.h" | |
| 15 #include "base/scoped_ptr.h" | |
| 16 #include "build/build_config.h" | |
| 17 #include "chrome/gpu/gpu_command_buffer_stub.h" | |
| 18 #include "content/common/message_router.h" | |
| 19 #include "ipc/ipc_sync_channel.h" | |
| 20 #include "ui/gfx/native_widget_types.h" | |
| 21 #include "ui/gfx/size.h" | |
| 22 | |
| 23 class GpuThread; | |
| 24 struct GPUCreateCommandBufferConfig; | |
| 25 | |
| 26 // Encapsulates an IPC channel between the GPU process and one renderer | |
| 27 // process. On the renderer side there's a corresponding GpuChannelHost. | |
| 28 class GpuChannel : public IPC::Channel::Listener, | |
| 29 public IPC::Message::Sender, | |
| 30 public base::RefCountedThreadSafe<GpuChannel> { | |
| 31 public: | |
| 32 // Takes ownership of the renderer process handle. | |
| 33 GpuChannel(GpuThread* gpu_thread, | |
| 34 int renderer_id); | |
| 35 virtual ~GpuChannel(); | |
| 36 | |
| 37 bool Init(); | |
| 38 | |
| 39 // Get the GpuThread that owns this channel. | |
| 40 GpuThread* gpu_thread() const { return gpu_thread_; } | |
| 41 | |
| 42 // Returns the name of the associated IPC channel. | |
| 43 std::string GetChannelName(); | |
| 44 | |
| 45 #if defined(OS_POSIX) | |
| 46 int GetRendererFileDescriptor(); | |
| 47 #endif // defined(OS_POSIX) | |
| 48 | |
| 49 base::ProcessHandle renderer_process() const { | |
| 50 return renderer_process_; | |
| 51 } | |
| 52 | |
| 53 // IPC::Channel::Listener implementation: | |
| 54 virtual bool OnMessageReceived(const IPC::Message& msg); | |
| 55 virtual void OnChannelError(); | |
| 56 virtual void OnChannelConnected(int32 peer_pid); | |
| 57 | |
| 58 // IPC::Message::Sender implementation: | |
| 59 virtual bool Send(IPC::Message* msg); | |
| 60 | |
| 61 void CreateViewCommandBuffer( | |
| 62 gfx::PluginWindowHandle window, | |
| 63 int32 render_view_id, | |
| 64 const GPUCreateCommandBufferConfig& init_params, | |
| 65 int32* route_id); | |
| 66 | |
| 67 #if defined(OS_MACOSX) | |
| 68 virtual void AcceleratedSurfaceBuffersSwapped( | |
| 69 int32 route_id, uint64 swap_buffers_count); | |
| 70 void DidDestroySurface(int32 renderer_route_id); | |
| 71 | |
| 72 bool IsRenderViewGone(int32 renderer_route_id); | |
| 73 #endif | |
| 74 | |
| 75 private: | |
| 76 bool OnControlMessageReceived(const IPC::Message& msg); | |
| 77 | |
| 78 int GenerateRouteID(); | |
| 79 | |
| 80 // Message handlers. | |
| 81 void OnInitialize(base::ProcessHandle renderer_process); | |
| 82 void OnCreateOffscreenCommandBuffer( | |
| 83 int32 parent_route_id, | |
| 84 const gfx::Size& size, | |
| 85 const GPUCreateCommandBufferConfig& init_params, | |
| 86 uint32 parent_texture_id, | |
| 87 int32* route_id); | |
| 88 void OnDestroyCommandBuffer(int32 route_id); | |
| 89 | |
| 90 void OnCreateVideoDecoder(int32 context_route_id, | |
| 91 int32 decoder_host_id); | |
| 92 void OnDestroyVideoDecoder(int32 decoder_id); | |
| 93 | |
| 94 // The lifetime of objects of this class is managed by a GpuThread. The | |
| 95 // GpuThreadss destroy all the GpuChannels that they own when they | |
| 96 // are destroyed. So a raw pointer is safe. | |
| 97 GpuThread* gpu_thread_; | |
| 98 | |
| 99 scoped_ptr<IPC::SyncChannel> channel_; | |
| 100 | |
| 101 // The id of the renderer who is on the other side of the channel. | |
| 102 int renderer_id_; | |
| 103 | |
| 104 // Handle to the renderer process that is on the other side of the channel. | |
| 105 base::ProcessHandle renderer_process_; | |
| 106 | |
| 107 // The process id of the renderer process. | |
| 108 base::ProcessId renderer_pid_; | |
| 109 | |
| 110 // Used to implement message routing functionality to CommandBuffer objects | |
| 111 MessageRouter router_; | |
| 112 | |
| 113 #if defined(ENABLE_GPU) | |
| 114 typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap; | |
| 115 StubMap stubs_; | |
| 116 | |
| 117 #if defined(OS_MACOSX) | |
| 118 std::set<int32> destroyed_renderer_routes_; | |
| 119 #endif // defined (OS_MACOSX) | |
| 120 #endif // defined (ENABLE_GPU) | |
| 121 | |
| 122 bool log_messages_; // True if we should log sent and received messages. | |
| 123 | |
| 124 DISALLOW_COPY_AND_ASSIGN(GpuChannel); | |
| 125 }; | |
| 126 | |
| 127 #endif // CHROME_GPU_GPU_CHANNEL_H_ | |
| OLD | NEW |