8#include "flutter/impeller/entity/gles3/entity_shaders_gles.h"
20std::vector<std::shared_ptr<fml::Mapping>>
21ShaderLibraryMappingsForApplication() {
23 std::make_shared<fml::NonOwnedMapping>(
24 impeller_entity_shaders_gles3_data,
25 impeller_entity_shaders_gles3_length),
31 ReactorWorker() =
default;
32 ReactorWorker(
const ReactorWorker&) =
delete;
34 ReactorWorker& operator=(
const ReactorWorker&) =
delete;
44 ImpellerRenderContext(std::shared_ptr<impeller::ContextGLES> context,
45 std::shared_ptr<ReactorWorker> worker)
46 : context_(
std::move(context)),
47 worker_(
std::move(worker)),
48 typographer_context_(
impeller::TypographerContextSkia::Make()),
50 std::make_unique<
impeller::ContentContext>(context_,
55 const sk_sp<flutter::DisplayList> display_list)
override {
57 *content_context_,
surface_->GetRenderTarget(), display_list,
77 void RecreateSurface() {
80 []() {
return true; },
86 std::shared_ptr<impeller::ContextGLES> context_;
87 std::shared_ptr<ReactorWorker> worker_;
88 std::shared_ptr<impeller::TypographerContext> typographer_context_;
89 std::unique_ptr<impeller::ContentContext> content_context_;
90 std::unique_ptr<impeller::Surface>
surface_;
99 auto clear_depth_emulated = [](
float depth) {};
100 auto depth_range_emulated = [](
float near_val,
float far_val) {};
102 std::map<std::string, void*> gl_procs;
104 gl_procs[
"glGetError"] = (
void*)&glGetError;
105 gl_procs[
"glClearDepthf"] = (
void*)&clear_depth_emulated;
106 gl_procs[
"glDepthRangef"] = (
void*)&depth_range_emulated;
108#define IMPELLER_PROC(name) gl_procs["gl" #name] = (void*)&gl##name;
120 auto gl = std::make_unique<impeller::ProcTableGLES>(
121 [gl_procs = std::move(gl_procs)](
const char* function_name) ->
void* {
122 auto found = gl_procs.find(function_name);
123 if (found == gl_procs.end()) {
126 return found->second;
130 impeller::Flags{}, std::move(gl), ShaderLibraryMappingsForApplication(),
133 auto worker = std::make_shared<ReactorWorker>();
134 context->AddReactorWorker(worker);
135 return std::make_unique<ImpellerRenderContext>(std::move(context),
virtual void RenderImage(flutter::DlImage *image, ImageByteFormat format)=0
virtual void RenderPicture(const sk_sp< flutter::DisplayList > display_list)=0
static std::unique_ptr< RenderContext > Make(int sample_count, int stencil)
virtual void Resize(int width, int height)=0
virtual void SetResourceCacheLimit(int bytes)=0
Represents an image whose allocation is (usually) resident on device memory.
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...
virtual bool CanReactorReactOnCurrentThreadNow(const ReactorGLES &reactor) const =0
Determines the ability of the worker to service a reaction on the current thread. The OpenGL context ...
The reactor attempts to make thread-safe usage of OpenGL ES easier to reason about.
static std::unique_ptr< Surface > WrapFBO(const std::shared_ptr< Context > &context, SwapCallback swap_callback, GLuint fbo, PixelFormat color_format, ISize fbo_size)
FlutterVulkanImage * image
bool RenderToTarget(ContentContext &context, RenderTarget render_target, const sk_sp< flutter::DisplayList > &display_list, Rect cull_rect, bool reset_host_buffer, bool is_onscreen)
Render the provided display list to the render target.
#define IMPELLER_PROC(proc_ivar)
#define FOR_EACH_IMPELLER_GLES3_PROC(PROC)
#define FOR_EACH_IMPELLER_ES_ONLY_PROC(PROC)
#define FOR_EACH_IMPELLER_PROC(PROC)
SKWASM_EXPORT bool skwasm_isWimp()
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)