Codechange: [SDL2] Split driver in base-part and default backend

This commit is contained in:
Michael Lutz
2021-02-11 21:03:18 +01:00
parent a303940372
commit 421b599541
7 changed files with 280 additions and 214 deletions

View File

@@ -15,9 +15,9 @@
#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;
@@ -59,19 +59,17 @@ protected:
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);
@@ -81,13 +79,10 @@ private:
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
/**
@@ -99,14 +94,7 @@ private:
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 */