|
5 | 5 | #include "imiv_frame.h" |
6 | 6 |
|
7 | 7 | #include "imiv_actions.h" |
| 8 | +#include "imiv_backend.h" |
8 | 9 | #include "imiv_drag_drop.h" |
9 | 10 | #include "imiv_image_view.h" |
10 | 11 | #include "imiv_menu.h" |
@@ -322,6 +323,49 @@ test_engine_json_write_ocio_state(FILE* f, const PlaceholderUiState& ui_state) |
322 | 323 | std::fputs("\n }\n }", f); |
323 | 324 | } |
324 | 325 |
|
| 326 | +void |
| 327 | +test_engine_json_write_backend_state(FILE* f, const PlaceholderUiState& ui_state, |
| 328 | + BackendKind active_backend) |
| 329 | +{ |
| 330 | + const BackendKind requested_backend = sanitize_backend_kind( |
| 331 | + ui_state.renderer_backend); |
| 332 | + const BackendKind next_launch_backend = resolve_backend_request( |
| 333 | + requested_backend); |
| 334 | + const bool requested_backend_compiled |
| 335 | + = requested_backend == BackendKind::Auto |
| 336 | + || backend_kind_is_compiled(requested_backend); |
| 337 | + |
| 338 | + std::vector<std::string> compiled_backends; |
| 339 | + std::vector<std::string> unavailable_backends; |
| 340 | + compiled_backends.reserve(compiled_backend_info().size()); |
| 341 | + unavailable_backends.reserve(compiled_backend_info().size()); |
| 342 | + for (const BackendInfo& info : compiled_backend_info()) { |
| 343 | + if (info.compiled) |
| 344 | + compiled_backends.emplace_back(info.cli_name); |
| 345 | + else |
| 346 | + unavailable_backends.emplace_back(info.cli_name); |
| 347 | + } |
| 348 | + |
| 349 | + std::fputs(",\n \"backend\": {\n", f); |
| 350 | + std::fputs(" \"active\": ", f); |
| 351 | + test_engine_json_write_escaped(f, backend_cli_name(active_backend)); |
| 352 | + std::fputs(",\n \"active_runtime\": ", f); |
| 353 | + test_engine_json_write_escaped(f, backend_runtime_name(active_backend)); |
| 354 | + std::fputs(",\n \"requested\": ", f); |
| 355 | + test_engine_json_write_escaped(f, backend_cli_name(requested_backend)); |
| 356 | + std::fputs(",\n \"next_launch\": ", f); |
| 357 | + test_engine_json_write_escaped(f, backend_cli_name(next_launch_backend)); |
| 358 | + std::fputs(",\n \"requested_compiled\": ", f); |
| 359 | + std::fputs(requested_backend_compiled ? "true" : "false", f); |
| 360 | + std::fputs(",\n \"restart_required\": ", f); |
| 361 | + std::fputs(next_launch_backend != active_backend ? "true" : "false", f); |
| 362 | + std::fputs(",\n \"compiled\": ", f); |
| 363 | + test_engine_json_write_string_array(f, compiled_backends); |
| 364 | + std::fputs(",\n \"not_compiled\": ", f); |
| 365 | + test_engine_json_write_string_array(f, unavailable_backends); |
| 366 | + std::fputs("\n }", f); |
| 367 | +} |
| 368 | + |
325 | 369 | bool |
326 | 370 | write_test_engine_viewer_state_json(const std::filesystem::path& out_path, |
327 | 371 | void* user_data, std::string& error_message) |
@@ -407,6 +451,7 @@ write_test_engine_viewer_state_json(const std::filesystem::path& out_path, |
407 | 451 | test_engine_json_write_escaped(f, viewer.area_probe_lines[i].c_str()); |
408 | 452 | } |
409 | 453 | std::fputs("]", f); |
| 454 | + test_engine_json_write_backend_state(f, ui_state, ctx->active_backend); |
410 | 455 | test_engine_json_write_ocio_state(f, ui_state); |
411 | 456 | std::fputs("\n}\n", f); |
412 | 457 | std::fflush(f); |
|
0 commit comments