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 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
6 #define CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 int channel_id() const { return channel_id_; } | 100 int channel_id() const { return channel_id_; } |
101 | 101 |
102 // The GPU stats reported by the GPU process. | 102 // The GPU stats reported by the GPU process. |
103 const gpu::GPUInfo& gpu_info() const { return gpu_info_; } | 103 const gpu::GPUInfo& gpu_info() const { return gpu_info_; } |
104 | 104 |
105 // IPC::Sender implementation: | 105 // IPC::Sender implementation: |
106 bool Send(IPC::Message* msg) override; | 106 bool Send(IPC::Message* msg) override; |
107 | 107 |
108 // Set an ordering barrier. AsyncFlushes any pending barriers on other | 108 // Set an ordering barrier. AsyncFlushes any pending barriers on other |
109 // routes. Combines multiple OrderingBarriers into a single AsyncFlush. | 109 // routes. Combines multiple OrderingBarriers into a single AsyncFlush. |
110 void OrderingBarrier(int32 route_id, | 110 // Returns the flush ID for the stream or 0 if put offset was not changed. |
111 int32 stream_id, | 111 uint32_t OrderingBarrier(int32 route_id, |
112 int32 put_offset, | 112 int32 stream_id, |
113 uint32 flush_count, | 113 int32 put_offset, |
114 const std::vector<ui::LatencyInfo>& latency_info, | 114 uint32 flush_count, |
115 bool put_offset_changed, | 115 const std::vector<ui::LatencyInfo>& latency_info, |
116 bool do_flush); | 116 bool put_offset_changed, |
| 117 bool do_flush); |
117 | 118 |
118 // Create and connect to a command buffer in the GPU process. | 119 // Create and connect to a command buffer in the GPU process. |
119 scoped_ptr<CommandBufferProxyImpl> CreateViewCommandBuffer( | 120 scoped_ptr<CommandBufferProxyImpl> CreateViewCommandBuffer( |
120 int32 surface_id, | 121 int32 surface_id, |
121 CommandBufferProxyImpl* share_group, | 122 CommandBufferProxyImpl* share_group, |
122 int32 stream_id, | 123 int32 stream_id, |
123 GpuStreamPriority stream_priority, | 124 GpuStreamPriority stream_priority, |
124 const std::vector<int32>& attribs, | 125 const std::vector<int32>& attribs, |
125 const GURL& active_url, | 126 const GURL& active_url, |
126 gfx::GpuPreference gpu_preference); | 127 gfx::GpuPreference gpu_preference); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 175 |
175 // Reserve one unused image ID. | 176 // Reserve one unused image ID. |
176 int32 ReserveImageId(); | 177 int32 ReserveImageId(); |
177 | 178 |
178 // Generate a route ID guaranteed to be unique for this channel. | 179 // Generate a route ID guaranteed to be unique for this channel. |
179 int32 GenerateRouteID(); | 180 int32 GenerateRouteID(); |
180 | 181 |
181 // Generate a stream ID guaranteed to be unique for this channel. | 182 // Generate a stream ID guaranteed to be unique for this channel. |
182 int32 GenerateStreamID(); | 183 int32 GenerateStreamID(); |
183 | 184 |
| 185 // Sends a synchronous nop to the server which validate that all previous IPC |
| 186 // messages have been received. Once the synchronous nop has been sent to the |
| 187 // server all previous flushes will all be marked as validated, including |
| 188 // flushes for other streams on the same channel. Once a validation has been |
| 189 // sent, it will return the highest validated flush id for the stream. |
| 190 // If the validation fails (which can only happen upon context lost), the |
| 191 // highest validated flush id will not change. If no flush ID were ever |
| 192 // validated then it will return 0 (Note the lowest valid flush ID is 1). |
| 193 uint32_t ValidateFlushIDReachedServer(int32 stream_id); |
| 194 |
| 195 // Returns the highest validated flush ID for a given stream. |
| 196 uint32_t GetHighestValidatedFlushID(int32 stream_id); |
| 197 |
184 private: | 198 private: |
185 friend class base::RefCountedThreadSafe<GpuChannelHost>; | 199 friend class base::RefCountedThreadSafe<GpuChannelHost>; |
186 | 200 |
187 // A filter used internally to route incoming messages from the IO thread | 201 // A filter used internally to route incoming messages from the IO thread |
188 // to the correct message loop. It also maintains some shared state between | 202 // to the correct message loop. It also maintains some shared state between |
189 // all the contexts. | 203 // all the contexts. |
190 class MessageFilter : public IPC::MessageFilter { | 204 class MessageFilter : public IPC::MessageFilter { |
191 public: | 205 public: |
192 MessageFilter(); | 206 MessageFilter(); |
193 | 207 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 mutable base::Lock lock_; | 241 mutable base::Lock lock_; |
228 | 242 |
229 // Whether the channel has been lost. | 243 // Whether the channel has been lost. |
230 bool lost_; | 244 bool lost_; |
231 }; | 245 }; |
232 | 246 |
233 struct StreamFlushInfo { | 247 struct StreamFlushInfo { |
234 StreamFlushInfo(); | 248 StreamFlushInfo(); |
235 ~StreamFlushInfo(); | 249 ~StreamFlushInfo(); |
236 | 250 |
| 251 // These are global per stream. |
| 252 uint32_t next_stream_flush_id; |
| 253 uint32_t flushed_stream_flush_id; |
| 254 uint32_t verified_stream_flush_id; |
| 255 |
| 256 // These are local per context. |
237 bool flush_pending; | 257 bool flush_pending; |
238 int32 route_id; | 258 int32 route_id; |
239 int32 put_offset; | 259 int32 put_offset; |
240 uint32 flush_count; | 260 uint32 flush_count; |
| 261 uint32_t flush_id; |
241 std::vector<ui::LatencyInfo> latency_info; | 262 std::vector<ui::LatencyInfo> latency_info; |
242 }; | 263 }; |
243 | 264 |
244 GpuChannelHost(GpuChannelHostFactory* factory, | 265 GpuChannelHost(GpuChannelHostFactory* factory, |
245 int channel_id, | 266 int channel_id, |
246 const gpu::GPUInfo& gpu_info, | 267 const gpu::GPUInfo& gpu_info, |
247 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager); | 268 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager); |
248 ~GpuChannelHost() override; | 269 ~GpuChannelHost() override; |
249 void Connect(const IPC::ChannelHandle& channel_handle, | 270 void Connect(const IPC::ChannelHandle& channel_handle, |
250 base::WaitableEvent* shutdown_event); | 271 base::WaitableEvent* shutdown_event); |
251 bool InternalSend(IPC::Message* msg); | 272 bool InternalSend(IPC::Message* msg); |
252 void InternalFlush(int32 stream_id); | 273 void InternalFlush(StreamFlushInfo* flush_info); |
253 | 274 |
254 // Threading notes: all fields are constant during the lifetime of |this| | 275 // Threading notes: all fields are constant during the lifetime of |this| |
255 // except: | 276 // except: |
256 // - |next_image_id_|, atomic type | 277 // - |next_image_id_|, atomic type |
257 // - |next_route_id_|, atomic type | 278 // - |next_route_id_|, atomic type |
258 // - |next_stream_id_|, atomic type | 279 // - |next_stream_id_|, atomic type |
259 // - |channel_| and |stream_flush_info_|, protected by |context_lock_| | 280 // - |channel_| and |stream_flush_info_|, protected by |context_lock_| |
260 GpuChannelHostFactory* const factory_; | 281 GpuChannelHostFactory* const factory_; |
261 | 282 |
262 const int channel_id_; | 283 const int channel_id_; |
(...skipping 19 matching lines...) Expand all Loading... |
282 mutable base::Lock context_lock_; | 303 mutable base::Lock context_lock_; |
283 scoped_ptr<IPC::SyncChannel> channel_; | 304 scoped_ptr<IPC::SyncChannel> channel_; |
284 base::hash_map<int32, StreamFlushInfo> stream_flush_info_; | 305 base::hash_map<int32, StreamFlushInfo> stream_flush_info_; |
285 | 306 |
286 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); | 307 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); |
287 }; | 308 }; |
288 | 309 |
289 } // namespace content | 310 } // namespace content |
290 | 311 |
291 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 312 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ |
OLD | NEW |