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 GPU_IPC_CLIENT_GPU_CHANNEL_HOST_H_ | 5 #ifndef GPU_IPC_CLIENT_GPU_CHANNEL_HOST_H_ |
6 #define GPU_IPC_CLIENT_GPU_CHANNEL_HOST_H_ | 6 #define GPU_IPC_CLIENT_GPU_CHANNEL_HOST_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/atomic_sequence_num.h" | 15 #include "base/atomic_sequence_num.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/process/process.h" | 19 #include "base/process/process.h" |
20 #include "base/synchronization/lock.h" | 20 #include "base/synchronization/lock.h" |
21 #include "gpu/config/gpu_info.h" | 21 #include "gpu/config/gpu_info.h" |
22 #include "gpu/gpu_export.h" | 22 #include "gpu/gpu_export.h" |
| 23 #include "gpu/ipc/common/gpu_stream_constants.h" |
23 #include "ipc/ipc_channel_handle.h" | 24 #include "ipc/ipc_channel_handle.h" |
24 #include "ipc/ipc_sync_channel.h" | 25 #include "ipc/ipc_sync_channel.h" |
25 #include "ipc/message_filter.h" | 26 #include "ipc/message_filter.h" |
26 #include "ipc/message_router.h" | 27 #include "ipc/message_router.h" |
27 #include "ui/gfx/gpu_memory_buffer.h" | 28 #include "ui/gfx/gpu_memory_buffer.h" |
28 #include "ui/latency/latency_info.h" | 29 #include "ui/latency/latency_info.h" |
29 | 30 |
30 namespace base { | 31 namespace base { |
31 class WaitableEvent; | 32 class WaitableEvent; |
32 } | 33 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 143 |
143 // Reserve one unused transfer buffer ID. | 144 // Reserve one unused transfer buffer ID. |
144 int32_t ReserveTransferBufferId(); | 145 int32_t ReserveTransferBufferId(); |
145 | 146 |
146 // Reserve one unused image ID. | 147 // Reserve one unused image ID. |
147 int32_t ReserveImageId(); | 148 int32_t ReserveImageId(); |
148 | 149 |
149 // Generate a route ID guaranteed to be unique for this channel. | 150 // Generate a route ID guaranteed to be unique for this channel. |
150 int32_t GenerateRouteID(); | 151 int32_t GenerateRouteID(); |
151 | 152 |
| 153 // Generate a stream ID guaranteed to be unique for this channel. |
| 154 int32_t GenerateStreamID(); |
| 155 |
152 // Sends a synchronous nop to the server which validate that all previous IPC | 156 // Sends a synchronous nop to the server which validate that all previous IPC |
153 // messages have been received. Once the synchronous nop has been sent to the | 157 // messages have been received. Once the synchronous nop has been sent to the |
154 // server all previous flushes will all be marked as validated, including | 158 // server all previous flushes will all be marked as validated, including |
155 // flushes for other streams on the same channel. Once a validation has been | 159 // flushes for other streams on the same channel. Once a validation has been |
156 // sent, it will return the highest validated flush id for the stream. | 160 // sent, it will return the highest validated flush id for the stream. |
157 // If the validation fails (which can only happen upon context lost), the | 161 // If the validation fails (which can only happen upon context lost), the |
158 // highest validated flush id will not change. If no flush ID were ever | 162 // highest validated flush id will not change. If no flush ID were ever |
159 // validated then it will return 0 (Note the lowest valid flush ID is 1). | 163 // validated then it will return 0 (Note the lowest valid flush ID is 1). |
160 uint32_t ValidateFlushIDReachedServer(int32_t stream_id, bool force_validate); | 164 uint32_t ValidateFlushIDReachedServer(int32_t stream_id, bool force_validate); |
161 | 165 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 ~GpuChannelHost() override; | 243 ~GpuChannelHost() override; |
240 void Connect(const IPC::ChannelHandle& channel_handle, | 244 void Connect(const IPC::ChannelHandle& channel_handle, |
241 base::WaitableEvent* shutdown_event); | 245 base::WaitableEvent* shutdown_event); |
242 bool InternalSend(IPC::Message* msg); | 246 bool InternalSend(IPC::Message* msg); |
243 void InternalFlush(StreamFlushInfo* flush_info); | 247 void InternalFlush(StreamFlushInfo* flush_info); |
244 | 248 |
245 // Threading notes: all fields are constant during the lifetime of |this| | 249 // Threading notes: all fields are constant during the lifetime of |this| |
246 // except: | 250 // except: |
247 // - |next_image_id_|, atomic type | 251 // - |next_image_id_|, atomic type |
248 // - |next_route_id_|, atomic type | 252 // - |next_route_id_|, atomic type |
| 253 // - |next_stream_id_|, atomic type |
249 // - |channel_| and |stream_flush_info_|, protected by |context_lock_| | 254 // - |channel_| and |stream_flush_info_|, protected by |context_lock_| |
250 GpuChannelHostFactory* const factory_; | 255 GpuChannelHostFactory* const factory_; |
251 | 256 |
252 const int channel_id_; | 257 const int channel_id_; |
253 const gpu::GPUInfo gpu_info_; | 258 const gpu::GPUInfo gpu_info_; |
254 | 259 |
255 scoped_refptr<MessageFilter> channel_filter_; | 260 scoped_refptr<MessageFilter> channel_filter_; |
256 | 261 |
257 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 262 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
258 | 263 |
259 // A filter for sending messages from thread other than the main thread. | 264 // A filter for sending messages from thread other than the main thread. |
260 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; | 265 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; |
261 | 266 |
262 // Image IDs are allocated in sequence. | 267 // Image IDs are allocated in sequence. |
263 base::AtomicSequenceNumber next_image_id_; | 268 base::AtomicSequenceNumber next_image_id_; |
264 | 269 |
265 // Route IDs are allocated in sequence. | 270 // Route IDs are allocated in sequence. |
266 base::AtomicSequenceNumber next_route_id_; | 271 base::AtomicSequenceNumber next_route_id_; |
267 | 272 |
| 273 // Stream IDs are allocated in sequence. |
| 274 base::AtomicSequenceNumber next_stream_id_; |
| 275 |
268 // Protects channel_ and stream_flush_info_. | 276 // Protects channel_ and stream_flush_info_. |
269 mutable base::Lock context_lock_; | 277 mutable base::Lock context_lock_; |
270 std::unique_ptr<IPC::SyncChannel> channel_; | 278 std::unique_ptr<IPC::SyncChannel> channel_; |
271 base::hash_map<int32_t, StreamFlushInfo> stream_flush_info_; | 279 base::hash_map<int32_t, StreamFlushInfo> stream_flush_info_; |
272 | 280 |
273 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); | 281 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); |
274 }; | 282 }; |
275 | 283 |
276 } // namespace gpu | 284 } // namespace gpu |
277 | 285 |
278 #endif // GPU_IPC_CLIENT_GPU_CHANNEL_HOST_H_ | 286 #endif // GPU_IPC_CLIENT_GPU_CHANNEL_HOST_H_ |
OLD | NEW |