File diff r24917:32c68f7840b0 → r24918:e55bb9103b0b
src/video/sdl2_v.h
Show inline comments
 
@@ -12,15 +12,15 @@
 

	
 
#include <condition_variable>
 

	
 
#include "video_driver.hpp"
 

	
 
/** The SDL video driver. */
 
class VideoDriver_SDL : public VideoDriver {
 
class VideoDriver_SDL_Base : public VideoDriver {
 
public:
 
	VideoDriver_SDL() : sdl_window(nullptr) {}
 
	VideoDriver_SDL_Base() : sdl_window(nullptr) {}
 

	
 
	const char *Start(const StringList &param) override;
 

	
 
	void Stop() override;
 

	
 
	void MakeDirty(int left, int top, int width, int height) override;
 
@@ -56,57 +56,45 @@ protected:
 
	Rect dirty_rect; ///< Rectangle encompassing the dirty area of the video buffer.
 

	
 
	Dimension GetScreenSize() const override;
 
	void InputLoop() override;
 
	bool LockVideoBuffer() override;
 
	void UnlockVideoBuffer() override;
 
	void Paint() override;
 
	void PaintThread() override;
 
	void CheckPaletteAnim() override;
 

	
 
	/** Indicate to the driver the client-side might have changed. */
 
	void ClientSizeChanged(int w, int h, bool force);
 

	
 
	/** (Re-)create the backing store. */
 
	virtual bool AllocateBackingStore(int w, int h, bool force = false);
 
	virtual bool AllocateBackingStore(int w, int h, bool force = false) = 0;
 
	/** Get a pointer to the video buffer. */
 
	virtual void *GetVideoPointer();
 
	virtual void *GetVideoPointer() = 0;
 
	/** Hand video buffer back to the painting backend. */
 
	virtual void ReleaseVideoPointer() {}
 
	virtual void ReleaseVideoPointer() = 0;
 
	/** Create the main window. */
 
	virtual bool CreateMainWindow(uint w, uint h, uint flags = 0);
 

	
 
private:
 
	int PollEvent();
 
	void LoopOnce();
 
	void MainLoopCleanup();
 
	bool CreateMainSurface(uint w, uint h, bool resize);
 
	const char *Initialize();
 
	bool CreateMainWindow(uint w, uint h);
 
	void UpdatePalette();
 
	void MakePalette();
 

	
 
#ifdef __EMSCRIPTEN__
 
	/* Convert a constant pointer back to a non-constant pointer to a member function. */
 
	static void EmscriptenLoop(void *self) { ((VideoDriver_SDL *)self)->LoopOnce(); }
 
	static void EmscriptenLoop(void *self) { ((VideoDriver_SDL_Base *)self)->LoopOnce(); }
 
#endif
 

	
 
	/**
 
	 * This is true to indicate that keyboard input is in text input mode, and SDL_TEXTINPUT events are enabled.
 
	 */
 
	bool edit_box_focused;
 

	
 
	int startup_display;
 
	std::thread draw_thread;
 
	std::unique_lock<std::recursive_mutex> draw_lock;
 

	
 
	static void PaintThreadThunk(VideoDriver_SDL *drv);
 
};
 

	
 
/** Factory for the SDL video driver. */
 
class FVideoDriver_SDL : public DriverFactoryBase {
 
public:
 
	FVideoDriver_SDL() : DriverFactoryBase(Driver::DT_VIDEO, 5, "sdl", "SDL Video Driver") {}
 
	Driver *CreateInstance() const override { return new VideoDriver_SDL(); }
 
	static void PaintThreadThunk(VideoDriver_SDL_Base *drv);
 
};
 

	
 
#endif /* VIDEO_SDL_H */