Files
Aerofoil/GpCommon/IGpDisplayDriver.h

76 lines
2.7 KiB
C
Raw Permalink Normal View History

#pragma once
2021-03-29 21:41:11 -04:00
#include "CoreDefs.h"
#include "GpPixelFormat.h"
2019-12-22 00:35:30 -05:00
#include "EGpStandardCursor.h"
2019-12-21 18:40:17 -05:00
2020-09-26 16:45:52 -04:00
#include <stdint.h>
2021-03-18 17:08:11 -04:00
#include <stddef.h>
2020-09-26 16:45:52 -04:00
2019-12-21 18:40:17 -05:00
struct IGpDisplayDriverSurface;
2020-02-23 20:21:04 -05:00
struct IGpCursor;
struct IGpPrefsHandler;
2020-06-13 04:33:41 -04:00
struct GpDisplayDriverProperties;
2019-12-21 18:40:17 -05:00
2020-05-18 02:03:17 -04:00
struct GpDisplayDriverSurfaceEffects
{
GpDisplayDriverSurfaceEffects();
bool m_darken;
bool m_flicker;
int32_t m_flickerAxisX;
int32_t m_flickerAxisY;
int32_t m_flickerStartThreshold;
int32_t m_flickerEndThreshold;
2020-05-22 21:14:43 -04:00
float m_desaturation;
2020-05-18 02:03:17 -04:00
};
2019-12-21 18:40:17 -05:00
// Display drivers are responsible for timing and calling the game tick function.
struct IGpDisplayDriver
{
typedef void (*SurfaceInvalidateCallback_t) (void *context);
2021-03-29 21:41:11 -04:00
GP_ASYNCIFY_PARANOID_VIRTUAL bool Init() GP_ASYNCIFY_PARANOID_PURE;
GP_ASYNCIFY_PARANOID_VIRTUAL void ServeTicks(int tickCount) GP_ASYNCIFY_PARANOID_PURE;
2021-03-26 17:05:38 -04:00
virtual void ForceSync() = 0;
2021-03-29 21:41:11 -04:00
GP_ASYNCIFY_PARANOID_VIRTUAL void Shutdown() GP_ASYNCIFY_PARANOID_PURE;
2019-12-21 18:40:17 -05:00
// Returns the initial resolution before any display resolution events are posted
virtual void GetInitialDisplayResolution(unsigned int *width, unsigned int *height) = 0;
2019-12-21 18:40:17 -05:00
virtual IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, size_t pitch, GpPixelFormat_t pixelFormat, SurfaceInvalidateCallback_t invalidateCallback, void *invalidateContext) = 0;
2020-05-18 02:03:17 -04:00
virtual void DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height, const GpDisplayDriverSurfaceEffects *effects) = 0;
2019-12-21 18:40:17 -05:00
2021-03-29 21:41:11 -04:00
GP_ASYNCIFY_PARANOID_VIRTUAL IGpCursor *CreateBWCursor(size_t width, size_t height, const void *pixelData, const void *maskData, size_t hotSpotX, size_t hotSpotY) GP_ASYNCIFY_PARANOID_PURE;
GP_ASYNCIFY_PARANOID_VIRTUAL IGpCursor *CreateColorCursor(size_t width, size_t height, const void *pixelDataRGBA, size_t hotSpotX, size_t hotSpotY) GP_ASYNCIFY_PARANOID_PURE;
2020-09-26 21:15:43 -04:00
2020-02-23 20:21:04 -05:00
virtual void SetCursor(IGpCursor *cursor) = 0;
2019-12-22 00:35:30 -05:00
virtual void SetStandardCursor(EGpStandardCursor_t standardCursor) = 0;
2019-12-21 18:40:17 -05:00
virtual void UpdatePalette(const void *paletteData) = 0;
virtual void SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) = 0;
virtual void SetBackgroundDarkenEffect(bool isDark) = 0;
2020-07-03 13:53:10 -04:00
virtual void SetUseICCProfile(bool useICCProfile) = 0;
virtual void RequestToggleFullScreen(uint32_t timestamp) = 0;
virtual void RequestResetVirtualResolution() = 0;
2020-06-13 04:33:41 -04:00
2020-07-20 23:38:31 -04:00
virtual bool IsFullScreen() const = 0;
2020-06-13 04:33:41 -04:00
virtual const GpDisplayDriverProperties &GetProperties() const = 0;
virtual IGpPrefsHandler *GetPrefsHandler() const = 0;
2019-12-21 18:40:17 -05:00
};
2020-05-18 02:03:17 -04:00
inline GpDisplayDriverSurfaceEffects::GpDisplayDriverSurfaceEffects()
: m_darken(false)
, m_flicker(false)
, m_flickerAxisX(0)
, m_flickerAxisY(0)
, m_flickerStartThreshold(0)
, m_flickerEndThreshold(0)
2020-05-22 21:14:43 -04:00
, m_desaturation(0)
{
2020-05-18 02:03:17 -04:00
}