1818#include " GPUCommonDef.h"
1919#include " GPUDisplayInterface.h"
2020#include < memory>
21+ #include < chrono>
2122
2223namespace o2 ::gpu
2324{
@@ -49,7 +50,8 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface
4950 static constexpr int32_t GL_MIN_VERSION_MINOR = 5 ;
5051
5152 int32_t StartDisplay (); // Start the display. This function returns, and should spawn a thread that runs the display, and calls InitDisplay
52- void DisplayExit () override = 0; // Stop the display. Display thread should call ExitDisplay and the function returns after the thread has terminated
53+ void DisplayExit () override = 0; // Stop the display. Display thread should call ExitDisplay and then wait that IsRunning() returns false
54+ bool IsRunning () const override { return mDisplayRunning ; }
5355 virtual void SwitchFullscreen (bool set) = 0; // Toggle full-screen mode
5456 virtual void ToggleMaximized (bool set) = 0; // Maximize window
5557 virtual void SetVSync (bool enable) = 0; // Enable / disable vsync
@@ -63,10 +65,8 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface
6365
6466 int32_t getDisplayControl () const override { return mDisplayControl ; }
6567 int32_t getSendKey () const override { return mSendKey ; }
66- int32_t getNeedUpdate () const override { return mNeedUpdate ; }
6768 void setDisplayControl (int32_t v) override { mDisplayControl = v; }
6869 void setSendKey (int32_t v) override { mSendKey = v; }
69- void setNeedUpdate (int32_t v) override { mNeedUpdate = v; }
7070
7171 frontendTypes frontendType () const { return mFrontendType ; }
7272 const char * frontendName () const override { return mFrontendName ; }
@@ -83,6 +83,7 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface
8383 protected:
8484 virtual int32_t FrontendMain () = 0;
8585 static void * FrontendThreadWrapper (void *);
86+ void waitForFPSLimit (); // Sleep until the next frame is due according to fpsRate (no sleep with maxFPSRate or fpsRate <= 0)
8687
8788 static constexpr int32_t INIT_WIDTH = 1024 , INIT_HEIGHT = 768 ; // Initial window size, before maximizing
8889 static constexpr const char * DISPLAY_WINDOW_NAME = " GPU CA Standalone Event Display" ; // Title of event display set by backend
@@ -129,13 +130,14 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface
129130 int32_t mDisplayWidth = INIT_WIDTH ;
130131 int32_t mCanDrawText = 0 ; // 1 = in compat mode, 2 = with shader
131132
132- int32_t mMaxFPSRate = 0 ; // run at highest possible frame rate, do not sleep in between frames
133+ std::chrono::steady_clock::time_point mNextFrameTime ;
133134
134135 GPUDisplay* mDisplay = nullptr ; // Ptr to display, not owning, set by display when it connects to backend
135136 GPUDisplayBackend* mBackend = nullptr ; // Ptr to backend, not owning
136137
137138 frontendTypes mFrontendType = TYPE_INVALID ;
138139 const char * mFrontendName = nullptr ;
140+ volatile bool mDisplayRunning = false ;
139141
140142 std::unique_ptr<GPUDisplayGUIWrapper> mGUI ;
141143
0 commit comments