Files
Renderive/render_2D/plottable/Performance_Overlay.h
T
2026-08-11 13:49:53 +08:00

80 lines
2.4 KiB
C++

#pragma once
#include "../base/Types.h"
#include "../plot/Plot_Core.h"
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
namespace renderive {
struct Performance_Log_Options {
bool enabled{};
std::string directory;
std::string session_name = "renderive";
};
struct Performance_Overlay_Style {
Font font;
int top_margin = 4;
int left_margin = 6;
int right_margin = 12;
int bottom_margin = 6;
Color background = Color::white();
Color section_color{64, 142, 255};
Color label_color{190, 190, 190};
Color value_color{235, 218, 130};
};
struct Performance_Overlay_Options {
Performance_Overlay_Style style;
Performance_Log_Options log;
};
struct Performance_Display_Snapshot {
Performance_Overlay_Style style;
Size viewport_size;
std::string plot_name;
std::vector<std::string> lines;
std::uint64_t frame_count{};
};
class LIB_DECL Performance_Overlay {
public:
Performance_Overlay();
explicit Performance_Overlay(Performance_Overlay_Options options);
~Performance_Overlay();
[[nodiscard]] bool enabled() const noexcept;
[[nodiscard]] std::shared_ptr<const Performance_Display_Snapshot> display_snapshot() const;
private:
friend class Plot_Core;
friend std::shared_ptr<Performance_Overlay> attach_performance_overlay(Plot_Core&);
friend std::shared_ptr<Performance_Overlay> attach_performance_overlay(
Plot_Core&, const Performance_Overlay_Options&);
friend void set_performance_plot_name(Plot_Core&, std::string);
friend void set_performance_overlay_enabled(Plot_Core&, bool);
struct Impl;
std::unique_ptr<Impl> impl_;
void set_enabled(bool enabled);
void set_plot_name(std::string name);
void set_options(Performance_Overlay_Options options);
void record_frame(double render_duration_ms,
const Low_Latency_Diagnostics& diagnostics,
std::size_t renderable_count,
Size viewport);
};
LIB_DECL std::shared_ptr<Performance_Overlay> attach_performance_overlay(Plot_Core& plot);
LIB_DECL std::shared_ptr<Performance_Overlay> attach_performance_overlay(
Plot_Core& plot, const Performance_Overlay_Options& options);
LIB_DECL void set_performance_plot_name(Plot_Core& plot, std::string name);
LIB_DECL void set_performance_overlay_enabled(Plot_Core& plot, bool enabled);
} // namespace renderive