5#include "flutter/shell/gpu/gpu_surface_gl_impeller.h"
7#include "flutter/fml/make_copyable.h"
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 renderer = std::make_shared<impeller::Renderer>(context);
33 auto aiks_context = std::make_shared<impeller::AiksContext>(
36 if (!aiks_context->IsValid()) {
41 impeller_context_ = std::move(context);
42 render_to_surface_ = render_to_surface;
43 impeller_renderer_ = std::move(
renderer);
44 aiks_context_ = std::move(aiks_context);
57std::unique_ptr<SurfaceFrame> GPUSurfaceGLImpeller::AcquireFrame(
64 auto swap_callback = [weak = weak_factory_.GetWeakPtr(),
65 delegate = delegate_]() ->
bool {
67 GLPresentInfo present_info = {
69 .frame_damage = std::nullopt,
72 .presentation_time = std::nullopt,
73 .buffer_damage = std::nullopt,
75 delegate->GLContextPresent(present_info);
81 if (!context_switch->GetResult()) {
83 <<
"Could not make the context current to acquire the frame.";
87 if (!render_to_surface_) {
88 return std::make_unique<SurfaceFrame>(
89 nullptr, SurfaceFrame::FramebufferInfo{.supports_readback =
true},
90 [](
const SurfaceFrame& surface_frame,
DlCanvas* canvas) {
96 GLFrameInfo frame_info = {
static_cast<uint32_t
>(
size.width()),
97 static_cast<uint32_t
>(
size.height())};
98 const GLFBOInfo fbo_info = delegate_->
GLContextFBO(frame_info);
109 aiks_context = aiks_context_,
111 ](SurfaceFrame& surface_frame,
DlCanvas* canvas)
mutable ->
bool {
116 auto display_list = surface_frame.BuildDisplayList();
118 FML_LOG(
ERROR) <<
"Could not build display list for surface frame.";
123 surface->GetTargetRenderPassDescriptor().GetRenderTargetSize();
126 display_list->Dispatch(
129 auto picture = impeller_dispatcher.EndRecordingAsPicture();
136 return aiks_context->Render(
picture, render_target,
141 return std::make_unique<SurfaceFrame>(
146 std::move(context_switch),
152SkMatrix GPUSurfaceGLImpeller::GetRootTransformation()
const {
165std::unique_ptr<GLContextResult>
166GPUSurfaceGLImpeller::MakeRenderContextCurrent() {
171bool GPUSurfaceGLImpeller::ClearRenderContext() {
175bool GPUSurfaceGLImpeller::AllowsDrawingWhenGpuDisabled()
const {
180bool GPUSurfaceGLImpeller::EnableRasterCache()
const {
185std::shared_ptr<impeller::AiksContext> GPUSurfaceGLImpeller::GetAiksContext()
187 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)> SubmitCallback
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)
sk_sp< const SkPicture > picture
it will be possible to load the file into Perfetto s trace viewer 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)
flutter::DlCanvas DlCanvas
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
static constexpr TRect MakeSize(const TSize< U > &size)