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