| 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 <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 <vector> | 13 #include <vector> |
| 13 | 14 |
| 14 #include "base/atomic_sequence_num.h" | 15 #include "base/atomic_sequence_num.h" |
| 15 #include "base/callback.h" | 16 #include "base/callback.h" |
| 16 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 17 #include "base/containers/scoped_ptr_hash_map.h" | 18 #include "base/containers/scoped_ptr_hash_map.h" |
| 18 #include "base/macros.h" | 19 #include "base/macros.h" |
| 19 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 20 #include "base/memory/scoped_ptr.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/gpu_preferences.h" | 28 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 29 #include "gpu/gpu_export.h" | 29 #include "gpu/gpu_export.h" |
| 30 #include "ui/gfx/gpu_memory_buffer.h" | 30 #include "ui/gfx/gpu_memory_buffer.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 scoped_refptr<gles2::SubscriptionRefSet> subscription_ref_set(); | 168 scoped_refptr<gles2::SubscriptionRefSet> subscription_ref_set(); |
| 169 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state(); | 169 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state(); |
| 170 gpu::gles2::ProgramCache* program_cache(); | 170 gpu::gles2::ProgramCache* program_cache(); |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 const GpuPreferences gpu_preferences_; | 173 const GpuPreferences gpu_preferences_; |
| 174 scoped_refptr<gfx::GLShareGroup> share_group_; | 174 scoped_refptr<gfx::GLShareGroup> share_group_; |
| 175 scoped_refptr<gles2::MailboxManager> mailbox_manager_; | 175 scoped_refptr<gles2::MailboxManager> mailbox_manager_; |
| 176 scoped_refptr<gles2::SubscriptionRefSet> subscription_ref_set_; | 176 scoped_refptr<gles2::SubscriptionRefSet> subscription_ref_set_; |
| 177 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state_; | 177 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state_; |
| 178 scoped_ptr<gpu::gles2::ProgramCache> program_cache_; | 178 std::unique_ptr<gpu::gles2::ProgramCache> program_cache_; |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 #if defined(OS_ANDROID) | 181 #if defined(OS_ANDROID) |
| 182 scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture(uint32_t stream_id); | 182 scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture(uint32_t stream_id); |
| 183 uint32_t CreateStreamTexture(uint32_t texture_id); | 183 uint32_t CreateStreamTexture(uint32_t texture_id); |
| 184 #endif | 184 #endif |
| 185 | 185 |
| 186 private: | 186 private: |
| 187 struct InitializeOnGpuThreadParams { | 187 struct InitializeOnGpuThreadParams { |
| 188 bool is_offscreen; | 188 bool is_offscreen; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 void PerformDelayedWorkOnGpuThread(); | 247 void PerformDelayedWorkOnGpuThread(); |
| 248 // Callback implementations on the client thread. | 248 // Callback implementations on the client thread. |
| 249 void OnContextLost(); | 249 void OnContextLost(); |
| 250 | 250 |
| 251 const CommandBufferId command_buffer_id_; | 251 const CommandBufferId command_buffer_id_; |
| 252 | 252 |
| 253 // Members accessed on the gpu thread (possibly with the exception of | 253 // Members accessed on the gpu thread (possibly with the exception of |
| 254 // creation): | 254 // creation): |
| 255 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; | 255 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; |
| 256 scoped_refptr<TransferBufferManagerInterface> transfer_buffer_manager_; | 256 scoped_refptr<TransferBufferManagerInterface> transfer_buffer_manager_; |
| 257 scoped_ptr<CommandExecutor> executor_; | 257 std::unique_ptr<CommandExecutor> executor_; |
| 258 scoped_ptr<gles2::GLES2Decoder> decoder_; | 258 std::unique_ptr<gles2::GLES2Decoder> decoder_; |
| 259 scoped_refptr<gfx::GLContext> context_; | 259 scoped_refptr<gfx::GLContext> context_; |
| 260 scoped_refptr<gfx::GLSurface> surface_; | 260 scoped_refptr<gfx::GLSurface> surface_; |
| 261 scoped_refptr<SyncPointOrderData> sync_point_order_data_; | 261 scoped_refptr<SyncPointOrderData> sync_point_order_data_; |
| 262 scoped_ptr<SyncPointClient> sync_point_client_; | 262 std::unique_ptr<SyncPointClient> sync_point_client_; |
| 263 base::Closure context_lost_callback_; | 263 base::Closure context_lost_callback_; |
| 264 // Used to throttle PerformDelayedWorkOnGpuThread. | 264 // Used to throttle PerformDelayedWorkOnGpuThread. |
| 265 bool delayed_work_pending_; | 265 bool delayed_work_pending_; |
| 266 ImageFactory* image_factory_; | 266 ImageFactory* image_factory_; |
| 267 | 267 |
| 268 // Members accessed on the client thread: | 268 // Members accessed on the client thread: |
| 269 GpuControlClient* gpu_control_client_; | 269 GpuControlClient* gpu_control_client_; |
| 270 #if DCHECK_IS_ON() | 270 #if DCHECK_IS_ON() |
| 271 bool context_lost_; | 271 bool context_lost_; |
| 272 #endif | 272 #endif |
| 273 State last_state_; | 273 State last_state_; |
| 274 int32_t last_put_offset_; | 274 int32_t last_put_offset_; |
| 275 gpu::Capabilities capabilities_; | 275 gpu::Capabilities capabilities_; |
| 276 GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 276 GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
| 277 base::AtomicSequenceNumber next_image_id_; | 277 base::AtomicSequenceNumber next_image_id_; |
| 278 uint64_t next_fence_sync_release_; | 278 uint64_t next_fence_sync_release_; |
| 279 uint64_t flushed_fence_sync_release_; | 279 uint64_t flushed_fence_sync_release_; |
| 280 | 280 |
| 281 // Accessed on both threads: | 281 // Accessed on both threads: |
| 282 scoped_ptr<CommandBufferServiceBase> command_buffer_; | 282 std::unique_ptr<CommandBufferServiceBase> command_buffer_; |
| 283 base::Lock command_buffer_lock_; | 283 base::Lock command_buffer_lock_; |
| 284 base::WaitableEvent flush_event_; | 284 base::WaitableEvent flush_event_; |
| 285 scoped_refptr<Service> service_; | 285 scoped_refptr<Service> service_; |
| 286 State state_after_last_flush_; | 286 State state_after_last_flush_; |
| 287 base::Lock state_after_last_flush_lock_; | 287 base::Lock state_after_last_flush_lock_; |
| 288 scoped_refptr<gfx::GLShareGroup> gl_share_group_; | 288 scoped_refptr<gfx::GLShareGroup> gl_share_group_; |
| 289 base::WaitableEvent fence_sync_wait_event_; | 289 base::WaitableEvent fence_sync_wait_event_; |
| 290 | 290 |
| 291 #if defined(OS_ANDROID) | 291 #if defined(OS_ANDROID) |
| 292 scoped_ptr<StreamTextureManagerInProcess> stream_texture_manager_; | 292 std::unique_ptr<StreamTextureManagerInProcess> stream_texture_manager_; |
| 293 #endif | 293 #endif |
| 294 | 294 |
| 295 // Only used with explicit scheduling and the gpu thread is the same as | 295 // Only used with explicit scheduling and the gpu thread is the same as |
| 296 // the client thread. | 296 // the client thread. |
| 297 scoped_ptr<base::SequenceChecker> sequence_checker_; | 297 std::unique_ptr<base::SequenceChecker> sequence_checker_; |
| 298 | 298 |
| 299 base::WeakPtr<InProcessCommandBuffer> client_thread_weak_ptr_; | 299 base::WeakPtr<InProcessCommandBuffer> client_thread_weak_ptr_; |
| 300 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_; | 300 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_; |
| 301 base::WeakPtrFactory<InProcessCommandBuffer> client_thread_weak_ptr_factory_; | 301 base::WeakPtrFactory<InProcessCommandBuffer> client_thread_weak_ptr_factory_; |
| 302 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_; | 302 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_; |
| 303 | 303 |
| 304 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer); | 304 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer); |
| 305 }; | 305 }; |
| 306 | 306 |
| 307 // Default Service class when a null service is used. | 307 // Default Service class when a null service is used. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 330 SyncPointManager* sync_point_manager_; // Non-owning. | 330 SyncPointManager* sync_point_manager_; // Non-owning. |
| 331 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; | 331 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; |
| 332 scoped_refptr<gpu::gles2::FramebufferCompletenessCache> | 332 scoped_refptr<gpu::gles2::FramebufferCompletenessCache> |
| 333 framebuffer_completeness_cache_; | 333 framebuffer_completeness_cache_; |
| 334 DISALLOW_COPY_AND_ASSIGN(GpuInProcessThread); | 334 DISALLOW_COPY_AND_ASSIGN(GpuInProcessThread); |
| 335 }; | 335 }; |
| 336 | 336 |
| 337 } // namespace gpu | 337 } // namespace gpu |
| 338 | 338 |
| 339 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ | 339 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ |
| OLD | NEW |