OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_MUS_GLES2_GPU_STATE_H_ | 5 #ifndef COMPONENTS_MUS_GLES2_GPU_STATE_H_ |
6 #define COMPONENTS_MUS_GLES2_GPU_STATE_H_ | 6 #define COMPONENTS_MUS_GLES2_GPU_STATE_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // We need to share these across all CommandBuffer instances so that contexts | 26 // We need to share these across all CommandBuffer instances so that contexts |
27 // they create can share resources with each other via mailboxes. | 27 // they create can share resources with each other via mailboxes. |
28 class GpuState : public base::RefCountedThreadSafe<GpuState> { | 28 class GpuState : public base::RefCountedThreadSafe<GpuState> { |
29 public: | 29 public: |
30 GpuState(); | 30 GpuState(); |
31 | 31 |
32 // We run the CommandBufferImpl on the control_task_runner, which forwards | 32 // We run the CommandBufferImpl on the control_task_runner, which forwards |
33 // most method class to the CommandBufferDriver, which runs on the "driver", | 33 // most method class to the CommandBufferDriver, which runs on the "driver", |
34 // thread (i.e., the thread on which GpuImpl instances are created). | 34 // thread (i.e., the thread on which GpuImpl instances are created). |
35 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner() { | 35 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner() { |
36 return control_thread_.task_runner(); | 36 return control_thread_task_runner_; |
37 } | 37 } |
38 | 38 |
39 void StopThreads(); | 39 void StopThreads(); |
40 | 40 |
41 const gpu::GpuPreferences& gpu_preferences() const { | 41 const gpu::GpuPreferences& gpu_preferences() const { |
42 return gpu_preferences_; | 42 return gpu_preferences_; |
43 } | 43 } |
44 | 44 |
45 CommandBufferTaskRunner* command_buffer_task_runner() const { | 45 CommandBufferTaskRunner* command_buffer_task_runner() const { |
46 return command_buffer_task_runner_.get(); | 46 return command_buffer_task_runner_.get(); |
(...skipping 20 matching lines...) Expand all Loading... |
67 bool HardwareRenderingAvailable() const { | 67 bool HardwareRenderingAvailable() const { |
68 return hardware_rendering_available_; | 68 return hardware_rendering_available_; |
69 } | 69 } |
70 | 70 |
71 private: | 71 private: |
72 friend class base::RefCountedThreadSafe<GpuState>; | 72 friend class base::RefCountedThreadSafe<GpuState>; |
73 ~GpuState(); | 73 ~GpuState(); |
74 | 74 |
75 void InitializeOnGpuThread(base::WaitableEvent* event); | 75 void InitializeOnGpuThread(base::WaitableEvent* event); |
76 | 76 |
| 77 void DestroyGpuSpecificStateOnGpuThread(); |
| 78 |
77 // |gpu_thread_| is for executing OS GL calls. | 79 // |gpu_thread_| is for executing OS GL calls. |
78 base::Thread gpu_thread_; | 80 base::Thread gpu_thread_; |
79 // |control_thread_| is for mojo incoming calls of CommandBufferImpl. | 81 // |control_thread_| is for mojo incoming calls of CommandBufferImpl. |
80 base::Thread control_thread_; | 82 base::Thread control_thread_; |
81 | 83 |
| 84 // Same as control_thread_->task_runner(). The TaskRunner is cached as it may |
| 85 // be needed during shutdown. |
| 86 scoped_refptr<base::SingleThreadTaskRunner> control_thread_task_runner_; |
| 87 |
82 gpu::GpuPreferences gpu_preferences_; | 88 gpu::GpuPreferences gpu_preferences_; |
83 scoped_refptr<CommandBufferTaskRunner> command_buffer_task_runner_; | 89 scoped_refptr<CommandBufferTaskRunner> command_buffer_task_runner_; |
84 scoped_ptr<CommandBufferDriverManager> driver_manager_; | 90 scoped_ptr<CommandBufferDriverManager> driver_manager_; |
85 scoped_ptr<gpu::SyncPointManager> sync_point_manager_; | 91 scoped_ptr<gpu::SyncPointManager> sync_point_manager_; |
86 scoped_refptr<gfx::GLShareGroup> share_group_; | 92 scoped_refptr<gfx::GLShareGroup> share_group_; |
87 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | 93 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; |
88 gpu::GPUInfo gpu_info_; | 94 gpu::GPUInfo gpu_info_; |
89 bool hardware_rendering_available_; | 95 bool hardware_rendering_available_; |
90 }; | 96 }; |
91 | 97 |
92 } // namespace mus | 98 } // namespace mus |
93 | 99 |
94 #endif // COMPONENTS_MUS_GLES2_GPU_STATE_H_ | 100 #endif // COMPONENTS_MUS_GLES2_GPU_STATE_H_ |
OLD | NEW |