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/gpu_preferences.h" |
15 #include "gpu/command_buffer/service/mailbox_manager_impl.h" | 15 #include "gpu/command_buffer/service/mailbox_manager_impl.h" |
16 #include "gpu/command_buffer/service/sync_point_manager.h" | 16 #include "gpu/command_buffer/service/sync_point_manager.h" |
17 #include "gpu/config/gpu_driver_bug_workarounds.h" | |
18 #include "gpu/config/gpu_info.h" | 17 #include "gpu/config/gpu_info.h" |
19 #include "ui/gl/gl_share_group.h" | 18 #include "ui/gl/gl_share_group.h" |
20 | 19 |
21 namespace { | 20 namespace { |
22 class WaitableEvent; | 21 class WaitableEvent; |
23 } | 22 } |
24 | 23 |
25 namespace mus { | 24 namespace mus { |
26 | 25 |
27 // 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 |
28 // they create can share resources with each other via mailboxes. | 27 // they create can share resources with each other via mailboxes. |
29 class GpuState : public base::RefCountedThreadSafe<GpuState> { | 28 class GpuState : public base::RefCountedThreadSafe<GpuState> { |
30 public: | 29 public: |
31 GpuState(); | 30 GpuState(); |
32 | 31 |
33 // We run the CommandBufferImpl on the control_task_runner, which forwards | 32 // We run the CommandBufferImpl on the control_task_runner, which forwards |
34 // most method class to the CommandBufferDriver, which runs on the "driver", | 33 // most method class to the CommandBufferDriver, which runs on the "driver", |
35 // thread (i.e., the thread on which GpuImpl instances are created). | 34 // thread (i.e., the thread on which GpuImpl instances are created). |
36 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner() { | 35 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner() { |
37 return control_thread_task_runner_; | 36 return control_thread_task_runner_; |
38 } | 37 } |
39 | 38 |
40 void StopThreads(); | 39 void StopThreads(); |
41 | 40 |
42 const gpu::GpuPreferences& gpu_preferences() const { | 41 const gpu::GpuPreferences& gpu_preferences() const { |
43 return gpu_preferences_; | 42 return gpu_preferences_; |
44 } | 43 } |
45 | 44 |
46 const gpu::GpuDriverBugWorkarounds& gpu_driver_bug_workarounds() const { | |
47 return gpu_driver_bug_workarounds_; | |
48 } | |
49 | |
50 CommandBufferTaskRunner* command_buffer_task_runner() const { | 45 CommandBufferTaskRunner* command_buffer_task_runner() const { |
51 return command_buffer_task_runner_.get(); | 46 return command_buffer_task_runner_.get(); |
52 } | 47 } |
53 | 48 |
54 CommandBufferDriverManager* driver_manager() const { | 49 CommandBufferDriverManager* driver_manager() const { |
55 return driver_manager_.get(); | 50 return driver_manager_.get(); |
56 } | 51 } |
57 | 52 |
58 // 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 |
59 // thread on which GpuImpl instances are created). | 54 // thread on which GpuImpl instances are created). |
(...skipping 24 matching lines...) Expand all Loading... |
84 // |gpu_thread_| is for executing OS GL calls. | 79 // |gpu_thread_| is for executing OS GL calls. |
85 base::Thread gpu_thread_; | 80 base::Thread gpu_thread_; |
86 // |control_thread_| is for mojo incoming calls of CommandBufferImpl. | 81 // |control_thread_| is for mojo incoming calls of CommandBufferImpl. |
87 base::Thread control_thread_; | 82 base::Thread control_thread_; |
88 | 83 |
89 // Same as control_thread_->task_runner(). The TaskRunner is cached as it may | 84 // Same as control_thread_->task_runner(). The TaskRunner is cached as it may |
90 // be needed during shutdown. | 85 // be needed during shutdown. |
91 scoped_refptr<base::SingleThreadTaskRunner> control_thread_task_runner_; | 86 scoped_refptr<base::SingleThreadTaskRunner> control_thread_task_runner_; |
92 | 87 |
93 gpu::GpuPreferences gpu_preferences_; | 88 gpu::GpuPreferences gpu_preferences_; |
94 const gpu::GpuDriverBugWorkarounds gpu_driver_bug_workarounds_; | |
95 scoped_refptr<CommandBufferTaskRunner> command_buffer_task_runner_; | 89 scoped_refptr<CommandBufferTaskRunner> command_buffer_task_runner_; |
96 scoped_ptr<CommandBufferDriverManager> driver_manager_; | 90 scoped_ptr<CommandBufferDriverManager> driver_manager_; |
97 scoped_ptr<gpu::SyncPointManager> sync_point_manager_; | 91 scoped_ptr<gpu::SyncPointManager> sync_point_manager_; |
98 scoped_refptr<gfx::GLShareGroup> share_group_; | 92 scoped_refptr<gfx::GLShareGroup> share_group_; |
99 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | 93 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; |
100 gpu::GPUInfo gpu_info_; | 94 gpu::GPUInfo gpu_info_; |
101 bool hardware_rendering_available_; | 95 bool hardware_rendering_available_; |
102 }; | 96 }; |
103 | 97 |
104 } // namespace mus | 98 } // namespace mus |
105 | 99 |
106 #endif // COMPONENTS_MUS_GLES2_GPU_STATE_H_ | 100 #endif // COMPONENTS_MUS_GLES2_GPU_STATE_H_ |
OLD | NEW |