10#include "impeller/entity/gles/entity_shaders_gles.h"
11#include "impeller/entity/gles/framebuffer_blend_shaders_gles.h"
12#include "impeller/entity/gles/modern_shaders_gles.h"
26 auto found = reactions_allowed_.find(std::this_thread::get_id());
27 if (found == reactions_allowed_.end()) {
35 reactions_allowed_[std::this_thread::get_id()] = allowed;
39 mutable impeller::RWMutex mutex_;
40 std::map<std::thread::id, bool> reactions_allowed_
IPLR_GUARDED_BY(mutex_);
47 bool fbo_reset_after_present,
48 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder)
49 : gl_dispatch_table_(
std::move(gl_dispatch_table)),
50 fbo_reset_after_present_(fbo_reset_after_present),
51 external_view_embedder_(
std::move(external_view_embedder)),
66 std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
67 std::make_shared<fml::NonOwnedMapping>(
68 impeller_entity_shaders_gles_data,
69 impeller_entity_shaders_gles_length),
70 std::make_shared<fml::NonOwnedMapping>(
71 impeller_modern_shaders_gles_data,
72 impeller_modern_shaders_gles_length),
73 std::make_shared<fml::NonOwnedMapping>(
74 impeller_framebuffer_blend_shaders_gles_data,
75 impeller_framebuffer_blend_shaders_gles_length),
77 auto gl = std::make_unique<impeller::ProcTableGLES>(
87 if (!impeller_context_) {
88 FML_LOG(ERROR) <<
"Could not create Impeller context.";
92 auto worker_id = impeller_context_->AddReactorWorker(worker_);
93 if (!worker_id.has_value()) {
94 FML_LOG(ERROR) <<
"Could not add reactor worker.";
99 FML_LOG(IMPORTANT) <<
"Using the Impeller rendering backend (OpenGL).";
106bool EmbedderSurfaceGLImpeller::IsValid()
const {
111std::unique_ptr<GLContextResult>
112EmbedderSurfaceGLImpeller::GLContextMakeCurrent() {
113 worker_->SetReactionsAllowedOnCurrentThread(
true);
114 return std::make_unique<GLContextDefaultResult>(
119bool EmbedderSurfaceGLImpeller::GLContextClearCurrent() {
120 worker_->SetReactionsAllowedOnCurrentThread(
false);
125bool EmbedderSurfaceGLImpeller::GLContextPresent(
126 const GLPresentInfo& present_info) {
132GLFBOInfo EmbedderSurfaceGLImpeller::GLContextFBO(
133 GLFrameInfo frame_info)
const {
141bool EmbedderSurfaceGLImpeller::GLContextFBOResetAfterPresent()
const {
142 return fbo_reset_after_present_;
146DlMatrix EmbedderSurfaceGLImpeller::GLContextSurfaceTransformation()
const {
156EmbedderSurfaceGLImpeller::GetGLProcResolver()
const {
161SurfaceFrame::FramebufferInfo
162EmbedderSurfaceGLImpeller::GLContextFramebufferInfo()
const {
164 auto info = SurfaceFrame::FramebufferInfo{};
165 info.supports_readback =
true;
166 info.supports_partial_repaint =
172std::unique_ptr<Surface> EmbedderSurfaceGLImpeller::CreateGPUSurface() {
176 GLContextMakeCurrent();
178 return std::make_unique<GPUSurfaceGLImpeller>(
181 !external_view_embedder_
186std::shared_ptr<impeller::Context>
187EmbedderSurfaceGLImpeller::CreateImpellerContext()
const {
188 return impeller_context_;
192sk_sp<GrDirectContext> EmbedderSurfaceGLImpeller::CreateResourceContext()
195 worker_->SetReactionsAllowedOnCurrentThread(
true);
197 FML_DLOG(ERROR) <<
"Could not make the resource context current.";
198 worker_->SetReactionsAllowedOnCurrentThread(
false);
EmbedderSurfaceGLImpeller(EmbedderSurfaceGLSkia::GLDispatchTable gl_dispatch_table, bool fbo_reset_after_present, std::shared_ptr< EmbedderExternalViewEmbedder > external_view_embedder)
~EmbedderSurfaceGLImpeller() 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(const Flags &flags, 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.
FlutterDesktopBinaryReply callback
#define FML_DLOG(severity)
#define FML_LOG(severity)
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
impeller::Matrix DlMatrix
std::function< bool(void)> gl_clear_current_callback
std::function< GLFBOInfo(intptr_t)> gl_populate_existing_damage
std::function< bool(void)> gl_make_current_callback
std::function< intptr_t(GLFrameInfo)> gl_fbo_callback
std::function< bool(GLPresentInfo)> gl_present_callback
std::function< bool(void)> gl_make_resource_current_callback
std::function< void *(const char *)> gl_proc_resolver
std::function< DlMatrix(void)> gl_surface_transformation_callback
#define IPLR_GUARDED_BY(x)