95 reactor_worker_(std::shared_ptr<ReactorWorker>(new ReactorWorker())),
96 display_(std::move(display)) {
97 if (!display_ || !display_->IsValid()) {
98 FML_DLOG(
ERROR) <<
"Could not create context with invalid EGL display.";
99 return;
100 }
101
108
110 std::unique_ptr<impeller::egl::Config> onscreen_config =
111 display_->ChooseConfig(
desc);
112 if (!onscreen_config) {
113
115 onscreen_config = display_->ChooseConfig(
desc);
116 if (onscreen_config) {
117 FML_LOG(INFO) <<
"Warning: This device doesn't support MSAA for onscreen "
118 "framebuffers. Falling back to a single sample.";
119 } else {
121 return;
122 }
123 }
124
126 auto offscreen_config = display_->ChooseConfig(
desc);
127 if (!offscreen_config) {
129 return;
130 }
131
132 auto onscreen_context = display_->CreateContext(*onscreen_config, nullptr);
133 if (!onscreen_context) {
135 return;
136 }
137
138 auto offscreen_context =
139 display_->CreateContext(*offscreen_config, onscreen_context.get());
140 if (!offscreen_context) {
142 return;
143 }
144
145
146
147 auto offscreen_surface =
148 display_->CreatePixelBufferSurface(*offscreen_config, 1u, 1u);
149 if (!offscreen_context->MakeCurrent(*offscreen_surface)) {
150 FML_DLOG(
ERROR) <<
"Could not make offscreen context current.";
151 return;
152 }
153
154 auto impeller_context =
156
157 if (!impeller_context) {
159 return;
160 }
161
162 if (!offscreen_context->ClearCurrent()) {
164 return;
165 }
166
168 [worker =
169 reactor_worker_](impeller::egl ::Context::LifecycleEvent
event) {
172 worker->SetReactionsAllowedOnCurrentThread(true);
173 break;
175 worker->SetReactionsAllowedOnCurrentThread(false);
176 break;
177 }
178 };
179 if (!onscreen_context->AddLifecycleListener(listener).has_value() ||
180 !offscreen_context->AddLifecycleListener(listener).has_value()) {
182 }
183
184 onscreen_config_ = std::move(onscreen_config);
185 offscreen_config_ = std::move(offscreen_config);
186 onscreen_context_ = std::move(onscreen_context);
187 offscreen_context_ = std::move(offscreen_context);
189
190 is_valid_ = true;
191}
AndroidContext(AndroidRenderingAPI rendering_api)
void SetImpellerContext(const std::shared_ptr< impeller::Context > &context)
std::function< void(LifecycleEvent)> LifecycleListener
#define FML_DLOG(severity)
#define FML_LOG(severity)
static std::shared_ptr< impeller::Context > CreateImpellerContext(const std::shared_ptr< impeller::ReactorGLES::Worker > &worker, bool enable_gpu_tracing)