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:
{
settings_t *settings = config_get_ptr();
if (!settings->bools.video_smooth)
bool video_smooth = settings->bools.video_smooth;
if (!video_smooth)
break;
}
/* fall-through */
@ -140,19 +141,19 @@ void d3d_input_driver(const char* input_name, const char* joypad_name,
if (string_is_equal(input_name, "xinput"))
{
void *xinput = input_xinput.init(joypad_name);
*input = xinput ? (input_driver_t*)&input_xinput : NULL;
*input_data = xinput;
*input = xinput ? (input_driver_t*)&input_xinput : NULL;
*input_data = xinput;
}
else
{
void *uwp = input_uwp.init(joypad_name);
*input = uwp ? (input_driver_t*)&input_uwp : NULL;
*input_data = uwp;
void *uwp = input_uwp.init(joypad_name);
*input = uwp ? (input_driver_t*)&input_uwp : NULL;
*input_data = uwp;
}
#elif defined(_XBOX)
void *xinput = input_xinput.init(joypad_name);
*input = xinput ? (input_driver_t*)&input_xinput : NULL;
*input_data = xinput;
void *xinput = input_xinput.init(joypad_name);
*input = xinput ? (input_driver_t*)&input_xinput : NULL;
*input_data = xinput;
#else
#if _WIN32_WINNT >= 0x0501
/* winraw only available since XP */
@ -169,7 +170,7 @@ void d3d_input_driver(const char* input_name, const char* joypad_name,
#ifdef HAVE_DINPUT
*input_data = input_dinput.init(joypad_name);
*input = *input_data ? &input_dinput : NULL;
*input = *input_data ? &input_dinput : NULL;
#endif
#endif
}

View File

@ -355,32 +355,42 @@
- (void)_renderMessage:(const char *)msg
info:(video_frame_info_t *)video_info
{
settings_t *settings = config_get_ptr();
if (settings && settings->bools.video_msg_bgcolor_enable)
settings_t *settings = config_get_ptr();
bool msg_bgcolor_enable = settings->bools.video_msg_bgcolor_enable;
if (msg_bgcolor_enable)
{
int msg_width =
float r, g, b, a;
int msg_width =
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 y = 1.0f - video_info->font_msg_pos_y;
float width = msg_width / (float)_viewport->full_width;
float height = font_size / (float)_viewport->full_height;
float x = video_info->font_msg_pos_x;
float y = 1.0f - video_info->font_msg_pos_y;
float width = msg_width / (float)_viewport->full_width;
float height =
settings->floats.video_font_size / (float)_viewport->full_height;
float x2 = 0.005f; /* extend background around text */
float y2 = 0.005f;
y -= height;
y -= height;
float x2 = 0.005f; /* extend background around text */
float y2 = 0.005f;
x -= x2;
y -= y2;
width += x2;
height += y2;
x -= x2;
y -= y2;
width += x2;
height += y2;
r = bgcolor_red / 255.0f;
g = bgcolor_green / 255.0f;
b = bgcolor_blue / 255.0f;
a = bgcolor_opacity;
float r = settings->uints.video_msg_bgcolor_red / 255.0f;
float g = settings->uints.video_msg_bgcolor_green / 255.0f;
float b = settings->uints.video_msg_bgcolor_blue / 255.0f;
float a = settings->floats.video_msg_bgcolor_opacity;
[_context resetRenderViewport:kFullscreenViewport];
[_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_driver_update_viewport(_viewport, NO, _keepAspect);
if (memcmp(&vp, _viewport, sizeof(vp)) != 0)
{
_context.viewport = _viewport;
}
[_context begin];
}
@ -403,7 +413,7 @@
{
id<MTLRenderCommandEncoder> rce = _context.rce;
// draw back buffer
/* draw back buffer */
[rce pushDebugGroup:@"core frame"];
[_frameView drawWithContext:_context];
@ -1182,11 +1192,11 @@ typedef struct MTLALIGN(16)
[self _freeVideoShader:_shader];
_shader = nil;
config_file_t *conf = video_shader_read_preset(path.UTF8String);
struct video_shader *shader = (struct video_shader *)calloc(1, sizeof(*shader));
settings_t *settings = config_get_ptr();
NSString *shadersPath = [NSString stringWithFormat:@"%s/", settings->paths.directory_video_shader];
config_file_t *conf = video_shader_read_preset(path.UTF8String);
struct video_shader *shader = (struct video_shader *)calloc(1, sizeof(*shader));
settings_t *settings = config_get_ptr();
const char *dir_video_shader = settings->paths.directory_video_shader;
NSString *shadersPath = [NSString stringWithFormat:@"%s/", dir_video_shader];
@try
{
@ -1252,15 +1262,16 @@ typedef struct MTLALIGN(16)
// vertex descriptor
@try
{
MTLVertexDescriptor *vd = [MTLVertexDescriptor new];
vd.attributes[0].offset = offsetof(VertexSlang, position);
vd.attributes[0].format = MTLVertexFormatFloat4;
NSError *err;
MTLVertexDescriptor *vd = [MTLVertexDescriptor new];
vd.attributes[0].offset = offsetof(VertexSlang, position);
vd.attributes[0].format = MTLVertexFormatFloat4;
vd.attributes[0].bufferIndex = 4;
vd.attributes[1].offset = offsetof(VertexSlang, texCoord);
vd.attributes[1].format = MTLVertexFormatFloat2;
vd.attributes[1].offset = offsetof(VertexSlang, texCoord);
vd.attributes[1].format = MTLVertexFormatFloat2;
vd.attributes[1].bufferIndex = 4;
vd.layouts[4].stride = sizeof(VertexSlang);
vd.layouts[4].stepFunction = MTLVertexStepFunctionPerVertex;
vd.layouts[4].stride = sizeof(VertexSlang);
vd.layouts[4].stepFunction = MTLVertexStepFunctionPerVertex;
MTLRenderPipelineDescriptor *psd = [MTLRenderPipelineDescriptor new];
@ -1271,18 +1282,17 @@ typedef struct MTLALIGN(16)
ca.pixelFormat = SelectOptimalPixelFormat(glslang_format_to_metal(_engine.pass[i].semantics.format));
// TODO(sgc): confirm we never need blending for render passes
ca.blendingEnabled = NO;
ca.sourceAlphaBlendFactor = MTLBlendFactorSourceAlpha;
ca.sourceRGBBlendFactor = MTLBlendFactorSourceAlpha;
/* TODO(sgc): confirm we never need blending for render passes */
ca.blendingEnabled = NO;
ca.sourceAlphaBlendFactor = MTLBlendFactorSourceAlpha;
ca.sourceRGBBlendFactor = MTLBlendFactorSourceAlpha;
ca.destinationAlphaBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
ca.destinationRGBBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
ca.destinationRGBBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
psd.sampleCount = 1;
psd.vertexDescriptor = vd;
psd.sampleCount = 1;
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 (lib == nil)
@ -1327,9 +1337,7 @@ typedef struct MTLALIGN(16)
{
unsigned int size = _engine.pass[i].semantics.cbuffers[j].size;
if (size == 0)
{
continue;
}
id<MTLBuffer> buf = [_context.device newBufferWithLength:size options:MTLResourceStorageModeManaged];
STRUCT_ASSIGN(_engine.pass[i].buffers[j], buf);
@ -1338,11 +1346,11 @@ typedef struct MTLALIGN(16)
{
if (save_msl)
{
NSError *err = nil;
NSString *basePath = [[NSString stringWithUTF8String:shader->pass[i].source.path] stringByDeletingPathExtension];
RARCH_LOG("[Metal]: saving metal shader files to %s\n", basePath.UTF8String);
NSError *err = nil;
[vs_src writeToFile:[basePath stringByAppendingPathExtension:@"vs.metal"]
atomically:NO
encoding:NSStringEncodingConversionAllowLossy
@ -1375,7 +1383,7 @@ typedef struct MTLALIGN(16)
for (i = 0; i < shader->luts; i++)
{
struct texture_image image = {0};
image.supports_rgba = true;
image.supports_rgba = true;
if (!image_texture_load(&image, shader->lut[i].path))
return NO;

View File

@ -579,10 +579,12 @@ static void win32_save_position(void)
{
RECT rect;
WINDOWPLACEMENT placement;
int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
int title_bar_height = GetSystemMetrics(SM_CYCAPTION);
int menu_bar_height = GetSystemMetrics(SM_CYMENU);
settings_t *settings = config_get_ptr();
int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
int title_bar_height = GetSystemMetrics(SM_CYCAPTION);
int menu_bar_height = GetSystemMetrics(SM_CYMENU);
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));
@ -598,9 +600,11 @@ static void win32_save_position(void)
g_win32_pos_width = rect.right - rect.left;
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_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();
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
* an integer, so video_refresh_rate needs to be rounded. Also, account
* for black frame insertion using video_refresh_rate set to half
* 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;
unsigned refresh = roundf(settings->floats.video_refresh_rate
* refresh_mod * settings->uints.video_swap_interval);
float refresh_mod = bfi ? 2.0f : 1.0f;
unsigned refresh = roundf(video_refresh * refresh_mod
* swap_interval);
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,
input_driver_t **input, void **input_data)
{
int fd;
gfx_ctx_input_t inp;
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;
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_data = NULL;
@ -106,7 +107,7 @@ static void *network_gfx_init(const video_info_t *video,
video_context_driver_input_driver(&inp);
if (settings->bools.video_font_enable)
if (font_enable)
font_driver_init_osd(network,
video,
false,

View File

@ -96,16 +96,20 @@ static INLINE void sdl_tex_zero(sdl2_tex_t *t)
}
static void sdl2_init_font(sdl2_video_t *vid, const char *font_path,
unsigned font_size)
unsigned font_size)
{
int i, r, g, b;
SDL_Color colors[256];
SDL_Surface *tmp = NULL;
SDL_Palette *pal = NULL;
SDL_Surface *tmp = NULL;
SDL_Palette *pal = 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;
if (!font_renderer_create_default(
@ -116,21 +120,22 @@ static void sdl2_init_font(sdl2_video_t *vid, const char *font_path,
return;
}
r = settings->floats.video_msg_color_r * 255;
g = settings->floats.video_msg_color_g * 255;
b = settings->floats.video_msg_color_b * 255;
r = msg_color_r * 255;
g = msg_color_g * 255;
b = msg_color_b * 255;
r = (r < 0) ? 0 : (r > 255 ? 255 : r);
g = (g < 0) ? 0 : (g > 255 ? 255 : g);
b = (b < 0) ? 0 : (b > 255 ? 255 : b);
r = (r < 0) ? 0 : (r > 255 ? 255 : r);
g = (g < 0) ? 0 : (g > 255 ? 255 : g);
b = (b < 0) ? 0 : (b > 255 ? 255 : b);
vid->font_r = r;
vid->font_g = g;
vid->font_b = b;
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,
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)
{
int x, y, delta_x, delta_y;
unsigned width = vid->vp.width;
unsigned height = vid->vp.height;
int delta_x = 0;
int delta_y = 0;
unsigned width = vid->vp.width;
unsigned height = vid->vp.height;
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)
return;
x = settings->floats.video_msg_pos_x * width;
y = (1.0f - settings->floats.video_msg_pos_y) * height;
delta_x = 0;
delta_y = 0;
SDL_SetTextureColorMod(vid->font.tex, vid->font_r, vid->font_g, vid->font_b);
SDL_SetTextureColorMod(vid->font.tex,
vid->font_r, vid->font_g, vid->font_b);
for (; *msg; msg++)
{
@ -258,7 +264,9 @@ static void sdl_refresh_renderer(sdl2_video_t *vid)
static void sdl_refresh_viewport(sdl2_video_t *vid)
{
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);
@ -269,11 +277,11 @@ static void sdl_refresh_viewport(sdl2_video_t *vid)
vid->vp.full_width = win_w;
vid->vp.full_height = win_h;
if (settings->bools.video_scale_integer)
if (video_scale_integer)
video_viewport_get_scaled_integer(&vid->vp,
win_w, win_h, video_driver_get_aspect_ratio(),
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*)video_viewport_get_custom();
@ -428,7 +436,9 @@ static void *sdl2_gfx_init(const video_info_t *video,
SDL_ShowCursor(SDL_DISABLE);
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)
sdl2_set_handles(vid->window, RARCH_DISPLAY_WIN32);
@ -455,7 +465,8 @@ static void check_window(sdl2_video_t *vid)
SDL_Event event;
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)
{
@ -520,7 +531,7 @@ static void sdl2_gfx_set_nonblock_state(void *data, bool toggle,
{
sdl2_video_t *vid = (sdl2_video_t*)data;
vid->video.vsync = !toggle;
vid->video.vsync = !toggle;
sdl_refresh_renderer(vid);
}

View File

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

View File

@ -212,34 +212,35 @@ static float get_from_selector(Class obj_class, id obj_id, SEL selector, CGFloat
void *get_chosen_screen(void)
{
unsigned monitor_index;
settings_t *settings = config_get_ptr();
NSArray *screens = [RAScreen screens];
NSArray *screens = [RAScreen screens];
if (!screens || !settings)
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.");
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)
{
static float
backing_scale_def = 0.0f;
backing_scale_def = 0.0f;
RAScreen *screen = NULL;
(void)screen;
if (backing_scale_def != 0.0f)
return backing_scale_def;
backing_scale_def = 1.0f;
backing_scale_def = 1.0f;
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
screen = (BRIDGE RAScreen*)get_chosen_screen();
screen = (BRIDGE RAScreen*)get_chosen_screen();
if (screen)
{

View File

@ -105,14 +105,15 @@ static void gfx_ctx_vc_check_window(void *data, bool *quit,
static void gfx_ctx_vc_get_video_size(void *data,
unsigned *width, unsigned *height)
{
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
settings_t *settings = config_get_ptr();
vc_ctx_data_t *vc = (vc_ctx_data_t*)data;
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
* fullscreen_x and fullscreen_y are set. */
if (settings->uints.video_fullscreen_x != 0 &&
settings->uints.video_fullscreen_y != 0)
if (fullscreen_x != 0 && fullscreen_y != 0)
{
/* Keep input and output aspect ratio equal.
* 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. */
float srcAspect = (float)settings->uints.video_fullscreen_x
/ (float)settings->uints.video_fullscreen_y;
float dstAspect = (float)vc->fb_width / (float)vc->fb_height;
float src_aspect = (float)fullscreen_x / (float)fullscreen_y;
float dst_aspect = (float)vc->fb_width / (float)vc->fb_height;
/* If source and destination aspect ratios
* are not equal correct source width. */
if (srcAspect != dstAspect)
*width = (unsigned)(settings->uints.video_fullscreen_y * dstAspect);
if (src_aspect != dst_aspect)
*width = (unsigned)(fullscreen_y * dst_aspect);
else
*width = settings->uints.video_fullscreen_x;
*height = settings->uints.video_fullscreen_y;
*width = fullscreen_x;
*height = fullscreen_y;
}
else
{
@ -183,8 +183,10 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver)
EGL_NONE
};
#endif
settings_t *settings = config_get_ptr();
vc_ctx_data_t *vc = NULL;
settings_t *settings = config_get_ptr();
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)
{
@ -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.
* 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.*/
/* if (video_info->max_swapchain_images <= 2)
#if 0
if (video_info->max_swapchain_images <= 2)
setenv("V3D_DOUBLE_BUFFER", "1", 1);
else
setenv("V3D_DOUBLE_BUFFER", "0", 1); */
setenv("V3D_DOUBLE_BUFFER", "0", 1);
#endif
bcm_host_init();
@ -226,7 +230,8 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver)
#endif
/* 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;
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
* and fullscreen_y are set. */
if ((settings->uints.video_fullscreen_x != 0) &&
(settings->uints.video_fullscreen_y != 0))
if ((fullscreen_x != 0) &&
(fullscreen_y != 0))
{
/* Keep input and output aspect ratio equal.
* There are other aspect ratio settings which can be used to stretch video output. */
/* Calculate source and destination aspect ratios. */
float srcAspect = (float)settings->uints.video_fullscreen_x / (float)settings->uints.video_fullscreen_y;
float dstAspect = (float)vc->fb_width / (float)vc->fb_height;
float src_aspect = (float)fullscreen_x / (float)fullscreen_y;
float dst_aspect = (float)vc->fb_width / (float)vc->fb_height;
/* If source and destination aspect ratios are not equal correct source width. */
if (srcAspect != dstAspect)
src_rect.width = (unsigned)(settings->uints.video_fullscreen_y * dstAspect) << 16;
if (src_aspect != dst_aspect)
src_rect.width = (unsigned)(fullscreen_y * dst_aspect) << 16;
else
src_rect.width = settings->uints.video_fullscreen_x << 16;
src_rect.height = settings->uints.video_fullscreen_y << 16;
src_rect.width = fullscreen_x << 16;
src_rect.height = fullscreen_y << 16;
}
else
{
@ -272,36 +277,43 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver)
alpha.opacity = 255;
alpha.mask = 0;
dispman_element = vc_dispmanx_element_add(dispman_update, dispman_display,
0 /*layer*/, &dst_rect, 0 /*src*/,
&src_rect, DISPMANX_PROTECTION_NONE, &alpha, 0 /*clamp*/, DISPMANX_NO_ROTATE);
dispman_element = vc_dispmanx_element_add(
dispman_update,
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;
/* Use dispmanx upscaling if fullscreen_x and fullscreen_y are set. */
if (settings->uints.video_fullscreen_x != 0 &&
settings->uints.video_fullscreen_y != 0)
if (fullscreen_x != 0 &&
fullscreen_y != 0)
{
/* Keep input and output aspect ratio equal.
* There are other aspect ratio settings which
* can be used to stretch video output. */
/* Calculate source and destination aspect ratios. */
float srcAspect = (float)settings->uints.video_fullscreen_x
/ (float)settings->uints.video_fullscreen_y;
float srcAspect = (float)fullscreen_x / (float)fullscreen_y;
float dstAspect = (float)vc->fb_width / (float)vc->fb_height;
/* If source and destination aspect ratios are not equal correct source width. */
if (srcAspect != dstAspect)
vc->native_window.width = (unsigned)(settings->uints.video_fullscreen_y * dstAspect);
vc->native_window.width = (unsigned)(fullscreen_y * dstAspect);
else
vc->native_window.width = settings->uints.video_fullscreen_x;
vc->native_window.height = settings->uints.video_fullscreen_y;
vc->native_window.width = fullscreen_x;
vc->native_window.height = fullscreen_y;
}
else
{
vc->native_window.width = vc->fb_width;
vc->native_window.width = vc->fb_width;
vc->native_window.height = vc->fb_height;
}
vc_dispmanx_update_submit_sync(dispman_update);
@ -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,
enum gfx_ctx_api api, unsigned major, unsigned minor)
{
(void)data;
(void)major;
(void)minor;
vc_api = api;
switch (api)

View File

@ -626,10 +626,13 @@ static bool gfx_ctx_x_set_video_mode(void *data,
char *wm_name = NULL;
int (*old_handler)(Display*, XErrorEvent*) = NULL;
gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data;
Atom net_wm_icon = XInternAtom(g_x11_dpy, "_NET_WM_ICON", False);
Atom cardinal = XInternAtom(g_x11_dpy, "CARDINAL", False);
settings_t *settings = config_get_ptr();
unsigned opacity = settings->uints.video_window_opacity * ((unsigned)-1 / 100.0);
Atom net_wm_icon = XInternAtom(g_x11_dpy, "_NET_WM_ICON", False);
Atom cardinal = XInternAtom(g_x11_dpy, "CARDINAL", False);
settings_t *settings = config_get_ptr();
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();
@ -734,9 +737,9 @@ 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));
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);
RARCH_LOG("[GLX]: Requesting compositor bypass.\n");
@ -749,14 +752,15 @@ 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);
}
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. */
Hints hints;
Atom property = XInternAtom(g_x11_dpy, "_MOTIF_WM_HINTS", False);
Atom property = XInternAtom(g_x11_dpy, "_MOTIF_WM_HINTS", False);
hints.flags = 2;
hints.flags = 2;
hints.decorations = 0;
XChangeProperty(g_x11_dpy, g_x11_win, property, property, 32, PropModeReplace, (const unsigned char*)&hints, 5);