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_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ | 5 #ifndef GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ |
6 #define GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ | 6 #define GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <deque> | 11 #include <deque> |
12 #include <memory> | 12 #include <memory> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "gpu/command_buffer/common/command_buffer_id.h" | 20 #include "gpu/command_buffer/common/command_buffer_id.h" |
21 #include "gpu/command_buffer/common/constants.h" | 21 #include "gpu/command_buffer/common/constants.h" |
22 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 22 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
23 #include "gpu/command_buffer/service/command_buffer_service.h" | 23 #include "gpu/command_buffer/service/command_buffer_service.h" |
24 #include "gpu/command_buffer/service/command_executor.h" | 24 #include "gpu/command_buffer/service/command_executor.h" |
25 #include "gpu/command_buffer/service/context_group.h" | 25 #include "gpu/command_buffer/service/context_group.h" |
| 26 #include "gpu/command_buffer/service/sequence_id.h" |
26 #include "gpu/gpu_export.h" | 27 #include "gpu/gpu_export.h" |
27 #include "gpu/ipc/common/surface_handle.h" | 28 #include "gpu/ipc/common/surface_handle.h" |
28 #include "gpu/ipc/service/gpu_memory_manager.h" | 29 #include "gpu/ipc/service/gpu_memory_manager.h" |
29 #include "gpu/ipc/service/image_transport_surface_delegate.h" | 30 #include "gpu/ipc/service/image_transport_surface_delegate.h" |
30 #include "ipc/ipc_listener.h" | 31 #include "ipc/ipc_listener.h" |
31 #include "ipc/ipc_sender.h" | 32 #include "ipc/ipc_sender.h" |
32 #include "ui/events/latency_info.h" | 33 #include "ui/events/latency_info.h" |
33 #include "ui/gfx/geometry/size.h" | 34 #include "ui/gfx/geometry/size.h" |
34 #include "ui/gfx/gpu_memory_buffer.h" | 35 #include "ui/gfx/gpu_memory_buffer.h" |
35 #include "ui/gfx/swap_result.h" | 36 #include "ui/gfx/swap_result.h" |
36 #include "ui/gl/gl_surface.h" | 37 #include "ui/gl/gl_surface.h" |
37 #include "ui/gl/gpu_preference.h" | 38 #include "ui/gl/gpu_preference.h" |
38 #include "url/gurl.h" | 39 #include "url/gurl.h" |
39 | 40 |
40 namespace gl { | 41 namespace gl { |
41 class GLShareGroup; | 42 class GLShareGroup; |
42 } | 43 } |
43 | 44 |
44 namespace gpu { | 45 namespace gpu { |
45 struct Mailbox; | 46 struct Mailbox; |
46 struct SyncToken; | 47 struct SyncToken; |
47 class SyncPointClient; | 48 class SyncPointClientState; |
48 } | 49 } |
49 | 50 |
50 struct GPUCreateCommandBufferConfig; | 51 struct GPUCreateCommandBufferConfig; |
51 struct GpuCommandBufferMsg_CreateImage_Params; | 52 struct GpuCommandBufferMsg_CreateImage_Params; |
52 | 53 |
53 namespace gpu { | 54 namespace gpu { |
54 | 55 |
55 class GpuChannel; | 56 class GpuChannel; |
56 struct WaitForCommandState; | 57 struct WaitForCommandState; |
57 | 58 |
58 class GPU_EXPORT GpuCommandBufferStub | 59 class GPU_EXPORT GpuCommandBufferStub |
59 : public IPC::Listener, | 60 : public IPC::Listener, |
60 public IPC::Sender, | 61 public IPC::Sender, |
61 public ImageTransportSurfaceDelegate, | 62 public ImageTransportSurfaceDelegate, |
62 public base::SupportsWeakPtr<GpuCommandBufferStub> { | 63 public base::SupportsWeakPtr<GpuCommandBufferStub> { |
63 public: | 64 public: |
64 class DestructionObserver { | 65 class DestructionObserver { |
65 public: | 66 public: |
66 // Called in Destroy(), before the context/surface are released. | 67 // Called in Destroy(), before the context/surface are released. |
67 virtual void OnWillDestroyStub() = 0; | 68 virtual void OnWillDestroyStub() = 0; |
68 | 69 |
69 protected: | 70 protected: |
70 virtual ~DestructionObserver() {} | 71 virtual ~DestructionObserver() {} |
71 }; | 72 }; |
72 | 73 |
73 typedef base::Callback<void(const std::vector<ui::LatencyInfo>&)> | 74 typedef base::Callback<void(const std::vector<ui::LatencyInfo>&)> |
74 LatencyInfoCallback; | 75 LatencyInfoCallback; |
75 | 76 |
76 static std::unique_ptr<GpuCommandBufferStub> Create( | 77 static std::unique_ptr<GpuCommandBufferStub> Create( |
77 GpuChannel* channel, | 78 GpuChannel* channel, |
78 GpuCommandBufferStub* share_group, | 79 GpuCommandBufferStub* share_group, |
79 const GPUCreateCommandBufferConfig& init_params, | 80 const GPUCreateCommandBufferConfig& init_params, |
80 int32_t route_id, | 81 CommandBufferId command_buffer_id, |
81 std::unique_ptr<base::SharedMemory> shared_state_shm); | 82 SequenceId sequence_id, |
| 83 int32_t route_id, |
| 84 std::unique_ptr<base::SharedMemory> shared_state_shm); |
82 | 85 |
83 ~GpuCommandBufferStub() override; | 86 ~GpuCommandBufferStub() override; |
84 | 87 |
85 // IPC::Listener implementation: | 88 // IPC::Listener implementation: |
86 bool OnMessageReceived(const IPC::Message& message) override; | 89 bool OnMessageReceived(const IPC::Message& message) override; |
87 | 90 |
88 // IPC::Sender implementation: | 91 // IPC::Sender implementation: |
89 bool Send(IPC::Message* msg) override; | 92 bool Send(IPC::Message* msg) override; |
90 | 93 |
91 // ImageTransportSurfaceDelegate implementation: | 94 // ImageTransportSurfaceDelegate implementation: |
(...skipping 19 matching lines...) Expand all Loading... |
111 // Whether there are commands in the buffer that haven't been processed. | 114 // Whether there are commands in the buffer that haven't been processed. |
112 bool HasUnprocessedCommands(); | 115 bool HasUnprocessedCommands(); |
113 | 116 |
114 gles2::GLES2Decoder* decoder() const { return decoder_.get(); } | 117 gles2::GLES2Decoder* decoder() const { return decoder_.get(); } |
115 CommandExecutor* scheduler() const { return executor_.get(); } | 118 CommandExecutor* scheduler() const { return executor_.get(); } |
116 GpuChannel* channel() const { return channel_; } | 119 GpuChannel* channel() const { return channel_; } |
117 | 120 |
118 // Unique command buffer ID for this command buffer stub. | 121 // Unique command buffer ID for this command buffer stub. |
119 CommandBufferId command_buffer_id() const { return command_buffer_id_; } | 122 CommandBufferId command_buffer_id() const { return command_buffer_id_; } |
120 | 123 |
121 // Identifies the stream for this command buffer. | 124 SequenceId sequence_id() const { return sequence_id_; } |
122 int32_t stream_id() const { return stream_id_; } | |
123 | 125 |
124 // Sends a message to the console. | 126 // Sends a message to the console. |
125 void SendConsoleMessage(int32_t id, const std::string& message); | 127 void SendConsoleMessage(int32_t id, const std::string& message); |
126 | 128 |
127 void SendCachedShader(const std::string& key, const std::string& shader); | 129 void SendCachedShader(const std::string& key, const std::string& shader); |
128 | 130 |
129 gl::GLSurface* surface() const { return surface_.get(); } | 131 gl::GLSurface* surface() const { return surface_.get(); } |
130 | 132 |
131 void AddDestructionObserver(DestructionObserver* observer); | 133 void AddDestructionObserver(DestructionObserver* observer); |
132 void RemoveDestructionObserver(DestructionObserver* observer); | 134 void RemoveDestructionObserver(DestructionObserver* observer); |
133 | 135 |
134 void MarkContextLost(); | 136 void MarkContextLost(); |
135 | 137 |
136 private: | 138 private: |
137 GpuCommandBufferStub(GpuChannel* channel, | 139 GpuCommandBufferStub(GpuChannel* channel, |
138 const GPUCreateCommandBufferConfig& init_params, | 140 const GPUCreateCommandBufferConfig& init_params, |
| 141 CommandBufferId command_buffer_id, |
| 142 SequenceId sequence_id, |
139 int32_t route_id); | 143 int32_t route_id); |
140 | 144 |
141 bool Initialize(GpuCommandBufferStub* share_group, | 145 bool Initialize(GpuCommandBufferStub* share_group, |
142 const GPUCreateCommandBufferConfig& init_params, | 146 const GPUCreateCommandBufferConfig& init_params, |
143 std::unique_ptr<base::SharedMemory> shared_state_shm); | 147 std::unique_ptr<base::SharedMemory> shared_state_shm); |
144 | 148 |
145 GpuMemoryManager* GetMemoryManager() const; | 149 GpuMemoryManager* GetMemoryManager() const; |
146 | 150 |
147 void Destroy(); | 151 void Destroy(); |
148 | 152 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // are destroyed. So a raw pointer is safe. | 217 // are destroyed. So a raw pointer is safe. |
214 GpuChannel* const channel_; | 218 GpuChannel* const channel_; |
215 | 219 |
216 // The group of contexts that share namespaces with this context. | 220 // The group of contexts that share namespaces with this context. |
217 scoped_refptr<gles2::ContextGroup> context_group_; | 221 scoped_refptr<gles2::ContextGroup> context_group_; |
218 | 222 |
219 bool initialized_; | 223 bool initialized_; |
220 const SurfaceHandle surface_handle_; | 224 const SurfaceHandle surface_handle_; |
221 bool use_virtualized_gl_context_; | 225 bool use_virtualized_gl_context_; |
222 const CommandBufferId command_buffer_id_; | 226 const CommandBufferId command_buffer_id_; |
223 const int32_t stream_id_; | 227 const SequenceId sequence_id_; |
224 const int32_t route_id_; | 228 const int32_t route_id_; |
225 uint32_t last_flush_count_; | 229 uint32_t last_flush_count_; |
226 | 230 |
227 std::unique_ptr<CommandBufferService> command_buffer_; | 231 std::unique_ptr<CommandBufferService> command_buffer_; |
228 std::unique_ptr<gles2::GLES2Decoder> decoder_; | 232 std::unique_ptr<gles2::GLES2Decoder> decoder_; |
229 std::unique_ptr<CommandExecutor> executor_; | 233 std::unique_ptr<CommandExecutor> executor_; |
230 std::unique_ptr<SyncPointClient> sync_point_client_; | 234 scoped_refptr<SyncPointClientState> sync_point_client_state_; |
231 scoped_refptr<gl::GLSurface> surface_; | 235 scoped_refptr<gl::GLSurface> surface_; |
232 scoped_refptr<gl::GLShareGroup> share_group_; | 236 scoped_refptr<gl::GLShareGroup> share_group_; |
233 | 237 |
234 base::ObserverList<DestructionObserver> destruction_observers_; | 238 base::ObserverList<DestructionObserver> destruction_observers_; |
235 | 239 |
236 bool waiting_for_sync_point_; | 240 bool waiting_for_sync_point_; |
237 | 241 |
238 base::TimeTicks process_delayed_work_time_; | 242 base::TimeTicks process_delayed_work_time_; |
239 uint32_t previous_processed_num_; | 243 uint32_t previous_processed_num_; |
240 base::TimeTicks last_idle_time_; | 244 base::TimeTicks last_idle_time_; |
241 | 245 |
242 LatencyInfoCallback latency_info_callback_; | 246 LatencyInfoCallback latency_info_callback_; |
243 | 247 |
244 GURL active_url_; | 248 GURL active_url_; |
245 size_t active_url_hash_; | 249 size_t active_url_hash_; |
246 | 250 |
247 std::unique_ptr<WaitForCommandState> wait_for_token_; | 251 std::unique_ptr<WaitForCommandState> wait_for_token_; |
248 std::unique_ptr<WaitForCommandState> wait_for_get_offset_; | 252 std::unique_ptr<WaitForCommandState> wait_for_get_offset_; |
249 | 253 |
250 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); | 254 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); |
251 }; | 255 }; |
252 | 256 |
253 } // namespace gpu | 257 } // namespace gpu |
254 | 258 |
255 #endif // GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ | 259 #endif // GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ |
OLD | NEW |