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_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/atomic_sequence_num.h" | 11 #include "base/atomic_sequence_num.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/containers/scoped_ptr_hash_map.h" | 14 #include "base/containers/scoped_ptr_hash_map.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
19 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
| 20 #include "base/threading/thread.h" |
20 #include "gpu/command_buffer/client/gpu_control.h" | 21 #include "gpu/command_buffer/client/gpu_control.h" |
21 #include "gpu/command_buffer/common/command_buffer.h" | 22 #include "gpu/command_buffer/common/command_buffer.h" |
22 #include "gpu/gpu_export.h" | 23 #include "gpu/gpu_export.h" |
23 #include "ui/gfx/gpu_memory_buffer.h" | 24 #include "ui/gfx/gpu_memory_buffer.h" |
24 #include "ui/gfx/native_widget_types.h" | 25 #include "ui/gfx/native_widget_types.h" |
25 #include "ui/gl/gl_surface.h" | 26 #include "ui/gl/gl_surface.h" |
26 #include "ui/gl/gpu_preference.h" | 27 #include "ui/gl/gpu_preference.h" |
27 | 28 |
28 namespace base { | 29 namespace base { |
29 class SequenceChecker; | 30 class SequenceChecker; |
30 } | 31 } |
31 | 32 |
32 namespace gfx { | 33 namespace gfx { |
33 class GLContext; | 34 class GLContext; |
34 class GLShareGroup; | 35 class GLShareGroup; |
35 class GLSurface; | 36 class GLSurface; |
36 class Size; | 37 class Size; |
37 } | 38 } |
38 | 39 |
39 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
40 namespace gfx { | 41 namespace gfx { |
41 class SurfaceTexture; | 42 class SurfaceTexture; |
42 } | 43 } |
43 namespace gpu { | 44 namespace gpu { |
44 class StreamTextureManagerInProcess; | 45 class StreamTextureManagerInProcess; |
45 } | 46 } |
46 #endif | 47 #endif |
47 | 48 |
48 namespace gpu { | 49 namespace gpu { |
| 50 class SyncPointManager; |
49 class ValueStateMap; | 51 class ValueStateMap; |
50 | 52 |
51 namespace gles2 { | 53 namespace gles2 { |
52 class GLES2Decoder; | 54 class GLES2Decoder; |
53 class MailboxManager; | 55 class MailboxManager; |
54 class ShaderTranslatorCache; | 56 class ShaderTranslatorCache; |
55 class SubscriptionRefSet; | 57 class SubscriptionRefSet; |
56 } | 58 } |
57 | 59 |
58 class CommandBufferServiceBase; | 60 class CommandBufferServiceBase; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // Queues a task to run as soon as possible. | 137 // Queues a task to run as soon as possible. |
136 virtual void ScheduleTask(const base::Closure& task) = 0; | 138 virtual void ScheduleTask(const base::Closure& task) = 0; |
137 | 139 |
138 // Schedules |callback| to run at an appropriate time for performing idle | 140 // Schedules |callback| to run at an appropriate time for performing idle |
139 // work. | 141 // work. |
140 virtual void ScheduleIdleWork(const base::Closure& task) = 0; | 142 virtual void ScheduleIdleWork(const base::Closure& task) = 0; |
141 | 143 |
142 virtual bool UseVirtualizedGLContexts() = 0; | 144 virtual bool UseVirtualizedGLContexts() = 0; |
143 virtual scoped_refptr<gles2::ShaderTranslatorCache> | 145 virtual scoped_refptr<gles2::ShaderTranslatorCache> |
144 shader_translator_cache() = 0; | 146 shader_translator_cache() = 0; |
| 147 virtual SyncPointManager* sync_point_manager() = 0; |
145 scoped_refptr<gfx::GLShareGroup> share_group(); | 148 scoped_refptr<gfx::GLShareGroup> share_group(); |
146 scoped_refptr<gles2::MailboxManager> mailbox_manager(); | 149 scoped_refptr<gles2::MailboxManager> mailbox_manager(); |
147 scoped_refptr<gles2::SubscriptionRefSet> subscription_ref_set(); | 150 scoped_refptr<gles2::SubscriptionRefSet> subscription_ref_set(); |
148 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state(); | 151 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state(); |
149 | 152 |
150 private: | 153 private: |
151 scoped_refptr<gfx::GLShareGroup> share_group_; | 154 scoped_refptr<gfx::GLShareGroup> share_group_; |
152 scoped_refptr<gles2::MailboxManager> mailbox_manager_; | 155 scoped_refptr<gles2::MailboxManager> mailbox_manager_; |
153 scoped_refptr<gles2::SubscriptionRefSet> subscription_ref_set_; | 156 scoped_refptr<gles2::SubscriptionRefSet> subscription_ref_set_; |
154 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state_; | 157 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state_; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // Only used with explicit scheduling and the gpu thread is the same as | 257 // Only used with explicit scheduling and the gpu thread is the same as |
255 // the client thread. | 258 // the client thread. |
256 scoped_ptr<base::SequenceChecker> sequence_checker_; | 259 scoped_ptr<base::SequenceChecker> sequence_checker_; |
257 | 260 |
258 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_; | 261 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_; |
259 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_; | 262 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_; |
260 | 263 |
261 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer); | 264 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer); |
262 }; | 265 }; |
263 | 266 |
| 267 // Default Service class when a null service is used. |
| 268 class GPU_EXPORT GpuInProcessThread |
| 269 : public base::Thread, |
| 270 public NON_EXPORTED_BASE(InProcessCommandBuffer::Service), |
| 271 public base::RefCountedThreadSafe<GpuInProcessThread> { |
| 272 public: |
| 273 explicit GpuInProcessThread(SyncPointManager* sync_point_manager); |
| 274 |
| 275 void AddRef() const override; |
| 276 void Release() const override; |
| 277 void ScheduleTask(const base::Closure& task) override; |
| 278 void ScheduleIdleWork(const base::Closure& callback) override; |
| 279 bool UseVirtualizedGLContexts() override; |
| 280 scoped_refptr<gles2::ShaderTranslatorCache> shader_translator_cache() |
| 281 override; |
| 282 SyncPointManager* sync_point_manager() override; |
| 283 |
| 284 private: |
| 285 ~GpuInProcessThread() override; |
| 286 friend class base::RefCountedThreadSafe<GpuInProcessThread>; |
| 287 |
| 288 SyncPointManager* sync_point_manager_; // Non-owning. |
| 289 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; |
| 290 DISALLOW_COPY_AND_ASSIGN(GpuInProcessThread); |
| 291 }; |
| 292 |
264 } // namespace gpu | 293 } // namespace gpu |
265 | 294 |
266 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ | 295 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ |
OLD | NEW |