Files
CoopAllTheThings/host/src/capture_panel.hpp
BlackMark a1b7578165 Video mirror: frametime + FPS graphs with min/max/avg stats
The mirror renders into the host window, so the host's render frame timing is
the mirror's performance. FrameStats now retains a ~2 s ring of frame-time
samples; the Video mirror panel plots them as a frametime graph (0-33 ms
scale) and an FPS graph (0-144 scale), each with an avg overlay, and prints
avg/min/max for both frametime and FPS underneath.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 15:19:00 +02:00

46 lines
1.1 KiB
C++

// Owns the video-mirror pipeline (WGC capture + frame renderer) and its UI.
// The target window comes from the injected hook's reported game HWND.
#pragma once
#include <cstdint>
#include <d3d11.h>
#include <windows.h>
#include "capture/frame_renderer.hpp"
#include "capture/window_capture.hpp"
#include "ui/app_chrome.hpp"
namespace coop
{
class CapturePanel
{
public:
bool init(ID3D11Device* device);
// The window to mirror (0 if none yet); typically the injected game's HWND.
void set_target(HWND target)
{
target_ = target;
}
// `stats` are the host's render frame-timing, drawn as the mirror's
// frametime / FPS graphs (this window is what the mirror renders into).
void draw_ui(const FrameStats& stats);
// Render thread: draw the mirrored frame as the window background.
void render(ID3D11DeviceContext* ctx, std::uint32_t dst_w, std::uint32_t dst_h);
private:
void draw_perf_graphs(const FrameStats& stats);
ID3D11Device* device_ = nullptr;
FrameRenderer renderer_;
WindowCapture capture_;
HWND target_ = nullptr;
bool enabled_ = false;
};
} // namespace coop