|
@@ -14,28 +14,24 @@
|
|
|
#include <mutex>
|
|
|
#include <condition_variable>
|
|
|
|
|
|
/** Base class for Windows video drivers. */
|
|
|
class VideoDriver_Win32Base : public VideoDriver {
|
|
|
public:
|
|
|
VideoDriver_Win32Base() : main_wnd(nullptr), fullscreen(false), draw_mutex(nullptr), draw_signal(nullptr) {}
|
|
|
VideoDriver_Win32Base() : main_wnd(nullptr), fullscreen(false) {}
|
|
|
|
|
|
void Stop() override;
|
|
|
|
|
|
void MakeDirty(int left, int top, int width, int height) override;
|
|
|
|
|
|
void MainLoop() override;
|
|
|
|
|
|
bool ChangeResolution(int w, int h) override;
|
|
|
|
|
|
bool ToggleFullscreen(bool fullscreen) override;
|
|
|
|
|
|
void AcquireBlitterLock() override;
|
|
|
|
|
|
void ReleaseBlitterLock() override;
|
|
|
|
|
|
bool ClaimMousePointer() override;
|
|
|
|
|
|
void EditBoxLostFocus() override;
|
|
|
|
|
|
protected:
|
|
|
HWND main_wnd; ///< Handle to system window.
|
|
@@ -44,18 +40,13 @@ protected:
|
|
|
Rect dirty_rect; ///< Region of the screen that needs redrawing.
|
|
|
int width = 0; ///< Width in pixels of our display surface.
|
|
|
int height = 0; ///< Height in pixels of our display surface.
|
|
|
int width_org = 0; ///< Original monitor resolution width, before we changed it.
|
|
|
int height_org = 0; ///< Original monitor resolution height, before we changed it.
|
|
|
|
|
|
bool draw_threaded; ///< Whether the drawing is/may be done in a separate thread.
|
|
|
bool buffer_locked; ///< Video buffer was locked by the main thread.
|
|
|
volatile bool draw_continue; ///< Should we keep continue drawing?
|
|
|
|
|
|
std::recursive_mutex *draw_mutex; ///< Mutex to keep the access to the shared memory controlled.
|
|
|
std::condition_variable_any *draw_signal; ///< Signal to draw the next frame.
|
|
|
bool buffer_locked; ///< Video buffer was locked by the main thread.
|
|
|
|
|
|
Dimension GetScreenSize() const override;
|
|
|
float GetDPIScale() override;
|
|
|
void InputLoop() override;
|
|
|
bool LockVideoBuffer() override;
|
|
|
void UnlockVideoBuffer() override;
|
|
@@ -75,16 +66,12 @@ protected:
|
|
|
/** Hand video buffer back to the painting backend. */
|
|
|
virtual void ReleaseVideoPointer() {}
|
|
|
/** Palette of the window has changed. */
|
|
|
virtual void PaletteChanged(HWND hWnd) = 0;
|
|
|
|
|
|
private:
|
|
|
std::unique_lock<std::recursive_mutex> draw_lock;
|
|
|
|
|
|
static void PaintThreadThunk(VideoDriver_Win32Base *drv);
|
|
|
|
|
|
friend LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
|
};
|
|
|
/** The GDI video driver for windows. */
|
|
|
class VideoDriver_Win32GDI : public VideoDriver_Win32Base {
|
|
|
public:
|
|
|
VideoDriver_Win32GDI() : dib_sect(nullptr), gdi_palette(nullptr), buffer_bits(nullptr) {}
|
|
@@ -101,13 +88,12 @@ protected:
|
|
|
HBITMAP dib_sect; ///< System bitmap object referencing our rendering buffer.
|
|
|
HPALETTE gdi_palette; ///< Palette object for 8bpp blitter.
|
|
|
void *buffer_bits; ///< Internal rendering buffer.
|
|
|
|
|
|
void Paint() override;
|
|
|
void *GetVideoPointer() override { return this->buffer_bits; }
|
|
|
void PaintThread() override;
|
|
|
|
|
|
bool AllocateBackingStore(int w, int h, bool force = false) override;
|
|
|
void PaletteChanged(HWND hWnd) override;
|
|
|
void MakePalette();
|
|
|
void UpdatePalette(HDC dc, uint start, uint count);
|
|
|
|
|
@@ -156,13 +142,12 @@ protected:
|
|
|
bool vsync; ///< Enable VSync?
|
|
|
uint8 *anim_buffer; ///< Animation buffer from OpenGL back-end.
|
|
|
|
|
|
uint8 GetFullscreenBpp() override { return 32; } // OpenGL is always 32 bpp.
|
|
|
|
|
|
void Paint() override;
|
|
|
void PaintThread() override {}
|
|
|
|
|
|
bool AllocateBackingStore(int w, int h, bool force = false) override;
|
|
|
void *GetVideoPointer() override;
|
|
|
void ReleaseVideoPointer() override;
|
|
|
void PaletteChanged(HWND hWnd) override {}
|
|
|
|