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
|
|
|
|
* Copyright (C) 2016-2019 - Brad Parker
|
|
|
|
*
|
|
|
|
* 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 "gfx_display.h"
|
|
|
|
|
|
|
|
#include "video_coord_array.h"
|
|
|
|
#include "../configuration.h"
|
|
|
|
#include "../verbosity.h"
|
|
|
|
|
2022-03-15 19:18:24 +00:00
|
|
|
#ifdef HAVE_MIST
|
|
|
|
#include "../steam/steam.h"
|
|
|
|
#endif
|
|
|
|
|
2020-02-17 12:01:14 +00:00
|
|
|
/* Standard reference DPI value, used when determining
|
2020-03-06 15:06:44 +00:00
|
|
|
* DPI-aware scaling factors */
|
2020-02-17 12:01:14 +00:00
|
|
|
#define REFERENCE_DPI 96.0f
|
|
|
|
|
|
|
|
/* 'OZONE_SIDEBAR_WIDTH' must be kept in sync
|
2020-03-06 15:06:44 +00:00
|
|
|
* with Ozone driver metrics */
|
2020-02-17 12:01:14 +00:00
|
|
|
#define OZONE_SIDEBAR_WIDTH 408
|
|
|
|
|
2021-09-13 17:55:53 +00:00
|
|
|
/* Small 1x1 white texture used for blending purposes */
|
|
|
|
static uintptr_t gfx_white_texture;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2021-09-30 15:14:26 +00:00
|
|
|
/* ptr alignment */
|
|
|
|
static gfx_display_t dispgfx_st = {0};
|
|
|
|
|
|
|
|
gfx_display_t *disp_get_ptr(void)
|
|
|
|
{
|
|
|
|
return &dispgfx_st;
|
|
|
|
}
|
|
|
|
|
2020-02-17 12:01:14 +00:00
|
|
|
static bool gfx_display_null_font_init_first(
|
|
|
|
void **font_handle, void *video_data,
|
|
|
|
const char *font_path, float font_size,
|
|
|
|
bool is_threaded)
|
|
|
|
{
|
|
|
|
font_data_t **handle = (font_data_t**)font_handle;
|
|
|
|
if ((*handle = font_driver_init_first(video_data,
|
|
|
|
font_path, font_size, true,
|
|
|
|
is_threaded,
|
|
|
|
FONT_DRIVER_RENDER_DONT_CARE)))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-02-02 11:28:17 +00:00
|
|
|
static const float *null_get_default_matrix(void)
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
|
|
|
static float dummy[16] = {0.0f};
|
|
|
|
return &dummy[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx_display_ctx_driver_t gfx_display_ctx_null = {
|
2020-09-26 22:18:16 +00:00
|
|
|
NULL, /* draw */
|
|
|
|
NULL, /* draw_pipeline */
|
|
|
|
NULL, /* blend_begin */
|
|
|
|
NULL, /* blend_end */
|
2020-09-26 19:40:16 +00:00
|
|
|
NULL, /* get_default_mvp */
|
2021-02-02 11:28:17 +00:00
|
|
|
null_get_default_matrix,
|
|
|
|
null_get_default_matrix,
|
2020-02-17 12:01:14 +00:00
|
|
|
gfx_display_null_font_init_first,
|
|
|
|
GFX_VIDEO_DRIVER_GENERIC,
|
|
|
|
"null",
|
|
|
|
false,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Menu display drivers */
|
|
|
|
static gfx_display_ctx_driver_t *gfx_display_ctx_drivers[] = {
|
|
|
|
#ifdef HAVE_D3D8
|
|
|
|
&gfx_display_ctx_d3d8,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_D3D9
|
|
|
|
&gfx_display_ctx_d3d9,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_D3D10
|
|
|
|
&gfx_display_ctx_d3d10,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_D3D11
|
|
|
|
&gfx_display_ctx_d3d11,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_D3D12
|
|
|
|
&gfx_display_ctx_d3d12,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_OPENGL
|
|
|
|
&gfx_display_ctx_gl,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_OPENGL1
|
|
|
|
&gfx_display_ctx_gl1,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_OPENGL_CORE
|
2021-11-23 07:45:54 +00:00
|
|
|
&gfx_display_ctx_gl3,
|
2020-02-17 12:01:14 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_VULKAN
|
|
|
|
&gfx_display_ctx_vulkan,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_METAL
|
|
|
|
&gfx_display_ctx_metal,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_VITA2D
|
|
|
|
&gfx_display_ctx_vita2d,
|
|
|
|
#endif
|
|
|
|
#ifdef _3DS
|
|
|
|
&gfx_display_ctx_ctr,
|
|
|
|
#endif
|
|
|
|
#ifdef WIIU
|
|
|
|
&gfx_display_ctx_wiiu,
|
|
|
|
#endif
|
2022-03-27 01:51:33 +00:00
|
|
|
#ifdef __PSL1GHT__
|
|
|
|
&gfx_display_ctx_rsx,
|
|
|
|
#endif
|
2020-02-17 12:01:14 +00:00
|
|
|
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
|
|
|
|
#ifdef HAVE_GDI
|
|
|
|
&gfx_display_ctx_gdi,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
&gfx_display_ctx_null,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2021-03-25 03:55:27 +00:00
|
|
|
float gfx_display_get_adjusted_scale(
|
2020-06-08 03:52:25 +00:00
|
|
|
gfx_display_t *p_disp,
|
2020-02-17 12:01:14 +00:00
|
|
|
float base_scale, float scale_factor, unsigned width)
|
|
|
|
{
|
|
|
|
/* Apply user-set scaling factor */
|
2020-03-06 15:33:34 +00:00
|
|
|
float adjusted_scale = base_scale * scale_factor;
|
2020-03-06 15:01:45 +00:00
|
|
|
#ifdef HAVE_OZONE
|
2020-02-17 12:01:14 +00:00
|
|
|
/* Ozone has a capped scale factor */
|
2020-03-06 15:33:34 +00:00
|
|
|
if (p_disp->menu_driver_id == MENU_DRIVER_ID_OZONE)
|
2020-03-06 15:01:45 +00:00
|
|
|
{
|
2020-09-28 05:22:52 +00:00
|
|
|
float new_width = (float)width * 0.3333333f;
|
|
|
|
if (((float)OZONE_SIDEBAR_WIDTH * adjusted_scale)
|
|
|
|
> new_width)
|
|
|
|
adjusted_scale = (new_width / (float)OZONE_SIDEBAR_WIDTH);
|
2020-03-06 15:01:45 +00:00
|
|
|
}
|
|
|
|
#endif
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
/* Ensure final scale is 'sane' */
|
2020-10-01 10:33:58 +00:00
|
|
|
if (adjusted_scale <= 0.0001f)
|
|
|
|
return 1.0f;
|
|
|
|
return adjusted_scale;
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
|
2020-06-08 03:52:25 +00:00
|
|
|
/* Check if the current menu driver is compatible
|
|
|
|
* with your video driver. */
|
|
|
|
static bool gfx_display_check_compatibility(
|
|
|
|
enum gfx_display_driver_type type,
|
|
|
|
bool video_is_threaded)
|
|
|
|
{
|
|
|
|
const char *video_driver = video_driver_get_ident();
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case GFX_VIDEO_DRIVER_GENERIC:
|
|
|
|
return true;
|
|
|
|
case GFX_VIDEO_DRIVER_OPENGL:
|
|
|
|
if (string_is_equal(video_driver, "gl"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_OPENGL1:
|
|
|
|
if (string_is_equal(video_driver, "gl1"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_OPENGL_CORE:
|
|
|
|
if (string_is_equal(video_driver, "glcore"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_VULKAN:
|
|
|
|
if (string_is_equal(video_driver, "vulkan"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_METAL:
|
|
|
|
if (string_is_equal(video_driver, "metal"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_DIRECT3D8:
|
|
|
|
if (string_is_equal(video_driver, "d3d8"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_DIRECT3D9:
|
|
|
|
if (string_is_equal(video_driver, "d3d9"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_DIRECT3D10:
|
|
|
|
if (string_is_equal(video_driver, "d3d10"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_DIRECT3D11:
|
|
|
|
if (string_is_equal(video_driver, "d3d11"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_DIRECT3D12:
|
|
|
|
if (string_is_equal(video_driver, "d3d12"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_VITA2D:
|
|
|
|
if (string_is_equal(video_driver, "vita2d"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_CTR:
|
|
|
|
if (string_is_equal(video_driver, "ctr"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_WIIU:
|
|
|
|
if (string_is_equal(video_driver, "gx2"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_GDI:
|
|
|
|
if (string_is_equal(video_driver, "gdi"))
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case GFX_VIDEO_DRIVER_SWITCH:
|
|
|
|
if (string_is_equal(video_driver, "switch"))
|
|
|
|
return true;
|
|
|
|
break;
|
2022-03-27 01:51:33 +00:00
|
|
|
case GFX_VIDEO_DRIVER_RSX:
|
|
|
|
if (string_is_equal(video_driver, "rsx"))
|
|
|
|
return true;
|
|
|
|
break;
|
2020-06-08 03:52:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-03-25 03:55:27 +00:00
|
|
|
float gfx_display_get_dpi_scale_internal(
|
2020-09-28 05:22:52 +00:00
|
|
|
unsigned width, unsigned height)
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
2020-03-06 15:01:45 +00:00
|
|
|
float dpi;
|
|
|
|
float diagonal_pixels;
|
|
|
|
float pixel_scale;
|
2020-02-17 12:01:14 +00:00
|
|
|
static unsigned last_width = 0;
|
|
|
|
static unsigned last_height = 0;
|
|
|
|
static float scale = 0.0f;
|
|
|
|
static bool scale_cached = false;
|
|
|
|
gfx_ctx_metrics_t metrics;
|
|
|
|
|
|
|
|
if (scale_cached &&
|
|
|
|
(width == last_width) &&
|
|
|
|
(height == last_height))
|
|
|
|
return scale;
|
|
|
|
|
|
|
|
/* Determine the diagonal 'size' of the display
|
|
|
|
* (or window) in terms of pixels */
|
|
|
|
diagonal_pixels = (float)sqrt(
|
|
|
|
(double)((width * width) + (height * height)));
|
|
|
|
|
2020-08-02 21:44:28 +00:00
|
|
|
/* TODO/FIXME: On Mac, calling video_context_driver_get_metrics()
|
2020-02-17 12:01:14 +00:00
|
|
|
* here causes RetroArch to crash (EXC_BAD_ACCESS). This is
|
|
|
|
* unfortunate, and needs to be fixed at the gfx context driver
|
|
|
|
* level. Until this is done, all we can do is fallback to using
|
|
|
|
* the old legacy 'magic number' scaling on Mac platforms. */
|
2020-07-07 15:03:42 +00:00
|
|
|
#if !defined(HAVE_COCOATOUCH) && (defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL))
|
2020-02-17 12:01:14 +00:00
|
|
|
if (true)
|
|
|
|
{
|
|
|
|
scale = (diagonal_pixels / 6.5f) / 212.0f;
|
|
|
|
scale_cached = true;
|
|
|
|
last_width = width;
|
|
|
|
last_height = height;
|
|
|
|
return scale;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Get pixel scale relative to baseline 1080p display */
|
2021-09-21 19:10:38 +00:00
|
|
|
pixel_scale = diagonal_pixels / DIAGONAL_PIXELS_1080P;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
/* Attempt to get display DPI */
|
|
|
|
metrics.type = DISPLAY_METRIC_DPI;
|
|
|
|
metrics.value = &dpi;
|
|
|
|
|
2020-08-02 21:44:28 +00:00
|
|
|
if (video_context_driver_get_metrics(&metrics) && (dpi > 0.0f))
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
|
|
|
float display_size;
|
|
|
|
float dpi_scale;
|
|
|
|
|
|
|
|
#if defined(ANDROID) || defined(HAVE_COCOATOUCH)
|
|
|
|
/* Android/iOS devices tell complete lies when
|
|
|
|
* reporting DPI values. From the Android devices
|
|
|
|
* I've had access to, the DPI is generally
|
|
|
|
* overestimated by 17%. All we can do is apply
|
|
|
|
* a blind correction factor... */
|
2020-09-28 05:22:52 +00:00
|
|
|
dpi *= 0.83f;
|
2020-02-17 12:01:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Note: If we are running in windowed mode, this
|
|
|
|
* 'display size' is actually the window size - which
|
|
|
|
* kinda makes a mess of everything. Since we cannot
|
|
|
|
* get fullscreen resolution when running in windowed
|
|
|
|
* mode, there is nothing we can do about this. So just
|
|
|
|
* treat the window as a display, and hope for the best... */
|
|
|
|
display_size = diagonal_pixels / dpi;
|
|
|
|
dpi_scale = dpi / REFERENCE_DPI;
|
|
|
|
|
|
|
|
/* Note: We have tried leveraging every possible metric
|
|
|
|
* (and numerous studies on TV/monitor/mobile device
|
|
|
|
* usage habits) to determine an appropriate auto scaling
|
|
|
|
* factor. *None of these 'smart'/technical methods work
|
|
|
|
* consistently in the real world* - there is simply too
|
|
|
|
* much variance.
|
|
|
|
* So instead we have implemented a very fuzzy/loose
|
|
|
|
* method which is crude as can be, but actually has
|
|
|
|
* some semblance of usability... */
|
|
|
|
|
|
|
|
if (display_size > 24.0f)
|
|
|
|
{
|
|
|
|
/* DPI scaling fails miserably when using large
|
|
|
|
* displays. Having a UI element that's 1 inch high
|
|
|
|
* on all screens might seem like a good idea - until
|
|
|
|
* you realise that a HTPC user is probably sitting
|
|
|
|
* several metres from their TV, which makes something
|
|
|
|
* 1 inch high virtually invisible.
|
|
|
|
* So we make some assumptions:
|
|
|
|
* - Normal size displays <= 24 inches are probably
|
|
|
|
* PC monitors, with an eye-to-screen distance of
|
|
|
|
* 1 arm length. Under these conditions, fixed size
|
|
|
|
* (DPI scaled) UI elements should be visible for most
|
|
|
|
* users
|
|
|
|
* - Large displays > 24 inches start to encroach on
|
|
|
|
* TV territory. Once we start working with TVs, we
|
|
|
|
* have to consider users sitting on a couch - and
|
|
|
|
* in this situation, we fall back to the age-old
|
|
|
|
* standard of UI elements occupying a fixed fraction
|
|
|
|
* of the display size (i.e. just look at the menu of
|
|
|
|
* any console system for the past decade)
|
|
|
|
* - 24 -> 32 inches is a grey area, where the display
|
|
|
|
* might be a monitor or a TV. Above 32 inches, a TV
|
|
|
|
* is almost a certainty. So we simply lerp between
|
|
|
|
* dpi scaling and pixel scaling as the display size
|
|
|
|
* increases from 24 to 32 */
|
2020-09-28 05:22:52 +00:00
|
|
|
float fraction = (display_size > 32.0f) ? 32.0f : display_size;
|
|
|
|
fraction -= 24.0f;
|
|
|
|
fraction /= (32.0f - 24.0f);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2020-09-28 05:22:52 +00:00
|
|
|
scale = ((1.0f - fraction) * dpi_scale)
|
|
|
|
+ (fraction * pixel_scale);
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
else if (display_size < 12.0f)
|
|
|
|
{
|
|
|
|
/* DPI scaling also fails when using very small
|
|
|
|
* displays - i.e. mobile devices (tablets/phones).
|
|
|
|
* That 1 inch UI element is going to look pretty
|
|
|
|
* dumb on a 5 inch screen in landscape orientation...
|
|
|
|
* We're essentially in the opposite situation to the
|
|
|
|
* TV case above, and it turns out that a similar
|
|
|
|
* solution provides relief: as screen size reduces
|
|
|
|
* from 12 inches to zero, we lerp from dpi scaling
|
|
|
|
* to pixel scaling */
|
|
|
|
float fraction = display_size / 12.0f;
|
|
|
|
|
2020-09-28 05:22:52 +00:00
|
|
|
scale = ((1.0f - fraction) * pixel_scale)
|
|
|
|
+ (fraction * dpi_scale);
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
else
|
2020-09-28 05:22:52 +00:00
|
|
|
scale = dpi_scale;
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
/* If DPI retrieval is unsupported, all we can do
|
|
|
|
* is use the raw pixel scale */
|
|
|
|
else
|
2020-09-28 05:22:52 +00:00
|
|
|
scale = pixel_scale;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2020-09-28 05:22:52 +00:00
|
|
|
scale_cached = true;
|
|
|
|
last_width = width;
|
|
|
|
last_height = height;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
return scale;
|
|
|
|
}
|
|
|
|
|
2021-03-25 18:22:12 +00:00
|
|
|
float gfx_display_get_dpi_scale(
|
|
|
|
gfx_display_t *p_disp,
|
|
|
|
void *settings_data,
|
2021-09-13 18:21:36 +00:00
|
|
|
unsigned width, unsigned height,
|
|
|
|
bool fullscreen,
|
|
|
|
bool is_widget
|
|
|
|
)
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
|
|
|
static unsigned last_width = 0;
|
|
|
|
static unsigned last_height = 0;
|
|
|
|
static float scale = 0.0f;
|
|
|
|
static bool scale_cached = false;
|
|
|
|
bool scale_updated = false;
|
|
|
|
static float last_menu_scale_factor = 0.0f;
|
|
|
|
static enum menu_driver_id_type last_menu_driver_id = MENU_DRIVER_ID_UNKNOWN;
|
|
|
|
static float adjusted_scale = 1.0f;
|
2021-03-25 18:22:12 +00:00
|
|
|
settings_t *settings = (settings_t*)settings_data;
|
2021-09-13 18:21:36 +00:00
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
|
|
|
bool gfx_widget_scale_auto = settings->bools.menu_widget_scale_auto;
|
|
|
|
#if (defined(RARCH_CONSOLE) || defined(RARCH_MOBILE))
|
|
|
|
float menu_widget_scale_factor = settings->floats.menu_widget_scale_factor;
|
|
|
|
#else
|
|
|
|
float menu_widget_scale_factor_fullscreen = settings->floats.menu_widget_scale_factor;
|
|
|
|
float menu_widget_scale_factor_windowed = settings->floats.menu_widget_scale_factor_windowed;
|
|
|
|
float menu_widget_scale_factor = fullscreen ?
|
|
|
|
menu_widget_scale_factor_fullscreen : menu_widget_scale_factor_windowed;
|
|
|
|
#endif
|
|
|
|
float menu_scale_factor = is_widget
|
|
|
|
? menu_widget_scale_factor
|
|
|
|
: settings->floats.menu_scale_factor;
|
|
|
|
#else
|
2020-02-17 12:01:14 +00:00
|
|
|
float menu_scale_factor = settings->floats.menu_scale_factor;
|
2021-09-13 18:21:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
|
|
|
if (is_widget)
|
|
|
|
{
|
|
|
|
if (gfx_widget_scale_auto)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_RGUI
|
|
|
|
/* When using RGUI, _menu_scale_factor
|
|
|
|
* is ignored
|
|
|
|
* > If we are not using a widget scale factor override,
|
|
|
|
* just set menu_scale_factor to 1.0 */
|
|
|
|
if (p_disp->menu_driver_id == MENU_DRIVER_ID_RGUI)
|
|
|
|
menu_scale_factor = 1.0f;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
float _menu_scale_factor =
|
|
|
|
settings->floats.menu_scale_factor;
|
|
|
|
menu_scale_factor = _menu_scale_factor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
/* Scale is based on display metrics - these are a fixed
|
|
|
|
* hardware property. To minimise performance overheads
|
2020-08-02 21:44:28 +00:00
|
|
|
* we therefore only call video_context_driver_get_metrics()
|
2020-02-17 12:01:14 +00:00
|
|
|
* on first run, or when the current video resolution changes */
|
|
|
|
if (!scale_cached ||
|
|
|
|
(width != last_width) ||
|
|
|
|
(height != last_height))
|
|
|
|
{
|
|
|
|
scale = gfx_display_get_dpi_scale_internal(width, height);
|
|
|
|
scale_cached = true;
|
|
|
|
scale_updated = true;
|
|
|
|
last_width = width;
|
|
|
|
last_height = height;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Adjusted scale calculation may also be slow, so
|
|
|
|
* only update if something changes */
|
|
|
|
if (scale_updated ||
|
|
|
|
(menu_scale_factor != last_menu_scale_factor) ||
|
2020-03-06 15:33:34 +00:00
|
|
|
(p_disp->menu_driver_id != last_menu_driver_id))
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
2021-03-25 03:55:27 +00:00
|
|
|
adjusted_scale = gfx_display_get_adjusted_scale(
|
2020-06-08 03:52:25 +00:00
|
|
|
p_disp,
|
2020-02-17 12:01:14 +00:00
|
|
|
scale, menu_scale_factor, width);
|
|
|
|
last_menu_scale_factor = menu_scale_factor;
|
2020-03-06 15:33:34 +00:00
|
|
|
last_menu_driver_id = p_disp->menu_driver_id;
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return adjusted_scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Begin scissoring operation */
|
2021-03-25 19:12:34 +00:00
|
|
|
void gfx_display_scissor_begin(
|
|
|
|
gfx_display_t *p_disp,
|
|
|
|
void *userdata,
|
2020-03-08 21:58:17 +00:00
|
|
|
unsigned video_width,
|
|
|
|
unsigned video_height,
|
2020-02-18 12:04:12 +00:00
|
|
|
int x, int y, unsigned width, unsigned height)
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
2020-06-07 20:58:06 +00:00
|
|
|
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
|
2021-11-09 18:47:45 +00:00
|
|
|
if (dispctx && dispctx->scissor_begin)
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
2021-11-09 18:47:45 +00:00
|
|
|
if (y < 0)
|
|
|
|
{
|
|
|
|
if (height < (unsigned)(-y))
|
|
|
|
height = 0;
|
|
|
|
else
|
|
|
|
height += y;
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
if (x < 0)
|
|
|
|
{
|
|
|
|
if (width < (unsigned)(-x))
|
|
|
|
width = 0;
|
|
|
|
else
|
|
|
|
width += x;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
if (y >= (int)video_height)
|
|
|
|
{
|
|
|
|
height = 0;
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
if (x >= (int)video_width)
|
|
|
|
{
|
|
|
|
width = 0;
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
if ((y + height) > video_height)
|
|
|
|
height = video_height - y;
|
|
|
|
if ((x + width) > video_width)
|
|
|
|
width = video_width - x;
|
|
|
|
|
|
|
|
dispctx->scissor_begin(userdata,
|
|
|
|
video_width, video_height,
|
|
|
|
x, y, width, height);
|
2021-09-21 19:10:38 +00:00
|
|
|
}
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
font_data_t *gfx_display_font_file(
|
2021-03-25 19:12:34 +00:00
|
|
|
gfx_display_t *p_disp,
|
2020-02-17 12:01:14 +00:00
|
|
|
char* fontpath, float menu_font_size, bool is_threaded)
|
|
|
|
{
|
2020-06-07 20:58:06 +00:00
|
|
|
font_data_t *font_data = NULL;
|
|
|
|
float font_size = menu_font_size;
|
|
|
|
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2020-03-06 15:06:44 +00:00
|
|
|
if (!dispctx)
|
2020-02-17 12:01:14 +00:00
|
|
|
return NULL;
|
|
|
|
|
2020-03-24 16:14:53 +00:00
|
|
|
/* Font size must be at least 2, or font_init_first()
|
|
|
|
* will generate a heap-buffer-overflow when using
|
|
|
|
* many font drivers */
|
2020-10-01 10:24:17 +00:00
|
|
|
if (font_size < 2.0f)
|
|
|
|
font_size = 2.0f;
|
2020-03-24 16:14:53 +00:00
|
|
|
|
2020-03-06 15:06:44 +00:00
|
|
|
if (!dispctx->font_init_first((void**)&font_data,
|
2021-03-21 16:33:44 +00:00
|
|
|
video_driver_get_ptr(),
|
2020-03-24 16:14:53 +00:00
|
|
|
fontpath, font_size, is_threaded))
|
2020-02-17 12:01:14 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return font_data;
|
|
|
|
}
|
|
|
|
|
2021-10-13 13:15:05 +00:00
|
|
|
/* Draw text on top of the screen */
|
|
|
|
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, bool shadows_enable, float shadow_offset,
|
|
|
|
bool draw_outside)
|
|
|
|
{
|
|
|
|
struct font_params params;
|
|
|
|
video_driver_state_t *video_st = video_state_get_ptr();
|
|
|
|
|
|
|
|
if ((color & 0x000000FF) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Don't draw outside of the screen */
|
|
|
|
if (!draw_outside &&
|
|
|
|
((x < -64 || x > width + 64)
|
|
|
|
|| (y < -64 || y > height + 64))
|
|
|
|
)
|
|
|
|
return;
|
|
|
|
|
|
|
|
params.x = x / width;
|
|
|
|
params.y = 1.0f - y / height;
|
|
|
|
params.scale = scale;
|
|
|
|
params.drop_mod = 0.0f;
|
|
|
|
params.drop_x = 0.0f;
|
|
|
|
params.drop_y = 0.0f;
|
|
|
|
params.color = color;
|
|
|
|
params.full_screen = true;
|
|
|
|
params.text_align = text_align;
|
|
|
|
|
|
|
|
if (shadows_enable)
|
|
|
|
{
|
|
|
|
params.drop_x = shadow_offset;
|
|
|
|
params.drop_y = -shadow_offset;
|
|
|
|
params.drop_alpha = 0.35f;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (video_st->poke && video_st->poke->set_osd_msg)
|
|
|
|
video_st->poke->set_osd_msg(video_st->data,
|
|
|
|
text, ¶ms, (void*)font);
|
|
|
|
}
|
|
|
|
|
2021-03-25 19:12:34 +00:00
|
|
|
void gfx_display_draw_bg(
|
|
|
|
gfx_display_t *p_disp,
|
|
|
|
gfx_display_ctx_draw_t *draw,
|
2020-03-08 23:34:31 +00:00
|
|
|
void *userdata, bool add_opacity_to_wallpaper,
|
2020-02-17 12:01:14 +00:00
|
|
|
float override_opacity)
|
|
|
|
{
|
|
|
|
static struct video_coords coords;
|
2020-06-07 20:58:06 +00:00
|
|
|
const float *new_vertex = NULL;
|
|
|
|
const float *new_tex_coord = NULL;
|
|
|
|
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
|
2020-03-06 15:06:44 +00:00
|
|
|
if (!dispctx || !draw)
|
2020-02-17 12:01:14 +00:00
|
|
|
return;
|
|
|
|
|
2020-09-30 16:56:46 +00:00
|
|
|
if (draw->vertex)
|
|
|
|
new_vertex = draw->vertex;
|
|
|
|
else if (dispctx->get_default_vertices)
|
|
|
|
new_vertex = dispctx->get_default_vertices();
|
|
|
|
|
|
|
|
if (draw->tex_coord)
|
|
|
|
new_tex_coord = draw->tex_coord;
|
|
|
|
else if (dispctx->get_default_tex_coords)
|
|
|
|
new_tex_coord = dispctx->get_default_tex_coords();
|
|
|
|
|
|
|
|
coords.vertices = (unsigned)draw->vertex_count;
|
|
|
|
coords.vertex = new_vertex;
|
|
|
|
coords.tex_coord = new_tex_coord;
|
|
|
|
coords.lut_tex_coord = new_tex_coord;
|
|
|
|
coords.color = (const float*)draw->color;
|
|
|
|
|
|
|
|
draw->coords = &coords;
|
|
|
|
draw->scale_factor = 1.0f;
|
|
|
|
draw->rotation = 0.0f;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
if (draw->texture)
|
2020-09-30 16:56:46 +00:00
|
|
|
add_opacity_to_wallpaper = true;
|
2020-09-30 16:52:22 +00:00
|
|
|
else
|
2021-09-13 17:55:53 +00:00
|
|
|
draw->texture = gfx_white_texture;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
if (add_opacity_to_wallpaper)
|
|
|
|
gfx_display_set_alpha(draw->color, override_opacity);
|
|
|
|
|
2020-10-01 16:34:01 +00:00
|
|
|
if (dispctx->get_default_mvp)
|
2020-03-06 15:06:44 +00:00
|
|
|
draw->matrix_data = (math_matrix_4x4*)dispctx->get_default_mvp(
|
2020-03-08 23:08:18 +00:00
|
|
|
userdata);
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gfx_display_draw_quad(
|
2021-03-25 19:12:34 +00:00
|
|
|
gfx_display_t *p_disp,
|
2020-03-08 22:56:22 +00:00
|
|
|
void *data,
|
|
|
|
unsigned video_width,
|
|
|
|
unsigned video_height,
|
2021-08-26 16:42:43 +00:00
|
|
|
int x, int y, unsigned w, unsigned h,
|
|
|
|
unsigned width, unsigned height,
|
2021-08-22 15:57:21 +00:00
|
|
|
float *color,
|
|
|
|
uintptr_t *texture)
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
2020-10-02 12:07:01 +00:00
|
|
|
gfx_display_ctx_draw_t draw;
|
|
|
|
struct video_coords coords;
|
2020-09-22 01:53:10 +00:00
|
|
|
gfx_display_ctx_driver_t
|
|
|
|
*dispctx = p_disp->dispctx;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2020-10-02 12:07:01 +00:00
|
|
|
if (w == 0 || h == 0)
|
|
|
|
return;
|
|
|
|
if (!dispctx)
|
|
|
|
return;
|
2020-09-22 01:53:10 +00:00
|
|
|
|
2020-10-02 12:07:01 +00:00
|
|
|
coords.vertices = 4;
|
|
|
|
coords.vertex = NULL;
|
|
|
|
coords.tex_coord = NULL;
|
|
|
|
coords.lut_tex_coord = NULL;
|
|
|
|
coords.color = color;
|
|
|
|
|
|
|
|
draw.x = x;
|
|
|
|
draw.y = (int)height - y - (int)h;
|
|
|
|
draw.width = w;
|
|
|
|
draw.height = h;
|
|
|
|
draw.coords = &coords;
|
|
|
|
draw.matrix_data = NULL;
|
2021-09-13 17:55:53 +00:00
|
|
|
draw.texture = (texture != 0)
|
|
|
|
? *texture
|
|
|
|
: gfx_white_texture;
|
2020-10-02 12:07:01 +00:00
|
|
|
draw.prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP;
|
|
|
|
draw.pipeline_id = 0;
|
|
|
|
draw.scale_factor = 1.0f;
|
|
|
|
draw.rotation = 0.0f;
|
|
|
|
|
|
|
|
if (dispctx->blend_begin)
|
|
|
|
dispctx->blend_begin(data);
|
|
|
|
if (dispctx->draw)
|
|
|
|
dispctx->draw(&draw, data, video_width, video_height);
|
|
|
|
if (dispctx->blend_end)
|
|
|
|
dispctx->blend_end(data);
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the texture split into 9 sections, without scaling the corners.
|
|
|
|
* The middle sections will only scale in the X axis, and the side
|
|
|
|
* sections will only scale in the Y axis. */
|
|
|
|
void gfx_display_draw_texture_slice(
|
2021-03-25 19:12:34 +00:00
|
|
|
gfx_display_t *p_disp,
|
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,
|
|
|
|
unsigned new_w, unsigned new_h,
|
|
|
|
unsigned width, unsigned height,
|
2021-09-21 19:38:07 +00:00
|
|
|
float *color, unsigned offset, float scale_factor, uintptr_t texture,
|
|
|
|
math_matrix_4x4 *mymat
|
|
|
|
)
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
|
|
|
gfx_display_ctx_draw_t draw;
|
|
|
|
struct video_coords coords;
|
2020-09-22 01:53:10 +00:00
|
|
|
gfx_display_ctx_driver_t
|
|
|
|
*dispctx = p_disp->dispctx;
|
2020-02-17 12:01:14 +00:00
|
|
|
float V_BL[2], V_BR[2], V_TL[2], V_TR[2], T_BL[2], T_BR[2], T_TL[2], T_TR[2];
|
2020-03-26 11:38:30 +00:00
|
|
|
/* To prevent visible seams between the corners and
|
|
|
|
* middle segments of the sliced texture, the texture
|
|
|
|
* must be scaled such that its effective size (before
|
|
|
|
* expansion of the middle segments) is no greater than
|
|
|
|
* the requested display size.
|
|
|
|
* > This is consequence of the way textures are rendered
|
|
|
|
* in hardware...
|
|
|
|
* > Whenever an image is scaled, the colours at the
|
|
|
|
* transparent edges get interpolated, which means
|
|
|
|
* the colours of the transparent pixels themselves bleed
|
|
|
|
* into the visible area.
|
|
|
|
* > This effectively 'blurs' anything that gets scaled
|
|
|
|
* [SIDE NOTE: this causes additional issues if the transparent
|
|
|
|
* pixels have the wrong colour - i.e. if they are black,
|
|
|
|
* every edge gets a nasty dark border...]
|
|
|
|
* > This burring is a problem because (by design) the corners
|
|
|
|
* of the sliced texture are drawn at native resolution,
|
|
|
|
* whereas the middle segments are stretched to fit the
|
|
|
|
* requested dimensions. Consequently, the corners are sharp
|
|
|
|
* while the middle segments are blurred.
|
|
|
|
* > When *upscaling* the middle segments (i.e. display size
|
|
|
|
* greater than texture size), the visible effects of this
|
|
|
|
* are mostly imperceptible.
|
|
|
|
* > When *downscaling* them, however, the interpolation effects
|
|
|
|
* completely dominate the output image - creating an ugly
|
|
|
|
* transition between the corners and middle parts.
|
|
|
|
* > Since this is a property of hardware rendering, it is not
|
|
|
|
* practical to fix this 'properly'...
|
|
|
|
* > However: An effective workaround is to force downscaling of
|
|
|
|
* the entire texture (including corners) whenever the
|
|
|
|
* requested display size is less than the texture dimensions.
|
|
|
|
* > This blurs the corners enough that the corner/middle
|
|
|
|
* transitions are essentially invisible. */
|
|
|
|
float max_scale_w = (float)new_w / (float)w;
|
|
|
|
float max_scale_h = (float)new_h / (float)h;
|
|
|
|
/* Find the minimum of scale_factor, max_scale_w, max_scale_h */
|
|
|
|
float slice_scale = (scale_factor < max_scale_w) ?
|
|
|
|
(scale_factor < max_scale_h) ? scale_factor : max_scale_h :
|
|
|
|
(max_scale_w < max_scale_h) ? max_scale_w : max_scale_h;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2020-02-18 12:04:12 +00:00
|
|
|
/* need space for the coordinates of two triangles in a strip,
|
|
|
|
* so 8 vertices */
|
2020-08-21 08:03:32 +00:00
|
|
|
float tex_coord[8];
|
|
|
|
float vert_coord[8];
|
2020-10-01 10:26:49 +00:00
|
|
|
static float colors[16] = {
|
|
|
|
1.0f, 1.0f, 1.0f, 1.0f,
|
|
|
|
1.0f, 1.0f, 1.0f, 1.0f,
|
|
|
|
1.0f, 1.0f, 1.0f, 1.0f,
|
|
|
|
1.0f, 1.0f, 1.0f, 1.0f
|
|
|
|
};
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
/* normalized width/height of the amount to offset from the corners,
|
|
|
|
* for both the vertex and texture coordinates */
|
2020-03-26 11:38:30 +00:00
|
|
|
float vert_woff = (offset * slice_scale) / (float)width;
|
|
|
|
float vert_hoff = (offset * slice_scale) / (float)height;
|
2020-02-17 12:01:14 +00:00
|
|
|
float tex_woff = offset / (float)w;
|
|
|
|
float tex_hoff = offset / (float)h;
|
|
|
|
|
|
|
|
/* the width/height of the middle sections of both the scaled and original image */
|
2020-03-26 11:38:30 +00:00
|
|
|
float vert_scaled_mid_width = (new_w - (offset * slice_scale * 2))
|
2020-02-18 12:04:12 +00:00
|
|
|
/ (float)width;
|
2020-03-26 11:38:30 +00:00
|
|
|
float vert_scaled_mid_height = (new_h - (offset * slice_scale * 2))
|
2020-02-18 12:04:12 +00:00
|
|
|
/ (float)height;
|
2020-02-17 12:01:14 +00:00
|
|
|
float tex_mid_width = (w - (offset * 2)) / (float)w;
|
|
|
|
float tex_mid_height = (h - (offset * 2)) / (float)h;
|
|
|
|
|
|
|
|
/* normalized coordinates for the start position of the image */
|
|
|
|
float norm_x = x / (float)width;
|
|
|
|
float norm_y = (height - y) / (float)height;
|
|
|
|
|
2020-10-02 12:07:01 +00:00
|
|
|
if (width == 0 || height == 0)
|
|
|
|
return;
|
|
|
|
if (!dispctx || !dispctx->draw)
|
|
|
|
return;
|
|
|
|
|
2020-02-17 12:01:14 +00:00
|
|
|
/* the four vertices of the top-left corner of the image,
|
|
|
|
* used as a starting point for all the other sections */
|
|
|
|
V_BL[0] = norm_x;
|
|
|
|
V_BL[1] = norm_y;
|
|
|
|
V_BR[0] = norm_x + vert_woff;
|
|
|
|
V_BR[1] = norm_y;
|
|
|
|
V_TL[0] = norm_x;
|
|
|
|
V_TL[1] = norm_y + vert_hoff;
|
|
|
|
V_TR[0] = norm_x + vert_woff;
|
|
|
|
V_TR[1] = norm_y + vert_hoff;
|
|
|
|
T_BL[0] = 0.0f;
|
|
|
|
T_BL[1] = tex_hoff;
|
|
|
|
T_BR[0] = tex_woff;
|
|
|
|
T_BR[1] = tex_hoff;
|
|
|
|
T_TL[0] = 0.0f;
|
|
|
|
T_TL[1] = 0.0f;
|
|
|
|
T_TR[0] = tex_woff;
|
|
|
|
T_TR[1] = 0.0f;
|
|
|
|
|
|
|
|
coords.vertices = 4;
|
|
|
|
coords.vertex = vert_coord;
|
|
|
|
coords.tex_coord = tex_coord;
|
|
|
|
coords.lut_tex_coord = NULL;
|
|
|
|
draw.width = width;
|
|
|
|
draw.height = height;
|
|
|
|
draw.coords = &coords;
|
2021-09-21 19:38:07 +00:00
|
|
|
draw.matrix_data = mymat;
|
2020-02-17 12:01:14 +00:00
|
|
|
draw.prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP;
|
2020-08-14 13:58:43 +00:00
|
|
|
draw.pipeline_id = 0;
|
2020-02-17 12:01:14 +00:00
|
|
|
coords.color = (const float*)(color == NULL ? colors : color);
|
|
|
|
|
|
|
|
draw.texture = texture;
|
|
|
|
draw.x = 0;
|
|
|
|
draw.y = 0;
|
|
|
|
|
|
|
|
/* vertex coords are specfied bottom-up in this order: BL BR TL TR */
|
|
|
|
/* texture coords are specfied top-down in this order: BL BR TL TR */
|
|
|
|
|
|
|
|
/* If someone wants to change this to not draw several times, the
|
|
|
|
* coordinates will need to be modified because of the triangle strip usage. */
|
|
|
|
|
|
|
|
/* top-left corner */
|
|
|
|
vert_coord[0] = V_BL[0];
|
|
|
|
vert_coord[1] = V_BL[1];
|
|
|
|
vert_coord[2] = V_BR[0];
|
|
|
|
vert_coord[3] = V_BR[1];
|
|
|
|
vert_coord[4] = V_TL[0];
|
|
|
|
vert_coord[5] = V_TL[1];
|
|
|
|
vert_coord[6] = V_TR[0];
|
|
|
|
vert_coord[7] = V_TR[1];
|
|
|
|
|
|
|
|
tex_coord[0] = T_BL[0];
|
|
|
|
tex_coord[1] = T_BL[1];
|
|
|
|
tex_coord[2] = T_BR[0];
|
|
|
|
tex_coord[3] = T_BR[1];
|
|
|
|
tex_coord[4] = T_TL[0];
|
|
|
|
tex_coord[5] = T_TL[1];
|
|
|
|
tex_coord[6] = T_TR[0];
|
|
|
|
tex_coord[7] = T_TR[1];
|
|
|
|
|
2020-10-02 12:07:01 +00:00
|
|
|
dispctx->draw(&draw, userdata, video_width, video_height);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
/* top-middle section */
|
|
|
|
vert_coord[0] = V_BL[0] + vert_woff;
|
|
|
|
vert_coord[1] = V_BL[1];
|
|
|
|
vert_coord[2] = V_BR[0] + vert_scaled_mid_width;
|
|
|
|
vert_coord[3] = V_BR[1];
|
|
|
|
vert_coord[4] = V_TL[0] + vert_woff;
|
|
|
|
vert_coord[5] = V_TL[1];
|
|
|
|
vert_coord[6] = V_TR[0] + vert_scaled_mid_width;
|
|
|
|
vert_coord[7] = V_TR[1];
|
|
|
|
|
|
|
|
tex_coord[0] = T_BL[0] + tex_woff;
|
|
|
|
tex_coord[1] = T_BL[1];
|
|
|
|
tex_coord[2] = T_BR[0] + tex_mid_width;
|
|
|
|
tex_coord[3] = T_BR[1];
|
|
|
|
tex_coord[4] = T_TL[0] + tex_woff;
|
|
|
|
tex_coord[5] = T_TL[1];
|
|
|
|
tex_coord[6] = T_TR[0] + tex_mid_width;
|
|
|
|
tex_coord[7] = T_TR[1];
|
|
|
|
|
2020-10-02 12:07:01 +00:00
|
|
|
dispctx->draw(&draw, userdata, video_width, video_height);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
/* top-right corner */
|
|
|
|
vert_coord[0] = V_BL[0] + vert_woff + vert_scaled_mid_width;
|
|
|
|
vert_coord[1] = V_BL[1];
|
|
|
|
vert_coord[2] = V_BR[0] + vert_scaled_mid_width + vert_woff;
|
|
|
|
vert_coord[3] = V_BR[1];
|
|
|
|
vert_coord[4] = V_TL[0] + vert_woff + vert_scaled_mid_width;
|
|
|
|
vert_coord[5] = V_TL[1];
|
|
|
|
vert_coord[6] = V_TR[0] + vert_scaled_mid_width + vert_woff;
|
|
|
|
vert_coord[7] = V_TR[1];
|
|
|
|
|
|
|
|
tex_coord[0] = T_BL[0] + tex_woff + tex_mid_width;
|
|
|
|
tex_coord[1] = T_BL[1];
|
|
|
|
tex_coord[2] = T_BR[0] + tex_mid_width + tex_woff;
|
|
|
|
tex_coord[3] = T_BR[1];
|
|
|
|
tex_coord[4] = T_TL[0] + tex_woff + tex_mid_width;
|
|
|
|
tex_coord[5] = T_TL[1];
|
|
|
|
tex_coord[6] = T_TR[0] + tex_mid_width + tex_woff;
|
|
|
|
tex_coord[7] = T_TR[1];
|
|
|
|
|
2020-10-02 12:07:01 +00:00
|
|
|
dispctx->draw(&draw, userdata, video_width, video_height);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
/* middle-left section */
|
|
|
|
vert_coord[0] = V_BL[0];
|
|
|
|
vert_coord[1] = V_BL[1] - vert_scaled_mid_height;
|
|
|
|
vert_coord[2] = V_BR[0];
|
|
|
|
vert_coord[3] = V_BR[1] - vert_scaled_mid_height;
|
|
|
|
vert_coord[4] = V_TL[0];
|
|
|
|
vert_coord[5] = V_TL[1] - vert_hoff;
|
|
|
|
vert_coord[6] = V_TR[0];
|
|
|
|
vert_coord[7] = V_TR[1] - vert_hoff;
|
|
|
|
|
|
|
|
tex_coord[0] = T_BL[0];
|
|
|
|
tex_coord[1] = T_BL[1] + tex_mid_height;
|
|
|
|
tex_coord[2] = T_BR[0];
|
|
|
|
tex_coord[3] = T_BR[1] + tex_mid_height;
|
|
|
|
tex_coord[4] = T_TL[0];
|
|
|
|
tex_coord[5] = T_TL[1] + tex_hoff;
|
|
|
|
tex_coord[6] = T_TR[0];
|
|
|
|
tex_coord[7] = T_TR[1] + tex_hoff;
|
|
|
|
|
2020-10-02 12:07:01 +00:00
|
|
|
dispctx->draw(&draw, userdata, video_width, video_height);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
/* center section */
|
|
|
|
vert_coord[0] = V_BL[0] + vert_woff;
|
|
|
|
vert_coord[1] = V_BL[1] - vert_scaled_mid_height;
|
|
|
|
vert_coord[2] = V_BR[0] + vert_scaled_mid_width;
|
|
|
|
vert_coord[3] = V_BR[1] - vert_scaled_mid_height;
|
|
|
|
vert_coord[4] = V_TL[0] + vert_woff;
|
|
|
|
vert_coord[5] = V_TL[1] - vert_hoff;
|
|
|
|
vert_coord[6] = V_TR[0] + vert_scaled_mid_width;
|
|
|
|
vert_coord[7] = V_TR[1] - vert_hoff;
|
|
|
|
|
|
|
|
tex_coord[0] = T_BL[0] + tex_woff;
|
|
|
|
tex_coord[1] = T_BL[1] + tex_mid_height;
|
|
|
|
tex_coord[2] = T_BR[0] + tex_mid_width;
|
|
|
|
tex_coord[3] = T_BR[1] + tex_mid_height;
|
|
|
|
tex_coord[4] = T_TL[0] + tex_woff;
|
|
|
|
tex_coord[5] = T_TL[1] + tex_hoff;
|
|
|
|
tex_coord[6] = T_TR[0] + tex_mid_width;
|
|
|
|
tex_coord[7] = T_TR[1] + tex_hoff;
|
|
|
|
|
2020-10-02 12:07:01 +00:00
|
|
|
dispctx->draw(&draw, userdata, video_width, video_height);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
/* middle-right section */
|
|
|
|
vert_coord[0] = V_BL[0] + vert_woff + vert_scaled_mid_width;
|
|
|
|
vert_coord[1] = V_BL[1] - vert_scaled_mid_height;
|
|
|
|
vert_coord[2] = V_BR[0] + vert_woff + vert_scaled_mid_width;
|
|
|
|
vert_coord[3] = V_BR[1] - vert_scaled_mid_height;
|
|
|
|
vert_coord[4] = V_TL[0] + vert_woff + vert_scaled_mid_width;
|
|
|
|
vert_coord[5] = V_TL[1] - vert_hoff;
|
|
|
|
vert_coord[6] = V_TR[0] + vert_woff + vert_scaled_mid_width;
|
|
|
|
vert_coord[7] = V_TR[1] - vert_hoff;
|
|
|
|
|
|
|
|
tex_coord[0] = T_BL[0] + tex_woff + tex_mid_width;
|
|
|
|
tex_coord[1] = T_BL[1] + tex_mid_height;
|
|
|
|
tex_coord[2] = T_BR[0] + tex_woff + tex_mid_width;
|
|
|
|
tex_coord[3] = T_BR[1] + tex_mid_height;
|
|
|
|
tex_coord[4] = T_TL[0] + tex_woff + tex_mid_width;
|
|
|
|
tex_coord[5] = T_TL[1] + tex_hoff;
|
|
|
|
tex_coord[6] = T_TR[0] + tex_woff + tex_mid_width;
|
|
|
|
tex_coord[7] = T_TR[1] + tex_hoff;
|
|
|
|
|
2020-10-02 12:07:01 +00:00
|
|
|
dispctx->draw(&draw, userdata, video_width, video_height);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
/* bottom-left corner */
|
|
|
|
vert_coord[0] = V_BL[0];
|
|
|
|
vert_coord[1] = V_BL[1] - vert_hoff - vert_scaled_mid_height;
|
|
|
|
vert_coord[2] = V_BR[0];
|
|
|
|
vert_coord[3] = V_BR[1] - vert_hoff - vert_scaled_mid_height;
|
|
|
|
vert_coord[4] = V_TL[0];
|
|
|
|
vert_coord[5] = V_TL[1] - vert_hoff - vert_scaled_mid_height;
|
|
|
|
vert_coord[6] = V_TR[0];
|
|
|
|
vert_coord[7] = V_TR[1] - vert_hoff - vert_scaled_mid_height;
|
|
|
|
|
|
|
|
tex_coord[0] = T_BL[0];
|
|
|
|
tex_coord[1] = T_BL[1] + tex_hoff + tex_mid_height;
|
|
|
|
tex_coord[2] = T_BR[0];
|
|
|
|
tex_coord[3] = T_BR[1] + tex_hoff + tex_mid_height;
|
|
|
|
tex_coord[4] = T_TL[0];
|
|
|
|
tex_coord[5] = T_TL[1] + tex_hoff + tex_mid_height;
|
|
|
|
tex_coord[6] = T_TR[0];
|
|
|
|
tex_coord[7] = T_TR[1] + tex_hoff + tex_mid_height;
|
|
|
|
|
2020-10-02 12:07:01 +00:00
|
|
|
dispctx->draw(&draw, userdata, video_width, video_height);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
/* bottom-middle section */
|
|
|
|
vert_coord[0] = V_BL[0] + vert_woff;
|
|
|
|
vert_coord[1] = V_BL[1] - vert_hoff - vert_scaled_mid_height;
|
|
|
|
vert_coord[2] = V_BR[0] + vert_scaled_mid_width;
|
|
|
|
vert_coord[3] = V_BR[1] - vert_hoff - vert_scaled_mid_height;
|
|
|
|
vert_coord[4] = V_TL[0] + vert_woff;
|
|
|
|
vert_coord[5] = V_TL[1] - vert_hoff - vert_scaled_mid_height;
|
|
|
|
vert_coord[6] = V_TR[0] + vert_scaled_mid_width;
|
|
|
|
vert_coord[7] = V_TR[1] - vert_hoff - vert_scaled_mid_height;
|
|
|
|
|
|
|
|
tex_coord[0] = T_BL[0] + tex_woff;
|
|
|
|
tex_coord[1] = T_BL[1] + tex_hoff + tex_mid_height;
|
|
|
|
tex_coord[2] = T_BR[0] + tex_mid_width;
|
|
|
|
tex_coord[3] = T_BR[1] + tex_hoff + tex_mid_height;
|
|
|
|
tex_coord[4] = T_TL[0] + tex_woff;
|
|
|
|
tex_coord[5] = T_TL[1] + tex_hoff + tex_mid_height;
|
|
|
|
tex_coord[6] = T_TR[0] + tex_mid_width;
|
|
|
|
tex_coord[7] = T_TR[1] + tex_hoff + tex_mid_height;
|
|
|
|
|
2020-10-02 12:07:01 +00:00
|
|
|
dispctx->draw(&draw, userdata, video_width, video_height);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
/* bottom-right corner */
|
|
|
|
vert_coord[0] = V_BL[0] + vert_woff + vert_scaled_mid_width;
|
|
|
|
vert_coord[1] = V_BL[1] - vert_hoff - vert_scaled_mid_height;
|
|
|
|
vert_coord[2] = V_BR[0] + vert_scaled_mid_width + vert_woff;
|
|
|
|
vert_coord[3] = V_BR[1] - vert_hoff - vert_scaled_mid_height;
|
|
|
|
vert_coord[4] = V_TL[0] + vert_woff + vert_scaled_mid_width;
|
|
|
|
vert_coord[5] = V_TL[1] - vert_hoff - vert_scaled_mid_height;
|
|
|
|
vert_coord[6] = V_TR[0] + vert_scaled_mid_width + vert_woff;
|
|
|
|
vert_coord[7] = V_TR[1] - vert_hoff - vert_scaled_mid_height;
|
|
|
|
|
|
|
|
tex_coord[0] = T_BL[0] + tex_woff + tex_mid_width;
|
|
|
|
tex_coord[1] = T_BL[1] + tex_hoff + tex_mid_height;
|
|
|
|
tex_coord[2] = T_BR[0] + tex_woff + tex_mid_width;
|
|
|
|
tex_coord[3] = T_BR[1] + tex_hoff + tex_mid_height;
|
|
|
|
tex_coord[4] = T_TL[0] + tex_woff + tex_mid_width;
|
|
|
|
tex_coord[5] = T_TL[1] + tex_hoff + tex_mid_height;
|
|
|
|
tex_coord[6] = T_TR[0] + tex_woff + tex_mid_width;
|
|
|
|
tex_coord[7] = T_TR[1] + tex_hoff + tex_mid_height;
|
|
|
|
|
2020-10-02 12:07:01 +00:00
|
|
|
dispctx->draw(&draw, userdata, video_width, video_height);
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
|
2021-03-25 19:12:34 +00:00
|
|
|
void gfx_display_rotate_z(gfx_display_t *p_disp,
|
|
|
|
gfx_display_ctx_rotate_draw_t *draw, void *data)
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
|
|
|
math_matrix_4x4 matrix_rotated, matrix_scaled;
|
2020-06-07 20:58:06 +00:00
|
|
|
math_matrix_4x4 *b = NULL;
|
|
|
|
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
if (
|
|
|
|
!draw ||
|
2020-03-06 15:06:44 +00:00
|
|
|
!dispctx ||
|
|
|
|
!dispctx->get_default_mvp ||
|
|
|
|
dispctx->handles_transform
|
2020-02-17 12:01:14 +00:00
|
|
|
)
|
|
|
|
return;
|
|
|
|
|
2020-03-08 21:33:11 +00:00
|
|
|
b = (math_matrix_4x4*)dispctx->get_default_mvp(data);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
if (!b)
|
|
|
|
return;
|
|
|
|
|
|
|
|
matrix_4x4_rotate_z(matrix_rotated, draw->rotation);
|
|
|
|
matrix_4x4_multiply(*draw->matrix, matrix_rotated, *b);
|
|
|
|
|
|
|
|
if (!draw->scale_enable)
|
|
|
|
return;
|
|
|
|
|
|
|
|
matrix_4x4_scale(matrix_scaled,
|
|
|
|
draw->scale_x, draw->scale_y, draw->scale_z);
|
|
|
|
matrix_4x4_multiply(*draw->matrix, matrix_scaled, *draw->matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Draw a hardware cursor on top of the screen for the mouse.
|
|
|
|
*/
|
|
|
|
void gfx_display_draw_cursor(
|
2021-03-25 19:12:34 +00:00
|
|
|
gfx_display_t *p_disp,
|
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)
|
|
|
|
{
|
|
|
|
gfx_display_ctx_draw_t draw;
|
|
|
|
struct video_coords coords;
|
2020-06-07 20:58:06 +00:00
|
|
|
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
|
2020-03-08 23:08:18 +00:00
|
|
|
|
2020-10-02 12:16:12 +00:00
|
|
|
if (!dispctx)
|
|
|
|
return;
|
|
|
|
|
2020-02-17 12:01:14 +00:00
|
|
|
coords.vertices = 4;
|
|
|
|
coords.vertex = NULL;
|
|
|
|
coords.tex_coord = NULL;
|
|
|
|
coords.lut_tex_coord = NULL;
|
|
|
|
coords.color = (const float*)color;
|
|
|
|
|
|
|
|
draw.x = x - (cursor_size / 2);
|
|
|
|
draw.y = (int)height - y - (cursor_size / 2);
|
|
|
|
draw.width = cursor_size;
|
|
|
|
draw.height = cursor_size;
|
|
|
|
draw.coords = &coords;
|
|
|
|
draw.matrix_data = NULL;
|
|
|
|
draw.texture = texture;
|
|
|
|
draw.prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP;
|
2020-08-14 13:58:43 +00:00
|
|
|
draw.pipeline_id = 0;
|
2021-06-22 03:43:31 +00:00
|
|
|
draw.scale_factor = 1.0f;
|
|
|
|
draw.rotation = 0.0f;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2020-10-02 12:16:12 +00:00
|
|
|
if (dispctx->blend_begin)
|
|
|
|
dispctx->blend_begin(userdata);
|
|
|
|
if (dispctx->draw)
|
|
|
|
dispctx->draw(&draw, userdata, video_width, video_height);
|
|
|
|
if (dispctx->blend_end)
|
|
|
|
dispctx->blend_end(userdata);
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup: Initializes the font associated
|
|
|
|
* to the menu driver */
|
|
|
|
font_data_t *gfx_display_font(
|
2021-03-25 19:12:34 +00:00
|
|
|
gfx_display_t *p_disp,
|
2020-02-17 12:01:14 +00:00
|
|
|
enum application_special_type type,
|
|
|
|
float menu_font_size,
|
|
|
|
bool is_threaded)
|
|
|
|
{
|
|
|
|
char fontpath[PATH_MAX_LENGTH];
|
|
|
|
|
|
|
|
fontpath[0] = '\0';
|
|
|
|
|
|
|
|
fill_pathname_application_special(
|
|
|
|
fontpath, sizeof(fontpath), type);
|
|
|
|
|
2021-03-25 19:12:34 +00:00
|
|
|
return gfx_display_font_file(p_disp, fontpath, menu_font_size, is_threaded);
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
int ptr_width = width / 11;
|
|
|
|
int ptr_height = height / 10;
|
|
|
|
|
|
|
|
if (ptr_width >= ptr_height)
|
|
|
|
ptr_width = ptr_height;
|
|
|
|
|
|
|
|
for (i = 0; i < 44; i++)
|
|
|
|
{
|
|
|
|
int line_y = (i / 11)*height/10.0;
|
|
|
|
int ptr_x = width/2.0 - (11*ptr_width)/2.0 + (i % 11) * ptr_width;
|
|
|
|
int ptr_y = height/2.0 + ptr_height*1.5 + line_y - ptr_height;
|
|
|
|
|
|
|
|
if (x > ptr_x && x < ptr_x + ptr_width
|
|
|
|
&& y > ptr_y && y < ptr_y + ptr_height)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-03-06 15:06:44 +00:00
|
|
|
/* Get the display framebuffer's size dimensions. */
|
2020-02-17 12:01:14 +00:00
|
|
|
void gfx_display_get_fb_size(unsigned *fb_width,
|
|
|
|
unsigned *fb_height, size_t *fb_pitch)
|
|
|
|
{
|
2021-09-30 15:14:26 +00:00
|
|
|
gfx_display_t *p_disp = &dispgfx_st;
|
2020-03-06 15:33:34 +00:00
|
|
|
*fb_width = p_disp->framebuf_width;
|
|
|
|
*fb_height = p_disp->framebuf_height;
|
|
|
|
*fb_pitch = p_disp->framebuf_pitch;
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
|
2021-08-26 16:42:43 +00:00
|
|
|
/* Set the display framebuffer's width. */
|
|
|
|
void gfx_display_set_width(unsigned width)
|
|
|
|
{
|
2021-09-30 15:14:26 +00:00
|
|
|
gfx_display_t *p_disp = &dispgfx_st;
|
2021-08-26 16:42:43 +00:00
|
|
|
p_disp->framebuf_width = width;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the display framebuffer's height. */
|
|
|
|
void gfx_display_set_height(unsigned height)
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
2021-09-30 15:14:26 +00:00
|
|
|
gfx_display_t *p_disp = &dispgfx_st;
|
2020-03-06 15:33:34 +00:00
|
|
|
p_disp->framebuf_height = height;
|
2021-08-26 16:42:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gfx_display_set_framebuffer_pitch(size_t pitch)
|
|
|
|
{
|
2021-09-30 15:14:26 +00:00
|
|
|
gfx_display_t *p_disp = &dispgfx_st;
|
2021-08-26 16:42:43 +00:00
|
|
|
p_disp->framebuf_pitch = pitch;
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gfx_display_draw_keyboard(
|
2021-03-25 19:12:34 +00:00
|
|
|
gfx_display_t *p_disp,
|
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)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
int ptr_width, ptr_height;
|
2020-09-23 07:32:42 +00:00
|
|
|
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2020-09-01 02:15:20 +00:00
|
|
|
static float white[16] = {
|
2020-02-17 12:01:14 +00:00
|
|
|
1.00, 1.00, 1.00, 1.00,
|
|
|
|
1.00, 1.00, 1.00, 1.00,
|
|
|
|
1.00, 1.00, 1.00, 1.00,
|
|
|
|
1.00, 1.00, 1.00, 1.00,
|
|
|
|
};
|
2020-09-11 11:48:23 +00:00
|
|
|
static float osk_dark[16] = {
|
|
|
|
0.00, 0.00, 0.00, 0.85,
|
|
|
|
0.00, 0.00, 0.00, 0.85,
|
|
|
|
0.00, 0.00, 0.00, 0.85,
|
|
|
|
0.00, 0.00, 0.00, 0.85,
|
|
|
|
};
|
2020-09-24 07:07:47 +00:00
|
|
|
math_matrix_4x4 mymat;
|
|
|
|
gfx_display_ctx_rotate_draw_t rotate_draw;
|
|
|
|
rotate_draw.matrix = &mymat;
|
|
|
|
rotate_draw.rotation = 0.0;
|
|
|
|
rotate_draw.scale_x = 1.0;
|
|
|
|
rotate_draw.scale_y = 1.0;
|
|
|
|
rotate_draw.scale_z = 1;
|
|
|
|
rotate_draw.scale_enable = true;
|
|
|
|
|
2022-03-15 19:18:24 +00:00
|
|
|
#ifdef HAVE_MIST
|
|
|
|
if(steam_has_osk_open()) return;
|
|
|
|
#endif
|
|
|
|
|
2020-02-17 12:01:14 +00:00
|
|
|
gfx_display_draw_quad(
|
2021-03-25 19:12:34 +00:00
|
|
|
p_disp,
|
2020-03-08 22:56:22 +00:00
|
|
|
userdata,
|
2020-03-09 00:26:43 +00:00
|
|
|
video_width,
|
|
|
|
video_height,
|
|
|
|
0,
|
|
|
|
video_height / 2.0,
|
|
|
|
video_width,
|
|
|
|
video_height / 2.0,
|
|
|
|
video_width,
|
|
|
|
video_height,
|
2021-08-22 15:57:21 +00:00
|
|
|
&osk_dark[0],
|
|
|
|
NULL);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2020-03-09 00:26:43 +00:00
|
|
|
ptr_width = video_width / 11;
|
|
|
|
ptr_height = video_height / 10;
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
if (ptr_width >= ptr_height)
|
|
|
|
ptr_width = ptr_height;
|
|
|
|
|
2021-03-25 19:12:34 +00:00
|
|
|
gfx_display_rotate_z(p_disp, &rotate_draw, userdata);
|
2020-09-24 07:07:47 +00:00
|
|
|
|
2020-02-17 12:01:14 +00:00
|
|
|
for (i = 0; i < 44; i++)
|
|
|
|
{
|
2020-03-09 00:26:43 +00:00
|
|
|
int line_y = (i / 11) * video_height / 10.0;
|
2020-02-17 12:01:14 +00:00
|
|
|
unsigned color = 0xffffffff;
|
|
|
|
|
|
|
|
if (i == id)
|
|
|
|
{
|
2020-09-23 07:32:42 +00:00
|
|
|
if (dispctx && dispctx->blend_begin)
|
|
|
|
dispctx->blend_begin(userdata);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2021-08-22 15:57:21 +00:00
|
|
|
gfx_display_draw_quad(
|
2021-08-22 15:17:09 +00:00
|
|
|
p_disp,
|
|
|
|
userdata,
|
|
|
|
video_width,
|
|
|
|
video_height,
|
|
|
|
video_width / 2.0 - (11 * ptr_width) / 2.0 + (i % 11) * ptr_width,
|
|
|
|
video_height / 2.0 + ptr_height * 1.5 + line_y - ptr_height,
|
|
|
|
ptr_width, ptr_height,
|
|
|
|
video_width,
|
|
|
|
video_height,
|
|
|
|
&white[0],
|
|
|
|
&hover_texture);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2020-09-23 07:32:42 +00:00
|
|
|
if (dispctx && dispctx->blend_end)
|
|
|
|
dispctx->blend_end(userdata);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
color = text_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx_display_draw_text(font, grid[i],
|
2020-03-09 00:26:43 +00:00
|
|
|
video_width/2.0 - (11*ptr_width)/2.0 + (i % 11)
|
2020-02-17 12:01:14 +00:00
|
|
|
* ptr_width + ptr_width/2.0,
|
2020-03-09 00:26:43 +00:00
|
|
|
video_height / 2.0 + ptr_height + line_y + font->size / 3,
|
|
|
|
video_width,
|
|
|
|
video_height,
|
|
|
|
color,
|
|
|
|
TEXT_ALIGN_CENTER,
|
|
|
|
1.0f,
|
2020-02-17 12:01:14 +00:00
|
|
|
false, 0, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-28 01:30:22 +00:00
|
|
|
/* NOTE: Reads image from file */
|
2020-02-17 12:01:14 +00:00
|
|
|
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)
|
|
|
|
{
|
2020-09-04 01:32:25 +00:00
|
|
|
char texpath[PATH_MAX_LENGTH];
|
2020-02-17 12:01:14 +00:00
|
|
|
struct texture_image ti;
|
2020-09-04 01:32:25 +00:00
|
|
|
|
|
|
|
texpath[0] = '\0';
|
2020-02-17 12:01:14 +00:00
|
|
|
|
|
|
|
ti.width = 0;
|
|
|
|
ti.height = 0;
|
|
|
|
ti.pixels = NULL;
|
|
|
|
ti.supports_rgba = video_driver_supports_rgba();
|
|
|
|
|
|
|
|
if (string_is_empty(texture_path))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
fill_pathname_join(texpath, iconpath, texture_path, sizeof(texpath));
|
|
|
|
|
|
|
|
if (!image_texture_load(&ti, texpath))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (width)
|
|
|
|
*width = ti.width;
|
|
|
|
|
|
|
|
if (height)
|
|
|
|
*height = ti.height;
|
|
|
|
|
|
|
|
video_driver_texture_load(&ti,
|
|
|
|
filter_type, item);
|
|
|
|
image_texture_free(&ti);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Teardown; deinitializes and frees all
|
2020-03-06 15:06:44 +00:00
|
|
|
* fonts associated to the display driver */
|
2020-02-17 12:01:14 +00:00
|
|
|
void gfx_display_font_free(font_data_t *font)
|
|
|
|
{
|
|
|
|
font_driver_free(font);
|
|
|
|
}
|
|
|
|
|
2021-09-13 17:55:53 +00:00
|
|
|
void gfx_display_deinit_white_texture(void)
|
|
|
|
{
|
|
|
|
if (gfx_white_texture)
|
|
|
|
video_driver_texture_unload(&gfx_white_texture);
|
2021-09-13 18:52:57 +00:00
|
|
|
gfx_white_texture = 0;
|
2021-09-13 17:55:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gfx_display_init_white_texture(void)
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
|
|
|
struct texture_image ti;
|
|
|
|
static const uint8_t white_data[] = { 0xff, 0xff, 0xff, 0xff };
|
|
|
|
|
|
|
|
ti.width = 1;
|
|
|
|
ti.height = 1;
|
|
|
|
ti.pixels = (uint32_t*)&white_data;
|
|
|
|
|
|
|
|
video_driver_texture_load(&ti,
|
2021-09-13 17:55:53 +00:00
|
|
|
TEXTURE_FILTER_NEAREST, &gfx_white_texture);
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
|
2021-08-26 16:42:43 +00:00
|
|
|
void gfx_display_free(void)
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
2021-09-30 15:14:26 +00:00
|
|
|
gfx_display_t *p_disp = &dispgfx_st;
|
2020-03-06 15:33:34 +00:00
|
|
|
video_coord_array_free(&p_disp->dispca);
|
2020-02-17 12:01:14 +00:00
|
|
|
|
2020-03-06 15:33:34 +00:00
|
|
|
p_disp->msg_force = false;
|
|
|
|
p_disp->header_height = 0;
|
|
|
|
p_disp->framebuf_width = 0;
|
|
|
|
p_disp->framebuf_height = 0;
|
|
|
|
p_disp->framebuf_pitch = 0;
|
|
|
|
p_disp->has_windowed = false;
|
2020-06-07 20:58:06 +00:00
|
|
|
p_disp->dispctx = NULL;
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
|
2021-08-26 16:42:43 +00:00
|
|
|
void gfx_display_init(void)
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
2021-09-30 15:14:26 +00:00
|
|
|
gfx_display_t *p_disp = &dispgfx_st;
|
2020-06-07 21:01:52 +00:00
|
|
|
video_coord_array_t *p_dispca = &p_disp->dispca;
|
2020-03-06 15:12:24 +00:00
|
|
|
|
2020-03-06 15:33:34 +00:00
|
|
|
p_disp->has_windowed = video_driver_has_windowed();
|
2020-03-06 15:12:24 +00:00
|
|
|
p_dispca->allocated = 0;
|
2020-02-17 12:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool gfx_display_driver_exists(const char *s)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(gfx_display_ctx_drivers); i++)
|
|
|
|
{
|
|
|
|
if (string_is_equal(s, gfx_display_ctx_drivers[i]->ident))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-03-25 19:12:34 +00:00
|
|
|
bool gfx_display_init_first_driver(gfx_display_t *p_disp,
|
|
|
|
bool video_is_threaded)
|
2020-02-17 12:01:14 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; gfx_display_ctx_drivers[i]; i++)
|
|
|
|
{
|
|
|
|
if (!gfx_display_check_compatibility(
|
|
|
|
gfx_display_ctx_drivers[i]->type,
|
|
|
|
video_is_threaded))
|
|
|
|
continue;
|
|
|
|
|
2020-06-08 16:01:15 +00:00
|
|
|
RARCH_LOG("[Display]: Found display driver: \"%s\".\n",
|
2020-02-17 12:01:14 +00:00
|
|
|
gfx_display_ctx_drivers[i]->ident);
|
2020-06-07 20:58:06 +00:00
|
|
|
p_disp->dispctx = gfx_display_ctx_drivers[i];
|
2020-02-17 12:01:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|