fsamuel | edc0c2c | 2016-11-18 22:28:04 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef GPU_IPC_GPU_IN_PROCESS_THREAD_SERVICE_H_ |
| 6 | #define GPU_IPC_GPU_IN_PROCESS_THREAD_SERVICE_H_ |
| 7 | |
Jonathan Backer | 968c7811 | 2019-01-23 20:00:57 | [diff] [blame] | 8 | #include <memory> |
| 9 | |
Bo Liu | 29543c9 | 2019-12-16 21:41:14 | [diff] [blame] | 10 | #include "base/callback.h" |
fsamuel | 4af1869e | 2016-11-22 21:41:34 | [diff] [blame] | 11 | #include "base/compiler_specific.h" |
Gabriel Charette | 5ff87ce | 2017-05-16 18:03:45 | [diff] [blame] | 12 | #include "base/single_thread_task_runner.h" |
fsamuel | edc0c2c | 2016-11-18 22:28:04 | [diff] [blame] | 13 | #include "gpu/command_buffer/service/mailbox_manager.h" |
kylechar | 2fdaa04 | 2018-07-03 17:36:23 | [diff] [blame] | 14 | #include "gpu/ipc/command_buffer_task_executor.h" |
Antoine Labour | ec6176b | 2018-01-05 00:00:10 | [diff] [blame] | 15 | #include "gpu/ipc/gl_in_process_context_export.h" |
fsamuel | edc0c2c | 2016-11-18 22:28:04 | [diff] [blame] | 16 | #include "gpu/ipc/in_process_command_buffer.h" |
Brian Sheedy | baa7414f | 2019-07-24 21:48:47 | [diff] [blame] | 17 | #include "gpu/ipc/single_task_sequence.h" |
fsamuel | edc0c2c | 2016-11-18 22:28:04 | [diff] [blame] | 18 | #include "ui/gl/gl_share_group.h" |
| 19 | |
| 20 | namespace gpu { |
Sunny Sachanandani | 1405fd6a | 2018-08-30 20:11:57 | [diff] [blame] | 21 | class Scheduler; |
Brian Sheedy | baa7414f | 2019-07-24 21:48:47 | [diff] [blame] | 22 | class SingleTaskSequence; |
Sunny Sachanandani | 1405fd6a | 2018-08-30 20:11:57 | [diff] [blame] | 23 | |
Jonathan Backer | 968c7811 | 2019-01-23 20:00:57 | [diff] [blame] | 24 | namespace gles2 { |
| 25 | class ProgramCache; |
| 26 | } // namespace gles2 |
| 27 | |
Bo Liu | af88457 | 2020-03-10 15:56:55 | [diff] [blame] | 28 | class GL_IN_PROCESS_CONTEXT_EXPORT GpuInProcessThreadServiceDelegate { |
| 29 | public: |
| 30 | GpuInProcessThreadServiceDelegate(); |
| 31 | |
| 32 | GpuInProcessThreadServiceDelegate(const GpuInProcessThreadServiceDelegate&) = |
| 33 | delete; |
| 34 | GpuInProcessThreadServiceDelegate& operator=( |
| 35 | const GpuInProcessThreadServiceDelegate&) = delete; |
| 36 | |
| 37 | virtual ~GpuInProcessThreadServiceDelegate(); |
| 38 | |
| 39 | virtual scoped_refptr<SharedContextState> GetSharedContextState() = 0; |
| 40 | virtual scoped_refptr<gl::GLShareGroup> GetShareGroup() = 0; |
| 41 | }; |
| 42 | |
fsamuel | 4af1869e | 2016-11-22 21:41:34 | [diff] [blame] | 43 | // Default Service class when no service is specified. GpuInProcessThreadService |
| 44 | // is used by Mus and unit tests. |
Antoine Labour | ec6176b | 2018-01-05 00:00:10 | [diff] [blame] | 45 | class GL_IN_PROCESS_CONTEXT_EXPORT GpuInProcessThreadService |
Sunny Sachanandani | 1405fd6a | 2018-08-30 20:11:57 | [diff] [blame] | 46 | : public CommandBufferTaskExecutor { |
fsamuel | edc0c2c | 2016-11-18 22:28:04 | [diff] [blame] | 47 | public: |
| 48 | GpuInProcessThreadService( |
Bo Liu | af88457 | 2020-03-10 15:56:55 | [diff] [blame] | 49 | GpuInProcessThreadServiceDelegate* delegate, |
fsamuel | edc0c2c | 2016-11-18 22:28:04 | [diff] [blame] | 50 | scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
Sunny Sachanandani | 1405fd6a | 2018-08-30 20:11:57 | [diff] [blame] | 51 | Scheduler* scheduler, |
| 52 | SyncPointManager* sync_point_manager, |
| 53 | MailboxManager* mailbox_manager, |
Eric Karl | 304eff1 | 2018-07-27 21:13:35 | [diff] [blame] | 54 | gl::GLSurfaceFormat share_group_surface_format, |
kylechar | 47df630 | 2018-02-14 01:45:48 | [diff] [blame] | 55 | const GpuFeatureInfo& gpu_feature_info, |
Eric Karl | 06d7a5b | 2019-01-18 08:05:01 | [diff] [blame] | 56 | const GpuPreferences& gpu_preferences, |
Jonathan Backer | 968c7811 | 2019-01-23 20:00:57 | [diff] [blame] | 57 | SharedImageManager* shared_image_manager, |
Bo Liu | af88457 | 2020-03-10 15:56:55 | [diff] [blame] | 58 | gles2::ProgramCache* program_cache); |
kylechar | c0acb51 | 2019-03-13 14:03:37 | [diff] [blame] | 59 | ~GpuInProcessThreadService() override; |
fsamuel | edc0c2c | 2016-11-18 22:28:04 | [diff] [blame] | 60 | |
Sunny Sachanandani | 1405fd6a | 2018-08-30 20:11:57 | [diff] [blame] | 61 | // CommandBufferTaskExecutor implementation. |
kylechar | d167a866 | 2018-09-14 20:16:29 | [diff] [blame] | 62 | bool ForceVirtualizedGLContexts() const override; |
| 63 | bool ShouldCreateMemoryTracker() const override; |
Brian Sheedy | baa7414f | 2019-07-24 21:48:47 | [diff] [blame] | 64 | std::unique_ptr<SingleTaskSequence> CreateSequence() override; |
Sunny Sachanandani | 1405fd6a | 2018-08-30 20:11:57 | [diff] [blame] | 65 | void ScheduleOutOfOrderTask(base::OnceClosure task) override; |
| 66 | void ScheduleDelayedWork(base::OnceClosure task) override; |
Bo Liu | f0574fc | 2019-03-22 23:21:21 | [diff] [blame] | 67 | void PostNonNestableToClient(base::OnceClosure callback) override; |
Bo Liu | 29543c9 | 2019-12-16 21:41:14 | [diff] [blame] | 68 | scoped_refptr<SharedContextState> GetSharedContextState() override; |
Bo Liu | af88457 | 2020-03-10 15:56:55 | [diff] [blame] | 69 | scoped_refptr<gl::GLShareGroup> GetShareGroup() override; |
fsamuel | edc0c2c | 2016-11-18 22:28:04 | [diff] [blame] | 70 | |
| 71 | private: |
Bo Liu | af88457 | 2020-03-10 15:56:55 | [diff] [blame] | 72 | GpuInProcessThreadServiceDelegate* const delegate_; |
fsamuel | edc0c2c | 2016-11-18 22:28:04 | [diff] [blame] | 73 | scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
Sunny Sachanandani | 1405fd6a | 2018-08-30 20:11:57 | [diff] [blame] | 74 | Scheduler* scheduler_; |
fsamuel | edc0c2c | 2016-11-18 22:28:04 | [diff] [blame] | 75 | |
| 76 | DISALLOW_COPY_AND_ASSIGN(GpuInProcessThreadService); |
| 77 | }; |
| 78 | |
| 79 | } // namespace gpu |
| 80 | |
| 81 | #endif // GPU_IPC_GPU_IN_PROCESS_THREAD_SERVICE_H_ |