blob: 442861adc7c1691e1cf76b234bbf93bdb8c6340f [file] [log] [blame]
fsamueledc0c2c2016-11-18 22:28:041// 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 Backer968c78112019-01-23 20:00:578#include <memory>
9
Bo Liu29543c92019-12-16 21:41:1410#include "base/callback.h"
fsamuel4af1869e2016-11-22 21:41:3411#include "base/compiler_specific.h"
Gabriel Charette5ff87ce2017-05-16 18:03:4512#include "base/single_thread_task_runner.h"
fsamueledc0c2c2016-11-18 22:28:0413#include "gpu/command_buffer/service/mailbox_manager.h"
kylechar2fdaa042018-07-03 17:36:2314#include "gpu/ipc/command_buffer_task_executor.h"
Antoine Labourec6176b2018-01-05 00:00:1015#include "gpu/ipc/gl_in_process_context_export.h"
fsamueledc0c2c2016-11-18 22:28:0416#include "gpu/ipc/in_process_command_buffer.h"
Brian Sheedybaa7414f2019-07-24 21:48:4717#include "gpu/ipc/single_task_sequence.h"
fsamueledc0c2c2016-11-18 22:28:0418#include "ui/gl/gl_share_group.h"
19
20namespace gpu {
Sunny Sachanandani1405fd6a2018-08-30 20:11:5721class Scheduler;
Brian Sheedybaa7414f2019-07-24 21:48:4722class SingleTaskSequence;
Sunny Sachanandani1405fd6a2018-08-30 20:11:5723
Jonathan Backer968c78112019-01-23 20:00:5724namespace gles2 {
25class ProgramCache;
26} // namespace gles2
27
Bo Liuaf884572020-03-10 15:56:5528class 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
fsamuel4af1869e2016-11-22 21:41:3443// Default Service class when no service is specified. GpuInProcessThreadService
44// is used by Mus and unit tests.
Antoine Labourec6176b2018-01-05 00:00:1045class GL_IN_PROCESS_CONTEXT_EXPORT GpuInProcessThreadService
Sunny Sachanandani1405fd6a2018-08-30 20:11:5746 : public CommandBufferTaskExecutor {
fsamueledc0c2c2016-11-18 22:28:0447 public:
48 GpuInProcessThreadService(
Bo Liuaf884572020-03-10 15:56:5549 GpuInProcessThreadServiceDelegate* delegate,
fsamueledc0c2c2016-11-18 22:28:0450 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
Sunny Sachanandani1405fd6a2018-08-30 20:11:5751 Scheduler* scheduler,
52 SyncPointManager* sync_point_manager,
53 MailboxManager* mailbox_manager,
Eric Karl304eff12018-07-27 21:13:3554 gl::GLSurfaceFormat share_group_surface_format,
kylechar47df6302018-02-14 01:45:4855 const GpuFeatureInfo& gpu_feature_info,
Eric Karl06d7a5b2019-01-18 08:05:0156 const GpuPreferences& gpu_preferences,
Jonathan Backer968c78112019-01-23 20:00:5757 SharedImageManager* shared_image_manager,
Bo Liuaf884572020-03-10 15:56:5558 gles2::ProgramCache* program_cache);
kylecharc0acb512019-03-13 14:03:3759 ~GpuInProcessThreadService() override;
fsamueledc0c2c2016-11-18 22:28:0460
Sunny Sachanandani1405fd6a2018-08-30 20:11:5761 // CommandBufferTaskExecutor implementation.
kylechard167a8662018-09-14 20:16:2962 bool ForceVirtualizedGLContexts() const override;
63 bool ShouldCreateMemoryTracker() const override;
Brian Sheedybaa7414f2019-07-24 21:48:4764 std::unique_ptr<SingleTaskSequence> CreateSequence() override;
Sunny Sachanandani1405fd6a2018-08-30 20:11:5765 void ScheduleOutOfOrderTask(base::OnceClosure task) override;
66 void ScheduleDelayedWork(base::OnceClosure task) override;
Bo Liuf0574fc2019-03-22 23:21:2167 void PostNonNestableToClient(base::OnceClosure callback) override;
Bo Liu29543c92019-12-16 21:41:1468 scoped_refptr<SharedContextState> GetSharedContextState() override;
Bo Liuaf884572020-03-10 15:56:5569 scoped_refptr<gl::GLShareGroup> GetShareGroup() override;
fsamueledc0c2c2016-11-18 22:28:0470
71 private:
Bo Liuaf884572020-03-10 15:56:5572 GpuInProcessThreadServiceDelegate* const delegate_;
fsamueledc0c2c2016-11-18 22:28:0473 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
Sunny Sachanandani1405fd6a2018-08-30 20:11:5774 Scheduler* scheduler_;
fsamueledc0c2c2016-11-18 22:28:0475
76 DISALLOW_COPY_AND_ASSIGN(GpuInProcessThreadService);
77};
78
79} // namespace gpu
80
81#endif // GPU_IPC_GPU_IN_PROCESS_THREAD_SERVICE_H_