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" | |
24 #include "ipc/ipc_channel_handle.h" | 23 #include "ipc/ipc_channel_handle.h" |
25 #include "ipc/ipc_sync_channel.h" | 24 #include "ipc/ipc_sync_channel.h" |
26 #include "ipc/message_filter.h" | 25 #include "ipc/message_filter.h" |
27 #include "ipc/message_router.h" | 26 #include "ipc/message_router.h" |
28 #include "ui/gfx/gpu_memory_buffer.h" | 27 #include "ui/gfx/gpu_memory_buffer.h" |
29 #include "ui/latency/latency_info.h" | 28 #include "ui/latency/latency_info.h" |
30 | 29 |
31 namespace base { | 30 namespace base { |
32 class WaitableEvent; | 31 class WaitableEvent; |
33 } | 32 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 142 |
144 // Reserve one unused transfer buffer ID. | 143 // Reserve one unused transfer buffer ID. |
145 int32_t ReserveTransferBufferId(); | 144 int32_t ReserveTransferBufferId(); |
146 | 145 |
147 // Reserve one unused image ID. | 146 // Reserve one unused image ID. |
148 int32_t ReserveImageId(); | 147 int32_t ReserveImageId(); |
149 | 148 |
150 // Generate a route ID guaranteed to be unique for this channel. | 149 // Generate a route ID guaranteed to be unique for this channel. |
151 int32_t GenerateRouteID(); | 150 int32_t GenerateRouteID(); |
152 | 151 |
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 | 152 // 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 | 153 // 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 | 154 // 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 | 155 // 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. | 156 // 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 | 157 // 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 | 158 // 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). | 159 // 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); | 160 uint32_t ValidateFlushIDReachedServer(int32_t stream_id, bool force_validate); |
165 | 161 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 ~GpuChannelHost() override; | 239 ~GpuChannelHost() override; |
244 void Connect(const IPC::ChannelHandle& channel_handle, | 240 void Connect(const IPC::ChannelHandle& channel_handle, |
245 base::WaitableEvent* shutdown_event); | 241 base::WaitableEvent* shutdown_event); |
246 bool InternalSend(IPC::Message* msg); | 242 bool InternalSend(IPC::Message* msg); |
247 void InternalFlush(StreamFlushInfo* flush_info); | 243 void InternalFlush(StreamFlushInfo* flush_info); |
248 | 244 |
249 // Threading notes: all fields are constant during the lifetime of |this| | 245 // Threading notes: all fields are constant during the lifetime of |this| |
250 // except: | 246 // except: |
251 // - |next_image_id_|, atomic type | 247 // - |next_image_id_|, atomic type |
252 // - |next_route_id_|, atomic type | 248 // - |next_route_id_|, atomic type |
253 // - |next_stream_id_|, atomic type | |
254 // - |channel_| and |stream_flush_info_|, protected by |context_lock_| | 249 // - |channel_| and |stream_flush_info_|, protected by |context_lock_| |
255 GpuChannelHostFactory* const factory_; | 250 GpuChannelHostFactory* const factory_; |
256 | 251 |
257 const int channel_id_; | 252 const int channel_id_; |
258 const gpu::GPUInfo gpu_info_; | 253 const gpu::GPUInfo gpu_info_; |
259 | 254 |
260 scoped_refptr<MessageFilter> channel_filter_; | 255 scoped_refptr<MessageFilter> channel_filter_; |
261 | 256 |
262 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 257 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
263 | 258 |
264 // A filter for sending messages from thread other than the main thread. | 259 // A filter for sending messages from thread other than the main thread. |
265 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; | 260 scoped_refptr<IPC::SyncMessageFilter> sync_filter_; |
266 | 261 |
267 // Image IDs are allocated in sequence. | 262 // Image IDs are allocated in sequence. |
268 base::AtomicSequenceNumber next_image_id_; | 263 base::AtomicSequenceNumber next_image_id_; |
269 | 264 |
270 // Route IDs are allocated in sequence. | 265 // Route IDs are allocated in sequence. |
271 base::AtomicSequenceNumber next_route_id_; | 266 base::AtomicSequenceNumber next_route_id_; |
272 | 267 |
273 // Stream IDs are allocated in sequence. | |
274 base::AtomicSequenceNumber next_stream_id_; | |
275 | |
276 // Protects channel_ and stream_flush_info_. | 268 // Protects channel_ and stream_flush_info_. |
277 mutable base::Lock context_lock_; | 269 mutable base::Lock context_lock_; |
278 std::unique_ptr<IPC::SyncChannel> channel_; | 270 std::unique_ptr<IPC::SyncChannel> channel_; |
279 base::hash_map<int32_t, StreamFlushInfo> stream_flush_info_; | 271 base::hash_map<int32_t, StreamFlushInfo> stream_flush_info_; |
280 | 272 |
281 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); | 273 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); |
282 }; | 274 }; |
283 | 275 |
284 } // namespace gpu | 276 } // namespace gpu |
285 | 277 |
286 #endif // GPU_IPC_CLIENT_GPU_CHANNEL_HOST_H_ | 278 #endif // GPU_IPC_CLIENT_GPU_CHANNEL_HOST_H_ |
OLD | NEW |