|
OpenTTD Source 20261112-master-gbcbec5e63f
|
GUI for displaying framerate/game speed information. More...
#include "stdafx.h"#include "framerate_type.h"#include <chrono>#include "gfx_func.h"#include "newgrf_sound.h"#include "window_gui.h"#include "window_func.h"#include "strings_func.h"#include "console_func.h"#include "console_type.h"#include "company_base.h"#include "ai/ai_info.hpp"#include "ai/ai_instance.hpp"#include "game/game.hpp"#include "game/game_instance.hpp"#include "timer/timer.h"#include "timer/timer_window.h"#include "zoom_func.h"#include "widgets/framerate_widget.h"#include <atomic>#include <mutex>#include "table/strings.h"#include "safeguards.h"Go to the source code of this file.
Data Structures | |
| struct | anonymous_namespace{framerate_gui.cpp}::PerformanceData |
| struct | FramerateWindow |
| struct | FramerateWindow::CachedDecimal |
| struct | FrametimeGraphWindow |
Namespaces | |
| namespace | anonymous_namespace{framerate_gui.cpp} |
| Private declarations for performance measurement implementation. | |
Functions | |
| static TimingMeasurement | GetPerformanceTimer () |
Return a timestamp with TIMESTAMP_PRECISION ticks per second precision. | |
| void | ShowFrametimeGraphWindow (PerformanceElement elem) |
| Open a graph window for a performance element. | |
| static constexpr CompanyID | GetAIIndex (PerformanceElement e) |
Get the CompanyID associated with the AI of the given PerformanceElement. | |
| static std::string_view | GetAIName (PerformanceElement e) |
Get the name of the AI of the given PerformanceElement. | |
| void | ShowFramerateWindow () |
| Open the general framerate window. | |
| void | ConPrintFramerate () |
| Print performance statistics to game console. | |
| void | ProcessPendingPerformanceMeasurements () |
| This drains the PerformanceElement::Sound measurement data queue into _pf_data. | |
Variables | |
| static std::mutex | _sound_perf_lock |
| static std::atomic< bool > | _sound_perf_pending |
| static std::vector< TimingMeasurement > | _sound_perf_measurements |
| const int | anonymous_namespace{framerate_gui.cpp}::NUM_FRAMERATE_POINTS = 512 |
| Number of data points to keep in buffer for each performance measurement. | |
| const TimingMeasurement | anonymous_namespace{framerate_gui.cpp}::TIMESTAMP_PRECISION = 1000000 |
| Units a second is divided into in performance measurements | |
| static const double | anonymous_namespace{framerate_gui.cpp}::GL_RATE = 1000.0 / MILLISECONDS_PER_TICK |
| Game loop rate, cycles per second | |
| static EnumIndexArray< PerformanceData, PerformanceElement, PerformanceElement::End > | anonymous_namespace{framerate_gui.cpp}::_pf_data |
| Storage for all performance element measurements. | |
| static constexpr EnumIndexArray< PerformanceElement, PerformanceElement, PerformanceElement::End > | DISPLAY_ORDER_PFE |
| Order of the performance elements in the user interface. | |
| static constexpr std::initializer_list< NWidgetPart > | _framerate_window_widgets |
| static WindowDesc | _framerate_display_desc (WindowPosition::Automatic, "framerate_display", 0, 0, WindowClass::FramerateDisplay, WindowClass::None, {}, _framerate_window_widgets) |
| Window definition for the frame rate window. | |
| static constexpr std::initializer_list< NWidgetPart > | _frametime_graph_window_widgets |
| static WindowDesc | _frametime_graph_window_desc (WindowPosition::Automatic, "frametime_graph", 140, 90, WindowClass::FrametimeGraph, WindowClass::None, {}, _frametime_graph_window_widgets) |
| Window definition for the frame rate graph window. | |
GUI for displaying framerate/game speed information.
Definition in file framerate_gui.cpp.
| void ConPrintFramerate | ( | ) |
Print performance statistics to game console.
Definition at line 1062 of file framerate_gui.cpp.
References anonymous_namespace{framerate_gui.cpp}::_pf_data, AI0, CC_ERROR, Drawing, End, GameLoop, GetAIIndex(), GetAIName(), Green, IConsolePrint(), LightBlue, anonymous_namespace{framerate_gui.cpp}::NUM_FRAMERATE_POINTS, Silver, and Video.
Referenced by ConFramerate().
|
staticconstexpr |
Get the CompanyID associated with the AI of the given PerformanceElement.
| e | The element to convert. |
CompanyID. Definition at line 406 of file framerate_gui.cpp.
References AI0.
Referenced by ConPrintFramerate(), FramerateWindow::DrawWidget(), GetAIName(), FrametimeGraphWindow::GetWidgetString(), and FramerateWindow::UpdateWidgetSize().
|
static |
Get the name of the AI of the given PerformanceElement.
| e | The element to get the name for. |
Definition at line 416 of file framerate_gui.cpp.
References GetAIIndex(), and Company::IsValidAiID().
Referenced by ConPrintFramerate(), FramerateWindow::DrawWidget(), FrametimeGraphWindow::GetWidgetString(), and FramerateWindow::UpdateWidgetSize().
|
static |
Return a timestamp with TIMESTAMP_PRECISION ticks per second precision.
The basis of the timestamp is implementation defined, but the value should be steady, so differences can be taken to reliably measure intervals.
Definition at line 257 of file framerate_gui.cpp.
Referenced by PerformanceMeasurer::Paused(), PerformanceAccumulator::PerformanceAccumulator(), PerformanceMeasurer::PerformanceMeasurer(), PerformanceAccumulator::Reset(), PerformanceAccumulator::~PerformanceAccumulator(), and PerformanceMeasurer::~PerformanceMeasurer().
| void ProcessPendingPerformanceMeasurements | ( | ) |
This drains the PerformanceElement::Sound measurement data queue into _pf_data.
PerformanceElement::Sound measurements are made by the mixer thread and so cannot be stored into _pf_data directly, because this would not be thread safe and would violate the invariants of the FPS and frame graph windows.
Definition at line 1130 of file framerate_gui.cpp.
References anonymous_namespace{framerate_gui.cpp}::_pf_data, and Sound.
Referenced by UpdateWindows().
| void ShowFramerateWindow | ( | ) |
Open the general framerate window.
Definition at line 1046 of file framerate_gui.cpp.
References _framerate_display_desc, and AllocateWindowDescFront().
Referenced by ConFramerateWindow(), and MenuClickHelp().
| void ShowFrametimeGraphWindow | ( | PerformanceElement | elem | ) |
Open a graph window for a performance element.
| elem | The element to show the graph for. |
Definition at line 1055 of file framerate_gui.cpp.
References _frametime_graph_window_desc, AllocateWindowDescFront(), and End.
Referenced by FramerateWindow::OnClick().
|
staticconstexpr |
Definition at line 424 of file framerate_gui.cpp.
|
staticconstexpr |
Definition at line 749 of file framerate_gui.cpp.
|
static |
Definition at line 39 of file framerate_gui.cpp.
|
static |
Definition at line 41 of file framerate_gui.cpp.
|
static |
Definition at line 40 of file framerate_gui.cpp.
|
staticconstexpr |
Order of the performance elements in the user interface.
Definition at line 369 of file framerate_gui.cpp.
Referenced by FramerateWindow::DrawElementTimesColumn(), FramerateWindow::DrawWidget(), FramerateWindow::OnClick(), and FramerateWindow::UpdateWidgetSize().