|
18 | 18 | #include <ostream> |
19 | 19 | #include <string_view> |
20 | 20 | #include <tuple> |
| 21 | +#include <type_traits> |
21 | 22 |
|
22 | 23 | #include "App.h" |
| 24 | +#include "CaptureClient/AppInterface.h" |
23 | 25 | #include "CaptureViewElement.h" |
24 | 26 | #include "ClientData/CallstackData.h" |
25 | 27 | #include "ClientData/CaptureData.h" |
|
38 | 40 | #include "OrbitBase/ThreadConstants.h" |
39 | 41 | #include "TextRenderer.h" |
40 | 42 | #include "TimeGraphLayout.h" |
| 43 | +#include "absl/strings/str_format.h" |
41 | 44 |
|
42 | 45 | using orbit_accessibility::AccessibleInterface; |
43 | 46 | using orbit_accessibility::AccessibleWidgetBridge; |
@@ -651,6 +654,62 @@ void CaptureWindow::RenderImGuiDebugUI() { |
651 | 654 | } |
652 | 655 | } |
653 | 656 |
|
| 657 | +std::string CaptureWindow::GetCaptureInfo() const { |
| 658 | + std::string capture_info; |
| 659 | + |
| 660 | + const auto append_variable = [&capture_info](std::string_view name, const auto& value) { |
| 661 | + if constexpr (std::is_floating_point_v<std::decay_t<decltype(value)>>) { |
| 662 | + absl::StrAppendFormat(&capture_info, "%s: %f\n", name, value); |
| 663 | + } else if constexpr (std::is_integral_v<std::decay_t<decltype(value)>>) { |
| 664 | + absl::StrAppendFormat(&capture_info, "%s: %d\n", name, value); |
| 665 | + } else { |
| 666 | + static_assert(!std::is_same_v<decltype(value), decltype(value)>, |
| 667 | + "Value type is not supported."); |
| 668 | + } |
| 669 | + }; |
| 670 | + |
| 671 | +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) |
| 672 | +#define APPEND_VARIABLE(name) append_variable(#name, name) |
| 673 | + |
| 674 | + APPEND_VARIABLE(viewport_.GetScreenWidth()); |
| 675 | + APPEND_VARIABLE(viewport_.GetScreenHeight()); |
| 676 | + APPEND_VARIABLE(viewport_.GetWorldWidth()); |
| 677 | + APPEND_VARIABLE(viewport_.GetWorldHeight()); |
| 678 | + APPEND_VARIABLE(mouse_move_pos_screen_[0]); |
| 679 | + APPEND_VARIABLE(mouse_move_pos_screen_[1]); |
| 680 | + if (time_graph_ != nullptr) { |
| 681 | + APPEND_VARIABLE(time_graph_->GetTrackContainer()->GetNumVisiblePrimitives()); |
| 682 | + APPEND_VARIABLE(time_graph_->GetTrackManager()->GetAllTracks().size()); |
| 683 | + APPEND_VARIABLE(time_graph_->GetMinTimeUs()); |
| 684 | + APPEND_VARIABLE(time_graph_->GetMaxTimeUs()); |
| 685 | + APPEND_VARIABLE(time_graph_->GetCaptureMin()); |
| 686 | + APPEND_VARIABLE(time_graph_->GetCaptureMax()); |
| 687 | + APPEND_VARIABLE(time_graph_->GetTimeWindowUs()); |
| 688 | + const CaptureData* capture_data = time_graph_->GetCaptureData(); |
| 689 | + if (capture_data != nullptr) { |
| 690 | + APPEND_VARIABLE(capture_data->GetCallstackData().GetCallstackEventsCount()); |
| 691 | + } |
| 692 | + } |
| 693 | + |
| 694 | +#undef APPEND_VARIABLE |
| 695 | + return capture_info; |
| 696 | +} |
| 697 | + |
| 698 | +std::string CaptureWindow::GetPerformanceInfo() const { |
| 699 | + std::string performance_info; |
| 700 | + for (const auto& item : scoped_frame_times_) { |
| 701 | + absl::StrAppendFormat(&performance_info, "Avg time for %s: %f ms\n", item.first, |
| 702 | + item.second->GetAverageTimeMs()); |
| 703 | + absl::StrAppendFormat(&performance_info, "Min time for %s: %f ms\n", item.first, |
| 704 | + item.second->GetMinTimeMs()); |
| 705 | + absl::StrAppendFormat(&performance_info, "Max time for %s: %f ms\n", item.first, |
| 706 | + item.second->GetMaxTimeMs()); |
| 707 | + } |
| 708 | + return performance_info; |
| 709 | +} |
| 710 | + |
| 711 | +std::string CaptureWindow::GetSelectionSummary() const { return selection_stats_.GetSummary(); } |
| 712 | + |
654 | 713 | void CaptureWindow::RenderText(QPainter* painter, float layer) { |
655 | 714 | ORBIT_SCOPE_FUNCTION; |
656 | 715 | if (time_graph_ == nullptr) return; |
|
0 commit comments