Const annotate overlay_params& across the board

Most of the API does not modify it, so annotate it as const.
This makes it earlier to reason what's happening.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
pull/707/head
Emil Velikov 2 years ago committed by jackun
parent f8e9ecb9fe
commit 2b7db32f54
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -73,7 +73,7 @@ R format_units(T value, const char*& unit)
return out_value;
}
void HudElements::convert_colors(struct overlay_params& params)
void HudElements::convert_colors(const struct overlay_params& params)
{
HUDElements.colors.update = false;
auto convert = [](unsigned color) -> ImVec4 {
@ -114,7 +114,7 @@ void HudElements::convert_colors(struct overlay_params& params)
style.WindowRounding = params.round_corners;
}
void HudElements::convert_colors(bool do_conv, struct overlay_params& params)
void HudElements::convert_colors(bool do_conv, const struct overlay_params& params)
{
HUDElements.colors.convert = do_conv;
convert_colors(params);
@ -188,7 +188,7 @@ void HudElements::gpu_stats(){
#ifdef MANGOAPP
right_aligned_text(text_color, HUDElements.ralign_width, "%.1f", gpu_info.powerUsage);
#else
right_aligned_text(text_color, HUDElements.ralign_width, "%.0f", gpu_info.powerUsage);
right_aligned_text(text_color, HUDElements.ralign_width, "%.0f", gpu_info.powerUsage);
#endif
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);

@ -64,8 +64,8 @@ class HudElements{
static void gamepad_battery();
static void framecount();
void convert_colors(struct overlay_params& params);
void convert_colors(bool do_conv, struct overlay_params& params);
void convert_colors(const struct overlay_params& params);
void convert_colors(bool do_conv, const struct overlay_params& params);
struct hud_colors {
bool convert, update;
ImVec4 cpu,

@ -141,7 +141,7 @@ string get_log_suffix(){
return log_name;
}
Logger::Logger(overlay_params* in_params)
Logger::Logger(const overlay_params* in_params)
: m_params(in_params),
m_logging_on(false),
m_values_valid(false)

@ -32,7 +32,7 @@ struct logData{
class Logger {
public:
Logger(overlay_params* in_params);
Logger(const overlay_params* in_params);
void start_logging();
void stop_logging();
@ -54,7 +54,7 @@ public:
void upload_last_log();
void upload_last_logs();
void calculate_benchmark_data();
overlay_params* m_params;
const overlay_params* m_params;
private:
std::vector<logData> m_log_array;

@ -84,7 +84,7 @@ void FpsLimiter(struct fps_limit& stats){
}
}
void update_hw_info(struct overlay_params& params, uint32_t vendorID)
void update_hw_info(const struct overlay_params& params, uint32_t vendorID)
{
if (params.enabled[OVERLAY_PARAM_ENABLED_cpu_stats] || logger->is_active()) {
cpuStats.UpdateCPUData();
@ -144,7 +144,7 @@ struct hw_info_updater
{
bool quit = false;
std::thread thread {};
struct overlay_params* params = nullptr;
const struct overlay_params* params = nullptr;
uint32_t vendorID;
bool update_hw_info_thread = false;
@ -164,7 +164,7 @@ struct hw_info_updater
thread.join();
}
void update(struct overlay_params* params_, uint32_t vendorID_)
void update(const struct overlay_params* params_, uint32_t vendorID_)
{
std::unique_lock<std::mutex> lk_hw_updating(m_hw_updating, std::try_to_lock);
if (lk_hw_updating.owns_lock())
@ -200,7 +200,7 @@ void stop_hw_updater()
hw_update_thread.reset();
}
void update_hud_info_with_frametime(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID, uint64_t frametime_ns){
void update_hud_info_with_frametime(struct swapchain_stats& sw_stats, const struct overlay_params& params, uint32_t vendorID, uint64_t frametime_ns){
uint32_t f_idx = sw_stats.n_frames % ARRAY_SIZE(sw_stats.frames_stats);
uint64_t now = os_time_get_nano(); /* ns */
auto elapsed = now - sw_stats.last_fps_update; /* ns */
@ -255,7 +255,7 @@ void update_hud_info_with_frametime(struct swapchain_stats& sw_stats, struct ove
sw_stats.n_frames_since_update++;
}
void update_hud_info(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID){
void update_hud_info(struct swapchain_stats& sw_stats, const struct overlay_params& params, uint32_t vendorID){
uint64_t now = os_time_get_nano(); /* ns */
uint64_t frametime_ns = now - sw_stats.last_present_time;
update_hud_info_with_frametime(sw_stats, params, vendorID, frametime_ns);
@ -275,7 +275,7 @@ float get_time_stat(void *_data, int _idx)
return data->frames_stats[idx].stats[data->stat_selector] / data->time_dividor;
}
void position_layer(struct swapchain_stats& data, struct overlay_params& params, const ImVec2& window_size)
void position_layer(struct swapchain_stats& data, const struct overlay_params& params, const ImVec2& window_size)
{
unsigned width = ImGui::GetIO().DisplaySize.x;
unsigned height = ImGui::GetIO().DisplaySize.y;
@ -363,7 +363,7 @@ float get_ticker_limited_pos(float pos, float tw, float& left_limit, float& righ
}
#ifdef HAVE_DBUS
void render_mpris_metadata(struct overlay_params& params, mutexed_metadata& meta, uint64_t frame_timing)
void render_mpris_metadata(const struct overlay_params& params, mutexed_metadata& meta, uint64_t frame_timing)
{
if (meta.meta.valid) {
auto color = ImGui::ColorConvertU32ToFloat4(params.media_player_color);
@ -426,7 +426,7 @@ void render_mpris_metadata(struct overlay_params& params, mutexed_metadata& meta
}
#endif
static void render_benchmark(swapchain_stats& data, struct overlay_params& params, const ImVec2& window_size, unsigned height, Clock::time_point now){
static void render_benchmark(swapchain_stats& data, const struct overlay_params& params, const ImVec2& window_size, unsigned height, Clock::time_point now){
// TODO, FIX LOG_DURATION FOR BENCHMARK
int benchHeight = (2 + benchmark.percentile_data.size()) * real_font_size.x + 10.0f + 58;
ImGui::SetNextWindowSize(ImVec2(window_size.x, benchHeight), ImGuiCond_Always);

@ -151,11 +151,11 @@ extern double min_frametime, max_frametime;
extern bool steam_focused;
void init_spdlog();
void position_layer(struct swapchain_stats& data, struct overlay_params& params, const ImVec2& window_size);
void position_layer(struct swapchain_stats& data, const struct overlay_params& params, const ImVec2& window_size);
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, bool is_vulkan);
void update_hud_info(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID);
void update_hud_info_with_frametime(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID, uint64_t frametime_ns);
void update_hw_info(struct overlay_params& params, uint32_t vendorID);
void update_hud_info(struct swapchain_stats& sw_stats, const struct overlay_params& params, uint32_t vendorID);
void update_hud_info_with_frametime(struct swapchain_stats& sw_stats, const struct overlay_params& params, uint32_t vendorID, uint64_t frametime_ns);
void update_hw_info(const struct overlay_params& params, uint32_t vendorID);
void init_gpu_stats(uint32_t& vendorID, uint32_t reported_deviceID, overlay_params& params);
void init_cpu_stats(overlay_params& params);
void check_keybinds(overlay_params& params, uint32_t vendorID);
@ -170,9 +170,9 @@ float get_time_stat(void *_data, int _idx);
void stop_hw_updater();
extern void control_client_check(struct device_data *device_data);
extern void process_control_socket(struct instance_data *instance_data);
#ifdef HAVE_DBUS
void render_mpris_metadata(overlay_params& params, mutexed_metadata& meta, uint64_t frame_timing);
#endif
#ifdef HAVE_DBUS
void render_mpris_metadata(const overlay_params& params, mutexed_metadata& meta, uint64_t frame_timing);
#endif
#endif //MANGOAPP_LAYER
#endif //MANGOHUD_OVERLAY_H

Loading…
Cancel
Save