This commit is contained in:
twinaphex 2020-02-21 07:34:53 +01:00
parent 391a02fe45
commit 1b0ab1c05f
9 changed files with 204 additions and 159 deletions

View File

@ -118,7 +118,8 @@ int32_t d3d_translate_filter(unsigned type)
case RARCH_FILTER_UNSPEC: case RARCH_FILTER_UNSPEC:
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
if (!settings->bools.video_smooth) bool video_smooth = settings->bools.video_smooth;
if (!video_smooth)
break; break;
} }
/* fall-through */ /* fall-through */

View File

@ -356,31 +356,41 @@
info:(video_frame_info_t *)video_info info:(video_frame_info_t *)video_info
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
if (settings && settings->bools.video_msg_bgcolor_enable) bool msg_bgcolor_enable = settings->bools.video_msg_bgcolor_enable;
if (msg_bgcolor_enable)
{ {
float r, g, b, a;
int msg_width = int msg_width =
font_driver_get_message_width(NULL, msg, (unsigned)strlen(msg), 1.0f); font_driver_get_message_width(NULL, msg, (unsigned)strlen(msg), 1.0f);
float font_size = settings->floats.video_font_size;
unsigned bgcolor_red
= settings->uints.video_msg_bgcolor_red;
unsigned bgcolor_green
= settings->uints.video_msg_bgcolor_green;
unsigned bgcolor_blue
= settings->uints.video_msg_bgcolor_blue;
float bgcolor_opacity = settings->floats.video_msg_bgcolor_opacity;
float x = video_info->font_msg_pos_x; float x = video_info->font_msg_pos_x;
float y = 1.0f - video_info->font_msg_pos_y; float y = 1.0f - video_info->font_msg_pos_y;
float width = msg_width / (float)_viewport->full_width; float width = msg_width / (float)_viewport->full_width;
float height = float height = font_size / (float)_viewport->full_height;
settings->floats.video_font_size / (float)_viewport->full_height;
y -= height;
float x2 = 0.005f; /* extend background around text */ float x2 = 0.005f; /* extend background around text */
float y2 = 0.005f; float y2 = 0.005f;
y -= height;
x -= x2; x -= x2;
y -= y2; y -= y2;
width += x2; width += x2;
height += y2; height += y2;
float r = settings->uints.video_msg_bgcolor_red / 255.0f; r = bgcolor_red / 255.0f;
float g = settings->uints.video_msg_bgcolor_green / 255.0f; g = bgcolor_green / 255.0f;
float b = settings->uints.video_msg_bgcolor_blue / 255.0f; b = bgcolor_blue / 255.0f;
float a = settings->floats.video_msg_bgcolor_opacity; a = bgcolor_opacity;
[_context resetRenderViewport:kFullscreenViewport]; [_context resetRenderViewport:kFullscreenViewport];
[_context drawQuadX:x y:y w:width h:height r:r g:g b:b a:a]; [_context drawQuadX:x y:y w:width h:height r:r g:g b:b a:a];
} }
@ -392,10 +402,10 @@
{ {
video_viewport_t vp = *_viewport; video_viewport_t vp = *_viewport;
video_driver_update_viewport(_viewport, NO, _keepAspect); video_driver_update_viewport(_viewport, NO, _keepAspect);
if (memcmp(&vp, _viewport, sizeof(vp)) != 0) if (memcmp(&vp, _viewport, sizeof(vp)) != 0)
{
_context.viewport = _viewport; _context.viewport = _viewport;
}
[_context begin]; [_context begin];
} }
@ -403,7 +413,7 @@
{ {
id<MTLRenderCommandEncoder> rce = _context.rce; id<MTLRenderCommandEncoder> rce = _context.rce;
// draw back buffer /* draw back buffer */
[rce pushDebugGroup:@"core frame"]; [rce pushDebugGroup:@"core frame"];
[_frameView drawWithContext:_context]; [_frameView drawWithContext:_context];
@ -1184,9 +1194,9 @@ typedef struct MTLALIGN(16)
config_file_t *conf = video_shader_read_preset(path.UTF8String); config_file_t *conf = video_shader_read_preset(path.UTF8String);
struct video_shader *shader = (struct video_shader *)calloc(1, sizeof(*shader)); struct video_shader *shader = (struct video_shader *)calloc(1, sizeof(*shader));
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
NSString *shadersPath = [NSString stringWithFormat:@"%s/", settings->paths.directory_video_shader]; const char *dir_video_shader = settings->paths.directory_video_shader;
NSString *shadersPath = [NSString stringWithFormat:@"%s/", dir_video_shader];
@try @try
{ {
@ -1252,6 +1262,7 @@ typedef struct MTLALIGN(16)
// vertex descriptor // vertex descriptor
@try @try
{ {
NSError *err;
MTLVertexDescriptor *vd = [MTLVertexDescriptor new]; MTLVertexDescriptor *vd = [MTLVertexDescriptor new];
vd.attributes[0].offset = offsetof(VertexSlang, position); vd.attributes[0].offset = offsetof(VertexSlang, position);
vd.attributes[0].format = MTLVertexFormatFloat4; vd.attributes[0].format = MTLVertexFormatFloat4;
@ -1271,7 +1282,7 @@ typedef struct MTLALIGN(16)
ca.pixelFormat = SelectOptimalPixelFormat(glslang_format_to_metal(_engine.pass[i].semantics.format)); ca.pixelFormat = SelectOptimalPixelFormat(glslang_format_to_metal(_engine.pass[i].semantics.format));
// TODO(sgc): confirm we never need blending for render passes /* TODO(sgc): confirm we never need blending for render passes */
ca.blendingEnabled = NO; ca.blendingEnabled = NO;
ca.sourceAlphaBlendFactor = MTLBlendFactorSourceAlpha; ca.sourceAlphaBlendFactor = MTLBlendFactorSourceAlpha;
ca.sourceRGBBlendFactor = MTLBlendFactorSourceAlpha; ca.sourceRGBBlendFactor = MTLBlendFactorSourceAlpha;
@ -1281,7 +1292,6 @@ typedef struct MTLALIGN(16)
psd.sampleCount = 1; psd.sampleCount = 1;
psd.vertexDescriptor = vd; psd.vertexDescriptor = vd;
NSError *err;
id<MTLLibrary> lib = [_context.device newLibraryWithSource:vs_src options:nil error:&err]; id<MTLLibrary> lib = [_context.device newLibraryWithSource:vs_src options:nil error:&err];
if (err != nil) if (err != nil)
{ {
@ -1327,9 +1337,7 @@ typedef struct MTLALIGN(16)
{ {
unsigned int size = _engine.pass[i].semantics.cbuffers[j].size; unsigned int size = _engine.pass[i].semantics.cbuffers[j].size;
if (size == 0) if (size == 0)
{
continue; continue;
}
id<MTLBuffer> buf = [_context.device newBufferWithLength:size options:MTLResourceStorageModeManaged]; id<MTLBuffer> buf = [_context.device newBufferWithLength:size options:MTLResourceStorageModeManaged];
STRUCT_ASSIGN(_engine.pass[i].buffers[j], buf); STRUCT_ASSIGN(_engine.pass[i].buffers[j], buf);
@ -1338,11 +1346,11 @@ typedef struct MTLALIGN(16)
{ {
if (save_msl) if (save_msl)
{ {
NSError *err = nil;
NSString *basePath = [[NSString stringWithUTF8String:shader->pass[i].source.path] stringByDeletingPathExtension]; NSString *basePath = [[NSString stringWithUTF8String:shader->pass[i].source.path] stringByDeletingPathExtension];
RARCH_LOG("[Metal]: saving metal shader files to %s\n", basePath.UTF8String); RARCH_LOG("[Metal]: saving metal shader files to %s\n", basePath.UTF8String);
NSError *err = nil;
[vs_src writeToFile:[basePath stringByAppendingPathExtension:@"vs.metal"] [vs_src writeToFile:[basePath stringByAppendingPathExtension:@"vs.metal"]
atomically:NO atomically:NO
encoding:NSStringEncodingConversionAllowLossy encoding:NSStringEncodingConversionAllowLossy

View File

@ -583,6 +583,8 @@ static void win32_save_position(void)
int title_bar_height = GetSystemMetrics(SM_CYCAPTION); int title_bar_height = GetSystemMetrics(SM_CYCAPTION);
int menu_bar_height = GetSystemMetrics(SM_CYMENU); int menu_bar_height = GetSystemMetrics(SM_CYMENU);
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
bool window_save_positions = settings->bools.video_window_save_positions;
bool video_fullscreen = settings->bools.video_fullscreen;
memset(&placement, 0, sizeof(placement)); memset(&placement, 0, sizeof(placement));
@ -598,9 +600,11 @@ static void win32_save_position(void)
g_win32_pos_width = rect.right - rect.left; g_win32_pos_width = rect.right - rect.left;
g_win32_pos_height = rect.bottom - rect.top; g_win32_pos_height = rect.bottom - rect.top;
} }
if (settings && settings->bools.video_window_save_positions) if (window_save_positions)
{ {
if (!settings->bools.video_fullscreen && !retroarch_is_forced_fullscreen() && !retroarch_is_switching_display_mode()) if ( !video_fullscreen &&
!retroarch_is_forced_fullscreen() &&
!retroarch_is_switching_display_mode())
{ {
settings->uints.window_position_x = g_win32_pos_x; settings->uints.window_position_x = g_win32_pos_x;
settings->uints.window_position_y = g_win32_pos_y; settings->uints.window_position_y = g_win32_pos_y;
@ -1463,13 +1467,16 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
if (fullscreen) if (fullscreen)
{ {
float video_refresh = settings->floats.video_refresh_rate;
unsigned swap_interval = settings->uints.video_swap_interval;
bool bfi = settings->bools.video_black_frame_insertion;
/* Windows only reports the refresh rates for modelines as /* Windows only reports the refresh rates for modelines as
* an integer, so video_refresh_rate needs to be rounded. Also, account * an integer, so video_refresh_rate needs to be rounded. Also, account
* for black frame insertion using video_refresh_rate set to half * for black frame insertion using video_refresh_rate set to half
* of the display refresh rate, as well as higher vsync swap intervals. */ * of the display refresh rate, as well as higher vsync swap intervals. */
float refresh_mod = settings->bools.video_black_frame_insertion ? 2.0f : 1.0f; float refresh_mod = bfi ? 2.0f : 1.0f;
unsigned refresh = roundf(settings->floats.video_refresh_rate unsigned refresh = roundf(video_refresh * refresh_mod
* refresh_mod * settings->uints.video_swap_interval); * swap_interval);
if (windowed_full) if (windowed_full)
{ {

View File

@ -67,13 +67,14 @@ static unsigned *network_video_temp_buf = NULL;
static void *network_gfx_init(const video_info_t *video, static void *network_gfx_init(const video_info_t *video,
input_driver_t **input, void **input_data) input_driver_t **input, void **input_data)
{ {
int fd;
gfx_ctx_input_t inp; gfx_ctx_input_t inp;
void *ctx_data = NULL; void *ctx_data = NULL;
settings_t *settings = config_get_ptr();
network_video_t *network = (network_video_t*)calloc(1, sizeof(*network));
const gfx_ctx_driver_t *ctx_driver = NULL; const gfx_ctx_driver_t *ctx_driver = NULL;
struct addrinfo *addr = NULL, *next_addr = NULL; struct addrinfo *addr = NULL, *next_addr = NULL;
int fd; settings_t *settings = config_get_ptr();
network_video_t *network = (network_video_t*)calloc(1, sizeof(*network));
bool video_font_enable = settings->bools.video_font_enable;
*input = NULL; *input = NULL;
*input_data = NULL; *input_data = NULL;
@ -106,7 +107,7 @@ static void *network_gfx_init(const video_info_t *video,
video_context_driver_input_driver(&inp); video_context_driver_input_driver(&inp);
if (settings->bools.video_font_enable) if (font_enable)
font_driver_init_osd(network, font_driver_init_osd(network,
video, video,
false, false,

View File

@ -104,8 +104,12 @@ static void sdl2_init_font(sdl2_video_t *vid, const char *font_path,
SDL_Palette *pal = NULL; SDL_Palette *pal = NULL;
const struct font_atlas *atlas = NULL; const struct font_atlas *atlas = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
bool video_font_enable = settings->bools.video_font_enable;
float msg_color_r = settings->floats.video_msg_color_r;
float msg_color_g = settings->floats.video_msg_color_g;
float msg_color_b = settings->floats.video_msg_color_b;
if (!settings->bools.video_font_enable) if (!video_font_enable)
return; return;
if (!font_renderer_create_default( if (!font_renderer_create_default(
@ -116,9 +120,9 @@ static void sdl2_init_font(sdl2_video_t *vid, const char *font_path,
return; return;
} }
r = settings->floats.video_msg_color_r * 255; r = msg_color_r * 255;
g = settings->floats.video_msg_color_g * 255; g = msg_color_g * 255;
b = settings->floats.video_msg_color_b * 255; b = msg_color_b * 255;
r = (r < 0) ? 0 : (r > 255 ? 255 : r); r = (r < 0) ? 0 : (r > 255 ? 255 : r);
g = (g < 0) ? 0 : (g > 255 ? 255 : g); g = (g < 0) ? 0 : (g > 255 ? 255 : g);
@ -130,7 +134,8 @@ static void sdl2_init_font(sdl2_video_t *vid, const char *font_path,
atlas = vid->font_driver->get_atlas(vid->font_data); atlas = vid->font_driver->get_atlas(vid->font_data);
tmp = SDL_CreateRGBSurfaceFrom(atlas->buffer, atlas->width, tmp = SDL_CreateRGBSurfaceFrom(
atlas->buffer, atlas->width,
atlas->height, 8, atlas->width, atlas->height, 8, atlas->width,
0, 0, 0, 0); 0, 0, 0, 0);
@ -164,20 +169,21 @@ static void sdl2_init_font(sdl2_video_t *vid, const char *font_path,
static void sdl2_render_msg(sdl2_video_t *vid, const char *msg) static void sdl2_render_msg(sdl2_video_t *vid, const char *msg)
{ {
int x, y, delta_x, delta_y; int delta_x = 0;
int delta_y = 0;
unsigned width = vid->vp.width; unsigned width = vid->vp.width;
unsigned height = vid->vp.height; unsigned height = vid->vp.height;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
float msg_pos_x = settings->floats.video_msg_pos_x;
float msg_pos_y = settings->floats.video_msg_pos_y;
int x = msg_pos_x * width;
int y = (1.0f - msg_pos_y) * height;
if (!vid->font_data) if (!vid->font_data)
return; return;
x = settings->floats.video_msg_pos_x * width; SDL_SetTextureColorMod(vid->font.tex,
y = (1.0f - settings->floats.video_msg_pos_y) * height; vid->font_r, vid->font_g, vid->font_b);
delta_x = 0;
delta_y = 0;
SDL_SetTextureColorMod(vid->font.tex, vid->font_r, vid->font_g, vid->font_b);
for (; *msg; msg++) for (; *msg; msg++)
{ {
@ -259,6 +265,8 @@ static void sdl_refresh_viewport(sdl2_video_t *vid)
{ {
int win_w, win_h; int win_w, win_h;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
bool video_scale_integer = settings->bools.video_scale_integer;
unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx;
SDL_GetWindowSize(vid->window, &win_w, &win_h); SDL_GetWindowSize(vid->window, &win_w, &win_h);
@ -269,11 +277,11 @@ static void sdl_refresh_viewport(sdl2_video_t *vid)
vid->vp.full_width = win_w; vid->vp.full_width = win_w;
vid->vp.full_height = win_h; vid->vp.full_height = win_h;
if (settings->bools.video_scale_integer) if (video_scale_integer)
video_viewport_get_scaled_integer(&vid->vp, video_viewport_get_scaled_integer(&vid->vp,
win_w, win_h, video_driver_get_aspect_ratio(), win_w, win_h, video_driver_get_aspect_ratio(),
vid->video.force_aspect); vid->video.force_aspect);
else if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) else if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
const struct video_viewport *custom = const struct video_viewport *custom =
(const struct video_viewport*)video_viewport_get_custom(); (const struct video_viewport*)video_viewport_get_custom();
@ -428,7 +436,9 @@ static void *sdl2_gfx_init(const video_info_t *video,
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
sdl2_init_renderer(vid); sdl2_init_renderer(vid);
sdl2_init_font(vid, settings->paths.path_font, settings->floats.video_font_size); sdl2_init_font(vid,
settings->paths.path_font,
settings->floats.video_font_size);
#if defined(_WIN32) #if defined(_WIN32)
sdl2_set_handles(vid->window, RARCH_DISPLAY_WIN32); sdl2_set_handles(vid->window, RARCH_DISPLAY_WIN32);
@ -455,7 +465,8 @@ static void check_window(sdl2_video_t *vid)
SDL_Event event; SDL_Event event;
SDL_PumpEvents(); SDL_PumpEvents();
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_QUIT, SDL_WINDOWEVENT) > 0) while (SDL_PeepEvents(&event, 1,
SDL_GETEVENT, SDL_QUIT, SDL_WINDOWEVENT) > 0)
{ {
switch (event.type) switch (event.type)
{ {

View File

@ -252,6 +252,10 @@ static void *sdl_gfx_init(const video_info_t *video,
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
const char *path_font = settings->paths.path_font; const char *path_font = settings->paths.path_font;
float video_font_size = settings->floats.video_font_size; float video_font_size = settings->floats.video_font_size;
bool video_font_enable = settings->bools.video_font_enable;
float msg_color_r = settings->floats.video_msg_color_r;
float msg_color_g = settings->floats.video_msg_color_g;
float msg_color_b = settings->floats.video_msg_color_b;
#ifdef HAVE_X11 #ifdef HAVE_X11
XInitThreads(); XInitThreads();
@ -313,11 +317,11 @@ static void *sdl_gfx_init(const video_info_t *video,
} }
sdl_init_font(vid, sdl_init_font(vid,
settings->bools.video_font_enable video_font_enable,
path_font, video_font_size, path_font, video_font_size,
settings->floats.video_msg_color_r, msg_color_r,
settings->floats.video_msg_color_g, msg_color_g,
settings->floats.video_msg_color_b); msg_color_b);
vid->scaler.scaler_type = video->smooth ? SCALER_TYPE_BILINEAR : SCALER_TYPE_POINT; vid->scaler.scaler_type = video->smooth ? SCALER_TYPE_BILINEAR : SCALER_TYPE_POINT;
vid->scaler.in_fmt = video->rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGB565; vid->scaler.in_fmt = video->rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGB565;

View File

@ -212,18 +212,21 @@ static float get_from_selector(Class obj_class, id obj_id, SEL selector, CGFloat
void *get_chosen_screen(void) void *get_chosen_screen(void)
{ {
unsigned monitor_index;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
NSArray *screens = [RAScreen screens]; NSArray *screens = [RAScreen screens];
if (!screens || !settings) if (!screens || !settings)
return NULL; return NULL;
if (settings->uints.video_monitor_index >= screens.count) monitor_index = settings->uints.video_monitor_index;
if (monitor_index >= screens.count)
{ {
RARCH_WARN("video_monitor_index is greater than the number of connected monitors; using main screen instead."); RARCH_WARN("video_monitor_index is greater than the number of connected monitors; using main screen instead.");
return (BRIDGE void*)screens; return (BRIDGE void*)screens;
} }
return ((BRIDGE void*)[screens objectAtIndex:settings->uints.video_monitor_index]); return ((BRIDGE void*)[screens objectAtIndex:monitor_index]);
} }
float get_backing_scale_factor(void) float get_backing_scale_factor(void)
@ -232,8 +235,6 @@ float get_backing_scale_factor(void)
backing_scale_def = 0.0f; backing_scale_def = 0.0f;
RAScreen *screen = NULL; RAScreen *screen = NULL;
(void)screen;
if (backing_scale_def != 0.0f) if (backing_scale_def != 0.0f)
return backing_scale_def; return backing_scale_def;

View File

@ -107,12 +107,13 @@ static void gfx_ctx_vc_get_video_size(void *data,
{ {
vc_ctx_data_t *vc = (vc_ctx_data_t*)data; vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
unsigned fullscreen_x = settings->uints.video_fullscreen_x;
unsigned fullscreen_y = settings->uints.video_fullscreen_y;
/* Use dispmanx upscaling if /* Use dispmanx upscaling if
* fullscreen_x and fullscreen_y are set. */ * fullscreen_x and fullscreen_y are set. */
if (settings->uints.video_fullscreen_x != 0 && if (fullscreen_x != 0 && fullscreen_y != 0)
settings->uints.video_fullscreen_y != 0)
{ {
/* Keep input and output aspect ratio equal. /* Keep input and output aspect ratio equal.
* There are other aspect ratio settings * There are other aspect ratio settings
@ -120,17 +121,16 @@ static void gfx_ctx_vc_get_video_size(void *data,
/* Calculate source and destination aspect ratios. */ /* Calculate source and destination aspect ratios. */
float srcAspect = (float)settings->uints.video_fullscreen_x float src_aspect = (float)fullscreen_x / (float)fullscreen_y;
/ (float)settings->uints.video_fullscreen_y; float dst_aspect = (float)vc->fb_width / (float)vc->fb_height;
float dstAspect = (float)vc->fb_width / (float)vc->fb_height;
/* If source and destination aspect ratios /* If source and destination aspect ratios
* are not equal correct source width. */ * are not equal correct source width. */
if (srcAspect != dstAspect) if (src_aspect != dst_aspect)
*width = (unsigned)(settings->uints.video_fullscreen_y * dstAspect); *width = (unsigned)(fullscreen_y * dst_aspect);
else else
*width = settings->uints.video_fullscreen_x; *width = fullscreen_x;
*height = settings->uints.video_fullscreen_y; *height = fullscreen_y;
} }
else else
{ {
@ -185,6 +185,8 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver)
#endif #endif
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
vc_ctx_data_t *vc = NULL; vc_ctx_data_t *vc = NULL;
unsigned fullscreen_x = settings->uints.video_fullscreen_x;
unsigned fullscreen_y = settings->uints.video_fullscreen_y;
if (g_egl_inited) if (g_egl_inited)
{ {
@ -202,10 +204,12 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver)
* Has to be done before any EGL call. * Has to be done before any EGL call.
* NOTE this is commented out because it should be the right way to do it, but * NOTE this is commented out because it should be the right way to do it, but
* currently it doesn't work, so we are using an vsync callback based solution.*/ * currently it doesn't work, so we are using an vsync callback based solution.*/
/* if (video_info->max_swapchain_images <= 2) #if 0
if (video_info->max_swapchain_images <= 2)
setenv("V3D_DOUBLE_BUFFER", "1", 1); setenv("V3D_DOUBLE_BUFFER", "1", 1);
else else
setenv("V3D_DOUBLE_BUFFER", "0", 1); */ setenv("V3D_DOUBLE_BUFFER", "0", 1);
#endif
bcm_host_init(); bcm_host_init();
@ -226,7 +230,8 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver)
#endif #endif
/* Create an EGL window surface. */ /* Create an EGL window surface. */
if (graphics_get_display_size(0 /* LCD */, &vc->fb_width, &vc->fb_height) < 0) if (graphics_get_display_size(0 /* LCD */,
&vc->fb_width, &vc->fb_height) < 0)
goto error; goto error;
dst_rect.x = 0; dst_rect.x = 0;
@ -239,21 +244,21 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver)
/* Use dispmanx upscaling if fullscreen_x /* Use dispmanx upscaling if fullscreen_x
* and fullscreen_y are set. */ * and fullscreen_y are set. */
if ((settings->uints.video_fullscreen_x != 0) && if ((fullscreen_x != 0) &&
(settings->uints.video_fullscreen_y != 0)) (fullscreen_y != 0))
{ {
/* Keep input and output aspect ratio equal. /* Keep input and output aspect ratio equal.
* There are other aspect ratio settings which can be used to stretch video output. */ * There are other aspect ratio settings which can be used to stretch video output. */
/* Calculate source and destination aspect ratios. */ /* Calculate source and destination aspect ratios. */
float srcAspect = (float)settings->uints.video_fullscreen_x / (float)settings->uints.video_fullscreen_y; float src_aspect = (float)fullscreen_x / (float)fullscreen_y;
float dstAspect = (float)vc->fb_width / (float)vc->fb_height; float dst_aspect = (float)vc->fb_width / (float)vc->fb_height;
/* If source and destination aspect ratios are not equal correct source width. */ /* If source and destination aspect ratios are not equal correct source width. */
if (srcAspect != dstAspect) if (src_aspect != dst_aspect)
src_rect.width = (unsigned)(settings->uints.video_fullscreen_y * dstAspect) << 16; src_rect.width = (unsigned)(fullscreen_y * dst_aspect) << 16;
else else
src_rect.width = settings->uints.video_fullscreen_x << 16; src_rect.width = fullscreen_x << 16;
src_rect.height = settings->uints.video_fullscreen_y << 16; src_rect.height = fullscreen_y << 16;
} }
else else
{ {
@ -272,32 +277,39 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver)
alpha.opacity = 255; alpha.opacity = 255;
alpha.mask = 0; alpha.mask = 0;
dispman_element = vc_dispmanx_element_add(dispman_update, dispman_display, dispman_element = vc_dispmanx_element_add(
0 /*layer*/, &dst_rect, 0 /*src*/, dispman_update,
&src_rect, DISPMANX_PROTECTION_NONE, &alpha, 0 /*clamp*/, DISPMANX_NO_ROTATE); dispman_display,
0 /*layer*/,
&dst_rect,
0 /*src*/,
&src_rect,
DISPMANX_PROTECTION_NONE,
&alpha,
0 /*clamp*/,
DISPMANX_NO_ROTATE);
vc->native_window.element = dispman_element; vc->native_window.element = dispman_element;
/* Use dispmanx upscaling if fullscreen_x and fullscreen_y are set. */ /* Use dispmanx upscaling if fullscreen_x and fullscreen_y are set. */
if (settings->uints.video_fullscreen_x != 0 && if (fullscreen_x != 0 &&
settings->uints.video_fullscreen_y != 0) fullscreen_y != 0)
{ {
/* Keep input and output aspect ratio equal. /* Keep input and output aspect ratio equal.
* There are other aspect ratio settings which * There are other aspect ratio settings which
* can be used to stretch video output. */ * can be used to stretch video output. */
/* Calculate source and destination aspect ratios. */ /* Calculate source and destination aspect ratios. */
float srcAspect = (float)settings->uints.video_fullscreen_x float srcAspect = (float)fullscreen_x / (float)fullscreen_y;
/ (float)settings->uints.video_fullscreen_y;
float dstAspect = (float)vc->fb_width / (float)vc->fb_height; float dstAspect = (float)vc->fb_width / (float)vc->fb_height;
/* If source and destination aspect ratios are not equal correct source width. */ /* If source and destination aspect ratios are not equal correct source width. */
if (srcAspect != dstAspect) if (srcAspect != dstAspect)
vc->native_window.width = (unsigned)(settings->uints.video_fullscreen_y * dstAspect); vc->native_window.width = (unsigned)(fullscreen_y * dstAspect);
else else
vc->native_window.width = settings->uints.video_fullscreen_x; vc->native_window.width = fullscreen_x;
vc->native_window.height = settings->uints.video_fullscreen_y; vc->native_window.height = fullscreen_y;
} }
else else
{ {
@ -368,10 +380,6 @@ static enum gfx_ctx_api gfx_ctx_vc_get_api(void *data)
static bool gfx_ctx_vc_bind_api(void *data, static bool gfx_ctx_vc_bind_api(void *data,
enum gfx_ctx_api api, unsigned major, unsigned minor) enum gfx_ctx_api api, unsigned major, unsigned minor)
{ {
(void)data;
(void)major;
(void)minor;
vc_api = api; vc_api = api;
switch (api) switch (api)

View File

@ -629,7 +629,10 @@ static bool gfx_ctx_x_set_video_mode(void *data,
Atom net_wm_icon = XInternAtom(g_x11_dpy, "_NET_WM_ICON", False); Atom net_wm_icon = XInternAtom(g_x11_dpy, "_NET_WM_ICON", False);
Atom cardinal = XInternAtom(g_x11_dpy, "CARDINAL", False); Atom cardinal = XInternAtom(g_x11_dpy, "CARDINAL", False);
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
unsigned opacity = settings->uints.video_window_opacity * ((unsigned)-1 / 100.0); unsigned opacity = settings->uints.video_window_opacity
* ((unsigned)-1 / 100.0);
bool disable_composition = settings->bools.video_disable_composition;
bool show_decorations = settings->bools.video_window_show_decorations;
frontend_driver_install_signal_handler(); frontend_driver_install_signal_handler();
@ -734,7 +737,7 @@ static bool gfx_ctx_x_set_video_mode(void *data,
XChangeProperty(g_x11_dpy, g_x11_win, net_wm_icon, cardinal, 32, PropModeReplace, (const unsigned char*)retroarch_icon_data, sizeof(retroarch_icon_data) / sizeof(*retroarch_icon_data)); XChangeProperty(g_x11_dpy, g_x11_win, net_wm_icon, cardinal, 32, PropModeReplace, (const unsigned char*)retroarch_icon_data, sizeof(retroarch_icon_data) / sizeof(*retroarch_icon_data));
if (fullscreen && settings->bools.video_disable_composition) if (fullscreen && disable_composition)
{ {
uint32_t value = 1; uint32_t value = 1;
Atom net_wm_bypass_compositor = XInternAtom(g_x11_dpy, "_NET_WM_BYPASS_COMPOSITOR", False); Atom net_wm_bypass_compositor = XInternAtom(g_x11_dpy, "_NET_WM_BYPASS_COMPOSITOR", False);
@ -749,9 +752,10 @@ static bool gfx_ctx_x_set_video_mode(void *data,
XChangeProperty(g_x11_dpy, g_x11_win, net_wm_opacity, cardinal, 32, PropModeReplace, (const unsigned char*)&opacity, 1); XChangeProperty(g_x11_dpy, g_x11_win, net_wm_opacity, cardinal, 32, PropModeReplace, (const unsigned char*)&opacity, 1);
} }
if (!settings->bools.video_window_show_decorations) if (!show_decorations)
{ {
/* We could have just set _NET_WM_WINDOW_TYPE_DOCK instead, but that removes the window from any taskbar/panel, /* We could have just set _NET_WM_WINDOW_TYPE_DOCK instead,
* but that removes the window from any taskbar/panel,
* so we are forced to use the old motif hints method. */ * so we are forced to use the old motif hints method. */
Hints hints; Hints hints;
Atom property = XInternAtom(g_x11_dpy, "_MOTIF_WM_HINTS", False); Atom property = XInternAtom(g_x11_dpy, "_MOTIF_WM_HINTS", False);