| 1415 | namespace android |
| 1416 | { |
| 1417 | class ANativeWindowCreator |
| 1418 | { |
| 1419 | public: |
| 1420 | struct DisplayInfo |
| 1421 | { |
| 1422 | int32_t theta; |
| 1423 | int32_t width; |
| 1424 | int32_t height; |
| 1425 | }; |
| 1426 | |
| 1427 | struct CreateOptions |
| 1428 | { |
| 1429 | const char *name; |
| 1430 | int32_t width; |
| 1431 | int32_t height; |
| 1432 | bool skipScreenshot; |
| 1433 | }; |
| 1434 | |
| 1435 | public: |
| 1436 | static void SetupCustomApiResolver(const anative_window_creator::detail::ApiResolver::ResolverImpl &resolver) |
| 1437 | { |
| 1438 | anative_window_creator::detail::ApiResolver::Resolve(resolver); |
| 1439 | } |
| 1440 | |
| 1441 | public: |
| 1442 | static anative_window_creator::detail::compat::SurfaceComposerClient &GetComposerInstance() |
| 1443 | { |
| 1444 | anative_window_creator::detail::ApiResolver::Resolve(); |
| 1445 | |
| 1446 | static anative_window_creator::detail::compat::SurfaceComposerClient surfaceComposerClient; |
| 1447 | |
| 1448 | return surfaceComposerClient; |
| 1449 | } |
| 1450 | |
| 1451 | static DisplayInfo GetDisplayInfo() |
| 1452 | { |
| 1453 | auto &surfaceComposerClient = GetComposerInstance(); |
| 1454 | anative_window_creator::detail::types::ui::DisplayState displayInfo{}; |
| 1455 | |
| 1456 | if (!surfaceComposerClient.GetDisplayInfo(&displayInfo)) |
| 1457 | return {}; |
| 1458 | |
| 1459 | return DisplayInfo{ |
| 1460 | .theta = 90 * static_cast<int32_t>(displayInfo.orientation), |
| 1461 | .width = displayInfo.layerStackSpaceRect.width, |
| 1462 | .height = displayInfo.layerStackSpaceRect.height, |
| 1463 | }; |
| 1464 | } |
| 1465 | |
| 1466 | static ANativeWindow *Create(const CreateOptions &options = {.name = "AImGui"}) |
| 1467 | { |
| 1468 | auto &surfaceComposerClient = GetComposerInstance(); |
| 1469 | |
| 1470 | int32_t width = options.width; |
| 1471 | int32_t height = options.height; |
| 1472 | while (0 == width || 0 == height) |
| 1473 | { |
| 1474 | anative_window_creator::detail::types::ui::DisplayState displayInfo{}; |
nothing calls this directly
no outgoing calls
no test coverage detected