File diff r25013:4c02a1340d93 → r25014:e1f1bf3a062e
src/video/video_driver.hpp
Show inline comments
 
@@ -13,13 +13,17 @@
 
#include "../driver.h"
 
#include "../core/geometry_type.hpp"
 
#include "../core/math_func.hpp"
 
#include "../gfx_func.h"
 
#include "../settings_type.h"
 
#include "../zoom_type.h"
 
#include <atomic>
 
#include <chrono>
 
#include <condition_variable>
 
#include <mutex>
 
#include <thread>
 
#include <vector>
 

	
 
extern std::string _ini_videodriver;
 
extern std::vector<Dimension> _resolutions;
 
extern Dimension _cur_resolution;
 
extern bool _rightclick_emulate;
 
@@ -28,12 +32,14 @@ extern bool _video_hw_accel;
 
/** The base of all video drivers. */
 
class VideoDriver : public Driver {
 
	const uint DEFAULT_WINDOW_WIDTH = 640u;  ///< Default window width.
 
	const uint DEFAULT_WINDOW_HEIGHT = 480u; ///< Default window height.
 

	
 
public:
 
	VideoDriver() : is_game_threaded(true) {}
 

	
 
	/**
 
	 * Mark a particular area dirty.
 
	 * @param left   The left most line of the dirty area.
 
	 * @param top    The top most line of the dirty area.
 
	 * @param width  The width of the dirty area.
 
	 * @param height The height of the dirty area.
 
@@ -81,12 +87,17 @@ public:
 
	virtual bool UseSystemCursor()
 
	{
 
		return false;
 
	}
 

	
 
	/**
 
	 * Populate all sprites in cache.
 
	 */
 
	virtual void PopulateSystemSprites() {}
 

	
 
	/**
 
	 * Clear all cached sprites.
 
	 */
 
	virtual void ClearSystemSprites() {}
 

	
 
	/**
 
	 * Whether the driver has a graphical user interface with the end user.
 
@@ -237,12 +248,22 @@ protected:
 
	 * Process a single system event.
 
	 * @returns False if there are no more events to process.
 
	 */
 
	virtual bool PollEvent() { return false; };
 

	
 
	/**
 
	 * Start the loop for game-tick.
 
	 */
 
	void StartGameThread();
 

	
 
	/**
 
	 * Stop the loop for the game-tick. This can still tick at most one time before truly shutting down.
 
	 */
 
	void StopGameThread();
 

	
 
	/**
 
	 * Give the video-driver a tick.
 
	 * It will process any potential game-tick and/or draw-tick, and/or any
 
	 * other video-driver related event.
 
	 */
 
	void Tick();
 

	
 
@@ -268,9 +289,20 @@ protected:
 

	
 
	std::chrono::steady_clock::time_point next_game_tick;
 
	std::chrono::steady_clock::time_point next_draw_tick;
 

	
 
	bool fast_forward_key_pressed; ///< The fast-forward key is being pressed.
 
	bool fast_forward_via_key; ///< The fast-forward was enabled by key press.
 

	
 
	bool is_game_threaded;
 
	std::thread game_thread;
 
	std::mutex game_state_mutex;
 
	std::mutex game_thread_wait_mutex;
 

	
 
	static void GameThreadThunk(VideoDriver *drv);
 

	
 
private:
 
	void GameLoop();
 
	void GameThread();
 
};
 

	
 
#endif /* VIDEO_VIDEO_DRIVER_HPP */