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" |
11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
12 #include "components/mus/gles2/command_buffer_driver_manager.h" | 12 #include "components/mus/gles2/command_buffer_driver_manager.h" |
13 #include "components/mus/gles2/command_buffer_task_runner.h" | 13 #include "components/mus/gles2/command_buffer_task_runner.h" |
| 14 #include "gpu/command_buffer/service/gpu_preferences.h" |
14 #include "gpu/command_buffer/service/mailbox_manager_impl.h" | 15 #include "gpu/command_buffer/service/mailbox_manager_impl.h" |
15 #include "gpu/command_buffer/service/sync_point_manager.h" | 16 #include "gpu/command_buffer/service/sync_point_manager.h" |
16 #include "gpu/config/gpu_info.h" | 17 #include "gpu/config/gpu_info.h" |
17 #include "ui/gl/gl_share_group.h" | 18 #include "ui/gl/gl_share_group.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 class WaitableEvent; | 21 class WaitableEvent; |
21 } | 22 } |
22 | 23 |
23 namespace mus { | 24 namespace mus { |
24 | 25 |
25 // 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 |
26 // they create can share resources with each other via mailboxes. | 27 // they create can share resources with each other via mailboxes. |
27 class GpuState : public base::RefCountedThreadSafe<GpuState> { | 28 class GpuState : public base::RefCountedThreadSafe<GpuState> { |
28 public: | 29 public: |
29 GpuState(); | 30 GpuState(); |
30 | 31 |
31 // We run the CommandBufferImpl on the control_task_runner, which forwards | 32 // We run the CommandBufferImpl on the control_task_runner, which forwards |
32 // most method class to the CommandBufferDriver, which runs on the "driver", | 33 // most method class to the CommandBufferDriver, which runs on the "driver", |
33 // thread (i.e., the thread on which GpuImpl instances are created). | 34 // thread (i.e., the thread on which GpuImpl instances are created). |
34 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner() { | 35 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner() { |
35 return control_thread_.task_runner(); | 36 return control_thread_.task_runner(); |
36 } | 37 } |
37 | 38 |
38 void StopThreads(); | 39 void StopThreads(); |
39 | 40 |
| 41 const gpu::GpuPreferences& gpu_preferences() const { |
| 42 return gpu_preferences_; |
| 43 } |
| 44 |
40 CommandBufferTaskRunner* command_buffer_task_runner() const { | 45 CommandBufferTaskRunner* command_buffer_task_runner() const { |
41 return command_buffer_task_runner_.get(); | 46 return command_buffer_task_runner_.get(); |
42 } | 47 } |
43 | 48 |
44 CommandBufferDriverManager* driver_manager() const { | 49 CommandBufferDriverManager* driver_manager() const { |
45 return driver_manager_.get(); | 50 return driver_manager_.get(); |
46 } | 51 } |
47 | 52 |
48 // These objects are intended to be used on the "driver" thread (i.e., the | 53 // These objects are intended to be used on the "driver" thread (i.e., the |
49 // thread on which GpuImpl instances are created). | 54 // thread on which GpuImpl instances are created). |
(...skipping 17 matching lines...) Expand all Loading... |
67 friend class base::RefCountedThreadSafe<GpuState>; | 72 friend class base::RefCountedThreadSafe<GpuState>; |
68 ~GpuState(); | 73 ~GpuState(); |
69 | 74 |
70 void InitializeOnGpuThread(base::WaitableEvent* event); | 75 void InitializeOnGpuThread(base::WaitableEvent* event); |
71 | 76 |
72 // |gpu_thread_| is for executing OS GL calls. | 77 // |gpu_thread_| is for executing OS GL calls. |
73 base::Thread gpu_thread_; | 78 base::Thread gpu_thread_; |
74 // |control_thread_| is for mojo incoming calls of CommandBufferImpl. | 79 // |control_thread_| is for mojo incoming calls of CommandBufferImpl. |
75 base::Thread control_thread_; | 80 base::Thread control_thread_; |
76 | 81 |
| 82 gpu::GpuPreferences gpu_preferences_; |
77 scoped_refptr<CommandBufferTaskRunner> command_buffer_task_runner_; | 83 scoped_refptr<CommandBufferTaskRunner> command_buffer_task_runner_; |
78 scoped_ptr<CommandBufferDriverManager> driver_manager_; | 84 scoped_ptr<CommandBufferDriverManager> driver_manager_; |
79 scoped_ptr<gpu::SyncPointManager> sync_point_manager_; | 85 scoped_ptr<gpu::SyncPointManager> sync_point_manager_; |
80 scoped_refptr<gfx::GLShareGroup> share_group_; | 86 scoped_refptr<gfx::GLShareGroup> share_group_; |
81 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | 87 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; |
82 gpu::GPUInfo gpu_info_; | 88 gpu::GPUInfo gpu_info_; |
83 bool hardware_rendering_available_; | 89 bool hardware_rendering_available_; |
84 }; | 90 }; |
85 | 91 |
86 } // namespace mus | 92 } // namespace mus |
87 | 93 |
88 #endif // COMPONENTS_MUS_GLES2_GPU_STATE_H_ | 94 #endif // COMPONENTS_MUS_GLES2_GPU_STATE_H_ |
OLD | NEW |