From d75f155eb61a3b44a9c4724fc2363c0c2b746cfe Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 9 May 2017 01:37:12 +0200 Subject: [PATCH] Reorder video_driver.h --- gfx/video_driver.h | 354 ++++++++++++++++++++++----------------------- 1 file changed, 176 insertions(+), 178 deletions(-) diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 2109ef2323..6797492fd1 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -72,6 +72,7 @@ enum display_flags GFX_CTX_FLAGS_CUSTOMIZABLE_SWAPCHAIN_IMAGES }; +typedef void (*gfx_ctx_proc_t)(void); typedef struct video_info { @@ -200,6 +201,176 @@ typedef struct video_frame_info char fps_text[128]; } video_frame_info_t; +typedef struct gfx_ctx_driver +{ + /* The opaque pointer is the underlying video driver data (e.g. gl_t for + * OpenGL contexts). Although not advised, the context driver is allowed + * to hold a pointer to it as the context never outlives the video driver. + * + * The context driver is responsible for it's own data.*/ + void* (*init)(video_frame_info_t *video_info, void *video_driver); + void (*destroy)(void *data); + + /* Which API to bind to. */ + bool (*bind_api)(void *video_driver, enum gfx_ctx_api, + unsigned major, unsigned minor); + + /* Sets the swap interval. */ + void (*swap_interval)(void *data, unsigned); + + /* Sets video mode. Creates a window, etc. */ + bool (*set_video_mode)(void*, video_frame_info_t *video_info, unsigned, unsigned, bool); + + /* Gets current window size. + * If not initialized yet, it returns current screen size. */ + void (*get_video_size)(void*, unsigned*, unsigned*); + + void (*get_video_output_size)(void*, unsigned*, unsigned*); + + void (*get_video_output_prev)(void*); + + void (*get_video_output_next)(void*); + + bool (*get_metrics)(void *data, enum display_metric_types type, + float *value); + + /* Translates a window size to an aspect ratio. + * In most cases this will be just width / height, but + * some contexts will better know which actual aspect ratio is used. + * This can be NULL to assume the default behavior. + */ + float (*translate_aspect)(void*, unsigned, unsigned); + + /* Asks driver to update window title (FPS, etc). */ + void (*update_window_title)(void*, video_frame_info_t *video_info); + + /* Queries for resize and quit events. + * Also processes events. */ + void (*check_window)(void*, bool*, bool*, + unsigned*, unsigned*, bool); + + /* Acknowledge a resize event. This is needed for some APIs. + * Most backends will ignore this. */ + bool (*set_resize)(void*, unsigned, unsigned); + + /* Checks if window has input focus. */ + bool (*has_focus)(void*); + + /* Should the screensaver be suppressed? */ + bool (*suppress_screensaver)(void *data, bool enable); + + /* Checks if context driver has windowed support. */ + bool (*has_windowed)(void*); + + /* Swaps buffers. VBlank sync depends on + * earlier calls to swap_interval. */ + void (*swap_buffers)(void*, video_frame_info_t *video_info); + + /* Most video backends will want to use a certain input driver. + * Checks for it here. */ + void (*input_driver)(void*, const char *, const input_driver_t**, void**); + + /* Wraps whatever gl_proc_address() there is. + * Does not take opaque, to avoid lots of ugly wrapper code. */ + gfx_ctx_proc_t (*get_proc_address)(const char*); + + /* Returns true if this context supports EGLImage buffers for + * screen drawing and was initalized correctly. */ + bool (*image_buffer_init)(void*, const video_info_t*); + + /* Writes the frame to the EGLImage and sets image_handle to it. + * Returns true if a new image handle is created. + * Always returns true the first time it's called for a new index. + * The graphics core must handle a change in the handle correctly. */ + bool (*image_buffer_write)(void*, const void *frame, unsigned width, + unsigned height, unsigned pitch, bool rgb32, + unsigned index, void **image_handle); + + /* Shows or hides mouse. Can be NULL if context doesn't + * have a concept of mouse pointer. */ + void (*show_mouse)(void *data, bool state); + + /* Human readable string. */ + const char *ident; + + uint32_t (*get_flags)(void *data); + + void (*set_flags)(void *data, uint32_t flags); + + /* Optional. Binds HW-render offscreen context. */ + void (*bind_hw_render)(void *data, bool enable); + + /* Optional. Gets base data for the context which is used by the driver. + * This is mostly relevant for graphics APIs such as Vulkan + * which do not have global context state. */ + void *(*get_context_data)(void *data); + + /* Optional. Makes driver context (only GLX right now) + * active for this thread. */ + void (*make_current)(bool release); +} gfx_ctx_driver_t; + +typedef struct gfx_ctx_flags +{ + uint32_t flags; +} gfx_ctx_flags_t; + +typedef struct gfx_ctx_size +{ + bool *quit; + bool *resize; + unsigned *width; + unsigned *height; +} gfx_ctx_size_t; + +typedef struct gfx_ctx_mode +{ + unsigned width; + unsigned height; + bool fullscreen; +} gfx_ctx_mode_t; + +typedef struct gfx_ctx_metrics +{ + enum display_metric_types type; + float *value; +} gfx_ctx_metrics_t; + +typedef struct gfx_ctx_aspect +{ + float *aspect; + unsigned width; + unsigned height; +} gfx_ctx_aspect_t; + +typedef struct gfx_ctx_image +{ + const void *frame; + unsigned width; + unsigned height; + unsigned pitch; + unsigned index; + bool rgb32; + void **handle; +} gfx_ctx_image_t; + +typedef struct gfx_ctx_input +{ + const input_driver_t **input; + void **input_data; +} gfx_ctx_input_t; + +typedef struct gfx_ctx_proc_address +{ + const char *sym; + retro_proc_address_t addr; +} gfx_ctx_proc_address_t; + +typedef struct gfx_ctx_ident +{ + const char *ident; +} gfx_ctx_ident_t; + /* Optionally implemented interface to poke more * deeply into video driver. */ @@ -669,184 +840,6 @@ extern video_driver_t video_gdi; extern video_driver_t video_vga; extern video_driver_t video_null; -extern const void *frame_cache_data; - -extern void *video_driver_data; -extern video_driver_t *current_video; - -typedef void (*gfx_ctx_proc_t)(void); - -typedef struct gfx_ctx_driver -{ - /* The opaque pointer is the underlying video driver data (e.g. gl_t for - * OpenGL contexts). Although not advised, the context driver is allowed - * to hold a pointer to it as the context never outlives the video driver. - * - * The context driver is responsible for it's own data.*/ - void* (*init)(video_frame_info_t *video_info, void *video_driver); - void (*destroy)(void *data); - - /* Which API to bind to. */ - bool (*bind_api)(void *video_driver, enum gfx_ctx_api, - unsigned major, unsigned minor); - - /* Sets the swap interval. */ - void (*swap_interval)(void *data, unsigned); - - /* Sets video mode. Creates a window, etc. */ - bool (*set_video_mode)(void*, video_frame_info_t *video_info, unsigned, unsigned, bool); - - /* Gets current window size. - * If not initialized yet, it returns current screen size. */ - void (*get_video_size)(void*, unsigned*, unsigned*); - - void (*get_video_output_size)(void*, unsigned*, unsigned*); - - void (*get_video_output_prev)(void*); - - void (*get_video_output_next)(void*); - - bool (*get_metrics)(void *data, enum display_metric_types type, - float *value); - - /* Translates a window size to an aspect ratio. - * In most cases this will be just width / height, but - * some contexts will better know which actual aspect ratio is used. - * This can be NULL to assume the default behavior. - */ - float (*translate_aspect)(void*, unsigned, unsigned); - - /* Asks driver to update window title (FPS, etc). */ - void (*update_window_title)(void*, video_frame_info_t *video_info); - - /* Queries for resize and quit events. - * Also processes events. */ - void (*check_window)(void*, bool*, bool*, - unsigned*, unsigned*, bool); - - /* Acknowledge a resize event. This is needed for some APIs. - * Most backends will ignore this. */ - bool (*set_resize)(void*, unsigned, unsigned); - - /* Checks if window has input focus. */ - bool (*has_focus)(void*); - - /* Should the screensaver be suppressed? */ - bool (*suppress_screensaver)(void *data, bool enable); - - /* Checks if context driver has windowed support. */ - bool (*has_windowed)(void*); - - /* Swaps buffers. VBlank sync depends on - * earlier calls to swap_interval. */ - void (*swap_buffers)(void*, video_frame_info_t *video_info); - - /* Most video backends will want to use a certain input driver. - * Checks for it here. */ - void (*input_driver)(void*, const char *, const input_driver_t**, void**); - - /* Wraps whatever gl_proc_address() there is. - * Does not take opaque, to avoid lots of ugly wrapper code. */ - gfx_ctx_proc_t (*get_proc_address)(const char*); - - /* Returns true if this context supports EGLImage buffers for - * screen drawing and was initalized correctly. */ - bool (*image_buffer_init)(void*, const video_info_t*); - - /* Writes the frame to the EGLImage and sets image_handle to it. - * Returns true if a new image handle is created. - * Always returns true the first time it's called for a new index. - * The graphics core must handle a change in the handle correctly. */ - bool (*image_buffer_write)(void*, const void *frame, unsigned width, - unsigned height, unsigned pitch, bool rgb32, - unsigned index, void **image_handle); - - /* Shows or hides mouse. Can be NULL if context doesn't - * have a concept of mouse pointer. */ - void (*show_mouse)(void *data, bool state); - - /* Human readable string. */ - const char *ident; - - uint32_t (*get_flags)(void *data); - - void (*set_flags)(void *data, uint32_t flags); - - /* Optional. Binds HW-render offscreen context. */ - void (*bind_hw_render)(void *data, bool enable); - - /* Optional. Gets base data for the context which is used by the driver. - * This is mostly relevant for graphics APIs such as Vulkan - * which do not have global context state. */ - void *(*get_context_data)(void *data); - - /* Optional. Makes driver context (only GLX right now) - * active for this thread. */ - void (*make_current)(bool release); -} gfx_ctx_driver_t; - - -typedef struct gfx_ctx_flags -{ - uint32_t flags; -} gfx_ctx_flags_t; - -typedef struct gfx_ctx_size -{ - bool *quit; - bool *resize; - unsigned *width; - unsigned *height; -} gfx_ctx_size_t; - -typedef struct gfx_ctx_mode -{ - unsigned width; - unsigned height; - bool fullscreen; -} gfx_ctx_mode_t; - -typedef struct gfx_ctx_metrics -{ - enum display_metric_types type; - float *value; -} gfx_ctx_metrics_t; - -typedef struct gfx_ctx_aspect -{ - float *aspect; - unsigned width; - unsigned height; -} gfx_ctx_aspect_t; - -typedef struct gfx_ctx_image -{ - const void *frame; - unsigned width; - unsigned height; - unsigned pitch; - unsigned index; - bool rgb32; - void **handle; -} gfx_ctx_image_t; - -typedef struct gfx_ctx_input -{ - const input_driver_t **input; - void **input_data; -} gfx_ctx_input_t; - -typedef struct gfx_ctx_proc_address -{ - const char *sym; - retro_proc_address_t addr; -} gfx_ctx_proc_address_t; - -typedef struct gfx_ctx_ident -{ - const char *ident; -} gfx_ctx_ident_t; - extern const gfx_ctx_driver_t gfx_ctx_osmesa; extern const gfx_ctx_driver_t gfx_ctx_sdl_gl; extern const gfx_ctx_driver_t gfx_ctx_x_egl; @@ -869,6 +862,11 @@ extern const gfx_ctx_driver_t gfx_ctx_khr_display; extern const gfx_ctx_driver_t gfx_ctx_gdi; extern const gfx_ctx_driver_t gfx_ctx_null; +extern const void *frame_cache_data; + +extern void *video_driver_data; +extern video_driver_t *current_video; + /** * video_context_driver_init_first: * @data : Input data.