2020-02-17 12:01:14 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
|
|
|
*
|
|
|
|
* 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 __GFX_DISPLAY_H__
|
|
|
|
#define __GFX_DISPLAY_H__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include <boolean.h>
|
|
|
|
#include <retro_common_api.h>
|
|
|
|
#include <string/stdstring.h>
|
2020-06-30 06:37:41 +00:00
|
|
|
#include <formats/image.h>
|
2020-02-17 12:01:14 +00:00
|
|
|
#include <gfx/math/matrix_4x4.h>
|
|
|
|
|
|
|
|
#include "../retroarch.h"
|
|
|
|
#include "../file_path_special.h"
|
|
|
|
#include "../gfx/font_driver.h"
|
|
|
|
|
|
|
|
RETRO_BEGIN_DECLS
|
|
|
|
|
|
|
|
#define COLOR_TEXT_ALPHA(color, alpha) (color & 0xFFFFFF00) | alpha
|
|
|
|
|
|
|
|
#define HEX_R(hex) ((hex >> 16) & 0xFF) * (1.0f / 255.0f)
|
|
|
|
#define HEX_G(hex) ((hex >> 8 ) & 0xFF) * (1.0f / 255.0f)
|
|
|
|
#define HEX_B(hex) ((hex >> 0 ) & 0xFF) * (1.0f / 255.0f)
|
|
|
|
|
|
|
|
#define COLOR_HEX_TO_FLOAT(hex, alpha) { \
|
|
|
|
HEX_R(hex), HEX_G(hex), HEX_B(hex), alpha, \
|
|
|
|
HEX_R(hex), HEX_G(hex), HEX_B(hex), alpha, \
|
|
|
|
HEX_R(hex), HEX_G(hex), HEX_B(hex), alpha, \
|
|
|
|
HEX_R(hex), HEX_G(hex), HEX_B(hex), alpha \
|
|
|
|
}
|
|
|
|
|
2020-06-07 20:58:06 +00:00
|
|
|
#define gfx_display_set_alpha(color, alpha_value) (color[3] = color[7] = color[11] = color[15] = (alpha_value))
|
|
|
|
|
2020-09-24 03:59:14 +00:00
|
|
|
/* Returns true if an animation is still active or
|
|
|
|
* when the display framebuffer still is dirty and
|
|
|
|
* therefore it still needs to be rendered onscreen.
|
|
|
|
*
|
|
|
|
* This macro can be used for optimization purposes
|
|
|
|
* so that we don't have to render the display graphics per-frame
|
|
|
|
* unless a change has happened.
|
|
|
|
* */
|
|
|
|
#define GFX_DISPLAY_GET_UPDATE_PENDING(p_anim, p_disp) (ANIM_IS_ACTIVE(p_anim) || p_disp->framebuf_dirty)
|
|
|
|
|
2020-02-17 12:01:14 +00:00
|
|
|
enum menu_driver_id_type
|
|
|
|
{
|
|
|
|
MENU_DRIVER_ID_UNKNOWN = 0,
|
|
|
|
MENU_DRIVER_ID_RGUI,
|
|
|
|
MENU_DRIVER_ID_OZONE,
|
|
|
|
MENU_DRIVER_ID_GLUI,
|
|
|
|
MENU_DRIVER_ID_XMB,
|
|
|
|
MENU_DRIVER_ID_XUI,
|
|
|
|
MENU_DRIVER_ID_STRIPES
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum gfx_display_prim_type
|
|
|
|
{
|
|
|
|
GFX_DISPLAY_PRIM_NONE = 0,
|
|
|
|
GFX_DISPLAY_PRIM_TRIANGLESTRIP,
|
|
|
|
GFX_DISPLAY_PRIM_TRIANGLES
|
|
|
|
};
|
|
|
|
|
|
|
|
enum gfx_display_driver_type
|
|
|
|
{
|
|
|
|
GFX_VIDEO_DRIVER_GENERIC = 0,
|
|
|
|
GFX_VIDEO_DRIVER_OPENGL,
|
|
|
|
GFX_VIDEO_DRIVER_OPENGL1,
|
|
|
|
GFX_VIDEO_DRIVER_OPENGL_CORE,
|
|
|
|
GFX_VIDEO_DRIVER_VULKAN,
|
|
|
|
GFX_VIDEO_DRIVER_METAL,
|
|
|
|
GFX_VIDEO_DRIVER_DIRECT3D8,
|
|
|
|
GFX_VIDEO_DRIVER_DIRECT3D9,
|
|
|
|
GFX_VIDEO_DRIVER_DIRECT3D10,
|
|
|
|
GFX_VIDEO_DRIVER_DIRECT3D11,
|
|
|
|
GFX_VIDEO_DRIVER_DIRECT3D12,
|
|
|
|
GFX_VIDEO_DRIVER_VITA2D,
|
|
|
|
GFX_VIDEO_DRIVER_CTR,
|
|
|
|
GFX_VIDEO_DRIVER_WIIU,
|
|
|
|
GFX_VIDEO_DRIVER_GDI,
|
|
|
|
GFX_VIDEO_DRIVER_SWITCH
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct gfx_display_frame_info
|
|
|
|
{
|
|
|
|
bool shadows_enable;
|
|
|
|
} gfx_display_frame_info_t;
|
|
|
|
|
|
|
|
typedef struct gfx_display_ctx_draw gfx_display_ctx_draw_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct gfx_display_ctx_driver
|
|
|
|
{
|
|
|
|
/* Draw graphics to the screen. */
|
2020-03-08 21:05:51 +00:00
|
|
|
void (*draw)(gfx_display_ctx_draw_t *draw,
|
|
|
|
void *data, unsigned video_width, unsigned video_height);
|
2020-02-17 12:01:14 +00:00
|
|
|
/* Draw one of the menu pipeline shaders. */
|
|
|
|
void (*draw_pipeline)(gfx_display_ctx_draw_t *draw,
|
2020-03-08 21:05:51 +00:00
|
|
|
void *data, unsigned video_width, unsigned video_height);
|
2020-02-17 12:01:14 +00:00
|
|
|
/* Start blending operation. */
|
2020-03-08 20:02:03 +00:00
|
|
|
void (*blend_begin)(void *data);
|
2020-02-17 12:01:14 +00:00
|
|
|
/* Finish blending operation. */
|
2020-03-08 20:02:03 +00:00
|
|
|
void (*blend_end)(void *data);
|
2020-02-17 12:01:14 +00:00
|
|
|
/* Get the default Model-View-Projection matrix */
|
2020-03-08 18:59:03 +00:00
|
|
|
void *(*get_default_mvp)(void *data);
|
2020-02-17 12:01:14 +00:00
|
|
|
/* Get the default vertices matrix */
|
|
|
|
const float *(*get_default_vertices)(void);
|
|
|
|
/* Get the default texture coordinates matrix */
|
|
|
|
const float *(*get_default_tex_coords)(void);
|
|
|
|
/* Initialize the first compatible font driver for this menu driver. */
|
|
|
|
bool (*font_init_first)(
|
|
|
|
void **font_handle, void *video_data,
|
|
|
|
const char *font_path, float font_size,
|
|
|
|
bool is_threaded);
|
|
|
|
enum gfx_display_driver_type type;
|
|
|
|
const char *ident;
|
|
|
|
bool handles_transform;
|
|
|
|
/* Enables and disables scissoring */
|
2020-03-08 20:46:52 +00:00
|
|
|
void (*scissor_begin)(void *data, unsigned video_width,
|
|
|
|
unsigned video_height,
|
|
|
|
int x, int y, unsigned width, unsigned height);
|
|
|
|
void (*scissor_end)(void *data, unsigned video_width,
|
|
|
|
unsigned video_height);
|
2020-02-17 12:01:14 +00:00
|
|
|
} gfx_display_ctx_driver_t;
|
|
|
|
|
|
|
|
struct gfx_display_ctx_draw
|
|
|
|
{
|
|
|
|
float *color;
|
|
|
|
const float *vertex;
|
|
|
|
const float *tex_coord;
|
2020-08-14 13:58:43 +00:00
|
|
|
const void *backend_data;
|
2020-02-17 12:01:14 +00:00
|
|
|
struct video_coords *coords;
|
|
|
|
void *matrix_data;
|
2020-08-14 19:09:24 +00:00
|
|
|
uintptr_t texture;
|
|
|
|
size_t vertex_count;
|
|
|
|
size_t backend_data_size;
|
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
|
|
|
unsigned pipeline_id;
|
2020-08-14 13:58:43 +00:00
|
|
|
float x;
|
|
|
|
float y;
|
2020-02-17 12:01:14 +00:00
|
|
|
float rotation;
|
|
|
|
float scale_factor;
|
2020-08-14 19:09:24 +00:00
|
|
|
enum gfx_display_prim_type prim_type;
|
|
|
|
bool pipeline_active;
|
2020-02-17 12:01:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct gfx_display_ctx_rotate_draw
|
|
|
|
{
|
2020-08-14 19:09:24 +00:00
|
|
|
math_matrix_4x4 *matrix;
|
2020-02-17 12:01:14 +00:00
|
|
|
float rotation;
|
|
|
|
float scale_x;
|
|
|
|
float scale_y;
|
|
|
|
float scale_z;
|
2020-08-14 19:09:24 +00:00
|
|
|
bool scale_enable;
|
2020-02-17 12:01:14 +00:00
|
|
|
} gfx_display_ctx_rotate_draw_t;
|
|
|
|
|
|
|
|
typedef struct gfx_display_ctx_coord_draw
|
|
|
|
{
|
|
|
|
const float *ptr;
|
|
|
|
} gfx_display_ctx_coord_draw_t;
|
|
|
|
|
|
|
|
typedef struct gfx_display_ctx_datetime
|
|
|
|
{
|
|
|
|
char *s;
|
|
|
|
size_t len;
|
|
|
|
unsigned time_mode;
|
2020-05-25 14:46:53 +00:00
|
|
|
unsigned date_separator;
|
2020-02-17 12:01:14 +00:00
|
|
|
} gfx_display_ctx_datetime_t;
|
|
|
|
|
|
|
|
typedef struct gfx_display_ctx_powerstate
|
|
|
|
{
|
|
|
|
char *s;
|
|
|
|
size_t len;
|
|
|
|
unsigned percent;
|
|
|
|
bool battery_enabled;
|
|
|
|
bool charging;
|
|
|
|
} gfx_display_ctx_powerstate_t;
|
|
|
|
|
2020-06-07 20:58:06 +00:00
|
|
|
struct gfx_display
|
|
|
|
{
|
2020-08-14 19:09:24 +00:00
|
|
|
gfx_display_ctx_driver_t *dispctx;
|
|
|
|
video_coord_array_t dispca; /* ptr alignment */
|
|
|
|
|
2020-06-07 20:58:06 +00:00
|
|
|
/* Width, height and pitch of the display framebuffer */
|
2020-08-14 19:09:24 +00:00
|
|
|
size_t framebuf_pitch;
|
2020-06-07 20:58:06 +00:00
|
|
|
unsigned framebuf_width;
|
|
|
|
unsigned framebuf_height;
|
|
|
|
|
|
|
|
/* Height of the display header */
|
|
|
|
unsigned header_height;
|
|
|
|
|
|
|
|
enum menu_driver_id_type menu_driver_id;
|
|
|
|
|
2020-08-14 19:09:24 +00:00
|
|
|
bool has_windowed;
|
|
|
|
bool msg_force;
|
|
|
|
bool framebuf_dirty;
|
2020-06-07 20:58:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct gfx_display gfx_display_t;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
void gfx_display_free(void);
|
|
|
|
|
|
|
|
void gfx_display_init(void);
|
|
|
|
|
|
|
|
void gfx_display_push_quad(
|
|
|
|
unsigned width, unsigned height,
|
|
|
|
const float *colors, int x1, int y1,
|
|
|
|
int x2, int y2);
|
|
|
|
|
|
|
|
void gfx_display_draw_cursor(
|
2020-03-09 00:32:05 +00:00
|
|
|
void *userdata,
|
|
|
|
unsigned video_width,
|
|
|
|
unsigned video_height,
|
|
|
|
bool cursor_visible,
|
2020-02-17 12:01:14 +00:00
|
|
|
float *color, float cursor_size, uintptr_t texture,
|
|
|
|
float x, float y, unsigned width, unsigned height);
|
|
|
|
|
|
|
|
void gfx_display_draw_text(
|
|
|
|
const font_data_t *font, const char *text,
|
|
|
|
float x, float y, int width, int height,
|
|
|
|
uint32_t color, enum text_alignment text_align,
|
|
|
|
float scale_factor, bool shadows_enable, float shadow_offset,
|
|
|
|
bool draw_outside);
|
|
|
|
|
|
|
|
font_data_t *gfx_display_font(
|
|
|
|
enum application_special_type type,
|
|
|
|
float font_size,
|
|
|
|
bool video_is_threaded);
|
|
|
|
|
2020-03-08 21:58:17 +00:00
|
|
|
void gfx_display_scissor_begin(void *data, unsigned video_width, unsigned video_height, int x, int y, unsigned width, unsigned height);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
void gfx_display_font_free(font_data_t *font);
|
|
|
|
|
|
|
|
void gfx_display_set_width(unsigned width);
|
|
|
|
void gfx_display_get_fb_size(unsigned *fb_width, unsigned *fb_height,
|
|
|
|
size_t *fb_pitch);
|
|
|
|
void gfx_display_set_height(unsigned height);
|
|
|
|
void gfx_display_set_framebuffer_pitch(size_t pitch);
|
|
|
|
|
|
|
|
bool gfx_display_get_msg_force(void);
|
|
|
|
void gfx_display_set_msg_force(bool state);
|
|
|
|
bool gfx_display_init_first_driver(bool video_is_threaded);
|
2020-03-08 21:52:02 +00:00
|
|
|
|
2020-06-07 20:58:06 +00:00
|
|
|
gfx_display_t *disp_get_ptr(void);
|
|
|
|
|
2020-02-17 12:01:14 +00:00
|
|
|
void gfx_display_draw_keyboard(
|
2020-03-09 00:26:43 +00:00
|
|
|
void *userdata,
|
|
|
|
unsigned video_width,
|
|
|
|
unsigned video_height,
|
2020-02-17 12:01:14 +00:00
|
|
|
uintptr_t hover_texture,
|
|
|
|
const font_data_t *font,
|
|
|
|
char *grid[], unsigned id,
|
|
|
|
unsigned text_color);
|
|
|
|
|
|
|
|
void gfx_display_draw_bg(
|
|
|
|
gfx_display_ctx_draw_t *draw,
|
2020-03-08 23:34:31 +00:00
|
|
|
void *userdata,
|
2020-02-17 12:01:14 +00:00
|
|
|
bool add_opacity, float opacity_override);
|
2020-03-08 23:34:31 +00:00
|
|
|
|
2020-02-17 12:01:14 +00:00
|
|
|
void gfx_display_draw_quad(
|
2020-03-08 22:56:22 +00:00
|
|
|
void *data,
|
|
|
|
unsigned video_width,
|
|
|
|
unsigned video_height,
|
2020-02-17 12:01:14 +00:00
|
|
|
int x, int y, unsigned w, unsigned h,
|
|
|
|
unsigned width, unsigned height,
|
|
|
|
float *color);
|
2020-03-08 22:56:22 +00:00
|
|
|
|
2020-02-17 12:01:14 +00:00
|
|
|
void gfx_display_draw_polygon(
|
2020-03-08 23:08:18 +00:00
|
|
|
void *userdata,
|
|
|
|
unsigned video_width,
|
|
|
|
unsigned video_height,
|
2020-02-17 12:01:14 +00:00
|
|
|
int x1, int y1,
|
|
|
|
int x2, int y2,
|
|
|
|
int x3, int y3,
|
|
|
|
int x4, int y4,
|
|
|
|
unsigned width, unsigned height,
|
|
|
|
float *color);
|
2020-03-08 23:08:18 +00:00
|
|
|
|
2020-02-17 12:01:14 +00:00
|
|
|
void gfx_display_draw_texture_slice(
|
2020-03-08 23:34:31 +00:00
|
|
|
void *userdata,
|
|
|
|
unsigned video_width,
|
|
|
|
unsigned video_height,
|
2020-02-17 12:01:14 +00:00
|
|
|
int x, int y, unsigned w, unsigned h,
|
2020-03-08 23:34:31 +00:00
|
|
|
unsigned new_w, unsigned new_h,
|
|
|
|
unsigned width, unsigned height,
|
2020-02-17 12:01:14 +00:00
|
|
|
float *color, unsigned offset, float scale_factor, uintptr_t texture);
|
|
|
|
|
2020-03-08 21:33:11 +00:00
|
|
|
void gfx_display_rotate_z(gfx_display_ctx_rotate_draw_t *draw, void *data);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
font_data_t *gfx_display_font_file(char* fontpath, float font_size, bool is_threaded);
|
|
|
|
|
|
|
|
bool gfx_display_reset_textures_list(
|
|
|
|
const char *texture_path, const char *iconpath,
|
|
|
|
uintptr_t *item, enum texture_filter_type filter_type,
|
|
|
|
unsigned *width, unsigned *height);
|
|
|
|
|
|
|
|
/* Returns the OSK key at a given position */
|
|
|
|
int gfx_display_osk_ptr_at_pos(void *data, int x, int y,
|
|
|
|
unsigned width, unsigned height);
|
|
|
|
|
|
|
|
float gfx_display_get_dpi_scale(unsigned width, unsigned height);
|
|
|
|
|
2020-03-04 17:07:49 +00:00
|
|
|
float gfx_display_get_widget_dpi_scale(
|
|
|
|
unsigned width, unsigned height, bool fullscreen);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2020-03-04 17:07:49 +00:00
|
|
|
float gfx_display_get_widget_pixel_scale(
|
|
|
|
unsigned width, unsigned height, bool fullscreen);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2020-09-24 04:46:21 +00:00
|
|
|
void gfx_display_init_white_texture(uintptr_t white_texture);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
bool gfx_display_driver_exists(const char *s);
|
|
|
|
|
|
|
|
bool gfx_display_init_first_driver(bool video_is_threaded);
|
|
|
|
|
|
|
|
extern uintptr_t gfx_display_white_texture;
|
|
|
|
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_gl;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_gl_core;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_gl1;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_vulkan;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_metal;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_d3d8;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_d3d9;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_d3d10;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_d3d11;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_d3d12;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_vita2d;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_ctr;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_wiiu;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_gdi;
|
|
|
|
extern gfx_display_ctx_driver_t gfx_display_ctx_switch;
|
|
|
|
|
|
|
|
RETRO_END_DECLS
|
|
|
|
|
|
|
|
#endif
|