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_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <queue> |
9 #include <set> | 10 #include <set> |
10 #include <string> | 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/id_map.h" | 14 #include "base/id_map.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/process.h" | 17 #include "base/process.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "gpu/command_buffer/service/surface_manager.h" | 19 #include "gpu/command_buffer/service/surface_manager.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 72 } |
72 | 73 |
73 // IPC::Channel::Listener implementation: | 74 // IPC::Channel::Listener implementation: |
74 virtual bool OnMessageReceived(const IPC::Message& msg); | 75 virtual bool OnMessageReceived(const IPC::Message& msg); |
75 virtual void OnChannelError(); | 76 virtual void OnChannelError(); |
76 virtual void OnChannelConnected(int32 peer_pid); | 77 virtual void OnChannelConnected(int32 peer_pid); |
77 | 78 |
78 // IPC::Message::Sender implementation: | 79 // IPC::Message::Sender implementation: |
79 virtual bool Send(IPC::Message* msg); | 80 virtual bool Send(IPC::Message* msg); |
80 | 81 |
| 82 // Whether this channel is able to handle IPC messages. |
| 83 bool IsScheduled(); |
| 84 |
| 85 // This is called when a command buffer transitions from the unscheduled |
| 86 // state to the scheduled state, which potentially means the channel |
| 87 // transitions from the unscheduled to the scheduled state. When this occurs |
| 88 // deferred IPC messaged are handled. |
| 89 void OnScheduled(); |
| 90 |
81 void CreateViewCommandBuffer( | 91 void CreateViewCommandBuffer( |
82 gfx::PluginWindowHandle window, | 92 gfx::PluginWindowHandle window, |
83 int32 render_view_id, | 93 int32 render_view_id, |
84 const GPUCreateCommandBufferConfig& init_params, | 94 const GPUCreateCommandBufferConfig& init_params, |
85 int32* route_id); | 95 int32* route_id); |
86 | 96 |
87 void ViewResized(int32 command_buffer_route_id); | 97 void ViewResized(int32 command_buffer_route_id); |
88 | 98 |
89 gfx::GLShareGroup* share_group() const { return share_group_.get(); } | 99 gfx::GLShareGroup* share_group() const { return share_group_.get(); } |
90 | 100 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // A callback which is called after a Set/WaitLatch command is processed. | 134 // A callback which is called after a Set/WaitLatch command is processed. |
125 // The bool parameter will be true for SetLatch, and false for a WaitLatch | 135 // The bool parameter will be true for SetLatch, and false for a WaitLatch |
126 // that is blocked. An unblocked WaitLatch will not trigger a callback. | 136 // that is blocked. An unblocked WaitLatch will not trigger a callback. |
127 void OnLatchCallback(int route_id, bool is_set_latch); | 137 void OnLatchCallback(int route_id, bool is_set_latch); |
128 | 138 |
129 private: | 139 private: |
130 void OnDestroy(); | 140 void OnDestroy(); |
131 | 141 |
132 bool OnControlMessageReceived(const IPC::Message& msg); | 142 bool OnControlMessageReceived(const IPC::Message& msg); |
133 | 143 |
| 144 void HandleDeferredMessages(); |
| 145 |
134 int GenerateRouteID(); | 146 int GenerateRouteID(); |
135 | 147 |
136 // Message handlers. | 148 // Message handlers. |
137 void OnInitialize(base::ProcessHandle renderer_process); | 149 void OnInitialize(base::ProcessHandle renderer_process); |
138 void OnCreateOffscreenCommandBuffer( | 150 void OnCreateOffscreenCommandBuffer( |
139 const gfx::Size& size, | 151 const gfx::Size& size, |
140 const GPUCreateCommandBufferConfig& init_params, | 152 const GPUCreateCommandBufferConfig& init_params, |
141 int32* route_id); | 153 IPC::Message* reply_message); |
142 void OnDestroyCommandBuffer(int32 route_id); | 154 void OnDestroyCommandBuffer(int32 route_id, IPC::Message* reply_message); |
143 | 155 |
144 void OnCreateOffscreenSurface(const gfx::Size& size, | 156 void OnCreateOffscreenSurface(const gfx::Size& size, |
145 int* route_id); | 157 IPC::Message* reply_message); |
146 void OnDestroySurface(int route_id); | 158 void OnDestroySurface(int route_id); |
147 | 159 |
148 void OnCreateTransportTexture(int32 context_route_id, int32 host_id); | 160 void OnCreateTransportTexture(int32 context_route_id, int32 host_id); |
149 | 161 |
150 // The lifetime of objects of this class is managed by a GpuChannelManager. | 162 // The lifetime of objects of this class is managed by a GpuChannelManager. |
151 // The GpuChannelManager destroy all the GpuChannels that they own when they | 163 // The GpuChannelManager destroy all the GpuChannels that they own when they |
152 // are destroyed. So a raw pointer is safe. | 164 // are destroyed. So a raw pointer is safe. |
153 GpuChannelManager* gpu_channel_manager_; | 165 GpuChannelManager* gpu_channel_manager_; |
154 | 166 |
155 scoped_ptr<IPC::SyncChannel> channel_; | 167 scoped_ptr<IPC::SyncChannel> channel_; |
156 | 168 |
| 169 std::queue<IPC::Message*> deferred_messages_; |
| 170 |
157 // The id of the renderer who is on the other side of the channel. | 171 // The id of the renderer who is on the other side of the channel. |
158 int renderer_id_; | 172 int renderer_id_; |
159 | 173 |
160 // Handle to the renderer process that is on the other side of the channel. | 174 // Handle to the renderer process that is on the other side of the channel. |
161 base::ProcessHandle renderer_process_; | 175 base::ProcessHandle renderer_process_; |
162 | 176 |
163 // The process id of the renderer process. | 177 // The process id of the renderer process. |
164 base::ProcessId renderer_pid_; | 178 base::ProcessId renderer_pid_; |
165 | 179 |
166 // Used to implement message routing functionality to CommandBuffer objects | 180 // Used to implement message routing functionality to CommandBuffer objects |
(...skipping 14 matching lines...) Expand all Loading... |
181 #endif // defined (ENABLE_GPU) | 195 #endif // defined (ENABLE_GPU) |
182 | 196 |
183 // A collection of transport textures created. | 197 // A collection of transport textures created. |
184 typedef IDMap<TransportTexture, IDMapOwnPointer> TransportTextureMap; | 198 typedef IDMap<TransportTexture, IDMapOwnPointer> TransportTextureMap; |
185 TransportTextureMap transport_textures_; | 199 TransportTextureMap transport_textures_; |
186 | 200 |
187 bool log_messages_; // True if we should log sent and received messages. | 201 bool log_messages_; // True if we should log sent and received messages. |
188 gpu::gles2::DisallowedExtensions disallowed_extensions_; | 202 gpu::gles2::DisallowedExtensions disallowed_extensions_; |
189 GpuWatchdog* watchdog_; | 203 GpuWatchdog* watchdog_; |
190 | 204 |
| 205 ScopedRunnableMethodFactory<GpuChannel> task_factory_; |
| 206 |
191 DISALLOW_COPY_AND_ASSIGN(GpuChannel); | 207 DISALLOW_COPY_AND_ASSIGN(GpuChannel); |
192 }; | 208 }; |
193 | 209 |
194 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 210 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
OLD | NEW |