Modules/Graphics/public/GraphicApplication.hpp
Шурупов Илья Викторович b061d4b600 Stop window resizing from falling behind the compositor
Every configure the compositor sent during an interactive resize ran a
whole frame inside Wayland event dispatch, including one at each stale
intermediate size, so a fast drag queued more frames than the app could
draw and the window lagged further and further behind. Configures and
input now only enter the coalescing queue during dispatch; each frame
applies the newest configure, acknowledges it and delivers the merged
input, and the main loop waits for the compositor's frame callback
before drawing again, so it renders at most once per display refresh.
The synchronous refresh path is removed. Platform input is muted before
the queue while tests inject theirs into it. Leo keeps every pointer
sample so strokes stay smooth; other applications merge motion.
2026-10-15 15:09:46 +03:00

56 lines
No EOL
1.1 KiB
C++

#pragma once
#include "Window.hpp"
#include "Graphics.hpp"
#include "Timing.hpp"
namespace tp {
class Application {
public:
Application();
void run();
void start();
void step(halnf deltaMs);
void finish();
[[nodiscard]] bool isRunning() const { return mEventHandler != nullptr; }
[[nodiscard]] Window& window() { return *mWindow; }
virtual bool forceNewFrame() { return false; }
virtual void processFrame(EventHandler* eventHandler, halnf deltaTime);
virtual void drawFrame(Canvas* canvas);
virtual ~Application();
void drawDebug();
private:
void runFrame();
[[nodiscard]] bool wantsFrame();
void runFrame(halnf deltaMs);
void processPendingInput(halnf deltaMs);
void present();
void updateFrameCounters();
EventHandler* mEventHandler = nullptr;
time_ms mPreviousFrameTime = 0;
time_ns mFrameStart = 0;
protected:
bool mInitialized = false;
Timer mPerSecondTimer;
halnf mFramesProcessedPerSecond = 0;
halnf mFramesDrawnPerSecond = 0;
halnf mFramesProcessed = 0;
halnf mFramesDrawn = 0;
Graphics* mGraphics = nullptr;
Window* mWindow = nullptr;
};
}