mirror of
https://github.com/libretro/RetroArch
synced 2024-07-03 00:38:44 +00:00
Move video driver functions over to gfx/video_driver.c
This commit is contained in:
parent
c3afd4b1a5
commit
0448afab96
|
@ -309,11 +309,12 @@ OBJ += \
|
|||
input/input_driver.o \
|
||||
input/common/input_hid_common.o \
|
||||
led/led_driver.o \
|
||||
gfx/video_coord_array.o \
|
||||
gfx/gfx_display.o \
|
||||
gfx/video_driver.o \
|
||||
gfx/gfx_display.o \
|
||||
gfx/gfx_animation.o \
|
||||
gfx/gfx_thumbnail_path.o \
|
||||
gfx/gfx_thumbnail.o \
|
||||
gfx/gfx_thumbnail_path.o \
|
||||
gfx/gfx_thumbnail.o \
|
||||
gfx/video_coord_array.o \
|
||||
configuration.o \
|
||||
$(LIBRETRO_COMM_DIR)/dynamic/dylib.o \
|
||||
cores/dynamic_dummy.o \
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
|
||||
#define CINTERFACE
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* For Xbox we will just link statically
|
||||
* to Direct3D libraries instead. */
|
||||
|
||||
|
|
185
gfx/video_driver.c
Normal file
185
gfx/video_driver.c
Normal file
|
@ -0,0 +1,185 @@
|
|||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2021 - 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/>.
|
||||
*/
|
||||
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "video_driver.h"
|
||||
|
||||
video_driver_t *hw_render_context_driver(
|
||||
enum retro_hw_context_type type, int major, int minor)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case RETRO_HW_CONTEXT_OPENGL_CORE:
|
||||
#ifdef HAVE_OPENGL_CORE
|
||||
return &video_gl_core;
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
case RETRO_HW_CONTEXT_OPENGL:
|
||||
#ifdef HAVE_OPENGL
|
||||
return &video_gl2;
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
case RETRO_HW_CONTEXT_DIRECT3D:
|
||||
#if defined(HAVE_D3D9)
|
||||
if (major == 9)
|
||||
return &video_d3d9;
|
||||
#endif
|
||||
#if defined(HAVE_D3D11)
|
||||
if (major == 11)
|
||||
return &video_d3d11;
|
||||
#endif
|
||||
break;
|
||||
case RETRO_HW_CONTEXT_VULKAN:
|
||||
#if defined(HAVE_VULKAN)
|
||||
return &video_vulkan;
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
case RETRO_HW_CONTEXT_NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *hw_render_context_name(
|
||||
enum retro_hw_context_type type, int major, int minor)
|
||||
{
|
||||
#ifdef HAVE_OPENGL_CORE
|
||||
if (type == RETRO_HW_CONTEXT_OPENGL_CORE)
|
||||
return "glcore";
|
||||
#endif
|
||||
#ifdef HAVE_OPENGL
|
||||
switch (type)
|
||||
{
|
||||
case RETRO_HW_CONTEXT_OPENGLES2:
|
||||
case RETRO_HW_CONTEXT_OPENGLES3:
|
||||
case RETRO_HW_CONTEXT_OPENGLES_VERSION:
|
||||
case RETRO_HW_CONTEXT_OPENGL:
|
||||
#ifndef HAVE_OPENGL_CORE
|
||||
case RETRO_HW_CONTEXT_OPENGL_CORE:
|
||||
#endif
|
||||
return "gl";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_VULKAN
|
||||
if (type == RETRO_HW_CONTEXT_VULKAN)
|
||||
return "vulkan";
|
||||
#endif
|
||||
#ifdef HAVE_D3D11
|
||||
if (type == RETRO_HW_CONTEXT_DIRECT3D && major == 11)
|
||||
return "d3d11";
|
||||
#endif
|
||||
#ifdef HAVE_D3D9
|
||||
if (type == RETRO_HW_CONTEXT_DIRECT3D && major == 9)
|
||||
return "d3d9";
|
||||
#endif
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
enum retro_hw_context_type hw_render_context_type(const char *s)
|
||||
{
|
||||
#ifdef HAVE_OPENGL_CORE
|
||||
if (string_is_equal(s, "glcore"))
|
||||
return RETRO_HW_CONTEXT_OPENGL_CORE;
|
||||
#endif
|
||||
#ifdef HAVE_OPENGL
|
||||
if (string_is_equal(s, "gl"))
|
||||
return RETRO_HW_CONTEXT_OPENGL;
|
||||
#endif
|
||||
#ifdef HAVE_VULKAN
|
||||
if (string_is_equal(s, "vulkan"))
|
||||
return RETRO_HW_CONTEXT_VULKAN;
|
||||
#endif
|
||||
#ifdef HAVE_D3D11
|
||||
if (string_is_equal(s, "d3d11"))
|
||||
return RETRO_HW_CONTEXT_DIRECT3D;
|
||||
#endif
|
||||
#ifdef HAVE_D3D11
|
||||
if (string_is_equal(s, "d3d9"))
|
||||
return RETRO_HW_CONTEXT_DIRECT3D;
|
||||
#endif
|
||||
return RETRO_HW_CONTEXT_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* video_driver_translate_coord_viewport:
|
||||
* @mouse_x : Pointer X coordinate.
|
||||
* @mouse_y : Pointer Y coordinate.
|
||||
* @res_x : Scaled X coordinate.
|
||||
* @res_y : Scaled Y coordinate.
|
||||
* @res_screen_x : Scaled screen X coordinate.
|
||||
* @res_screen_y : Scaled screen Y coordinate.
|
||||
*
|
||||
* Translates pointer [X,Y] coordinates into scaled screen
|
||||
* coordinates based on viewport info.
|
||||
*
|
||||
* Returns: true (1) if successful, false if video driver doesn't support
|
||||
* viewport info.
|
||||
**/
|
||||
bool video_driver_translate_coord_viewport(
|
||||
struct video_viewport *vp,
|
||||
int mouse_x, int mouse_y,
|
||||
int16_t *res_x, int16_t *res_y,
|
||||
int16_t *res_screen_x, int16_t *res_screen_y)
|
||||
{
|
||||
int norm_vp_width = (int)vp->width;
|
||||
int norm_vp_height = (int)vp->height;
|
||||
int norm_full_vp_width = (int)vp->full_width;
|
||||
int norm_full_vp_height = (int)vp->full_height;
|
||||
int scaled_screen_x = -0x8000; /* OOB */
|
||||
int scaled_screen_y = -0x8000; /* OOB */
|
||||
int scaled_x = -0x8000; /* OOB */
|
||||
int scaled_y = -0x8000; /* OOB */
|
||||
if (norm_vp_width <= 0 ||
|
||||
norm_vp_height <= 0 ||
|
||||
norm_full_vp_width <= 0 ||
|
||||
norm_full_vp_height <= 0)
|
||||
return false;
|
||||
|
||||
if (mouse_x >= 0 && mouse_x <= norm_full_vp_width)
|
||||
scaled_screen_x = ((2 * mouse_x * 0x7fff)
|
||||
/ norm_full_vp_width) - 0x7fff;
|
||||
|
||||
if (mouse_y >= 0 && mouse_y <= norm_full_vp_height)
|
||||
scaled_screen_y = ((2 * mouse_y * 0x7fff)
|
||||
/ norm_full_vp_height) - 0x7fff;
|
||||
|
||||
mouse_x -= vp->x;
|
||||
mouse_y -= vp->y;
|
||||
|
||||
if (mouse_x >= 0 && mouse_x <= norm_vp_width)
|
||||
scaled_x = ((2 * mouse_x * 0x7fff)
|
||||
/ norm_vp_width) - 0x7fff;
|
||||
else
|
||||
scaled_x = -0x8000; /* OOB */
|
||||
|
||||
if (mouse_y >= 0 && mouse_y <= norm_vp_height)
|
||||
scaled_y = ((2 * mouse_y * 0x7fff)
|
||||
/ norm_vp_height) - 0x7fff;
|
||||
|
||||
*res_x = scaled_x;
|
||||
*res_y = scaled_y;
|
||||
*res_screen_x = scaled_screen_x;
|
||||
*res_screen_y = scaled_screen_y;
|
||||
return true;
|
||||
}
|
1219
gfx/video_driver.h
Normal file
1219
gfx/video_driver.h
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -231,6 +231,7 @@ CHEATS
|
|||
#endif
|
||||
#include "../libretro-common/hash/lrc_hash.c"
|
||||
|
||||
#include "../gfx/video_driver.c"
|
||||
/*============================================================
|
||||
UI COMMON CONTEXT
|
||||
============================================================ */
|
||||
|
|
|
@ -3348,6 +3348,39 @@ bool generic_menu_init_list(struct menu_state *menu_st,
|
|||
return true;
|
||||
}
|
||||
|
||||
/* This function gets called at first startup on Android/iOS
|
||||
* when we need to extract the APK contents/zip file. This
|
||||
* file contains assets which then get extracted to the
|
||||
* user's asset directories. */
|
||||
static void bundle_decompressed(retro_task_t *task,
|
||||
void *task_data,
|
||||
void *user_data, const char *err)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
decompress_task_data_t *dec = (decompress_task_data_t*)task_data;
|
||||
|
||||
if (err)
|
||||
RARCH_ERR("%s", err);
|
||||
|
||||
if (dec)
|
||||
{
|
||||
if (!err)
|
||||
command_event(CMD_EVENT_REINIT, NULL);
|
||||
|
||||
/* delete bundle? */
|
||||
free(dec->source_file);
|
||||
free(dec);
|
||||
}
|
||||
|
||||
configuration_set_uint(settings,
|
||||
settings->uints.bundle_assets_extract_last_version,
|
||||
settings->uints.bundle_assets_extract_version_current);
|
||||
|
||||
configuration_set_bool(settings, settings->bools.bundle_finished, true);
|
||||
|
||||
command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL);
|
||||
}
|
||||
|
||||
bool rarch_menu_init(
|
||||
struct menu_state *menu_st,
|
||||
menu_dialog_t *p_dialog,
|
||||
|
|
|
@ -776,10 +776,6 @@ bool menu_driver_displaylist_push(
|
|||
file_list_t *entry_list,
|
||||
file_list_t *entry_stack);
|
||||
|
||||
void bundle_decompressed(retro_task_t *task,
|
||||
void *task_data,
|
||||
void *user_data, const char *err);
|
||||
|
||||
int generic_menu_entry_action(void *userdata, menu_entry_t *entry, size_t i, enum menu_action action);
|
||||
|
||||
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
|
||||
|
|
201
retroarch.c
201
retroarch.c
|
@ -1482,41 +1482,6 @@ int generic_menu_entry_action(
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef HAVE_COMPRESSION
|
||||
/* This function gets called at first startup on Android/iOS
|
||||
* when we need to extract the APK contents/zip file. This
|
||||
* file contains assets which then get extracted to the
|
||||
* user's asset directories. */
|
||||
void bundle_decompressed(retro_task_t *task,
|
||||
void *task_data,
|
||||
void *user_data, const char *err)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
decompress_task_data_t *dec = (decompress_task_data_t*)task_data;
|
||||
|
||||
if (err)
|
||||
RARCH_ERR("%s", err);
|
||||
|
||||
if (dec)
|
||||
{
|
||||
if (!err)
|
||||
command_event(CMD_EVENT_REINIT, NULL);
|
||||
|
||||
/* delete bundle? */
|
||||
free(dec->source_file);
|
||||
free(dec);
|
||||
}
|
||||
|
||||
configuration_set_uint(settings,
|
||||
settings->uints.bundle_assets_extract_last_version,
|
||||
settings->uints.bundle_assets_extract_version_current);
|
||||
|
||||
configuration_set_bool(settings, settings->bools.bundle_finished, true);
|
||||
|
||||
command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *menu_driver_ident(void)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
|
@ -10365,109 +10330,6 @@ static void runloop_core_msg_queue_push(
|
|||
category);
|
||||
}
|
||||
|
||||
#if defined(HAVE_VULKAN) || defined(HAVE_D3D11) || defined(HAVE_D3D9) || defined(HAVE_OPENGL_CORE)
|
||||
static video_driver_t *hw_render_context_driver(enum retro_hw_context_type type, int major, int minor)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case RETRO_HW_CONTEXT_OPENGL_CORE:
|
||||
#ifdef HAVE_OPENGL_CORE
|
||||
return &video_gl_core;
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
case RETRO_HW_CONTEXT_OPENGL:
|
||||
#ifdef HAVE_OPENGL
|
||||
return &video_gl2;
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
case RETRO_HW_CONTEXT_DIRECT3D:
|
||||
#if defined(HAVE_D3D9)
|
||||
if (major == 9)
|
||||
return &video_d3d9;
|
||||
#endif
|
||||
#if defined(HAVE_D3D11)
|
||||
if (major == 11)
|
||||
return &video_d3d11;
|
||||
#endif
|
||||
break;
|
||||
case RETRO_HW_CONTEXT_VULKAN:
|
||||
#if defined(HAVE_VULKAN)
|
||||
return &video_vulkan;
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
case RETRO_HW_CONTEXT_NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static enum retro_hw_context_type hw_render_context_type(const char *s)
|
||||
{
|
||||
#ifdef HAVE_OPENGL_CORE
|
||||
if (string_is_equal(s, "glcore"))
|
||||
return RETRO_HW_CONTEXT_OPENGL_CORE;
|
||||
#endif
|
||||
#ifdef HAVE_OPENGL
|
||||
if (string_is_equal(s, "gl"))
|
||||
return RETRO_HW_CONTEXT_OPENGL;
|
||||
#endif
|
||||
#ifdef HAVE_VULKAN
|
||||
if (string_is_equal(s, "vulkan"))
|
||||
return RETRO_HW_CONTEXT_VULKAN;
|
||||
#endif
|
||||
#ifdef HAVE_D3D11
|
||||
if (string_is_equal(s, "d3d11"))
|
||||
return RETRO_HW_CONTEXT_DIRECT3D;
|
||||
#endif
|
||||
#ifdef HAVE_D3D11
|
||||
if (string_is_equal(s, "d3d9"))
|
||||
return RETRO_HW_CONTEXT_DIRECT3D;
|
||||
#endif
|
||||
return RETRO_HW_CONTEXT_NONE;
|
||||
}
|
||||
|
||||
static const char *hw_render_context_name(enum retro_hw_context_type type, int major, int minor)
|
||||
{
|
||||
#ifdef HAVE_OPENGL_CORE
|
||||
if (type == RETRO_HW_CONTEXT_OPENGL_CORE)
|
||||
return "glcore";
|
||||
#endif
|
||||
#ifdef HAVE_OPENGL
|
||||
switch (type)
|
||||
{
|
||||
case RETRO_HW_CONTEXT_OPENGLES2:
|
||||
case RETRO_HW_CONTEXT_OPENGLES3:
|
||||
case RETRO_HW_CONTEXT_OPENGLES_VERSION:
|
||||
case RETRO_HW_CONTEXT_OPENGL:
|
||||
#ifndef HAVE_OPENGL_CORE
|
||||
case RETRO_HW_CONTEXT_OPENGL_CORE:
|
||||
#endif
|
||||
return "gl";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_VULKAN
|
||||
if (type == RETRO_HW_CONTEXT_VULKAN)
|
||||
return "vulkan";
|
||||
#endif
|
||||
#ifdef HAVE_D3D11
|
||||
if (type == RETRO_HW_CONTEXT_DIRECT3D && major == 11)
|
||||
return "d3d11";
|
||||
#endif
|
||||
#ifdef HAVE_D3D9
|
||||
if (type == RETRO_HW_CONTEXT_DIRECT3D && major == 9)
|
||||
return "d3d9";
|
||||
#endif
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
/**
|
||||
* rarch_environment_cb:
|
||||
* @cmd : Identifier of command.
|
||||
|
@ -23087,69 +22949,6 @@ void video_driver_build_info(video_frame_info_t *video_info)
|
|||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* video_driver_translate_coord_viewport:
|
||||
* @mouse_x : Pointer X coordinate.
|
||||
* @mouse_y : Pointer Y coordinate.
|
||||
* @res_x : Scaled X coordinate.
|
||||
* @res_y : Scaled Y coordinate.
|
||||
* @res_screen_x : Scaled screen X coordinate.
|
||||
* @res_screen_y : Scaled screen Y coordinate.
|
||||
*
|
||||
* Translates pointer [X,Y] coordinates into scaled screen
|
||||
* coordinates based on viewport info.
|
||||
*
|
||||
* Returns: true (1) if successful, false if video driver doesn't support
|
||||
* viewport info.
|
||||
**/
|
||||
bool video_driver_translate_coord_viewport(
|
||||
struct video_viewport *vp,
|
||||
int mouse_x, int mouse_y,
|
||||
int16_t *res_x, int16_t *res_y,
|
||||
int16_t *res_screen_x, int16_t *res_screen_y)
|
||||
{
|
||||
int norm_vp_width = (int)vp->width;
|
||||
int norm_vp_height = (int)vp->height;
|
||||
int norm_full_vp_width = (int)vp->full_width;
|
||||
int norm_full_vp_height = (int)vp->full_height;
|
||||
int scaled_screen_x = -0x8000; /* OOB */
|
||||
int scaled_screen_y = -0x8000; /* OOB */
|
||||
int scaled_x = -0x8000; /* OOB */
|
||||
int scaled_y = -0x8000; /* OOB */
|
||||
if (norm_vp_width <= 0 ||
|
||||
norm_vp_height <= 0 ||
|
||||
norm_full_vp_width <= 0 ||
|
||||
norm_full_vp_height <= 0)
|
||||
return false;
|
||||
|
||||
if (mouse_x >= 0 && mouse_x <= norm_full_vp_width)
|
||||
scaled_screen_x = ((2 * mouse_x * 0x7fff)
|
||||
/ norm_full_vp_width) - 0x7fff;
|
||||
|
||||
if (mouse_y >= 0 && mouse_y <= norm_full_vp_height)
|
||||
scaled_screen_y = ((2 * mouse_y * 0x7fff)
|
||||
/ norm_full_vp_height) - 0x7fff;
|
||||
|
||||
mouse_x -= vp->x;
|
||||
mouse_y -= vp->y;
|
||||
|
||||
if (mouse_x >= 0 && mouse_x <= norm_vp_width)
|
||||
scaled_x = ((2 * mouse_x * 0x7fff)
|
||||
/ norm_vp_width) - 0x7fff;
|
||||
else
|
||||
scaled_x = -0x8000; /* OOB */
|
||||
|
||||
if (mouse_y >= 0 && mouse_y <= norm_vp_height)
|
||||
scaled_y = ((2 * mouse_y * 0x7fff)
|
||||
/ norm_vp_height) - 0x7fff;
|
||||
|
||||
*res_x = scaled_x;
|
||||
*res_y = scaled_y;
|
||||
*res_screen_x = scaled_screen_x;
|
||||
*res_screen_y = scaled_screen_y;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool video_driver_has_focus(void)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
|
|
1179
retroarch.h
1179
retroarch.h
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user