| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CONTENT_GPU_GPU_CHANNEL_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
| 6 #define CONTENT_GPU_GPU_CHANNEL_H_ | 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/process.h" | 15 #include "base/process.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 17 #include "content/common/message_router.h" | 18 #include "content/common/message_router.h" |
| 18 #include "content/gpu/gpu_command_buffer_stub.h" | |
| 19 #include "ipc/ipc_sync_channel.h" | 19 #include "ipc/ipc_sync_channel.h" |
| 20 #include "ui/gfx/native_widget_types.h" | 20 #include "ui/gfx/native_widget_types.h" |
| 21 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 22 | 22 |
| 23 class GpuRenderThread; | 23 class GpuChannelManager; |
| 24 class GpuWatchdogThread; | 24 class GpuWatchdogThread; |
| 25 struct GPUCreateCommandBufferConfig; | 25 struct GPUCreateCommandBufferConfig; |
| 26 class MessageLoop; | 26 class MessageLoop; |
| 27 | 27 |
| 28 namespace base { | 28 namespace base { |
| 29 class WaitableEvent; | 29 class WaitableEvent; |
| 30 } | 30 } |
| 31 | 31 |
| 32 // Encapsulates an IPC channel between the GPU process and one renderer | 32 // Encapsulates an IPC channel between the GPU process and one renderer |
| 33 // process. On the renderer side there's a corresponding GpuChannelHost. | 33 // process. On the renderer side there's a corresponding GpuChannelHost. |
| 34 class GpuChannel : public IPC::Channel::Listener, | 34 class GpuChannel : public IPC::Channel::Listener, |
| 35 public IPC::Message::Sender, | 35 public IPC::Message::Sender, |
| 36 public base::RefCountedThreadSafe<GpuChannel> { | 36 public base::RefCountedThreadSafe<GpuChannel> { |
| 37 public: | 37 public: |
| 38 // Takes ownership of the renderer process handle. | 38 // Takes ownership of the renderer process handle. |
| 39 GpuChannel(GpuRenderThread* gpu_render_thread, | 39 GpuChannel(GpuChannelManager* gpu_channel_manager, |
| 40 GpuWatchdogThread* gpu_watchdog_thread, | 40 GpuWatchdogThread* gpu_watchdog_thread, |
| 41 int renderer_id); | 41 int renderer_id); |
| 42 virtual ~GpuChannel(); | 42 virtual ~GpuChannel(); |
| 43 | 43 |
| 44 bool Init(MessageLoop* io_message_loop, base::WaitableEvent* shutdown_event); | 44 bool Init(MessageLoop* io_message_loop, base::WaitableEvent* shutdown_event); |
| 45 | 45 |
| 46 // Get the GpuThread that owns this channel. | 46 // Get the GpuChannelManager that owns this channel. |
| 47 GpuRenderThread* gpu_render_thread() const { return gpu_render_thread_; } | 47 GpuChannelManager* gpu_channel_manager() const { |
| 48 return gpu_channel_manager_; |
| 49 } |
| 48 | 50 |
| 49 // Returns the name of the associated IPC channel. | 51 // Returns the name of the associated IPC channel. |
| 50 std::string GetChannelName(); | 52 std::string GetChannelName(); |
| 51 | 53 |
| 52 #if defined(OS_POSIX) | 54 #if defined(OS_POSIX) |
| 53 int GetRendererFileDescriptor(); | 55 int GetRendererFileDescriptor(); |
| 54 #endif // defined(OS_POSIX) | 56 #endif // defined(OS_POSIX) |
| 55 | 57 |
| 56 base::ProcessHandle renderer_process() const { | 58 base::ProcessHandle renderer_process() const { |
| 57 return renderer_process_; | 59 return renderer_process_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 const gfx::Size& size, | 91 const gfx::Size& size, |
| 90 const GPUCreateCommandBufferConfig& init_params, | 92 const GPUCreateCommandBufferConfig& init_params, |
| 91 uint32 parent_texture_id, | 93 uint32 parent_texture_id, |
| 92 int32* route_id); | 94 int32* route_id); |
| 93 void OnDestroyCommandBuffer(int32 route_id); | 95 void OnDestroyCommandBuffer(int32 route_id); |
| 94 | 96 |
| 95 void OnCreateVideoDecoder(int32 context_route_id, | 97 void OnCreateVideoDecoder(int32 context_route_id, |
| 96 int32 decoder_host_id); | 98 int32 decoder_host_id); |
| 97 void OnDestroyVideoDecoder(int32 decoder_id); | 99 void OnDestroyVideoDecoder(int32 decoder_id); |
| 98 | 100 |
| 99 // The lifetime of objects of this class is managed by a GpuRenderThread. The | 101 // The lifetime of objects of this class is managed by a GpuChannelManager. |
| 100 // GpuRenderThreads destroy all the GpuChannels that they own when they | 102 // The GpuChannelManager destroy all the GpuChannels that they own when they |
| 101 // are destroyed. So a raw pointer is safe. | 103 // are destroyed. So a raw pointer is safe. |
| 102 GpuRenderThread* gpu_render_thread_; | 104 GpuChannelManager* gpu_channel_manager_; |
| 103 | 105 |
| 104 scoped_ptr<IPC::SyncChannel> channel_; | 106 scoped_ptr<IPC::SyncChannel> channel_; |
| 105 | 107 |
| 106 // The id of the renderer who is on the other side of the channel. | 108 // The id of the renderer who is on the other side of the channel. |
| 107 int renderer_id_; | 109 int renderer_id_; |
| 108 | 110 |
| 109 // Handle to the renderer process that is on the other side of the channel. | 111 // Handle to the renderer process that is on the other side of the channel. |
| 110 base::ProcessHandle renderer_process_; | 112 base::ProcessHandle renderer_process_; |
| 111 | 113 |
| 112 // The process id of the renderer process. | 114 // The process id of the renderer process. |
| 113 base::ProcessId renderer_pid_; | 115 base::ProcessId renderer_pid_; |
| 114 | 116 |
| 115 // Used to implement message routing functionality to CommandBuffer objects | 117 // Used to implement message routing functionality to CommandBuffer objects |
| 116 MessageRouter router_; | 118 MessageRouter router_; |
| 117 | 119 |
| 118 #if defined(ENABLE_GPU) | 120 #if defined(ENABLE_GPU) |
| 119 typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap; | 121 typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap; |
| 120 StubMap stubs_; | 122 StubMap stubs_; |
| 121 #endif // defined (ENABLE_GPU) | 123 #endif // defined (ENABLE_GPU) |
| 122 | 124 |
| 123 bool log_messages_; // True if we should log sent and received messages. | 125 bool log_messages_; // True if we should log sent and received messages. |
| 124 gpu::gles2::DisallowedExtensions disallowed_extensions_; | 126 gpu::gles2::DisallowedExtensions disallowed_extensions_; |
| 125 GpuWatchdogThread* watchdog_thread_; | 127 GpuWatchdogThread* watchdog_thread_; |
| 126 | 128 |
| 127 DISALLOW_COPY_AND_ASSIGN(GpuChannel); | 129 DISALLOW_COPY_AND_ASSIGN(GpuChannel); |
| 128 }; | 130 }; |
| 129 | 131 |
| 130 #endif // CONTENT_GPU_GPU_CHANNEL_H_ | 132 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
| OLD | NEW |