2015-01-12 17:26:46 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2015-08-30 18:04:52 +00:00
|
|
|
*
|
2015-01-12 17:26:46 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIDEO_DRIVER__H
|
|
|
|
#define __VIDEO_DRIVER__H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <boolean.h>
|
2015-01-12 17:57:37 +00:00
|
|
|
#include <gfx/scaler/scaler.h>
|
2015-01-13 21:11:26 +00:00
|
|
|
#include "video_filter.h"
|
|
|
|
#include "video_shader_parse.h"
|
2015-02-14 04:52:05 +00:00
|
|
|
#include "video_viewport.h"
|
2015-01-12 17:26:46 +00:00
|
|
|
|
2015-01-13 21:11:26 +00:00
|
|
|
#include "../libretro.h"
|
2015-01-12 17:39:27 +00:00
|
|
|
#include "../input/input_driver.h"
|
2015-01-12 17:26:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct video_info
|
|
|
|
{
|
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
|
|
|
bool fullscreen;
|
|
|
|
bool vsync;
|
|
|
|
bool force_aspect;
|
|
|
|
#ifdef GEKKO
|
|
|
|
/* TODO - we can't really have driver system-specific
|
|
|
|
* variables in here. There should be some
|
|
|
|
* kind of publicly accessible driver implementation
|
|
|
|
* video struct for specific things like this.
|
|
|
|
*/
|
|
|
|
unsigned viwidth;
|
|
|
|
#endif
|
|
|
|
bool vfilter;
|
|
|
|
bool smooth;
|
|
|
|
/* Maximum input size: RARCH_SCALE_BASE * input_scale */
|
|
|
|
unsigned input_scale;
|
|
|
|
/* Use 32bit RGBA rather than native XBGR1555. */
|
|
|
|
bool rgb32;
|
|
|
|
} video_info_t;
|
|
|
|
|
2015-03-31 12:00:30 +00:00
|
|
|
enum text_alignment
|
|
|
|
{
|
|
|
|
TEXT_ALIGN_LEFT = 0,
|
|
|
|
TEXT_ALIGN_RIGHT,
|
|
|
|
TEXT_ALIGN_CENTER
|
|
|
|
};
|
|
|
|
|
2015-01-12 17:26:46 +00:00
|
|
|
struct font_params
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float scale;
|
|
|
|
/* Drop shadow color multiplier. */
|
|
|
|
float drop_mod;
|
|
|
|
/* Drop shadow offset.
|
|
|
|
* If both are 0, no drop shadow will be rendered. */
|
|
|
|
int drop_x, drop_y;
|
|
|
|
/* ABGR. Use the macros. */
|
|
|
|
uint32_t color;
|
|
|
|
bool full_screen;
|
2015-03-31 12:00:30 +00:00
|
|
|
enum text_alignment text_align;
|
2015-01-12 17:26:46 +00:00
|
|
|
};
|
|
|
|
|
2015-02-11 14:19:21 +00:00
|
|
|
enum texture_filter_type
|
|
|
|
{
|
|
|
|
TEXTURE_FILTER_LINEAR = 0,
|
|
|
|
TEXTURE_FILTER_NEAREST,
|
|
|
|
TEXTURE_FILTER_MIPMAP_LINEAR,
|
2015-06-26 13:53:18 +00:00
|
|
|
TEXTURE_FILTER_MIPMAP_NEAREST
|
2015-02-11 14:19:21 +00:00
|
|
|
};
|
2015-01-12 17:26:46 +00:00
|
|
|
|
2015-03-15 15:50:51 +00:00
|
|
|
#define FONT_COLOR_RGBA(r, g, b, a) (((r) << 24) | ((g) << 16) | ((b) << 8) | ((a) << 0))
|
|
|
|
#define FONT_COLOR_GET_RED(col) (((col) >> 24) & 0xff)
|
|
|
|
#define FONT_COLOR_GET_GREEN(col) (((col) >> 16) & 0xff)
|
|
|
|
#define FONT_COLOR_GET_BLUE(col) (((col) >> 8) & 0xff)
|
|
|
|
#define FONT_COLOR_GET_ALPHA(col) (((col) >> 0) & 0xff)
|
|
|
|
#define FONT_COLOR_ARGB_TO_RGBA(col) ( (((col) >> 24) & 0xff) | (((col) << 8) & 0xffffff00) )
|
2015-01-12 17:26:46 +00:00
|
|
|
|
|
|
|
/* Optionally implemented interface to poke more
|
|
|
|
* deeply into video driver. */
|
|
|
|
|
|
|
|
typedef struct video_poke_interface
|
|
|
|
{
|
2015-02-24 20:57:51 +00:00
|
|
|
void (*set_video_mode)(void *data, unsigned width, unsigned height, bool fullscreen);
|
2015-01-12 17:26:46 +00:00
|
|
|
void (*set_filtering)(void *data, unsigned index, bool smooth);
|
2015-02-24 19:06:58 +00:00
|
|
|
void (*get_video_output_size)(void *data, unsigned *width, unsigned *height);
|
2015-02-24 20:36:23 +00:00
|
|
|
void (*get_video_output_prev)(void *data);
|
|
|
|
void (*get_video_output_next)(void *data);
|
2015-01-12 17:26:46 +00:00
|
|
|
uintptr_t (*get_current_framebuffer)(void *data);
|
2015-02-08 17:39:12 +00:00
|
|
|
retro_proc_address_t (*get_proc_address)(void *data, const char *sym);
|
2015-01-12 17:26:46 +00:00
|
|
|
void (*set_aspect_ratio)(void *data, unsigned aspectratio_index);
|
|
|
|
void (*apply_state_changes)(void *data);
|
|
|
|
|
|
|
|
#ifdef HAVE_MENU
|
|
|
|
/* Update texture. */
|
|
|
|
void (*set_texture_frame)(void *data, const void *frame, bool rgb32,
|
|
|
|
unsigned width, unsigned height, float alpha);
|
2015-07-26 22:08:14 +00:00
|
|
|
#endif
|
2015-01-12 17:26:46 +00:00
|
|
|
/* Enable or disable rendering. */
|
|
|
|
void (*set_texture_enable)(void *data, bool enable, bool full_screen);
|
|
|
|
void (*set_osd_msg)(void *data, const char *msg,
|
|
|
|
const struct font_params *params, void *font);
|
|
|
|
|
|
|
|
void (*show_mouse)(void *data, bool state);
|
|
|
|
void (*grab_mouse_toggle)(void *data);
|
|
|
|
|
2015-01-19 20:24:08 +00:00
|
|
|
struct video_shader *(*get_current_shader)(void *data);
|
2015-01-12 17:26:46 +00:00
|
|
|
} video_poke_interface_t;
|
|
|
|
|
|
|
|
typedef struct video_driver
|
|
|
|
{
|
|
|
|
/* Should the video driver act as an input driver as well?
|
2015-08-30 18:04:52 +00:00
|
|
|
* The video initialization might preinitialize an input driver
|
|
|
|
* to override the settings in case the video driver relies on
|
2015-01-12 17:26:46 +00:00
|
|
|
* input driver for event handling. */
|
|
|
|
void *(*init)(const video_info_t *video, const input_driver_t **input,
|
2015-08-30 18:04:52 +00:00
|
|
|
void **input_data);
|
2015-01-12 17:26:46 +00:00
|
|
|
|
|
|
|
/* msg is for showing a message on the screen along with the video frame. */
|
|
|
|
bool (*frame)(void *data, const void *frame, unsigned width,
|
2015-08-03 21:01:07 +00:00
|
|
|
unsigned height, uint64_t frame_count, unsigned pitch, const char *msg);
|
2015-01-12 17:26:46 +00:00
|
|
|
|
|
|
|
/* Should we care about syncing to vblank? Fast forwarding. */
|
|
|
|
void (*set_nonblock_state)(void *data, bool toggle);
|
|
|
|
|
|
|
|
/* Is the window still active? */
|
|
|
|
bool (*alive)(void *data);
|
|
|
|
|
|
|
|
/* Does the window have focus? */
|
|
|
|
bool (*focus)(void *data);
|
|
|
|
|
2015-01-18 21:32:14 +00:00
|
|
|
/* Should the screensaver be suppressed? */
|
|
|
|
bool (*suppress_screensaver)(void *data, bool enable);
|
|
|
|
|
|
|
|
/* Does the graphics context support windowed mode? */
|
2015-01-12 17:26:46 +00:00
|
|
|
bool (*has_windowed)(void *data);
|
|
|
|
|
|
|
|
/* Sets shader. Might not be implemented. Will be moved to
|
|
|
|
* poke_interface later. */
|
|
|
|
bool (*set_shader)(void *data, enum rarch_shader_type type,
|
|
|
|
const char *path);
|
|
|
|
|
|
|
|
/* Frees driver. */
|
|
|
|
void (*free)(void *data);
|
|
|
|
|
|
|
|
/* Human-readable identifier. */
|
|
|
|
const char *ident;
|
|
|
|
|
2015-04-26 17:46:59 +00:00
|
|
|
void (*set_viewport)(void *data, unsigned width, unsigned height,
|
|
|
|
bool force_full, bool allow_rotate);
|
|
|
|
|
2015-01-12 17:26:46 +00:00
|
|
|
void (*set_rotation)(void *data, unsigned rotation);
|
2015-02-14 04:52:05 +00:00
|
|
|
void (*viewport_info)(void *data, struct video_viewport *vp);
|
2015-01-12 17:26:46 +00:00
|
|
|
|
|
|
|
/* Reads out in BGR byte order (24bpp). */
|
|
|
|
bool (*read_viewport)(void *data, uint8_t *buffer);
|
|
|
|
|
2015-03-16 08:33:16 +00:00
|
|
|
/* Returns a pointer to a newly allocated buffer that can
|
|
|
|
* (and must) be passed to free() by the caller, containing a
|
|
|
|
* copy of the current raw frame in the active pixel format
|
|
|
|
* and sets width, height and pitch to the correct values. */
|
|
|
|
void* (*read_frame_raw)(void *data, unsigned *width,
|
|
|
|
unsigned *height, size_t *pitch);
|
|
|
|
|
2015-01-12 17:26:46 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
|
|
|
void (*overlay_interface)(void *data, const video_overlay_interface_t **iface);
|
|
|
|
#endif
|
|
|
|
void (*poke_interface)(void *data, const video_poke_interface_t **iface);
|
|
|
|
unsigned (*wrap_type_to_enum)(enum gfx_wrap_type type);
|
|
|
|
} video_driver_t;
|
|
|
|
|
|
|
|
extern video_driver_t video_gl;
|
|
|
|
extern video_driver_t video_psp1;
|
2015-08-30 18:04:52 +00:00
|
|
|
extern video_driver_t video_vita2d;
|
2015-04-01 21:14:13 +00:00
|
|
|
extern video_driver_t video_ctr;
|
2015-01-12 17:26:46 +00:00
|
|
|
extern video_driver_t video_d3d;
|
|
|
|
extern video_driver_t video_gx;
|
|
|
|
extern video_driver_t video_xenon360;
|
|
|
|
extern video_driver_t video_xvideo;
|
|
|
|
extern video_driver_t video_xdk_d3d;
|
|
|
|
extern video_driver_t video_sdl;
|
|
|
|
extern video_driver_t video_sdl2;
|
|
|
|
extern video_driver_t video_vg;
|
|
|
|
extern video_driver_t video_omap;
|
|
|
|
extern video_driver_t video_exynos;
|
2015-03-13 04:59:52 +00:00
|
|
|
extern video_driver_t video_dispmanx;
|
2016-01-10 11:04:32 +00:00
|
|
|
extern video_driver_t video_sunxi;
|
2015-10-11 07:50:01 +00:00
|
|
|
extern video_driver_t video_xshm;
|
2015-01-12 17:26:46 +00:00
|
|
|
extern video_driver_t video_null;
|
|
|
|
|
2015-01-12 20:16:17 +00:00
|
|
|
enum rarch_display_type
|
|
|
|
{
|
|
|
|
/* Non-bindable types like consoles, KMS, VideoCore, etc. */
|
|
|
|
RARCH_DISPLAY_NONE = 0,
|
|
|
|
/* video_display => Display*, video_window => Window */
|
|
|
|
RARCH_DISPLAY_X11,
|
|
|
|
/* video_display => N/A, video_window => HWND */
|
|
|
|
RARCH_DISPLAY_WIN32,
|
|
|
|
RARCH_DISPLAY_OSX
|
|
|
|
};
|
|
|
|
|
2015-01-12 17:26:46 +00:00
|
|
|
/**
|
|
|
|
* video_driver_find_handle:
|
|
|
|
* @index : index of driver to get handle to.
|
|
|
|
*
|
|
|
|
* Returns: handle to video driver at index. Can be NULL
|
|
|
|
* if nothing found.
|
|
|
|
**/
|
|
|
|
const void *video_driver_find_handle(int index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* video_driver_find_ident:
|
|
|
|
* @index : index of driver to get handle to.
|
|
|
|
*
|
|
|
|
* Returns: Human-readable identifier of video driver at index. Can be NULL
|
|
|
|
* if nothing found.
|
|
|
|
**/
|
|
|
|
const char *video_driver_find_ident(int index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* config_get_video_driver_options:
|
|
|
|
*
|
|
|
|
* Get an enumerated list of all video driver names, separated by '|'.
|
|
|
|
*
|
|
|
|
* Returns: string listing of all video driver names, separated by '|'.
|
|
|
|
**/
|
|
|
|
const char* config_get_video_driver_options(void);
|
|
|
|
|
|
|
|
void find_video_driver(void);
|
|
|
|
|
2015-01-12 19:20:58 +00:00
|
|
|
/**
|
2015-03-21 22:46:49 +00:00
|
|
|
* video_driver_get_ptr:
|
2015-01-12 19:20:58 +00:00
|
|
|
* @drv : real video driver will be set to this.
|
|
|
|
*
|
2015-08-30 18:04:52 +00:00
|
|
|
* Use this if you need the real video driver
|
2015-01-12 19:20:58 +00:00
|
|
|
* and driver data pointers.
|
|
|
|
*
|
|
|
|
* Returns: video driver's userdata.
|
|
|
|
**/
|
2015-03-21 22:46:49 +00:00
|
|
|
void *video_driver_get_ptr(const video_driver_t **drv);
|
2015-01-12 19:20:58 +00:00
|
|
|
|
2015-01-19 03:19:30 +00:00
|
|
|
/**
|
|
|
|
* video_driver_get_current_framebuffer:
|
|
|
|
*
|
|
|
|
* Gets pointer to current hardware renderer framebuffer object.
|
|
|
|
* Used by RETRO_ENVIRONMENT_SET_HW_RENDER.
|
|
|
|
*
|
|
|
|
* Returns: pointer to hardware framebuffer object, otherwise 0.
|
|
|
|
**/
|
|
|
|
uintptr_t video_driver_get_current_framebuffer(void);
|
|
|
|
|
|
|
|
retro_proc_address_t video_driver_get_proc_address(const char *sym);
|
|
|
|
|
2015-02-10 16:20:02 +00:00
|
|
|
bool video_driver_set_shader(enum rarch_shader_type type,
|
|
|
|
const char *shader);
|
|
|
|
|
2015-01-26 19:30:48 +00:00
|
|
|
void uninit_video_input(void);
|
|
|
|
|
|
|
|
void init_video(void);
|
|
|
|
|
2015-03-22 06:20:55 +00:00
|
|
|
bool video_driver_has_windowed(void);
|
|
|
|
|
2015-03-22 09:25:51 +00:00
|
|
|
void video_driver_set_nonblock_state(bool toggle);
|
|
|
|
|
2015-03-22 09:38:26 +00:00
|
|
|
bool video_driver_set_rotation(unsigned rotation);
|
|
|
|
|
2015-03-22 17:38:11 +00:00
|
|
|
void video_driver_set_video_mode(unsigned width,
|
|
|
|
unsigned height, bool fullscreen);
|
|
|
|
|
|
|
|
bool video_driver_get_video_output_size(
|
|
|
|
unsigned *width, unsigned *height);
|
|
|
|
|
|
|
|
void video_driver_set_aspect_ratio(unsigned aspectratio_index);
|
|
|
|
|
2015-03-22 17:48:24 +00:00
|
|
|
void video_driver_show_mouse(bool state);
|
|
|
|
|
|
|
|
void video_driver_set_osd_msg(const char *msg,
|
|
|
|
const struct font_params *params, void *font);
|
|
|
|
|
2015-03-22 17:59:16 +00:00
|
|
|
void video_driver_set_texture_enable(bool enable, bool full_screen);
|
|
|
|
|
2015-03-22 18:15:34 +00:00
|
|
|
void video_driver_set_texture_frame(const void *frame, bool rgb32,
|
|
|
|
unsigned width, unsigned height, float alpha);
|
|
|
|
|
2015-03-22 20:28:50 +00:00
|
|
|
bool video_driver_viewport_info(struct video_viewport *vp);
|
|
|
|
|
2015-03-22 20:57:17 +00:00
|
|
|
bool video_driver_read_viewport(uint8_t *buffer);
|
|
|
|
|
2015-03-22 21:17:52 +00:00
|
|
|
bool video_driver_set_shader(enum rarch_shader_type type,
|
|
|
|
const char *path);
|
|
|
|
|
2015-03-22 22:40:22 +00:00
|
|
|
bool video_driver_focus(void);
|
|
|
|
|
2015-03-23 03:32:12 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
2015-03-22 22:44:58 +00:00
|
|
|
bool video_driver_overlay_interface(const video_overlay_interface_t **iface);
|
2015-03-23 03:32:12 +00:00
|
|
|
#endif
|
2015-03-22 22:44:58 +00:00
|
|
|
|
2015-03-22 22:52:01 +00:00
|
|
|
void * video_driver_read_frame_raw(unsigned *width,
|
|
|
|
unsigned *height, size_t *pitch);
|
|
|
|
|
2015-03-22 23:39:42 +00:00
|
|
|
void video_driver_set_filtering(unsigned index, bool smooth);
|
|
|
|
|
2015-03-22 23:42:55 +00:00
|
|
|
void video_driver_apply_state_changes(void);
|
|
|
|
|
2015-03-22 23:50:33 +00:00
|
|
|
void video_driver_get_video_output_next(void);
|
|
|
|
|
|
|
|
void video_driver_get_video_output_prev(void);
|
|
|
|
|
2015-04-11 04:12:27 +00:00
|
|
|
bool video_driver_suppress_screensaver(bool enable);
|
|
|
|
|
2015-04-26 14:46:56 +00:00
|
|
|
const char *video_driver_get_ident(void);
|
|
|
|
|
2015-04-26 17:46:59 +00:00
|
|
|
bool video_driver_set_viewport(unsigned width, unsigned height,
|
|
|
|
bool force_fullscreen, bool allow_rotate);
|
|
|
|
|
2015-05-19 22:29:46 +00:00
|
|
|
void video_driver_get_size(unsigned *width, unsigned *height);
|
|
|
|
|
2015-05-19 23:39:35 +00:00
|
|
|
void video_driver_set_size_width(unsigned width);
|
|
|
|
|
|
|
|
void video_driver_set_size_height(unsigned width);
|
|
|
|
|
2015-05-20 16:24:45 +00:00
|
|
|
float video_driver_get_aspect_ratio(void);
|
|
|
|
|
|
|
|
void video_driver_set_aspect_ratio_value(float value);
|
|
|
|
|
2015-05-20 17:56:12 +00:00
|
|
|
struct retro_hw_render_callback *video_driver_callback(void);
|
|
|
|
|
|
|
|
void video_driver_unset_callback(void);
|
|
|
|
|
2015-05-20 18:49:52 +00:00
|
|
|
bool video_driver_frame_filter(const void *data,
|
|
|
|
unsigned width, unsigned height,
|
|
|
|
size_t pitch,
|
|
|
|
unsigned *output_width, unsigned *output_height,
|
|
|
|
unsigned *output_pitch);
|
|
|
|
|
|
|
|
bool video_driver_frame_filter_alive(void);
|
|
|
|
|
|
|
|
bool video_driver_frame_filter_is_32bit(void);
|
|
|
|
|
|
|
|
rarch_softfilter_t *video_driver_frame_filter_get_ptr(void);
|
|
|
|
|
|
|
|
void *video_driver_frame_filter_get_buf_ptr(void);
|
|
|
|
|
2015-05-20 18:59:12 +00:00
|
|
|
enum retro_pixel_format video_driver_get_pixel_format(void);
|
|
|
|
|
|
|
|
void video_driver_set_pixel_format(enum retro_pixel_format fmt);
|
|
|
|
|
2015-05-20 19:06:44 +00:00
|
|
|
/**
|
|
|
|
* video_driver_cached_frame:
|
|
|
|
*
|
|
|
|
* Renders the current video frame.
|
|
|
|
**/
|
|
|
|
void video_driver_cached_frame(void);
|
|
|
|
|
2015-05-20 19:13:25 +00:00
|
|
|
void video_driver_cached_frame_set(const void *data, unsigned width,
|
|
|
|
unsigned height, size_t pitch);
|
|
|
|
|
2015-05-20 19:29:23 +00:00
|
|
|
void video_driver_cached_frame_set_ptr(const void *data);
|
|
|
|
|
2015-06-17 12:29:09 +00:00
|
|
|
void video_driver_cached_frame_get(const void **data, unsigned *width,
|
2015-05-20 19:29:23 +00:00
|
|
|
unsigned *height, size_t *pitch);
|
|
|
|
|
|
|
|
bool video_driver_cached_frame_has_valid_fb(void);
|
|
|
|
|
2015-08-03 21:01:07 +00:00
|
|
|
uint64_t *video_driver_get_frame_count(void);
|
|
|
|
|
2015-01-12 17:26:46 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|