| Flutter Impeller |

context_gles.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_CONTEXT_GLES_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_CONTEXT_GLES_H_
7
8 #include "impeller/base/backend_cast.h"
9 #include "impeller/core/runtime_types.h"
10 #include "impeller/renderer/backend/gles/allocator_gles.h"
11 #include "impeller/renderer/backend/gles/capabilities_gles.h"
12 #include "impeller/renderer/backend/gles/gpu_tracer_gles.h"
13 #include "impeller/renderer/backend/gles/pipeline_library_gles.h"
14 #include "impeller/renderer/backend/gles/reactor_gles.h"
15 #include "impeller/renderer/backend/gles/sampler_library_gles.h"
16 #include "impeller/renderer/backend/gles/shader_library_gles.h"
17 #include "impeller/renderer/capabilities.h"
18 #include "impeller/renderer/command_queue.h"
19 #include "impeller/renderer/context.h"
20
21 namespace impeller {
22
23 class ContextGLES final : public Context,
24 public BackendCast<ContextGLES, Context>,
25 public std::enable_shared_from_this<ContextGLES> {
26 public:
27 static std::shared_ptr<ContextGLES> Create(
28 std::unique_ptr<ProcTableGLES> gl,
29 const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries,
30 bool enable_gpu_tracing);
31
32 // |Context|
33 ~ContextGLES() override;
34
35 // |Context|
36 BackendType GetBackendType() const override;
37
38 const std::shared_ptr<ReactorGLES>& GetReactor() const;
39
40 std::optional<ReactorGLES::WorkerID> AddReactorWorker(
41 const std::shared_ptr<ReactorGLES::Worker>& worker);
42
43 bool RemoveReactorWorker(ReactorGLES::WorkerID id);
44
45 std::shared_ptr<GPUTracerGLES> GetGPUTracer() const { return gpu_tracer_; }
46
47 private:
48 std::shared_ptr<ReactorGLES> reactor_;
49 std::shared_ptr<ShaderLibraryGLES> shader_library_;
50 std::shared_ptr<PipelineLibraryGLES> pipeline_library_;
51 std::shared_ptr<SamplerLibraryGLES> sampler_library_;
52 std::shared_ptr<AllocatorGLES> resource_allocator_;
53 std::shared_ptr<CommandQueue> command_queue_;
54 std::shared_ptr<GPUTracerGLES> gpu_tracer_;
55
56 // Note: This is stored separately from the ProcTableGLES CapabilitiesGLES
57 // in order to satisfy the Context::GetCapabilities signature which returns
58 // a reference.
59 std::shared_ptr<const Capabilities> device_capabilities_;
60 bool is_valid_ = false;
61
62 ContextGLES(
63 std::unique_ptr<ProcTableGLES> gl,
64 const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries,
65 bool enable_gpu_tracing);
66
67 // |Context|
68 std::string DescribeGpuModel() const override;
69
70 // |Context|
71 bool IsValid() const override;
72
73 // |Context|
74 std::shared_ptr<Allocator> GetResourceAllocator() const override;
75
76 // |Context|
77 std::shared_ptr<ShaderLibrary> GetShaderLibrary() const override;
78
79 // |Context|
80 std::shared_ptr<SamplerLibrary> GetSamplerLibrary() const override;
81
82 // |Context|
83 std::shared_ptr<PipelineLibrary> GetPipelineLibrary() const override;
84
85 // |Context|
86 std::shared_ptr<CommandBuffer> CreateCommandBuffer() const override;
87
88 // |Context|
89 const std::shared_ptr<const Capabilities>& GetCapabilities() const override;
90
91 // |Context|
92 std::shared_ptr<CommandQueue> GetCommandQueue() const override;
93
94 // |Context|
95 void Shutdown() override;
96
97 // |Context|
98 bool AddTrackingFence(const std::shared_ptr<Texture>& texture) const override;
99
100 // |Context|
101 void ResetThreadLocalState() const override;
102
103 // |Context|
104 [[nodiscard]] bool EnqueueCommandBuffer(
105 std::shared_ptr<CommandBuffer> command_buffer) override;
106
107 // |Context|
108 [[nodiscard]] bool FlushCommandBuffers() override;
109
110 // |Context|
111 RuntimeStageBackend GetRuntimeStageBackend() const override;
112
113 ContextGLES(const ContextGLES&) = delete;
114
115 ContextGLES& operator=(const ContextGLES&) = delete;
116 };
117
118 } // namespace impeller
119
120 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_CONTEXT_GLES_H_
allocator_gles.h
backend_cast.h
capabilities.h
capabilities_gles.h
impeller::BackendCast
Definition: backend_cast.h:11
impeller::ContextGLES
Definition: context_gles.h:25
impeller::ContextGLES::~ContextGLES
~ContextGLES() override
impeller::ContextGLES::GetBackendType
BackendType GetBackendType() const override
Get the graphics backend of an Impeller context.
Definition: context_gles.cc:82
impeller::ContextGLES::RemoveReactorWorker
bool RemoveReactorWorker(ReactorGLES::WorkerID id)
Definition: context_gles.cc:98
impeller::ContextGLES::GetReactor
const std::shared_ptr< ReactorGLES > & GetReactor() const
Definition: context_gles.cc:86
impeller::ContextGLES::GetGPUTracer
std::shared_ptr< GPUTracerGLES > GetGPUTracer() const
Definition: context_gles.h:45
impeller::ContextGLES::Create
static std::shared_ptr< ContextGLES > Create(std::unique_ptr< ProcTableGLES > gl, const std::vector< std::shared_ptr< fml::Mapping >> &shader_libraries, bool enable_gpu_tracing)
Definition: context_gles.cc:21
impeller::ContextGLES::AddReactorWorker
std::optional< ReactorGLES::WorkerID > AddReactorWorker(const std::shared_ptr< ReactorGLES::Worker > &worker)
Definition: context_gles.cc:90
impeller::Context
To do anything rendering related with Impeller, you need a context.
Definition: context.h:46
impeller::Context::BackendType
BackendType
Definition: context.h:48
command_queue.h
gpu_tracer_gles.h
impeller
Definition: allocation.cc:12
impeller::RuntimeStageBackend
RuntimeStageBackend
Definition: runtime_types.h:16
pipeline_library_gles.h
reactor_gles.h
context.h
runtime_types.h
sampler_library_gles.h
shader_library_gles.h
impeller::UniqueID
Definition: comparable.h:16