17 std::shared_ptr<impeller::Context> context,
18 bool render_to_surface)
19 : weak_factory_(this) {
20 if (delegate ==
nullptr) {
24 if (!context || !context->IsValid()) {
28 auto aiks_context = std::make_shared<impeller::AiksContext>(
31 if (!aiks_context->IsValid()) {
36 impeller_context_ = std::move(context);
37 render_to_surface_ = render_to_surface;
38 aiks_context_ = std::move(aiks_context);
51std::unique_ptr<SurfaceFrame> GPUSurfaceGLImpeller::AcquireFrame(
54 FML_LOG(ERROR) <<
"OpenGL surface was invalid.";
58 auto swap_callback = [weak = weak_factory_.GetWeakPtr(),
59 delegate = delegate_]() ->
bool {
61 GLPresentInfo present_info = {
63 .frame_damage = std::nullopt,
66 .presentation_time = std::nullopt,
67 .buffer_damage = std::nullopt,
69 delegate->GLContextPresent(present_info);
75 if (!context_switch->GetResult()) {
77 <<
"Could not make the context current to acquire the frame.";
81 if (!render_to_surface_) {
82 return std::make_unique<SurfaceFrame>(
83 nullptr, SurfaceFrame::FramebufferInfo{.supports_readback =
true},
84 [](
const SurfaceFrame& surface_frame,
DlCanvas* canvas) {
87 [](
const SurfaceFrame& surface_frame) {
return true; },
size);
90 GLFrameInfo frame_info = {
static_cast<uint32_t
>(
size.width),
91 static_cast<uint32_t
>(
size.height)};
92 const GLFBOInfo fbo_info = delegate_->
GLContextFBO(frame_info);
104 [aiks_context = aiks_context_,
105 render_target](SurfaceFrame& surface_frame,
111 auto display_list = surface_frame.BuildDisplayList();
113 FML_LOG(ERROR) <<
"Could not build display list for surface frame.";
128 return std::make_unique<SurfaceFrame>(
133 return surface->Present();
136 std::move(context_switch),
142DlMatrix GPUSurfaceGLImpeller::GetRootTransformation()
const {
149GrDirectContext* GPUSurfaceGLImpeller::GetContext() {
155std::unique_ptr<GLContextResult>
156GPUSurfaceGLImpeller::MakeRenderContextCurrent() {
161bool GPUSurfaceGLImpeller::ClearRenderContext() {
165bool GPUSurfaceGLImpeller::AllowsDrawingWhenGpuDisabled()
const {
170bool GPUSurfaceGLImpeller::EnableRasterCache()
const {
175std::shared_ptr<impeller::AiksContext> GPUSurfaceGLImpeller::GetAiksContext()
177 return aiks_context_;
virtual bool AllowsDrawingWhenGpuDisabled() const
virtual std::unique_ptr< GLContextResult > GLContextMakeCurrent()=0
virtual bool GLContextClearCurrent()=0
virtual SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const
virtual GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const =0
GPUSurfaceGLImpeller(GPUSurfaceGLDelegate *delegate, std::shared_ptr< impeller::Context > context, bool render_to_surface)
~GPUSurfaceGLImpeller() override
std::function< bool(SurfaceFrame &surface_frame, DlCanvas *canvas)> EncodeCallback
ISize GetRenderTargetSize() const
static std::unique_ptr< Surface > WrapFBO(const std::shared_ptr< Context > &context, SwapCallback swap_callback, GLuint fbo, PixelFormat color_format, ISize fbo_size)
static std::shared_ptr< TypographerContext > Make()
#define FML_LOG(severity)
impeller::Matrix DlMatrix
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
internal::CopyableLambda< T > MakeCopyable(T lambda)
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.
flutter::DlCanvas DlCanvas
static constexpr TRect MakeSize(const TSize< U > &size)