5#include "flutter/shell/platform/embedder/embedder_surface_gl_impeller.h"
9#include "impeller/entity/gles/entity_shaders_gles.h"
10#include "impeller/entity/gles/framebuffer_blend_shaders_gles.h"
11#include "impeller/entity/gles/modern_shaders_gles.h"
16#include "impeller/scene/shaders/gles/scene_shaders_gles.h"
29 auto found = reactions_allowed_.find(std::this_thread::get_id());
30 if (found == reactions_allowed_.end()) {
38 reactions_allowed_[std::this_thread::get_id()] = allowed;
42 mutable impeller::RWMutex mutex_;
43 std::map<std::thread::id, bool> reactions_allowed_
IPLR_GUARDED_BY(mutex_);
50 bool fbo_reset_after_present,
51 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder)
52 : gl_dispatch_table_(
std::move(gl_dispatch_table)),
53 fbo_reset_after_present_(fbo_reset_after_present),
54 external_view_embedder_(
std::move(external_view_embedder)),
69 std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
70 std::make_shared<fml::NonOwnedMapping>(
71 impeller_entity_shaders_gles_data,
72 impeller_entity_shaders_gles_length),
73 std::make_shared<fml::NonOwnedMapping>(
74 impeller_modern_shaders_gles_data,
75 impeller_modern_shaders_gles_length),
76 std::make_shared<fml::NonOwnedMapping>(
77 impeller_framebuffer_blend_shaders_gles_data,
78 impeller_framebuffer_blend_shaders_gles_length),
80 std::make_shared<fml::NonOwnedMapping>(
81 impeller_scene_shaders_gles_data, impeller_scene_shaders_gles_length),
84 auto gl = std::make_unique<impeller::ProcTableGLES>(
91 std::move(gl), shader_mappings,
false);
93 if (!impeller_context_) {
98 auto worker_id = impeller_context_->AddReactorWorker(worker_);
99 if (!worker_id.has_value()) {
105 FML_LOG(IMPORTANT) <<
"Using the Impeller rendering backend (OpenGL).";
117std::unique_ptr<GLContextResult>
119 worker_->SetReactionsAllowedOnCurrentThread(
true);
120 return std::make_unique<GLContextDefaultResult>(
126 worker_->SetReactionsAllowedOnCurrentThread(
false);
148 return fbo_reset_after_present_;
156 matrix.setIdentity();
174 info.supports_partial_repaint =
186 return std::make_unique<GPUSurfaceGLImpeller>(
189 !external_view_embedder_
194std::shared_ptr<impeller::Context>
196 return impeller_context_;
203 worker_->SetReactionsAllowedOnCurrentThread(
true);
205 FML_DLOG(
ERROR) <<
"Could not make the resource context current.";
206 worker_->SetReactionsAllowedOnCurrentThread(
false);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkMatrix GLContextSurfaceTransformation() const override
std::shared_ptr< impeller::Context > CreateImpellerContext() const override
SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const override
~EmbedderSurfaceGLImpeller() override
std::unique_ptr< GLContextResult > GLContextMakeCurrent() override
bool GLContextClearCurrent() override
bool IsValid() const override
bool GLContextFBOResetAfterPresent() const override
bool GLContextPresent(const GLPresentInfo &present_info) override
EmbedderSurfaceGLImpeller(EmbedderSurfaceGL::GLDispatchTable gl_dispatch_table, bool fbo_reset_after_present, std::shared_ptr< EmbedderExternalViewEmbedder > external_view_embedder)
std::unique_ptr< Surface > CreateGPUSurface() override
GLProcResolver GetGLProcResolver() const override
GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override
sk_sp< GrDirectContext > CreateResourceContext() const override
std::function< void *(const char *)> GLProcResolver
bool CanReactorReactOnCurrentThreadNow(const impeller::ReactorGLES &reactor) const override
Determines the ability of the worker to service a reaction on the current thread. The OpenGL context ...
void SetReactionsAllowedOnCurrentThread(bool allowed)
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.
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_DLOG(severity)
#define FML_LOG(severity)
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
std::function< bool(GLPresentInfo)> gl_present_callback
std::function< bool(void)> gl_clear_current_callback
std::function< void *(const char *)> gl_proc_resolver
std::function< bool(void)> gl_make_resource_current_callback
std::function< bool(void)> gl_make_current_callback
std::function< intptr_t(GLFrameInfo)> gl_fbo_callback
std::function< SkMatrix(void)> gl_surface_transformation_callback
std::function< GLFBOInfo(intptr_t)> gl_populate_existing_damage
#define IPLR_GUARDED_BY(x)