9 #include "flutter/fml/logging.h"
13 #if IMPELLER_ENABLE_OPENGLES
14 #include "impeller/entity/gles/entity_shaders_gles.h"
15 #include "impeller/entity/gles/framebuffer_blend_shaders_gles.h"
27 std::shared_ptr<BackendData> backend_data)
29 backend_data_(
std::move(backend_data)) {}
41 #if IMPELLER_ENABLE_OPENGLES
46 ReactorWorker() : thread_id_(
std::this_thread::get_id()) {}
49 ~ReactorWorker()
override =
default;
52 bool CanReactorReactOnCurrentThreadNow(
54 return thread_id_ == std::this_thread::get_id();
58 std::thread::id thread_id_;
60 FML_DISALLOW_COPY_AND_ASSIGN(ReactorWorker);
66 std::function<
void*(
const char* gl_proc_name)> proc_address_callback) {
67 #if IMPELLER_ENABLE_OPENGLES
68 auto proc_table = std::make_unique<ProcTableGLES>(
70 if (!proc_table || !proc_table->IsValid()) {
74 std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
75 std::make_shared<fml::NonOwnedMapping>(
76 impeller_entity_shaders_gles_data,
77 impeller_entity_shaders_gles_length),
78 std::make_shared<fml::NonOwnedMapping>(
79 impeller_framebuffer_blend_shaders_gles_data,
80 impeller_framebuffer_blend_shaders_gles_length),
82 auto impeller_context =
84 if (!impeller_context) {
88 auto reactor_worker = std::make_shared<ReactorWorker>();
89 auto worker_id = impeller_context->AddReactorWorker(reactor_worker);
90 if (!worker_id.has_value()) {
95 Create<Context>(std::move(impeller_context), std::move(reactor_worker));
96 if (!context->IsValid()) {
102 VALIDATION_LOG <<
"This build does not support OpenGL ES contexts.";
std::shared_ptr< Context > GetContext() const
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)
A delegate implemented by a thread on which an OpenGL context is current. There may be multiple worke...
The reactor attempts to make thread-safe usage of OpenGL ES easier to reason about.
virtual ~BackendData()=default
std::shared_ptr< impeller::Context > GetContext() const
Context(std::shared_ptr< impeller::Context > context, std::shared_ptr< BackendData > backend_data)
static ScopedObject< Context > CreateOpenGLES(std::function< void *(const char *gl_proc_name)> proc_address_callback)
AiksContext & GetAiksContext()