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);
29 if (!renderer->IsValid()) {
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);
64 auto swap_callback = [weak = weak_factory_.GetWeakPtr(),
65 delegate = delegate_]() ->
bool {
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>(
97 static_cast<uint32_t
>(
size.height())};
109 aiks_context = aiks_context_,
118 FML_LOG(
ERROR) <<
"Could not build display list for surface frame.";
123 surface->GetTargetRenderPassDescriptor().GetRenderTargetSize();
126 display_list->Dispatch(
131 return renderer->Render(
134 [aiks_context, picture = std::move(picture)](
136 return aiks_context->Render(picture, render_target,
141 return std::make_unique<SurfaceFrame>(
146 std::move(context_switch),
static std::shared_ptr< TypographerContext > Make()