| 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 <thread>
9 #include <unordered_map>
10 #include "flutter/fml/macros.h"
11 #include "impeller/base/backend_cast.h"
12 #include "impeller/renderer/backend/gles/allocator_gles.h"
13 #include "impeller/renderer/backend/gles/capabilities_gles.h"
14 #include "impeller/renderer/backend/gles/gpu_tracer_gles.h"
15 #include "impeller/renderer/backend/gles/pipeline_library_gles.h"
16 #include "impeller/renderer/backend/gles/reactor_gles.h"
17 #include "impeller/renderer/backend/gles/sampler_library_gles.h"
18 #include "impeller/renderer/backend/gles/shader_library_gles.h"
19 #include "impeller/renderer/capabilities.h"
20 #include "impeller/renderer/context.h"
21
22 namespace impeller {
23
24 class ContextGLES final : public Context,
25 public BackendCast<ContextGLES, Context>,
26 public std::enable_shared_from_this<ContextGLES> {
27 public:
28 static std::shared_ptr<ContextGLES> Create(
29 std::unique_ptr<ProcTableGLES> gl,
30 const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries,
31 bool enable_gpu_tracing);
32
33 // |Context|
34 ~ContextGLES() override;
35
36 // |Context|
37 BackendType GetBackendType() const override;
38
39 const ReactorGLES::Ref& GetReactor() const;
40
41 std::optional<ReactorGLES::WorkerID> AddReactorWorker(
42 const std::shared_ptr<ReactorGLES::Worker>& worker);
43
44 bool RemoveReactorWorker(ReactorGLES::WorkerID id);
45
46 std::shared_ptr<GPUTracerGLES> GetGPUTracer() const { return gpu_tracer_; }
47
48 private:
49 ReactorGLES::Ref reactor_;
50 std::shared_ptr<ShaderLibraryGLES> shader_library_;
51 std::shared_ptr<PipelineLibraryGLES> pipeline_library_;
52 std::shared_ptr<SamplerLibraryGLES> sampler_library_;
53 std::shared_ptr<AllocatorGLES> resource_allocator_;
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 void Shutdown() override;
93
94 ContextGLES(const ContextGLES&) = delete;
95
96 ContextGLES& operator=(const ContextGLES&) = delete;
97 };
98
99 } // namespace impeller
100
101 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_CONTEXT_GLES_H_
impeller::ContextGLES::RemoveReactorWorker
bool RemoveReactorWorker(ReactorGLES::WorkerID id)
Definition: context_gles.cc:91
impeller::Context::BackendType
BackendType
Definition: context.h:49
impeller::ContextGLES::AddReactorWorker
std::optional< ReactorGLES::WorkerID > AddReactorWorker(const std::shared_ptr< ReactorGLES::Worker > &worker)
Definition: context_gles.cc:83
impeller::ReactorGLES::Ref
std::shared_ptr< ReactorGLES > Ref
Definition: reactor_gles.h:87
impeller::ContextGLES::GetReactor
const ReactorGLES::Ref & GetReactor() const
Definition: context_gles.cc:79
impeller::ContextGLES
Definition: context_gles.h:24
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:15
gpu_tracer_gles.h
sampler_library_gles.h
backend_cast.h
impeller::ContextGLES::GetBackendType
BackendType GetBackendType() const override
Get the graphics backend of an Impeller context.
Definition: context_gles.cc:75
capabilities.h
reactor_gles.h
pipeline_library_gles.h
allocator_gles.h
impeller::Context
To do anything rendering related with Impeller, you need a context.
Definition: context.h:47
impeller::BackendCast
Definition: backend_cast.h:13
shader_library_gles.h
impeller::ContextGLES::~ContextGLES
~ContextGLES() override
context.h
impeller::ContextGLES::GetGPUTracer
std::shared_ptr< GPUTracerGLES > GetGPUTracer() const
Definition: context_gles.h:46
impeller::UniqueID
Definition: comparable.h:16
capabilities_gles.h
impeller
Definition: aiks_context.cc:10