205 {
207 return true;
208 }
209
210 if (!render_callback) {
211 return true;
212 }
213
214 if (!renderer_ || !renderer_->IsValid()) {
215 return false;
216 }
217
218 IMGUI_CHECKVERSION();
221 []() { ImGui::DestroyContext(); });
222 ImGui::StyleColorsDark();
223
224 auto& io = ImGui::GetIO();
225 io.IniFilename = nullptr;
226 io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
227 io.ConfigWindowsResizeFromEdges = true;
228
229 auto window =
reinterpret_cast<GLFWwindow*
>(impl_->GetWindowHandle());
231 return false;
232 }
234 ::glfwSetWindowUserPointer(
window,
this);
235 ::glfwSetWindowSizeCallback(
237 auto playground =
239 if (!playground) {
240 return;
241 }
243 });
245 ::glfwSetCursorPosCallback(
window, [](GLFWwindow*
window,
double x,
248 ->SetCursorPosition({
static_cast<Scalar>(
x),
static_cast<Scalar>(
y)});
249 });
250
251 ImGui_ImplGlfw_InitForOther(
window,
true);
253
257
258 ImGui::SetNextWindowPos({10, 10});
259
261 ::glfwSetWindowPos(
window, 200, 100);
263
264 while (true) {
265#if FML_OS_MACOSX
267#endif
268 ::glfwPollEvents();
269
270 if (::glfwWindowShouldClose(
window)) {
271 return true;
272 }
273
274 ImGui_ImplGlfw_NewFrame();
275
277 [render_callback,
279 ImGui::NewFrame();
280 ImGui::DockSpaceOverViewport(ImGui::GetMainViewport(),
281 ImGuiDockNodeFlags_PassthruCentralNode);
282 bool result = render_callback(render_target);
283 ImGui::Render();
284
285
286 {
289 return false;
290 }
291 buffer->SetLabel(
"ImGui Command Buffer");
292
293 if (render_target.GetColorAttachments().empty()) {
294 return false;
295 }
296
297 auto color0 = render_target.GetColorAttachments().find(0)->second;
299 if (color0.resolve_texture) {
300 color0.texture = color0.resolve_texture;
301 color0.resolve_texture = nullptr;
303 }
304 render_target.SetColorAttachment(color0, 0);
305
306 render_target.SetStencilAttachment(std::nullopt);
307 render_target.SetDepthAttachment(std::nullopt);
308
309 auto pass =
buffer->CreateRenderPass(render_target);
310 if (!pass) {
311 return false;
312 }
313 pass->SetLabel("ImGui Render Pass");
314
316
317 pass->EncodeCommands();
318 if (!
renderer->GetContext()->GetCommandQueue()->Submit({buffer}).ok()) {
319 return false;
320 }
321 }
322
324 };
325
326 if (!renderer_->Render(impl_->AcquireSurfaceFrame(renderer_->GetContext()),
327 wrapped_callback)) {
329 return false;
330 }
331
333 break;
334 }
335 }
336
338
339 return true;
340}
Wraps a closure that is invoked in the destructor unless released by the caller.
Playground(PlaygroundSwitches switches)
virtual bool ShouldKeepRendering() const
ISize GetWindowSize() const
virtual std::string GetWindowTitle() const =0
std::function< bool(RenderTarget &render_target)> RenderCallback
bool ImGui_ImplImpeller_Init(const std::shared_ptr< impeller::Context > &context)
void ImGui_ImplImpeller_RenderDrawData(ImDrawData *draw_data, impeller::RenderPass &render_pass)
void ImGui_ImplImpeller_Shutdown()
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
static EGLResult< EGLContext > CreateContext(EGLDisplay display, EGLConfig config, EGLContext share=EGL_NO_CONTEXT)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
static void PlaygroundKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)