OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_IN_PROCESS_COMMAND_BUFFER_H_ | 5 #ifndef GPU_IPC_IN_PROCESS_COMMAND_BUFFER_H_ |
6 #define GPU_IPC_IN_PROCESS_COMMAND_BUFFER_H_ | 6 #define GPU_IPC_IN_PROCESS_COMMAND_BUFFER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <memory> | 12 #include <memory> |
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/callback.h" | 16 #include "base/callback.h" |
17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
18 #include "base/containers/scoped_ptr_hash_map.h" | 18 #include "base/containers/scoped_ptr_hash_map.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
22 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
23 #include "base/synchronization/lock.h" | 23 #include "base/synchronization/lock.h" |
24 #include "base/synchronization/waitable_event.h" | 24 #include "base/synchronization/waitable_event.h" |
25 #include "base/threading/thread.h" | 25 #include "base/threading/thread.h" |
26 #include "gpu/command_buffer/client/gpu_control.h" | 26 #include "gpu/command_buffer/client/gpu_control.h" |
27 #include "gpu/command_buffer/common/command_buffer.h" | 27 #include "gpu/command_buffer/common/command_buffer.h" |
| 28 #include "gpu/command_buffer/service/command_executor.h" |
| 29 #include "gpu/command_buffer/service/context_group.h" |
28 #include "gpu/command_buffer/service/gpu_preferences.h" | 30 #include "gpu/command_buffer/service/gpu_preferences.h" |
29 #include "gpu/config/gpu_driver_bug_workarounds.h" | 31 #include "gpu/config/gpu_driver_bug_workarounds.h" |
30 #include "gpu/gpu_export.h" | 32 #include "gpu/gpu_export.h" |
| 33 #include "gpu/ipc/service/image_transport_surface_delegate.h" |
31 #include "ui/gfx/gpu_memory_buffer.h" | 34 #include "ui/gfx/gpu_memory_buffer.h" |
32 #include "ui/gfx/native_widget_types.h" | 35 #include "ui/gfx/native_widget_types.h" |
33 #include "ui/gl/gl_surface.h" | 36 #include "ui/gl/gl_surface.h" |
34 #include "ui/gl/gpu_preference.h" | 37 #include "ui/gl/gpu_preference.h" |
35 | 38 |
36 namespace base { | 39 namespace base { |
37 class SequenceChecker; | 40 class SequenceChecker; |
38 } | 41 } |
39 | 42 |
40 namespace gl { | 43 namespace gl { |
41 class GLContext; | 44 class GLContext; |
42 class GLShareGroup; | 45 class GLShareGroup; |
43 class GLSurface; | 46 class GLSurface; |
44 } | 47 } |
45 | 48 |
46 namespace gfx { | 49 namespace gfx { |
47 class Size; | 50 class Size; |
48 } | 51 } |
49 | 52 |
50 namespace gpu { | 53 namespace gpu { |
| 54 |
51 class SyncPointClient; | 55 class SyncPointClient; |
52 class SyncPointOrderData; | 56 class SyncPointOrderData; |
53 class SyncPointManager; | 57 class SyncPointManager; |
| 58 struct GpuProcessHostedCALayerTreeParamsMac; |
54 | 59 |
55 namespace gles2 { | 60 namespace gles2 { |
56 struct ContextCreationAttribHelper; | 61 struct ContextCreationAttribHelper; |
57 class FramebufferCompletenessCache; | 62 class FramebufferCompletenessCache; |
58 class GLES2Decoder; | 63 class GLES2Decoder; |
59 class MailboxManager; | 64 class MailboxManager; |
60 class ProgramCache; | 65 class ProgramCache; |
61 class ShaderTranslatorCache; | 66 class ShaderTranslatorCache; |
62 } | 67 } |
63 | 68 |
64 class CommandBufferServiceBase; | 69 class CommandBufferServiceBase; |
65 class GpuMemoryBufferManager; | 70 class GpuMemoryBufferManager; |
66 class CommandExecutor; | 71 class CommandExecutor; |
67 class ImageFactory; | 72 class ImageFactory; |
68 class TransferBufferManagerInterface; | 73 class TransferBufferManagerInterface; |
69 | 74 |
70 // This class provides a thread-safe interface to the global GPU service (for | 75 // This class provides a thread-safe interface to the global GPU service (for |
71 // example GPU thread) when being run in single process mode. | 76 // example GPU thread) when being run in single process mode. |
72 // However, the behavior for accessing one context (i.e. one instance of this | 77 // However, the behavior for accessing one context (i.e. one instance of this |
73 // class) from different client threads is undefined. | 78 // class) from different client threads is undefined. |
74 class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, | 79 class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, |
75 public GpuControl { | 80 public GpuControl, |
| 81 public ImageTransportSurfaceDelegate { |
76 public: | 82 public: |
77 class Service; | 83 class Service; |
78 explicit InProcessCommandBuffer(const scoped_refptr<Service>& service); | 84 explicit InProcessCommandBuffer(const scoped_refptr<Service>& service); |
79 ~InProcessCommandBuffer() override; | 85 ~InProcessCommandBuffer() override; |
80 | 86 |
81 // If |surface| is not null, use it directly; in this case, the command | 87 // If |surface| is not null, use it directly; in this case, the command |
82 // buffer gpu thread must be the same as the client thread. Otherwise create | 88 // buffer gpu thread must be the same as the client thread. Otherwise create |
83 // a new GLSurface. | 89 // a new GLSurface. |
84 bool Initialize(scoped_refptr<gl::GLSurface> surface, | 90 bool Initialize(scoped_refptr<gl::GLSurface> surface, |
85 bool is_offscreen, | 91 bool is_offscreen, |
86 gfx::AcceleratedWidget window, | 92 SurfaceHandle window, |
87 const gles2::ContextCreationAttribHelper& attribs, | 93 const gles2::ContextCreationAttribHelper& attribs, |
88 InProcessCommandBuffer* share_group, | 94 InProcessCommandBuffer* share_group, |
89 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 95 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
90 ImageFactory* image_factory, | 96 ImageFactory* image_factory, |
91 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 97 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
92 | 98 |
93 // CommandBuffer implementation: | 99 // CommandBuffer implementation: |
94 State GetLastState() override; | 100 State GetLastState() override; |
95 int32_t GetLastToken() override; | 101 int32_t GetLastToken() override; |
96 void Flush(int32_t put_offset) override; | 102 void Flush(int32_t put_offset) override; |
(...skipping 26 matching lines...) Expand all Loading... |
123 CommandBufferId GetCommandBufferID() const override; | 129 CommandBufferId GetCommandBufferID() const override; |
124 int32_t GetExtraCommandBufferData() const override; | 130 int32_t GetExtraCommandBufferData() const override; |
125 uint64_t GenerateFenceSyncRelease() override; | 131 uint64_t GenerateFenceSyncRelease() override; |
126 bool IsFenceSyncRelease(uint64_t release) override; | 132 bool IsFenceSyncRelease(uint64_t release) override; |
127 bool IsFenceSyncFlushed(uint64_t release) override; | 133 bool IsFenceSyncFlushed(uint64_t release) override; |
128 bool IsFenceSyncFlushReceived(uint64_t release) override; | 134 bool IsFenceSyncFlushReceived(uint64_t release) override; |
129 void SignalSyncToken(const SyncToken& sync_token, | 135 void SignalSyncToken(const SyncToken& sync_token, |
130 const base::Closure& callback) override; | 136 const base::Closure& callback) override; |
131 bool CanWaitUnverifiedSyncToken(const SyncToken* sync_token) override; | 137 bool CanWaitUnverifiedSyncToken(const SyncToken* sync_token) override; |
132 | 138 |
| 139 // ImageTransportSurfaceDelegate implementation: |
| 140 #if defined(OS_WIN) |
| 141 void DidCreateAcceleratedSurfaceChildWindow( |
| 142 SurfaceHandle parent_window, |
| 143 SurfaceHandle child_window) override; |
| 144 #endif |
| 145 void DidSwapBuffersComplete(SwapBuffersCompleteParams params) override; |
| 146 const gles2::FeatureInfo* GetFeatureInfo() const override; |
| 147 void SetLatencyInfoCallback(const LatencyInfoCallback& callback) override; |
| 148 void UpdateVSyncParameters(base::TimeTicks timebase, |
| 149 base::TimeDelta interval) override; |
| 150 |
| 151 using SwapBuffersCompletionCallback = base::Callback<void( |
| 152 const std::vector<ui::LatencyInfo>& latency_info, |
| 153 gfx::SwapResult result, |
| 154 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac)>; |
| 155 void SetSwapBuffersCompletionCallback( |
| 156 const SwapBuffersCompletionCallback& callback); |
| 157 |
| 158 using UpdateVSyncParametersCallback = |
| 159 base::Callback<void(base::TimeTicks timebase, base::TimeDelta interval)>; |
| 160 void SetUpdateVSyncParametersCallback( |
| 161 const UpdateVSyncParametersCallback& callback); |
| 162 |
133 // The serializer interface to the GPU service (i.e. thread). | 163 // The serializer interface to the GPU service (i.e. thread). |
134 class Service { | 164 class Service { |
135 public: | 165 public: |
136 Service(); | 166 Service(); |
137 Service(const gpu::GpuPreferences& gpu_preferences); | 167 Service(const gpu::GpuPreferences& gpu_preferences); |
| 168 Service(gpu::gles2::MailboxManager* mailbox_manager, |
| 169 scoped_refptr<gl::GLShareGroup> share_group); |
| 170 |
138 virtual ~Service(); | 171 virtual ~Service(); |
139 | 172 |
140 virtual void AddRef() const = 0; | 173 virtual void AddRef() const = 0; |
141 virtual void Release() const = 0; | 174 virtual void Release() const = 0; |
142 | 175 |
143 // Queues a task to run as soon as possible. | 176 // Queues a task to run as soon as possible. |
144 virtual void ScheduleTask(const base::Closure& task) = 0; | 177 virtual void ScheduleTask(const base::Closure& task) = 0; |
145 | 178 |
146 // Schedules |callback| to run at an appropriate time for performing delayed | 179 // Schedules |callback| to run at an appropriate time for performing delayed |
147 // work. | 180 // work. |
148 virtual void ScheduleDelayedWork(const base::Closure& task) = 0; | 181 virtual void ScheduleDelayedWork(const base::Closure& task) = 0; |
149 | 182 |
150 virtual bool UseVirtualizedGLContexts() = 0; | 183 virtual bool UseVirtualizedGLContexts() = 0; |
151 virtual scoped_refptr<gles2::ShaderTranslatorCache> | 184 virtual scoped_refptr<gles2::ShaderTranslatorCache> |
152 shader_translator_cache() = 0; | 185 shader_translator_cache() = 0; |
153 virtual scoped_refptr<gles2::FramebufferCompletenessCache> | 186 virtual scoped_refptr<gles2::FramebufferCompletenessCache> |
154 framebuffer_completeness_cache() = 0; | 187 framebuffer_completeness_cache() = 0; |
155 virtual SyncPointManager* sync_point_manager() = 0; | 188 virtual SyncPointManager* sync_point_manager() = 0; |
156 const GpuPreferences& gpu_preferences(); | 189 const GpuPreferences& gpu_preferences(); |
157 const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds(); | 190 const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds(); |
158 scoped_refptr<gl::GLShareGroup> share_group(); | 191 scoped_refptr<gl::GLShareGroup> share_group(); |
159 scoped_refptr<gles2::MailboxManager> mailbox_manager(); | 192 scoped_refptr<gles2::MailboxManager> mailbox_manager(); |
160 gpu::gles2::ProgramCache* program_cache(); | 193 gpu::gles2::ProgramCache* program_cache(); |
| 194 virtual bool BlockThreadOnWaitSyncToken() const = 0; |
161 | 195 |
162 private: | 196 protected: |
163 const GpuPreferences gpu_preferences_; | 197 const GpuPreferences gpu_preferences_; |
164 const GpuDriverBugWorkarounds gpu_driver_bug_workarounds_; | 198 const GpuDriverBugWorkarounds gpu_driver_bug_workarounds_; |
| 199 scoped_refptr<gles2::MailboxManager> mailbox_manager_; |
165 scoped_refptr<gl::GLShareGroup> share_group_; | 200 scoped_refptr<gl::GLShareGroup> share_group_; |
166 scoped_refptr<gles2::MailboxManager> mailbox_manager_; | |
167 std::unique_ptr<gpu::gles2::ProgramCache> program_cache_; | 201 std::unique_ptr<gpu::gles2::ProgramCache> program_cache_; |
168 }; | 202 }; |
169 | 203 |
170 private: | 204 private: |
171 struct InitializeOnGpuThreadParams { | 205 struct InitializeOnGpuThreadParams { |
172 bool is_offscreen; | 206 bool is_offscreen; |
173 gfx::AcceleratedWidget window; | 207 SurfaceHandle window; |
174 const gles2::ContextCreationAttribHelper& attribs; | 208 const gles2::ContextCreationAttribHelper& attribs; |
175 gpu::Capabilities* capabilities; // Ouptut. | 209 gpu::Capabilities* capabilities; // Ouptut. |
176 InProcessCommandBuffer* context_group; | 210 InProcessCommandBuffer* context_group; |
177 ImageFactory* image_factory; | 211 ImageFactory* image_factory; |
178 | 212 |
179 InitializeOnGpuThreadParams( | 213 InitializeOnGpuThreadParams( |
180 bool is_offscreen, | 214 bool is_offscreen, |
181 gfx::AcceleratedWidget window, | 215 SurfaceHandle window, |
182 const gles2::ContextCreationAttribHelper& attribs, | 216 const gles2::ContextCreationAttribHelper& attribs, |
183 gpu::Capabilities* capabilities, | 217 gpu::Capabilities* capabilities, |
184 InProcessCommandBuffer* share_group, | 218 InProcessCommandBuffer* share_group, |
185 ImageFactory* image_factory) | 219 ImageFactory* image_factory) |
186 : is_offscreen(is_offscreen), | 220 : is_offscreen(is_offscreen), |
187 window(window), | 221 window(window), |
188 attribs(attribs), | 222 attribs(attribs), |
189 capabilities(capabilities), | 223 capabilities(capabilities), |
190 context_group(share_group), | 224 context_group(share_group), |
191 image_factory(image_factory) {} | 225 image_factory(image_factory) {} |
192 }; | 226 }; |
193 | 227 |
194 bool InitializeOnGpuThread(const InitializeOnGpuThreadParams& params); | 228 bool InitializeOnGpuThread(const InitializeOnGpuThreadParams& params); |
195 void Destroy(); | 229 void Destroy(); |
196 bool DestroyOnGpuThread(); | 230 bool DestroyOnGpuThread(); |
197 void FlushOnGpuThread(int32_t put_offset, uint32_t order_num); | 231 void FlushOnGpuThread(int32_t put_offset); |
198 void ScheduleDelayedWorkOnGpuThread(); | 232 void ScheduleDelayedWorkOnGpuThread(); |
199 bool MakeCurrent(); | 233 bool MakeCurrent(); |
200 base::Closure WrapCallback(const base::Closure& callback); | 234 base::Closure WrapCallback(const base::Closure& callback); |
201 State GetStateFast(); | 235 State GetStateFast(); |
202 void QueueTask(const base::Closure& task) { service_->ScheduleTask(task); } | 236 void QueueTask(bool out_of_order, const base::Closure& task); |
| 237 void ProcessTasksOnGpuThread(); |
203 void CheckSequencedThread(); | 238 void CheckSequencedThread(); |
204 void FenceSyncReleaseOnGpuThread(uint64_t release); | 239 void FenceSyncReleaseOnGpuThread(uint64_t release); |
205 bool WaitFenceSyncOnGpuThread(gpu::CommandBufferNamespace namespace_id, | 240 bool WaitFenceSyncOnGpuThread(gpu::CommandBufferNamespace namespace_id, |
206 gpu::CommandBufferId command_buffer_id, | 241 gpu::CommandBufferId command_buffer_id, |
207 uint64_t release); | 242 uint64_t release); |
| 243 void OnWaitFenceSyncCompleted(CommandBufferNamespace namespace_id, |
| 244 CommandBufferId command_buffer_id, |
| 245 uint64_t release); |
208 void DescheduleUntilFinishedOnGpuThread(); | 246 void DescheduleUntilFinishedOnGpuThread(); |
209 void RescheduleAfterFinishedOnGpuThread(); | 247 void RescheduleAfterFinishedOnGpuThread(); |
210 void SignalSyncTokenOnGpuThread(const SyncToken& sync_token, | 248 void SignalSyncTokenOnGpuThread(const SyncToken& sync_token, |
211 const base::Closure& callback); | 249 const base::Closure& callback); |
212 void SignalQueryOnGpuThread(unsigned query_id, const base::Closure& callback); | 250 void SignalQueryOnGpuThread(unsigned query_id, const base::Closure& callback); |
213 void DestroyTransferBufferOnGpuThread(int32_t id); | 251 void DestroyTransferBufferOnGpuThread(int32_t id); |
214 void CreateImageOnGpuThread(int32_t id, | 252 void CreateImageOnGpuThread(int32_t id, |
215 const gfx::GpuMemoryBufferHandle& handle, | 253 const gfx::GpuMemoryBufferHandle& handle, |
216 const gfx::Size& size, | 254 const gfx::Size& size, |
217 gfx::BufferFormat format, | 255 gfx::BufferFormat format, |
218 uint32_t internalformat, | 256 uint32_t internalformat, |
219 uint32_t order_num, | 257 // uint32_t order_num, |
220 uint64_t fence_sync); | 258 uint64_t fence_sync); |
221 void DestroyImageOnGpuThread(int32_t id); | 259 void DestroyImageOnGpuThread(int32_t id); |
222 void SetGetBufferOnGpuThread(int32_t shm_id, base::WaitableEvent* completion); | 260 void SetGetBufferOnGpuThread(int32_t shm_id, base::WaitableEvent* completion); |
223 | 261 |
224 // Callbacks on the gpu thread. | 262 // Callbacks on the gpu thread. |
225 void OnContextLostOnGpuThread(); | 263 void OnContextLostOnGpuThread(); |
226 void PumpCommandsOnGpuThread(); | 264 void PumpCommandsOnGpuThread(); |
227 void PerformDelayedWorkOnGpuThread(); | 265 void PerformDelayedWorkOnGpuThread(); |
228 // Callback implementations on the client thread. | 266 // Callback implementations on the client thread. |
229 void OnContextLost(); | 267 void OnContextLost(); |
230 | 268 |
231 const CommandBufferId command_buffer_id_; | 269 const CommandBufferId command_buffer_id_; |
232 | 270 |
233 // Members accessed on the gpu thread (possibly with the exception of | 271 // Members accessed on the gpu thread (possibly with the exception of |
234 // creation): | 272 // creation): |
| 273 bool waiting_for_sync_point_ = false; |
| 274 |
235 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; | 275 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; |
236 scoped_refptr<TransferBufferManagerInterface> transfer_buffer_manager_; | 276 scoped_refptr<TransferBufferManagerInterface> transfer_buffer_manager_; |
237 std::unique_ptr<CommandExecutor> executor_; | 277 std::unique_ptr<CommandExecutor> executor_; |
238 std::unique_ptr<gles2::GLES2Decoder> decoder_; | 278 std::unique_ptr<gles2::GLES2Decoder> decoder_; |
239 scoped_refptr<gl::GLContext> context_; | 279 scoped_refptr<gl::GLContext> context_; |
240 scoped_refptr<gl::GLSurface> surface_; | 280 scoped_refptr<gl::GLSurface> surface_; |
241 scoped_refptr<SyncPointOrderData> sync_point_order_data_; | 281 scoped_refptr<SyncPointOrderData> sync_point_order_data_; |
242 std::unique_ptr<SyncPointClient> sync_point_client_; | 282 std::unique_ptr<SyncPointClient> sync_point_client_; |
243 base::Closure context_lost_callback_; | 283 base::Closure context_lost_callback_; |
244 // Used to throttle PerformDelayedWorkOnGpuThread. | 284 // Used to throttle PerformDelayedWorkOnGpuThread. |
(...skipping 13 matching lines...) Expand all Loading... |
258 uint64_t next_fence_sync_release_; | 298 uint64_t next_fence_sync_release_; |
259 uint64_t flushed_fence_sync_release_; | 299 uint64_t flushed_fence_sync_release_; |
260 | 300 |
261 // Accessed on both threads: | 301 // Accessed on both threads: |
262 std::unique_ptr<CommandBufferServiceBase> command_buffer_; | 302 std::unique_ptr<CommandBufferServiceBase> command_buffer_; |
263 base::Lock command_buffer_lock_; | 303 base::Lock command_buffer_lock_; |
264 base::WaitableEvent flush_event_; | 304 base::WaitableEvent flush_event_; |
265 scoped_refptr<Service> service_; | 305 scoped_refptr<Service> service_; |
266 State state_after_last_flush_; | 306 State state_after_last_flush_; |
267 base::Lock state_after_last_flush_lock_; | 307 base::Lock state_after_last_flush_lock_; |
| 308 |
| 309 // The group of contexts that share namespaces with this context. |
| 310 scoped_refptr<gles2::ContextGroup> context_group_; |
| 311 |
268 scoped_refptr<gl::GLShareGroup> gl_share_group_; | 312 scoped_refptr<gl::GLShareGroup> gl_share_group_; |
269 base::WaitableEvent fence_sync_wait_event_; | 313 base::WaitableEvent fence_sync_wait_event_; |
270 | 314 |
271 // Only used with explicit scheduling and the gpu thread is the same as | 315 // Only used with explicit scheduling and the gpu thread is the same as |
272 // the client thread. | 316 // the client thread. |
273 std::unique_ptr<base::SequenceChecker> sequence_checker_; | 317 std::unique_ptr<base::SequenceChecker> sequence_checker_; |
274 | 318 |
| 319 base::Lock task_queue_lock_; |
| 320 struct GpuTask { |
| 321 GpuTask(const base::Closure& callback, uint32_t order_number); |
| 322 ~GpuTask(); |
| 323 base::Closure callback; |
| 324 uint32_t order_number; |
| 325 }; |
| 326 std::queue<std::unique_ptr<GpuTask>> task_queue_; |
| 327 |
| 328 SwapBuffersCompletionCallback swap_buffers_completion_callback_; |
| 329 UpdateVSyncParametersCallback update_vsync_parameters_completion_callback_; |
| 330 |
275 base::WeakPtr<InProcessCommandBuffer> client_thread_weak_ptr_; | 331 base::WeakPtr<InProcessCommandBuffer> client_thread_weak_ptr_; |
276 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_; | 332 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_; |
277 base::WeakPtrFactory<InProcessCommandBuffer> client_thread_weak_ptr_factory_; | 333 base::WeakPtrFactory<InProcessCommandBuffer> client_thread_weak_ptr_factory_; |
278 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_; | 334 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_; |
279 | 335 |
280 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer); | 336 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer); |
281 }; | 337 }; |
282 | 338 |
283 // Default Service class when a null service is used. | |
284 class GPU_EXPORT GpuInProcessThread | |
285 : public base::Thread, | |
286 public NON_EXPORTED_BASE(InProcessCommandBuffer::Service), | |
287 public base::RefCountedThreadSafe<GpuInProcessThread> { | |
288 public: | |
289 explicit GpuInProcessThread(SyncPointManager* sync_point_manager); | |
290 | |
291 void AddRef() const override; | |
292 void Release() const override; | |
293 void ScheduleTask(const base::Closure& task) override; | |
294 void ScheduleDelayedWork(const base::Closure& callback) override; | |
295 bool UseVirtualizedGLContexts() override; | |
296 scoped_refptr<gles2::ShaderTranslatorCache> shader_translator_cache() | |
297 override; | |
298 scoped_refptr<gles2::FramebufferCompletenessCache> | |
299 framebuffer_completeness_cache() override; | |
300 SyncPointManager* sync_point_manager() override; | |
301 | |
302 private: | |
303 ~GpuInProcessThread() override; | |
304 friend class base::RefCountedThreadSafe<GpuInProcessThread>; | |
305 | |
306 SyncPointManager* sync_point_manager_; // Non-owning. | |
307 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; | |
308 scoped_refptr<gpu::gles2::FramebufferCompletenessCache> | |
309 framebuffer_completeness_cache_; | |
310 DISALLOW_COPY_AND_ASSIGN(GpuInProcessThread); | |
311 }; | |
312 | |
313 } // namespace gpu | 339 } // namespace gpu |
314 | 340 |
315 #endif // GPU_IPC_IN_PROCESS_COMMAND_BUFFER_H_ | 341 #endif // GPU_IPC_IN_PROCESS_COMMAND_BUFFER_H_ |
OLD | NEW |