| 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_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ |
| 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ | 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "ipc/ipc_channel.h" | 13 #include "ipc/ipc_channel.h" |
| 14 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
| 15 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class WaitableEvent; | 18 class WaitableEvent; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace IPC { | 21 namespace IPC { |
| 22 struct ChannelHandle; | 22 struct ChannelHandle; |
| 23 } | 23 } |
| 24 | 24 |
| 25 class ChildThread; |
| 25 class GpuChannel; | 26 class GpuChannel; |
| 26 class GpuWatchdog; | 27 class GpuWatchdog; |
| 27 struct GPUCreateCommandBufferConfig; | 28 struct GPUCreateCommandBufferConfig; |
| 28 | 29 |
| 29 // A GpuChannelManager is a thread responsible for issuing rendering commands | 30 // A GpuChannelManager is a thread responsible for issuing rendering commands |
| 30 // managing the lifetimes of GPU channels and forwarding IPC requests from the | 31 // managing the lifetimes of GPU channels and forwarding IPC requests from the |
| 31 // browser process to them based on the corresponding renderer ID. | 32 // browser process to them based on the corresponding renderer ID. |
| 32 // | 33 // |
| 33 // A GpuChannelManager can also be hosted in the browser process in single | 34 // A GpuChannelManager can also be hosted in the browser process in single |
| 34 // process or in-process GPU modes. In this case there is no corresponding | 35 // process or in-process GPU modes. In this case there is no corresponding |
| 35 // GpuChildThread and this is the reason the GpuChildThread is referenced via | 36 // GpuChildThread and this is the reason the GpuChildThread is referenced via |
| 36 // a pointer to IPC::Message::Sender, which can be implemented by other hosts | 37 // a pointer to IPC::Message::Sender, which can be implemented by other hosts |
| 37 // to send IPC messages to the browser process IO thread on the | 38 // to send IPC messages to the browser process IO thread on the |
| 38 // GpuChannelManager's behalf. | 39 // GpuChannelManager's behalf. |
| 39 class GpuChannelManager : public IPC::Channel::Listener, | 40 class GpuChannelManager : public IPC::Channel::Listener, |
| 40 public IPC::Message::Sender { | 41 public IPC::Message::Sender { |
| 41 public: | 42 public: |
| 42 GpuChannelManager(IPC::Message::Sender* browser_channel, | 43 GpuChannelManager(ChildThread* gpu_child_thread, |
| 43 GpuWatchdog* watchdog, | 44 GpuWatchdog* watchdog, |
| 44 base::MessageLoopProxy* io_message_loop, | 45 base::MessageLoopProxy* io_message_loop, |
| 45 base::WaitableEvent* shutdown_event); | 46 base::WaitableEvent* shutdown_event); |
| 46 virtual ~GpuChannelManager(); | 47 virtual ~GpuChannelManager(); |
| 47 | 48 |
| 48 // Remove the channel for a particular renderer. | 49 // Remove the channel for a particular renderer. |
| 49 void RemoveChannel(int renderer_id); | 50 void RemoveChannel(int renderer_id); |
| 50 | 51 |
| 51 // Listener overrides. | 52 // Listener overrides. |
| 52 virtual bool OnMessageReceived(const IPC::Message& msg); | 53 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 53 | 54 |
| 54 // Sender overrides. | 55 // Sender overrides. |
| 55 virtual bool Send(IPC::Message* msg); | 56 virtual bool Send(IPC::Message* msg); |
| 56 | 57 |
| 57 void LoseAllContexts(); | 58 void LoseAllContexts(); |
| 58 | 59 |
| 59 ScopedRunnableMethodFactory<GpuChannelManager> method_factory_; | 60 ScopedRunnableMethodFactory<GpuChannelManager> method_factory_; |
| 60 | 61 |
| 62 int GenerateRouteID(); |
| 63 void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); |
| 64 void RemoveRoute(int32 routing_id); |
| 65 |
| 61 private: | 66 private: |
| 62 // Message handlers. | 67 // Message handlers. |
| 63 void OnEstablishChannel(int renderer_id); | 68 void OnEstablishChannel(int renderer_id); |
| 64 void OnCloseChannel(const IPC::ChannelHandle& channel_handle); | 69 void OnCloseChannel(const IPC::ChannelHandle& channel_handle); |
| 65 void OnVisibilityChanged( | 70 void OnVisibilityChanged( |
| 66 int32 render_view_id, int32 renderer_id, bool visible); | 71 int32 render_view_id, int32 renderer_id, bool visible); |
| 67 void OnCreateViewCommandBuffer( | 72 void OnCreateViewCommandBuffer( |
| 68 gfx::PluginWindowHandle window, | 73 gfx::PluginWindowHandle window, |
| 69 int32 render_view_id, | 74 int32 render_view_id, |
| 70 int32 renderer_id, | 75 int32 renderer_id, |
| 71 const GPUCreateCommandBufferConfig& init_params); | 76 const GPUCreateCommandBufferConfig& init_params); |
| 72 void OnResizeViewACK(int32 renderer_id, int32 command_buffer_route_id); | 77 void OnResizeViewACK(int32 renderer_id, int32 command_buffer_route_id); |
| 73 | 78 |
| 74 #if defined(TOUCH_UI) | 79 #if defined(OS_MACOSX) |
| 75 void OnAcceleratedSurfaceSetIOSurfaceACK( | |
| 76 int renderer_id, int32 route_id, uint64 surface_id); | |
| 77 void OnAcceleratedSurfaceReleaseACK( | |
| 78 int renderer_id, int32 route_id, uint64 surface_id); | |
| 79 #endif | |
| 80 | |
| 81 #if defined(OS_MACOSX) || defined(TOUCH_UI) | |
| 82 void OnAcceleratedSurfaceBuffersSwappedACK( | 80 void OnAcceleratedSurfaceBuffersSwappedACK( |
| 83 int renderer_id, int32 route_id, uint64 swap_buffers_count); | 81 int renderer_id, int32 route_id, uint64 swap_buffers_count); |
| 84 #endif | |
| 85 | |
| 86 #if defined(OS_MACOSX) | |
| 87 void OnDestroyCommandBuffer(int renderer_id, int32 renderer_view_id); | 82 void OnDestroyCommandBuffer(int renderer_id, int32 renderer_view_id); |
| 88 #endif | 83 #endif |
| 89 | 84 |
| 90 void OnLoseAllContexts(); | 85 void OnLoseAllContexts(); |
| 91 | 86 |
| 92 scoped_refptr<base::MessageLoopProxy> io_message_loop_; | 87 scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
| 93 base::WaitableEvent* shutdown_event_; | 88 base::WaitableEvent* shutdown_event_; |
| 94 | 89 |
| 95 // Either an IPC channel to the browser or, if the GpuChannelManager is | 90 // Used to send and receive IPC messages from the browser process. |
| 96 // running in the browser process, a Sender implementation that will post | 91 ChildThread* gpu_child_thread_; |
| 97 // IPC messages to the UI thread. | |
| 98 IPC::Message::Sender* browser_channel_; | |
| 99 | 92 |
| 100 // These objects manage channels to individual renderer processes there is | 93 // These objects manage channels to individual renderer processes there is |
| 101 // one channel for each renderer process that has connected to this GPU | 94 // one channel for each renderer process that has connected to this GPU |
| 102 // process. | 95 // process. |
| 103 typedef base::hash_map<int, scoped_refptr<GpuChannel> > GpuChannelMap; | 96 typedef base::hash_map<int, scoped_refptr<GpuChannel> > GpuChannelMap; |
| 104 GpuChannelMap gpu_channels_; | 97 GpuChannelMap gpu_channels_; |
| 105 GpuWatchdog* watchdog_; | 98 GpuWatchdog* watchdog_; |
| 106 | 99 |
| 107 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); | 100 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); |
| 108 }; | 101 }; |
| 109 | 102 |
| 110 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ | 103 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ |
| OLD | NEW |