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 
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 
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 
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_
BackendType GetBackendType() const override
Get the graphics backend of an Impeller context.
Definition: context_gles.cc:82
bool RemoveReactorWorker(ReactorGLES::WorkerID id)
Definition: context_gles.cc:98
const std::shared_ptr< ReactorGLES > & GetReactor() const
Definition: context_gles.cc:86
std::shared_ptr< GPUTracerGLES > GetGPUTracer() const
Definition: context_gles.h:45
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
std::optional< ReactorGLES::WorkerID > AddReactorWorker(const std::shared_ptr< ReactorGLES::Worker > &worker)
Definition: context_gles.cc:90
To do anything rendering related with Impeller, you need a context.
Definition: context.h:46