Refactor menu_driver_frame

This commit is contained in:
twinaphex 2020-05-19 16:20:43 +02:00
parent 0aff65e77b
commit 9ace693ec0
38 changed files with 528 additions and 456 deletions

View File

@ -443,6 +443,8 @@
- (void)_drawMenu:(video_frame_info_t *)video_info
{
bool menu_is_alive = video_info->menu_is_alive;
if (!_menu.enabled)
return;
@ -470,7 +472,7 @@
{
[rce pushDebugGroup:@"menu"];
[_context resetRenderViewport:kFullscreenViewport];
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
[rce popDebugGroup];
}
#endif

View File

@ -141,7 +141,7 @@ static bool caca_gfx_frame(void *data, const void *frame,
caca_clear_canvas(caca->cv);
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
if (msg)

View File

@ -546,7 +546,7 @@ static bool ctr_frame(void* data, const void* frame,
int custom_vp_y = video_info->custom_vp_y;
unsigned custom_vp_width = video_info->custom_vp_width;
unsigned custom_vp_height = video_info->custom_vp_height;
bool menu_is_alive = video_info->menu_is_alive;
if (!width || !height || !settings)
{
@ -873,9 +873,8 @@ static bool ctr_frame(void* data, const void* frame,
}
ctr->msg_rendering_enabled = true;
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
ctr->msg_rendering_enabled = false;
}
else if (statistics_show)
{

View File

@ -1211,6 +1211,7 @@ static bool d3d10_gfx_frame(
*osd_params = (struct font_params*)
&video_info->osd_stat_params;
const char *stat_text = video_info->stat_text;
bool menu_is_alive = video_info->menu_is_alive;
if (d3d10->resize_chain)
{
@ -1471,7 +1472,7 @@ static bool d3d10_gfx_frame(
#ifdef HAVE_MENU
if (d3d10->menu.enabled)
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
else
#endif
if (statistics_show)

View File

@ -1290,6 +1290,7 @@ static bool d3d11_gfx_frame(
unsigned video_height = video_info->height;
bool statistics_show = video_info->statistics_show;
struct font_params* osd_params = (struct font_params*)&video_info->osd_stat_params;
bool menu_is_alive = video_info->menu_is_alive;
if (d3d11->resize_chain)
{
@ -1544,7 +1545,7 @@ static bool d3d11_gfx_frame(
#ifdef HAVE_MENU
if (d3d11->menu.enabled)
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
else
#endif
if (statistics_show)

View File

@ -1174,6 +1174,7 @@ static bool d3d12_gfx_frame(
unsigned video_height = video_info->height;
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
bool menu_is_alive = video_info->menu_is_alive;
d3d12_gfx_sync(d3d12);
@ -1513,7 +1514,7 @@ static bool d3d12_gfx_frame(
#ifdef HAVE_MENU
if (d3d12->menu.enabled)
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
else
#endif
if (statistics_show)

View File

@ -1489,6 +1489,7 @@ static bool d3d8_frame(void *data, const void *frame,
const char *stat_text = video_info->stat_text;
bool statistics_show = video_info->statistics_show;
bool black_frame_insertion = video_info->black_frame_insertion;
bool menu_is_alive = video_info->menu_is_alive;
(void)i;
@ -1556,7 +1557,7 @@ static bool d3d8_frame(void *data, const void *frame,
d3d8_set_stream_source(d3d->dev, 0, d3d->menu_display.buffer, 0, sizeof(Vertex));
d3d8_set_viewports(d3d->dev, &screen_vp);
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
}
else if (statistics_show)
{

View File

@ -1532,7 +1532,7 @@ static bool d3d9_frame(void *data, const void *frame,
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
const char *stat_text = video_info->stat_text;
bool menu_is_alive = video_info->menu_is_alive;
if (!frame)
return true;
@ -1602,7 +1602,7 @@ static bool d3d9_frame(void *data, const void *frame,
d3d9_set_stream_source(d3d->dev, 0, (LPDIRECT3DVERTEXBUFFER9)d3d->menu_display.buffer, 0, sizeof(Vertex));
d3d9_set_viewports(d3d->dev, &screen_vp);
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
}
else if (statistics_show)
{

View File

@ -439,6 +439,7 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width,
struct dispmanx_video *_dispvars = data;
float aspect = video_driver_get_aspect_ratio();
unsigned max_swapchain_images = video_info->max_swapchain_images;
bool menu_is_alive = video_info->menu_is_alive;
if (!frame)
return true;
@ -480,7 +481,7 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width,
}
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
/* Update main surface: locate free page, blit and flip. */

View File

@ -757,6 +757,7 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width,
video_frame_info_t *video_info)
{
struct drm_video *_drmvars = data;
bool menu_is_alive = video_info->menu_is_alive;
if ( ( width != _drmvars->core_width) ||
(height != _drmvars->core_height))
@ -790,7 +791,7 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width,
}
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
/* Update main surface: locate free page, blit and flip. */

View File

@ -902,10 +902,13 @@ static void exynos_set_fake_blit(struct exynos_data *pdata)
pdata->pages[i].clear = true;
}
static int exynos_blit_frame(struct exynos_data *pdata, const void *frame,
unsigned src_pitch)
static int exynos_blit_frame(
struct exynos_data *pdata,
const void *frame,
unsigned src_pitch)
{
const enum exynos_buffer_type buf_type = defaults[EXYNOS_IMAGE_FRAME].buf_type;
const enum exynos_buffer_type
buf_type = defaults[EXYNOS_IMAGE_FRAME].buf_type;
const unsigned size = src_pitch * pdata->blit_params[5];
struct g2d_image *src = pdata->src[EXYNOS_IMAGE_FRAME];
@ -1280,12 +1283,13 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width,
{
struct exynos_video *vid = data;
struct exynos_page *page = NULL;
bool menu_is_alive = video_info->menu_is_alive;
/* Check if neither menu nor core framebuffer is to be displayed. */
if (!vid->menu_active && !frame)
return true;
if (frame != NULL)
if (frame)
{
if (width != vid->width || height != vid->height)
{
@ -1315,15 +1319,16 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width,
if (!page)
page = exynos_free_page(vid->data);
#ifdef HAVE_MENU
if (vid->menu_active)
{
if (exynos_blend_menu(vid->data, vid->menu_rotation) != 0)
goto fail;
#ifdef HAVE_MENU
menu_driver_frame(video_info);
#endif
menu_driver_frame(menu_is_alive, video_info);
}
else if (video_info->statistics_show)
else
#endif
if (video_info->statistics_show)
{
struct font_params *osd_params = video_info ?
(struct font_params*)&video_info->osd_stat_params : NULL;

View File

@ -209,12 +209,13 @@ static bool fpga_gfx_frame(void *data, const void *frame,
bool draw = true;
fpga_t *fpga = (fpga_t*)data;
unsigned bits = fpga->video_bits;
bool menu_is_alive = video_info->menu_is_alive;
if (!frame || !frame_width || !frame_height)
return true;
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
if ( fpga->video_width != frame_width ||

View File

@ -189,6 +189,7 @@ static bool gdi_gfx_frame(void *data, const void *frame,
gdi_t *gdi = (gdi_t*)data;
unsigned bits = gdi->video_bits;
HWND hwnd = win32_get_window();
bool menu_is_alive = video_info->menu_is_alive;
/* FIXME: Force these settings off as they interfere with the rendering */
video_info->xmb_shadows_enable = false;
@ -198,7 +199,7 @@ static bool gdi_gfx_frame(void *data, const void *frame,
return true;
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
if ( gdi->video_width != frame_width ||

View File

@ -2829,6 +2829,7 @@ static bool gl2_frame(void *data, const void *frame,
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
const char *stat_text = video_info->stat_text;
bool menu_is_alive = video_info->menu_is_alive;
if (!gl)
return false;
@ -3036,7 +3037,7 @@ static bool gl2_frame(void *data, const void *frame,
#if defined(HAVE_MENU)
if (gl->menu_texture_enable)
{
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
if (gl->menu_texture)
gl2_draw_texture(gl);

View File

@ -696,6 +696,7 @@ static bool gl1_gfx_frame(void *data, const void *frame,
unsigned pot_height = 0;
unsigned video_width = video_info->width;
unsigned video_height = video_info->height;
bool menu_is_alive = video_info->menu_is_alive;
gl1_context_bind_hw_render(gl1, false);
@ -790,9 +791,8 @@ static bool gl1_gfx_frame(void *data, const void *frame,
if (draw)
{
if (frame_to_copy)
{
draw_tex(gl1, pot_width, pot_height, width, height, gl1->tex, frame_to_copy);
}
draw_tex(gl1, pot_width, pot_height,
width, height, gl1->tex, frame_to_copy);
}
if (gl1->menu_frame && video_info->menu_is_alive)
@ -837,25 +837,26 @@ static bool gl1_gfx_frame(void *data, const void *frame,
#ifdef HAVE_MENU
if (gl1->menu_texture_enable)
menu_driver_frame(video_info);
else if (video_info->statistics_show)
{
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
if (osd_params)
menu_driver_frame(menu_is_alive, video_info);
else
#endif
if (video_info->statistics_show)
{
font_driver_render_msg(gl1, video_info->stat_text,
(const struct font_params*)&video_info->osd_stat_params, NULL);
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
if (osd_params)
{
font_driver_render_msg(gl1, video_info->stat_text,
(const struct font_params*)&video_info->osd_stat_params, NULL);
#if 0
osd_params->y = 0.350f;
osd_params->scale = 0.75f;
font_driver_render_msg(gl1, video_info->chat_text,
(const struct font_params*)&video_info->osd_stat_params, NULL);
osd_params->y = 0.350f;
osd_params->scale = 0.75f;
font_driver_render_msg(gl1, video_info->chat_text,
(const struct font_params*)&video_info->osd_stat_params, NULL);
#endif
}
}
}
#endif
#ifdef HAVE_GFX_WIDGETS
gfx_widgets_frame(video_info);

View File

@ -1850,6 +1850,8 @@ static bool gl_core_frame(void *data, const void *frame,
bool runloop_is_paused = video_info->runloop_is_paused;
bool runloop_is_slowmotion = video_info->runloop_is_slowmotion;
bool input_driver_nonblock_state = video_info->input_driver_nonblock_state;
bool menu_is_alive = video_info->menu_is_alive;
if (!gl)
return false;
@ -1919,7 +1921,7 @@ static bool gl_core_frame(void *data, const void *frame,
#if defined(HAVE_MENU)
if (gl->menu_texture_enable)
{
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
if (gl->menu_texture_enable && gl->menu_texture)
gl_core_draw_menu_texture(gl, width, height);
}

View File

@ -1140,44 +1140,45 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
if (wiiu->shader_preset)
{
unsigned i;
int32_t frame_direction = state_manager_frame_is_reversed() ? -1 : 1;
for (int i = 0; i < wiiu->shader_preset->passes; i++)
for (i = 0; i < wiiu->shader_preset->passes; i++)
{
unsigned j;
GX2SetVertexShader(wiiu->pass[i].gfd->vs);
for (int j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++)
for (j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++)
{
wiiu_gfx_update_uniform_block(wiiu, i, wiiu->pass[i].vs_ubos[j], j,
wiiu->pass[i].gfd->vs->uniformBlocks[j].size,
wiiu->pass[i].gfd->vs->uniformVarCount, wiiu->pass[i].gfd->vs->uniformVars,
frame_count, frame_direction);
wiiu->pass[i].gfd->vs->uniformBlocks[j].size,
wiiu->pass[i].gfd->vs->uniformVarCount, wiiu->pass[i].gfd->vs->uniformVars,
frame_count, frame_direction);
GX2SetVertexUniformBlock(wiiu->pass[i].gfd->vs->uniformBlocks[j].offset,
wiiu->pass[i].gfd->vs->uniformBlocks[j].size, wiiu->pass[i].vs_ubos[j]);
wiiu->pass[i].gfd->vs->uniformBlocks[j].size, wiiu->pass[i].vs_ubos[j]);
}
GX2SetPixelShader(wiiu->pass[i].gfd->ps);
for (int j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++)
for (j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++)
{
wiiu_gfx_update_uniform_block(wiiu, i, wiiu->pass[i].ps_ubos[j], j,
wiiu->pass[i].gfd->ps->uniformBlocks[j].size,
wiiu->pass[i].gfd->ps->uniformVarCount, wiiu->pass[i].gfd->ps->uniformVars,
frame_count, frame_direction);
wiiu->pass[i].gfd->ps->uniformBlocks[j].size,
wiiu->pass[i].gfd->ps->uniformVarCount, wiiu->pass[i].gfd->ps->uniformVars,
frame_count, frame_direction);
GX2SetPixelUniformBlock(wiiu->pass[i].gfd->ps->uniformBlocks[j].offset,
wiiu->pass[i].gfd->ps->uniformBlocks[j].size, wiiu->pass[i].ps_ubos[j]);
wiiu->pass[i].gfd->ps->uniformBlocks[j].size, wiiu->pass[i].ps_ubos[j]);
}
for (int j = 0; j < wiiu->pass[i].gfd->ps->samplerVarCount; j++)
for (j = 0; j < wiiu->pass[i].gfd->ps->samplerVarCount; j++)
{
if (string_is_equal(wiiu->pass[i].gfd->ps->samplerVars[j].name, "Source"))
{
GX2SetPixelTexture(texture, wiiu->pass[i].gfd->ps->samplerVars[j].location);
GX2SetPixelSampler(wiiu->shader_preset->pass[i].filter ?
&wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] :
&wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap],
wiiu->pass[i].gfd->ps->samplerVars[j].location);
&wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] :
&wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap],
wiiu->pass[i].gfd->ps->samplerVars[j].location);
continue;
}
@ -1185,9 +1186,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
{
GX2SetPixelTexture(&wiiu->texture, wiiu->pass[i].gfd->ps->samplerVars[j].location);
GX2SetPixelSampler(wiiu->shader_preset->pass[0].filter ?
&wiiu->sampler_linear[wiiu->shader_preset->pass[0].wrap] :
&wiiu->sampler_nearest[wiiu->shader_preset->pass[0].wrap],
wiiu->pass[i].gfd->ps->samplerVars[j].location);
&wiiu->sampler_linear[wiiu->shader_preset->pass[0].wrap] :
&wiiu->sampler_nearest[wiiu->shader_preset->pass[0].wrap],
wiiu->pass[i].gfd->ps->samplerVars[j].location);
continue;
}
@ -1203,9 +1204,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
GX2Texture *source = (index > 0) ? &wiiu->pass[index - 1].texture : &wiiu->texture;
GX2SetPixelTexture(source, wiiu->pass[i].gfd->ps->samplerVars[j].location);
GX2SetPixelSampler(wiiu->shader_preset->pass[index].filter ?
&wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] :
&wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap],
wiiu->pass[i].gfd->ps->samplerVars[j].location);
&wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] :
&wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap],
wiiu->pass[i].gfd->ps->samplerVars[j].location);
continue;
}
@ -1216,9 +1217,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
index = i - 1;
GX2SetPixelTexture(&wiiu->pass[index].texture, wiiu->pass[i].gfd->ps->samplerVars[j].location);
GX2SetPixelSampler(wiiu->shader_preset->pass[index].filter ?
&wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] :
&wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap],
wiiu->pass[i].gfd->ps->samplerVars[j].location);
&wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] :
&wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap],
wiiu->pass[i].gfd->ps->samplerVars[j].location);
continue;
}
@ -1231,9 +1232,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
GX2SetPixelTexture(&wiiu->pass[index].texture, wiiu->pass[i].gfd->ps->samplerVars[j].location);
GX2SetPixelSampler(wiiu->shader_preset->pass[i].filter ?
&wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] :
&wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap],
wiiu->pass[i].gfd->ps->samplerVars[j].location);
&wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] :
&wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap],
wiiu->pass[i].gfd->ps->samplerVars[j].location);
continue;
}
@ -1244,9 +1245,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
{
GX2SetPixelTexture(&wiiu->luts[k], wiiu->pass[i].gfd->ps->samplerVars[j].location);
GX2SetPixelSampler(wiiu->shader_preset->lut[k].filter ?
&wiiu->sampler_linear[wiiu->shader_preset->lut[k].wrap] :
&wiiu->sampler_nearest[wiiu->shader_preset->lut[k].wrap],
wiiu->pass[i].gfd->ps->samplerVars[j].location);
&wiiu->sampler_linear[wiiu->shader_preset->lut[k].wrap] :
&wiiu->sampler_nearest[wiiu->shader_preset->lut[k].wrap],
wiiu->pass[i].gfd->ps->samplerVars[j].location);
}
}
@ -1308,12 +1309,11 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
0.0f, 1.0f);
#ifdef HAVE_OVERLAY
if (wiiu->overlay_enable)
gx2_render_overlay(wiiu);
#endif
#ifdef HAVE_MENU
if (wiiu->menu.enable)
{
GX2SetAttribBuffer(0, 4 * sizeof(*wiiu->menu.v), sizeof(*wiiu->menu.v), wiiu->menu.v);
@ -1325,6 +1325,7 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
GX2DrawEx(GX2_PRIMITIVE_MODE_POINTS, 1, 0, 1);
}
#endif
wiiu->vertex_cache.current = 0;
wiiu->vertex_cache_tex.current = 0;
@ -1335,9 +1336,12 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
wiiu->render_msg_enabled = true;
#ifdef HAVE_MENU
if (wiiu->menu.enable)
menu_driver_frame(video_info);
else if (video_info->statistics_show)
menu_driver_frame(menu_is_alive, video_info);
else
#endif
if (video_info->statistics_show)
{
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
@ -1446,6 +1450,7 @@ static bool wiiu_gfx_set_shader(void *data,
for (i = 0; i < wiiu->shader_preset->passes; i++)
{
unsigned j;
char gfdpath[PATH_MAX_LENGTH];
struct video_shader_pass *pass = &wiiu->shader_preset->pass[i];
@ -1470,22 +1475,22 @@ static bool wiiu_gfx_set_shader(void *data,
return false;
}
for (int j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++)
for (j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++)
{
wiiu->pass[i].vs_ubos[j] = MEM2_alloc(wiiu->pass[i].gfd->vs->uniformBlocks[j].size,
GX2_UNIFORM_BLOCK_ALIGNMENT);
GX2_UNIFORM_BLOCK_ALIGNMENT);
memset(wiiu->pass[i].vs_ubos[j], 0, wiiu->pass[i].gfd->vs->uniformBlocks[j].size);
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->pass[i].vs_ubos[j],
wiiu->pass[i].gfd->vs->uniformBlocks[j].size);
wiiu->pass[i].gfd->vs->uniformBlocks[j].size);
}
for (int j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++)
for (j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++)
{
wiiu->pass[i].ps_ubos[j] = MEM2_alloc(wiiu->pass[i].gfd->ps->uniformBlocks[j].size,
GX2_UNIFORM_BLOCK_ALIGNMENT);
GX2_UNIFORM_BLOCK_ALIGNMENT);
memset(wiiu->pass[i].ps_ubos[j], 0, wiiu->pass[i].gfd->ps->uniformBlocks[j].size);
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->pass[i].ps_ubos[j],
wiiu->pass[i].gfd->ps->uniformBlocks[j].size);
wiiu->pass[i].gfd->ps->uniformBlocks[j].size);
}
}
@ -1510,7 +1515,7 @@ static bool wiiu_gfx_set_shader(void *data,
wiiu->luts[i].surface.image = MEM2_alloc(wiiu->luts[i].surface.imageSize,
wiiu->luts[i].surface.alignment);
for (int j = 0; (j < image.height) && (j < wiiu->luts[i].surface.height); j++)
for (j = 0; (j < image.height) && (j < wiiu->luts[i].surface.height); j++)
memcpy((uint32_t *)wiiu->luts[i].surface.image + (j * wiiu->luts[i].surface.pitch),
image.pixels + (j * image.width), image.width * sizeof(image.pixels));

View File

@ -1574,6 +1574,7 @@ static bool gx_frame(void *data, const void *frame,
unsigned overscan_corr_bottom = settings->uints.video_overscan_correction_bottom;
bool video_smooth = settings->bools.video_smooth;
unsigned video_aspect_ratio_idx = settings->uints.video_aspect_ratio_idx;
bool menu_is_alive = video_info->menu_is_alive;
fps_text_buf[0] = '\0';
@ -1615,7 +1616,7 @@ static bool gx_frame(void *data, const void *frame,
gx->old_height = height;
}
g_draw_done = false;
g_draw_done = false;
gx->current_framebuf ^= 1;
if (frame)
@ -1649,7 +1650,7 @@ static bool gx_frame(void *data, const void *frame,
}
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
GX_InvalidateTexAll();

View File

@ -178,26 +178,30 @@ static bool network_gfx_frame(void *data, const void *frame,
unsigned pixfmt = NETWORK_VIDEO_PIXELFORMAT_RGB565;
bool draw = true;
network_video_t *network = (network_video_t*)data;
bool menu_is_alive = video_info->menu_is_alive;
if (!frame || !frame_width || !frame_height)
return true;
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
if (network_video_width != frame_width || network_video_height != frame_height || network_video_pitch != pitch)
if ( network_video_width != frame_width ||
network_video_height != frame_height ||
network_video_pitch != pitch)
{
if (frame_width > 4 && frame_height > 4)
{
network_video_width = frame_width;
network_video_height = frame_height;
network_video_pitch = pitch;
network->screen_width = network_video_width;
network_video_width = frame_width;
network_video_height = frame_height;
network_video_pitch = pitch;
network->screen_width = network_video_width;
network->screen_height = network_video_height;
}
}
#ifdef HAVE_MENU
if (network_menu_frame && video_info->menu_is_alive)
{
frame_to_copy = network_menu_frame;
@ -207,16 +211,21 @@ static bool network_gfx_frame(void *data, const void *frame,
bits = network_menu_bits;
}
else
#endif
{
width = network_video_width;
height = network_video_height;
pitch = network_video_pitch;
if (frame_width == 4 && frame_height == 4 && (frame_width < width && frame_height < height))
if ( frame_width == 4 &&
frame_height == 4 &&
(frame_width < width && frame_height < height))
draw = false;
#ifdef HAVE_MENU
if (video_info->menu_is_alive)
draw = false;
#endif
}
if (network->video_width != width || network->video_height != height)
@ -225,9 +234,7 @@ static bool network_gfx_frame(void *data, const void *frame,
network->video_height = height;
if (network_video_temp_buf)
{
free(network_video_temp_buf);
}
network_video_temp_buf = (unsigned*)malloc(network->screen_width * network->screen_height * sizeof(unsigned));
}
@ -246,8 +253,8 @@ static bool network_gfx_frame(void *data, const void *frame,
for (x = 0; x < network->screen_width; x++)
{
/* scale incoming frame to fit the screen */
unsigned scaled_x = (width * x) / network->screen_width;
unsigned scaled_y = (height * y) / network->screen_height;
unsigned scaled_x = (width * x) / network->screen_width;
unsigned scaled_y = (height * y) / network->screen_height;
unsigned short pixel = ((unsigned short*)frame_to_copy)[width * scaled_y + scaled_x];
/* convert RGBX4444 to RGBX8888 */
@ -272,8 +279,8 @@ static bool network_gfx_frame(void *data, const void *frame,
for (x = 0; x < network->screen_width; x++)
{
/* scale incoming frame to fit the screen */
unsigned scaled_x = (width * x) / network->screen_width;
unsigned scaled_y = (height * y) / network->screen_height;
unsigned scaled_x = (width * x) / network->screen_width;
unsigned scaled_y = (height * y) / network->screen_height;
unsigned short pixel = ((unsigned short*)frame_to_copy)[(pitch / (bits / 8)) * scaled_y + scaled_x];
/* convert RGB565 to RGBX8888 */
@ -306,7 +313,7 @@ static bool network_gfx_frame(void *data, const void *frame,
/* scale incoming frame to fit the screen */
unsigned scaled_x = (width * x) / network->screen_width;
unsigned scaled_y = (height * y) / network->screen_height;
unsigned pixel = ((unsigned*)frame_to_copy)[(pitch / (bits / 8)) * scaled_y + scaled_x];
unsigned pixel = ((unsigned*)frame_to_copy)[(pitch / (bits / 8)) * scaled_y + scaled_x];
network_video_temp_buf[network->screen_width * y + x] = pixel;
}

View File

@ -76,85 +76,91 @@ go2_rotation_t oga_rotation = GO2_ROTATION_DEGREES_0;
static void oga_gfx_free(void *data)
{
oga_video_t *vid = (oga_video_t*)data;
if (!vid)
return;
unsigned i;
oga_video_t *vid = (oga_video_t*)data;
if (vid->font) {
vid->font_driver->free(vid->font);
vid->font_driver = NULL;
}
if (!vid)
return;
for (int i = 0; i < NUM_PAGES; ++i)
{
go2_frame_buffer_t* frameBuffer = vid->frameBuffer[i];
go2_surface_t* surface = go2_frame_buffer_surface_get(frameBuffer);
if (vid->font)
{
vid->font_driver->free(vid->font);
vid->font_driver = NULL;
}
go2_frame_buffer_destroy(frameBuffer);
go2_surface_destroy(surface);
}
for (i = 0; i < NUM_PAGES; ++i)
{
go2_frame_buffer_t* frameBuffer = vid->frameBuffer[i];
go2_surface_t* surface = go2_frame_buffer_surface_get(frameBuffer);
go2_surface_destroy(vid->frame);
go2_surface_destroy(vid->menu_surface);
go2_presenter_destroy(vid->presenter);
go2_display_destroy(vid->display);
go2_frame_buffer_destroy(frameBuffer);
go2_surface_destroy(surface);
}
free(vid);
vid = NULL;
go2_surface_destroy(vid->frame);
go2_surface_destroy(vid->menu_surface);
go2_presenter_destroy(vid->presenter);
go2_display_destroy(vid->display);
free(vid);
vid = NULL;
}
static void *oga_gfx_init(const video_info_t *video,
input_driver_t **input, void **input_data)
{
oga_video_t *vid = NULL;
settings_t *settings = config_get_ptr();
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
oga_video_t *vid = NULL;
settings_t *settings = config_get_ptr();
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
frontend_driver_install_signal_handler();
if (input && input_data) {
void* udev = input_udev.init(settings->arrays.input_joypad_driver);
if (udev) {
*input = &input_udev;
*input_data = udev;
}
else
*input = NULL;
}
if (input && input_data)
{
void* udev = input_udev.init(settings->arrays.input_joypad_driver);
if (udev)
{
*input = &input_udev;
*input_data = udev;
}
else
*input = NULL;
}
vid = (oga_video_t*)calloc(1, sizeof(*vid));
vid = (oga_video_t*)calloc(1, sizeof(*vid));
vid->menu_frame = NULL;
vid->display = go2_display_create();
vid->presenter = go2_presenter_create(vid->display, DRM_FORMAT_RGB565, 0xff000000, false);
vid->menu_surface = go2_surface_create(vid->display, NATIVE_WIDTH, NATIVE_HEIGHT, DRM_FORMAT_RGB565);
vid->font = NULL;
vid->font_driver = NULL;
vid->menu_frame = NULL;
vid->display = go2_display_create();
vid->presenter = go2_presenter_create(vid->display, DRM_FORMAT_RGB565, 0xff000000, false);
vid->menu_surface = go2_surface_create(vid->display, NATIVE_WIDTH, NATIVE_HEIGHT, DRM_FORMAT_RGB565);
vid->font = NULL;
vid->font_driver = NULL;
int aw = MAX(ALIGN(av_info->geometry.max_width, 32), NATIVE_WIDTH);
int ah = MAX(ALIGN(av_info->geometry.max_height, 32), NATIVE_HEIGHT);
int aw = MAX(ALIGN(av_info->geometry.max_width, 32), NATIVE_WIDTH);
int ah = MAX(ALIGN(av_info->geometry.max_height, 32), NATIVE_HEIGHT);
printf("oga_gfx_init video %dx%d rgb32 %d smooth %d input_scale %u force_aspect %d fullscreen %d aw %d ah %d rgb %d\n",
video->width, video->height, video->rgb32, video->smooth, video->input_scale, video->force_aspect,
video->fullscreen, aw, ah, video->rgb32);
printf("oga_gfx_init video %dx%d rgb32 %d smooth %d input_scale %u force_aspect %d fullscreen %d aw %d ah %d rgb %d\n",
video->width, video->height, video->rgb32, video->smooth, video->input_scale, video->force_aspect,
video->fullscreen, aw, ah, video->rgb32);
vid->frame = go2_surface_create(vid->display, aw, ah, video->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_RGB565);
vid->frame = go2_surface_create(vid->display, aw, ah, video->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_RGB565);
// bitmap only for now
if (settings->bools.video_font_enable) {
vid->font_driver = &bitmap_font_renderer;
vid->font = vid->font_driver->init("", settings->floats.video_font_size);
}
/* bitmap only for now */
if (settings->bools.video_font_enable)
{
vid->font_driver = &bitmap_font_renderer;
vid->font = vid->font_driver->init("", settings->floats.video_font_size);
}
for (int i = 0; i < NUM_PAGES; ++i)
{
go2_surface_t* surface = go2_surface_create(vid->display, NATIVE_HEIGHT, NATIVE_WIDTH,
video->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_XRGB8888);
vid->frameBuffer[i] = go2_frame_buffer_create(surface);
}
vid->cur_page = 0;
for (int i = 0; i < NUM_PAGES; ++i)
{
go2_surface_t* surface = go2_surface_create(vid->display, NATIVE_HEIGHT, NATIVE_WIDTH,
video->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_XRGB8888);
vid->frameBuffer[i] = go2_frame_buffer_create(surface);
}
vid->cur_page = 0;
return vid;
return vid;
}
int get_message_width(oga_video_t* vid, const char* msg)
@ -171,110 +177,126 @@ int get_message_width(oga_video_t* vid, const char* msg)
return width;
}
static void render_msg(oga_video_t* vid, go2_surface_t* surface, const char* msg, int width, int bpp)
static void render_msg(oga_video_t* vid,
go2_surface_t* surface, const char* msg, int width, int bpp)
{
const struct font_atlas* atlas = vid->font_driver->get_atlas(vid->font);
int msg_width = get_message_width(vid, msg);
int dest_x = MAX(0, width - get_message_width(vid, msg));
int dest_stride = go2_surface_stride_get(surface);
const struct font_atlas* atlas = vid->font_driver->get_atlas(vid->font);
int msg_width = get_message_width(vid, msg);
int dest_x = MAX(0, width - get_message_width(vid, msg));
int dest_stride = go2_surface_stride_get(surface);
const char *c = msg;
const char* c = msg;
while (*c) {
const struct font_glyph* g = vid->font_driver->get_glyph(vid->font, *c);
if (!g)
continue;
if (dest_x + g->advance_x >= width)
break;
while (*c)
{
const struct font_glyph* g = vid->font_driver->get_glyph(vid->font, *c);
if (!g)
continue;
if (dest_x + g->advance_x >= width)
break;
const uint8_t* source = atlas->buffer + g->atlas_offset_y * atlas->width + g->atlas_offset_x;
uint8_t* dest = (uint8_t*)go2_surface_map(surface) + dest_x * bpp;
const uint8_t* source = atlas->buffer + g->atlas_offset_y * atlas->width + g->atlas_offset_x;
uint8_t* dest = (uint8_t*)go2_surface_map(surface) + dest_x * bpp;
for (int y = 0; y < g->height; y++) {
for (int x = 0; x < g->advance_x; x++) {
uint8_t px = (x < g->width) ? *(source++) : 0x00;
if (bpp == 4) {
*(dest++) = px;
*(dest++) = px;
*(dest++) = px;
*(dest++) = px;
}
else {
*(dest++) = px;
*(dest++) = px;
}
for (int y = 0; y < g->height; y++)
{
for (int x = 0; x < g->advance_x; x++)
{
uint8_t px = (x < g->width) ? *(source++) : 0x00;
if (bpp == 4)
{
*(dest++) = px;
*(dest++) = px;
*(dest++) = px;
*(dest++) = px;
}
dest += dest_stride - g->advance_x * bpp;
source += atlas->width - g->width;
}
else
{
*(dest++) = px;
*(dest++) = px;
}
}
dest += dest_stride - g->advance_x * bpp;
source += atlas->width - g->width;
}
c++;
dest_x += g->advance_x;
}
c++;
dest_x += g->advance_x;
}
}
static bool oga_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg, video_frame_info_t *video_info)
{
oga_video_t* vid = (oga_video_t*)data;
go2_surface_t* dst_surface = vid->frame;
uint8_t* src = (uint8_t*)frame;
int bpp = go2_drm_format_get_bpp(go2_surface_format_get(dst_surface)) / 8;
int out_w, out_h;
int yy, stride, dst_stride;
int out_x = 0;
int out_y = 0;
go2_display_t *display = NULL;
go2_frame_buffer_t *dstFrameBuffer = NULL;
go2_surface_t *dstSurface = NULL;
uint8_t *dst = NULL;
oga_video_t *vid = (oga_video_t*)data;
go2_surface_t *dst_surface = vid->frame;
uint8_t *src = (uint8_t*)frame;
int bpp = go2_drm_format_get_bpp(
go2_surface_format_get(dst_surface)) / 8;
bool menu_is_alive = video_info->menu_is_alive;
if (unlikely(video_info->menu_is_alive)) {
#ifdef HAVE_MENU
menu_driver_frame(video_info);
if (unlikely(menu_is_alive))
{
menu_driver_frame(menu_is_alive, video_info);
dst_surface = vid->menu_surface;
src = (uint8_t*)vid->menu_frame;
width = vid->menu_width;
height = vid->menu_height;
pitch = vid->menu_pitch;
bpp = vid->menu_pitch / vid->menu_width;
}
#endif
dst_surface = vid->menu_surface;
src = (uint8_t*)vid->menu_frame;
width = vid->menu_width;
height = vid->menu_height;
pitch = vid->menu_pitch;
bpp = vid->menu_pitch / vid->menu_width;
}
if (unlikely(!frame || width == 0 || height == 0))
return true;
if (unlikely(!frame || width == 0 || height == 0))
return true;
// copy buffer to surface
uint8_t* dst = (uint8_t*)go2_surface_map(dst_surface);
int yy = height;
int stride = width * bpp;
int dst_stride = go2_surface_stride_get(dst_surface);
while (yy > 0) {
memcpy(dst, src, stride);
src += pitch;
dst += dst_stride;
--yy;
}
/* copy buffer to surface */
dst = (uint8_t*)go2_surface_map(dst_surface);
yy = height;
stride = width * bpp;
dst_stride = go2_surface_stride_get(dst_surface);
int out_w = NATIVE_WIDTH;
int out_h = NATIVE_HEIGHT;
int out_x = 0;
int out_y = 0;
while (yy > 0)
{
memcpy(dst, src, stride);
src += pitch;
dst += dst_stride;
--yy;
}
if ((out_w != width || out_h != height))
{
out_w = MIN(out_h * video_driver_get_aspect_ratio(), NATIVE_WIDTH);
out_x = MAX((NATIVE_WIDTH - out_w) / 2, 0);
}
out_w = NATIVE_WIDTH;
out_h = NATIVE_HEIGHT;
if (msg && vid->font) {
render_msg(vid, dst_surface, msg, width, bpp);
}
if ((out_w != width || out_h != height))
{
out_w = MIN(out_h * video_driver_get_aspect_ratio(), NATIVE_WIDTH);
out_x = MAX((NATIVE_WIDTH - out_w) / 2, 0);
}
go2_frame_buffer_t* dstFrameBuffer = vid->frameBuffer[vid->cur_page];
go2_surface_t* dstSurface = go2_frame_buffer_surface_get(dstFrameBuffer);
if (msg && vid->font)
render_msg(vid, dst_surface, msg, width, bpp);
go2_surface_blit(dst_surface, 0, 0, width, height,
dstSurface, out_y, out_x, out_h, out_w,
!video_info->menu_is_alive ? oga_rotation : GO2_ROTATION_DEGREES_270, 2);
dstFrameBuffer = vid->frameBuffer[vid->cur_page];
dstSurface = go2_frame_buffer_surface_get(dstFrameBuffer);
go2_display_t* display = go2_presenter_display_get(vid->presenter);
go2_display_present(display, dstFrameBuffer);
vid->cur_page = !vid->cur_page;
go2_surface_blit(dst_surface, 0, 0, width, height,
dstSurface, out_y, out_x, out_h, out_w,
!menu_is_alive ? oga_rotation : GO2_ROTATION_DEGREES_270, 2);
return true;
display = go2_presenter_display_get(vid->presenter);
go2_display_present(display, dstFrameBuffer);
vid->cur_page = !vid->cur_page;
return true;
}
static void oga_set_texture_frame(void *data, const void *frame, bool rgb32,
@ -353,25 +375,26 @@ static const video_poke_interface_t oga_poke_interface = {
void oga_set_rotation(void *data, unsigned rotation)
{
// called before init?
(void)data;
switch (rotation) {
case 0:
oga_rotation = GO2_ROTATION_DEGREES_270;
break;
case 1:
oga_rotation = GO2_ROTATION_DEGREES_180;
break;
case 2:
oga_rotation = GO2_ROTATION_DEGREES_90;
break;
case 3:
oga_rotation = GO2_ROTATION_DEGREES_0;
break;
default:
RARCH_ERR("Unhandled rotation %hu\n", rotation);
break;
}
/* called before init? */
(void)data;
switch (rotation)
{
case 0:
oga_rotation = GO2_ROTATION_DEGREES_270;
break;
case 1:
oga_rotation = GO2_ROTATION_DEGREES_180;
break;
case 2:
oga_rotation = GO2_ROTATION_DEGREES_90;
break;
case 3:
oga_rotation = GO2_ROTATION_DEGREES_0;
break;
default:
RARCH_ERR("Unhandled rotation %hu\n", rotation);
break;
}
}
static void oga_get_poke_interface(void *data, const video_poke_interface_t **iface)

View File

@ -989,7 +989,8 @@ static bool omap_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count, unsigned pitch, const char *msg,
video_frame_info_t *video_info)
{
omap_video_t *vid = (omap_video_t*)data;
omap_video_t *vid = (omap_video_t*)data;
bool menu_is_alive = video_info->menu_is_alive;
if (!frame)
return true;
@ -1012,13 +1013,13 @@ static bool omap_gfx_frame(void *data, const void *frame, unsigned width,
omapfb_blit_frame(vid->omap, frame, vid->height, pitch);
#ifdef HAVE_MENU
menu_driver_frame(video_info);
#endif
menu_driver_frame(menu_is_alive, video_info);
if (vid->menu.active)
omapfb_blit_frame(vid->omap, vid->menu.frame,
vid->menu.scaler.out_height,
vid->menu.scaler.out_stride);
#endif
if (msg)
omap_render_msg(vid, msg);

View File

@ -475,7 +475,8 @@ static bool psp_frame(void *data, const void *frame,
unsigned width, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg, video_frame_info_t *video_info)
{
psp1_video_t *psp = (psp1_video_t*)data;
psp1_video_t *psp = (psp1_video_t*)data;
bool menu_is_alive = video_info->menu_is_alive;
if (!width || !height)
return false;
@ -536,7 +537,7 @@ static bool psp_frame(void *data, const void *frame,
sceGuFinish();
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
if(psp->menu.active)

View File

@ -487,13 +487,15 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg, video_frame_info_t *video_info)
{
sdl2_video_t *vid = (sdl2_video_t*)data;
char title[128];
sdl2_video_t *vid = (sdl2_video_t*)data;
bool menu_is_alive = video_info->menu_is_alive;
bool libretro_running = video_info->libretro_running;
if (vid->should_resize)
sdl_refresh_viewport(vid);
if (frame && video_info->libretro_running)
if (frame && libretro_running)
{
SDL_RenderClear(vid->renderer);
sdl_refresh_input_size(vid, false, vid->video.rgb32, width, height, pitch);
@ -503,7 +505,7 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width,
SDL_RenderCopyEx(vid->renderer, vid->frame.tex, NULL, NULL, vid->rotation, NULL, SDL_FLIP_NONE);
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
if (vid->menu.active)

View File

@ -130,19 +130,21 @@ error:
static void clear_screen(void* data)
{
sdl_dingux_video_t* vid = (sdl_dingux_video_t*)data;
SDL_FillRect(vid->screen, 0, 0);
SDL_Flip(vid->screen);
SDL_FillRect(vid->screen, 0, 0);
SDL_Flip(vid->screen);
SDL_FillRect(vid->screen, 0, 0);
SDL_Flip(vid->screen);
sdl_dingux_video_t* vid = (sdl_dingux_video_t*)data;
SDL_FillRect(vid->screen, 0, 0);
SDL_Flip(vid->screen);
SDL_FillRect(vid->screen, 0, 0);
SDL_Flip(vid->screen);
SDL_FillRect(vid->screen, 0, 0);
SDL_Flip(vid->screen);
}
static void set_output(sdl_dingux_video_t* vid, int width, int height, int pitch, bool rgb)
static void sdl_dingux_set_output(
sdl_dingux_video_t* vid,
int width, int height, int pitch, bool rgb)
{
#ifdef VERBOSE
printf("set_output current w %d h %d pitch %d new_w %d new_h %d pitch %d rgb %d\n",
printf("sdl_dingux_set_output current w %d h %d pitch %d new_w %d new_h %d pitch %d rgb %d\n",
vid->screen->w, vid->screen->h, vid->screen->pitch, width, height, pitch, (int)vid->rgb);
#endif
@ -153,61 +155,62 @@ static void set_output(sdl_dingux_video_t* vid, int width, int height, int pitch
static void blit(uint32_t* d, uint32_t* s, int width, int height, int pitch)
{
int skip = pitch/4 - width;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
*(d++) = *(s++);
s += skip;
}
unsigned i;
int skip = pitch/4 - width;
for (i = 0; i < height; i++)
{
unsigned j;
for (j = 0; j < width; j++)
*(d++) = *(s++);
s += skip;
}
}
static bool sdl_dingux_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg, video_frame_info_t *video_info)
{
sdl_dingux_video_t* vid = (sdl_dingux_video_t*)data;
sdl_dingux_video_t* vid = (sdl_dingux_video_t*)data;
bool menu_is_alive = video_info->menu_is_alive;
if (unlikely(!frame))
return true;
if (unlikely(!frame))
return true;
if (unlikely((vid->screen->w != width || vid->screen->h != height) && !vid->menu_active))
{
set_output(vid, width, height, pitch, vid->rgb);
}
if (unlikely((vid->screen->w != width || vid->screen->h != height) && !vid->menu_active))
sdl_dingux_set_output(vid, width, height, pitch, vid->rgb);
menu_driver_frame(video_info);
#ifdef HAVE_MENU
menu_driver_frame(menu_is_alive, video_info);
#endif
if (likely(!vid->menu_active))
{
blit((uint32_t*)vid->screen->pixels, (uint32_t*)frame, vid->rgb ? width : width/2, height, pitch);
if (unlikely(vid->was_in_menu))
vid->was_in_menu = false;
}
else
{
if (!vid->was_in_menu)
{
set_output(vid, 320, 240, 320*2, false);
vid->was_in_menu = true;
}
memcpy(vid->screen->pixels, vid->menu_frame, 320*240*2);
}
if (likely(!vid->menu_active))
{
blit((uint32_t*)vid->screen->pixels, (uint32_t*)frame, vid->rgb ? width : width/2, height, pitch);
if (unlikely(vid->was_in_menu))
vid->was_in_menu = false;
}
else
{
if (!vid->was_in_menu)
{
sdl_dingux_set_output(vid, 320, 240, 320*2, false);
vid->was_in_menu = true;
}
memcpy(vid->screen->pixels, vid->menu_frame, 320*240*2);
}
SDL_Flip(vid->screen);
SDL_Flip(vid->screen);
return true;
return true;
}
static void sdl_dingux_set_texture_enable(void *data, bool state, bool full_screen)
{
sdl_dingux_video_t *vid = (sdl_dingux_video_t*)data;
(void)full_screen;
sdl_dingux_video_t *vid = (sdl_dingux_video_t*)data;
(void)full_screen;
if (vid->menu_active != state)
{
vid->menu_active = state;
}
if (vid->menu_active != state)
vid->menu_active = state;
}
static void sdl_dingux_set_texture_frame(void *data, const void *frame, bool rgb32,

View File

@ -363,8 +363,9 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg, video_frame_info_t *video_info)
{
sdl_video_t *vid = (sdl_video_t*)data;
char title[128];
sdl_video_t *vid = (sdl_video_t*)data;
bool menu_is_alive = video_info->menu_is_alive;
if (!frame)
return true;
@ -389,11 +390,11 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width,
pitch);
#ifdef HAVE_MENU
menu_driver_frame(video_info);
#endif
menu_driver_frame(menu_is_alive, video_info);
if (vid->menu.active)
SDL_BlitSurface(vid->menu.frame, NULL, vid->screen, NULL);
#endif
if (msg)
sdl_render_msg(vid, vid->screen,

View File

@ -269,12 +269,13 @@ static bool sixel_gfx_frame(void *data, const void *frame,
unsigned pixfmt = SIXEL_PIXELFORMAT_RGB565;
bool draw = true;
sixel_t *sixel = (sixel_t*)data;
bool menu_is_alive = video_info->menu_is_alive;
if (!frame || !frame_width || !frame_height)
return true;
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
if (sixel_video_width != frame_width || sixel_video_height != frame_height || sixel_video_pitch != pitch)

View File

@ -776,6 +776,7 @@ static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width,
video_frame_info_t *video_info)
{
struct sunxi_video *_dispvars = (struct sunxi_video*)data;
bool menu_is_alive = video_info->menu_is_alive;
if (_dispvars->src_width != width || _dispvars->src_height != height)
{
@ -790,7 +791,7 @@ static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width,
}
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
if (_dispvars->menu_active)

View File

@ -142,7 +142,7 @@ static bool switch_frame(void *data, const void *frame,
uint64_t frame_count, unsigned pitch,
const char *msg, video_frame_info_t *video_info)
{
static uint64_t last_frame = 0;
static uint64_t last_frame = 0;
unsigned x, y;
result_t r;
@ -152,6 +152,7 @@ static bool switch_frame(void *data, const void *frame,
int xsf = 1280 / width;
int ysf = 720 / height;
int sf = xsf;
bool menu_is_alive = video_info->menu_is_alive;
if (ysf < sf)
sf = ysf;
@ -170,8 +171,8 @@ static bool switch_frame(void *data, const void *frame,
if(width > 0 && height > 0)
{
if(sw->last_width != width ||
sw->last_height != height)
if(sw->last_width != width ||
sw->last_height != height)
{
scaler_ctx_gen_reset(&sw->scaler);
@ -197,31 +198,31 @@ static bool switch_frame(void *data, const void *frame,
sw->last_height = height;
}
scaler_ctx_scale(&sw->scaler, sw->image + (centery * 1280) + centerx, frame);
scaler_ctx_scale(&sw->scaler, sw->image + (centery * 1280) + centerx, frame);
}
#if defined(HAVE_MENU)
if (sw->menu_texture.enable)
{
menu_driver_frame(video_info);
{
menu_driver_frame(menu_is_alive, video_info);
if (sw->menu_texture.pixels)
{
if (sw->menu_texture.pixels)
{
#if 0
if (sw->menu_texture.fullscreen)
if (sw->menu_texture.fullscreen)
{
#endif
scaler_ctx_scale(&sw->menu_texture.scaler, sw->image +
((720-sw->menu_texture.tgth)/2)*1280 +
((1280-sw->menu_texture.tgtw)/2), sw->menu_texture.pixels);
scaler_ctx_scale(&sw->menu_texture.scaler, sw->image +
((720-sw->menu_texture.tgth)/2)*1280 +
((1280-sw->menu_texture.tgtw)/2), sw->menu_texture.pixels);
#if 0
}
else
{
}
#endif
}
}
}
}
else if (video_info->statistics_show)
{
struct font_params *osd_params = (struct font_params*)
@ -246,11 +247,11 @@ static bool switch_frame(void *data, const void *frame,
r = surface_dequeue_buffer(&sw->surface, &out_buffer);
if(r != RESULT_OK)
return true; /* just skip the frame */
return true; /* just skip the frame */
r = surface_wait_buffer(&sw->surface);
if(r != RESULT_OK)
return true;
return true;
gfx_slow_swizzling_blit(out_buffer, sw->image, 1280, 720, 0, 0);
r = surface_queue_buffer(&sw->surface);

View File

@ -344,135 +344,138 @@ static bool switch_frame(void *data, const void *frame,
uint64_t frame_count, unsigned pitch,
const char *msg, video_frame_info_t *video_info)
{
switch_video_t *sw = data;
uint32_t *out_buffer = NULL;
bool ffwd_mode = video_info->input_driver_nonblock_state;
uint32_t stride;
switch_video_t *sw = data;
uint32_t *out_buffer = NULL;
bool ffwd_mode = video_info->input_driver_nonblock_state;
bool menu_is_alive = video_info->menu_is_alive;
if (!frame)
return true;
if (!frame)
return true;
if (ffwd_mode && !sw->is_threaded)
{
/* render every 4th frame when in ffwd mode and not threaded */
if ((frame_count % 4) != 0)
return true;
}
if (ffwd_mode && !sw->is_threaded)
{
/* render every 4th frame when in ffwd mode and not threaded */
if ((frame_count % 4) != 0)
return true;
}
if ( sw->should_resize ||
width != sw->last_width ||
height != sw->last_height)
{
switch_update_viewport(sw, video_info);
if ( sw->should_resize ||
width != sw->last_width ||
height != sw->last_height)
{
switch_update_viewport(sw, video_info);
/* Sanity check */
sw->vp.width = MIN(sw->vp.width, sw->vp.full_width);
sw->vp.height = MIN(sw->vp.height, sw->vp.full_height);
/* Sanity check */
sw->vp.width = MIN(sw->vp.width, sw->vp.full_width);
sw->vp.height = MIN(sw->vp.height, sw->vp.full_height);
scaler_ctx_gen_reset(&sw->scaler);
scaler_ctx_gen_reset(&sw->scaler);
sw->scaler.in_width = width;
sw->scaler.in_height = height;
sw->scaler.in_stride = pitch;
sw->scaler.in_fmt = sw->rgb32
? SCALER_FMT_ARGB8888
: SCALER_FMT_RGB565;
sw->scaler.in_width = width;
sw->scaler.in_height = height;
sw->scaler.in_stride = pitch;
sw->scaler.in_fmt = sw->rgb32
? SCALER_FMT_ARGB8888
: SCALER_FMT_RGB565;
if (!sw->smooth)
{
sw->scaler.out_width = sw->vp.width;
sw->scaler.out_height = sw->vp.height;
sw->scaler.out_stride = sw->vp.full_width * sizeof(uint32_t);
}
else
{
sw->scaler.out_width = width;
sw->scaler.out_height = height;
sw->scaler.out_stride = width * sizeof(uint32_t);
if (!sw->smooth)
{
sw->scaler.out_width = sw->vp.width;
sw->scaler.out_height = sw->vp.height;
sw->scaler.out_stride = sw->vp.full_width * sizeof(uint32_t);
}
else
{
sw->scaler.out_width = width;
sw->scaler.out_height = height;
sw->scaler.out_stride = width * sizeof(uint32_t);
float screen_ratio = (float)sw->vp.full_width / sw->vp.full_height;
float tgt_ratio = (float)sw->vp.width / sw->vp.height;
float screen_ratio = (float)sw->vp.full_width / sw->vp.full_height;
float tgt_ratio = (float)sw->vp.width / sw->vp.height;
sw->hw_scale.width = ceil(screen_ratio / tgt_ratio * sw->scaler.out_width);
sw->hw_scale.height = sw->scaler.out_height;
sw->hw_scale.x_offset = ceil((sw->hw_scale.width - sw->scaler.out_width) / 2.0);
if (!video_info->menu_is_alive)
{
clear_screen(sw);
nwindowSetDimensions(sw->win, sw->hw_scale.width, sw->hw_scale.height);
}
}
sw->scaler.out_fmt = SCALER_FMT_ABGR8888;
sw->hw_scale.width = ceil(screen_ratio / tgt_ratio * sw->scaler.out_width);
sw->hw_scale.height = sw->scaler.out_height;
sw->hw_scale.x_offset = ceil((sw->hw_scale.width - sw->scaler.out_width) / 2.0);
if (!video_info->menu_is_alive)
{
clear_screen(sw);
nwindowSetDimensions(sw->win, sw->hw_scale.width, sw->hw_scale.height);
}
}
sw->scaler.out_fmt = SCALER_FMT_ABGR8888;
sw->scaler.scaler_type = SCALER_TYPE_POINT;
sw->scaler.scaler_type = SCALER_TYPE_POINT;
if (!scaler_ctx_gen_filter(&sw->scaler))
return false;
if (!scaler_ctx_gen_filter(&sw->scaler))
return false;
sw->last_width = width;
sw->last_height = height;
sw->last_width = width;
sw->last_height = height;
sw->should_resize = false;
}
sw->should_resize = false;
}
uint32_t stride;
out_buffer = (uint32_t *)framebufferBegin(&sw->fb, &stride);
sw->out_buffer = out_buffer;
sw->stride = stride;
out_buffer = (uint32_t *)framebufferBegin(&sw->fb, &stride);
sw->out_buffer = out_buffer;
sw->stride = stride;
if (sw->in_menu && !video_info->menu_is_alive && sw->smooth)
{
memset(out_buffer, 0, stride * sw->vp.full_height);
nwindowSetDimensions(sw->win, sw->hw_scale.width, sw->hw_scale.height);
}
sw->in_menu = video_info->menu_is_alive;
if (sw->in_menu && !video_info->menu_is_alive && sw->smooth)
{
memset(out_buffer, 0, stride * sw->vp.full_height);
nwindowSetDimensions(sw->win, sw->hw_scale.width, sw->hw_scale.height);
}
sw->in_menu = video_info->menu_is_alive;
#ifdef HAVE_MENU
if (sw->menu_texture.enable)
{
menu_driver_frame(menu_is_alive, video_info);
if (sw->menu_texture.enable)
{
menu_driver_frame(video_info);
if (sw->menu_texture.pixels)
{
memset(out_buffer, 0, stride * sw->vp.full_height);
scaler_ctx_scale(&sw->menu_texture.scaler, sw->tmp_image + ((sw->vp.full_height - sw->menu_texture.tgth) / 2) * sw->vp.full_width + ((sw->vp.full_width - sw->menu_texture.tgtw) / 2), sw->menu_texture.pixels);
gfx_cpy_dsp_buf(out_buffer, sw->tmp_image, sw->vp.full_width, sw->vp.full_height, stride, true);
}
}
else
#endif
if (sw->smooth) /* bilinear */
{
int w, h;
unsigned x, y;
struct scaler_ctx *ctx = &sw->scaler;
scaler_ctx_scale_direct(ctx, sw->image, frame);
w = sw->scaler.out_width;
h = sw->scaler.out_height;
if (sw->menu_texture.pixels)
{
memset(out_buffer, 0, stride * sw->vp.full_height);
scaler_ctx_scale(&sw->menu_texture.scaler, sw->tmp_image + ((sw->vp.full_height - sw->menu_texture.tgth) / 2) * sw->vp.full_width + ((sw->vp.full_width - sw->menu_texture.tgtw) / 2), sw->menu_texture.pixels);
gfx_cpy_dsp_buf(out_buffer, sw->tmp_image, sw->vp.full_width, sw->vp.full_height, stride, true);
}
}
else if (sw->smooth) /* bilinear */
{
int w, h;
unsigned x, y;
struct scaler_ctx *ctx = &sw->scaler;
scaler_ctx_scale_direct(ctx, sw->image, frame);
w = sw->scaler.out_width;
h = sw->scaler.out_height;
for (y = 0; y < h; y++)
for (y = 0; y < h; y++)
for (x = 0; x < w; x++)
out_buffer[y * stride / sizeof(uint32_t) + (x + sw->hw_scale.x_offset)] = sw->image[y * w + x];
}
else
{
struct scaler_ctx *ctx = &sw->scaler;
scaler_ctx_scale(ctx, sw->image + (sw->vp.y * sw->vp.full_width) + sw->vp.x, frame);
gfx_cpy_dsp_buf(out_buffer, sw->image, sw->vp.full_width, sw->vp.full_height, stride, false);
}
out_buffer[y * stride / sizeof(uint32_t) + (x + sw->hw_scale.x_offset)] = sw->image[y * w + x];
}
else
{
struct scaler_ctx *ctx = &sw->scaler;
scaler_ctx_scale(ctx, sw->image + (sw->vp.y * sw->vp.full_width) + sw->vp.x, frame);
gfx_cpy_dsp_buf(out_buffer, sw->image, sw->vp.full_width, sw->vp.full_height, stride, false);
}
if (video_info->statistics_show && !sw->smooth)
{
struct font_params *osd_params = (struct font_params *)&video_info->osd_stat_params;
if (video_info->statistics_show && !sw->smooth)
{
struct font_params *osd_params = (struct font_params *)&video_info->osd_stat_params;
if (osd_params)
font_driver_render_msg(sw, video_info->stat_text,
(const struct font_params *)&video_info->osd_stat_params, NULL);
}
if (osd_params)
font_driver_render_msg(sw, video_info->stat_text,
(const struct font_params *)&video_info->osd_stat_params, NULL);
}
if (msg)
font_driver_render_msg(sw, msg, NULL, NULL);
if (msg)
font_driver_render_msg(sw, msg, NULL, NULL);
framebufferEnd(&sw->fb);
return true;
return true;
}
static void switch_set_nonblock_state(void *data, bool toggle, bool c, unsigned d)

View File

@ -416,8 +416,9 @@ static bool vg_frame(void *data, const void *frame,
video_frame_info_t *video_info)
{
vg_t *vg = (vg_t*)data;
unsigned width = video_info->width;
unsigned height = video_info->height;
unsigned width = video_info->width;
unsigned height = video_info->height;
bool menu_is_alive = video_info->menu_is_alive;
if ( frame_width != vg->mRenderWidth
|| frame_height != vg->mRenderHeight
@ -444,7 +445,7 @@ static bool vg_frame(void *data, const void *frame,
vg_copy_frame(vg, frame, frame_width, frame_height, pitch);
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
vgDrawImage(vg->mImage);

View File

@ -144,12 +144,13 @@ static bool vga_gfx_frame(void *data, const void *frame,
const void *frame_to_copy = frame;
bool draw = true;
vga_t *vga = (vga_t*)data;
bool menu_is_alive = video_info->menu_is_alive;
if (!frame || !frame_width || !frame_height)
return true;
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
if ( vga->vga_video_width != frame_width ||

View File

@ -145,6 +145,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
{
void *tex_p;
vita_video_t *vita = (vita_video_t *)data;
bool menu_is_alive = video_info->menu_is_alive;
if (frame)
{
@ -221,7 +222,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
if (vita->menu.active)
{
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
if(vita->menu.texture)

View File

@ -1685,6 +1685,7 @@ static bool vulkan_frame(void *data, const void *frame,
unsigned video_height = video_info->height;
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
bool menu_is_alive = video_info->menu_is_alive;
VkCommandBufferBeginInfo begin_info = {
VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO };
@ -1934,7 +1935,7 @@ static bool vulkan_frame(void *data, const void *frame,
settings_t *settings = config_get_ptr();
bool menu_linear_filter = settings->bools.menu_linear_filter;
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
if (vk->menu.textures[vk->menu.last_index].image != VK_NULL_HANDLE ||
vk->menu.textures[vk->menu.last_index].buffer != VK_NULL_HANDLE)

View File

@ -198,7 +198,8 @@ static bool xenon360_gfx_frame(void *data,
uint64_t frame_count, unsigned pitch, const char *msg,
video_frame_info_t *video_info)
{
xenos_t *xenos = (xenos_t*)data;
xenos_t *xenos = (xenos_t*)data;
bool menu_is_alive = video_info->menu_is_alive;
ScreenUv[UV_TOP] = ((float) (width) / (float) XE_W)*2;
ScreenUv[UV_LEFT] = ((float) (height) / (float) XE_H)*2;
@ -238,7 +239,7 @@ static bool xenon360_gfx_frame(void *data,
Xe_SetShader(xenos->device, SHADER_TYPE_VERTEX, xenos->g_pVertexShader, 0);
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
/* Draw */

View File

@ -98,17 +98,16 @@ static bool xshm_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg, video_frame_info_t *video_info)
{
xshm_t* xshm = (xshm_t*)data;
int y;
unsigned y;
xshm_t *xshm = (xshm_t*)data;
bool menu_is_alive = video_info->menu_is_alive;
for (y=0;y<height;y++)
{
for (y = 0; y < height; y++)
memcpy((uint8_t*)xshm->shmInfo.shmaddr + sizeof(uint32_t)*xshm->width*y,
(uint8_t*)frame + pitch*y, pitch);
}
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
XShmPutImage(xshm->display, xshm->wndw, xshm->gc, xshm->image,

View File

@ -844,6 +844,7 @@ static bool xv_frame(void *data, const void *frame, unsigned width,
{
XWindowAttributes target;
xv_t *xv = (xv_t*)data;
bool menu_is_alive = video_info->menu_is_alive;
if (!frame)
return true;
@ -859,7 +860,7 @@ static bool xv_frame(void *data, const void *frame, unsigned width,
xv->vp.full_height = target.height;
#ifdef HAVE_MENU
menu_driver_frame(video_info);
menu_driver_frame(menu_is_alive, video_info);
#endif
if (msg)

View File

@ -2215,9 +2215,8 @@ const char *menu_driver_ident(void)
return menu_driver_ctx->ident;
}
void menu_driver_frame(video_frame_info_t *video_info)
void menu_driver_frame(bool menu_is_alive, video_frame_info_t *video_info)
{
bool menu_is_alive = video_info->menu_is_alive;
if (menu_is_alive && menu_driver_ctx->frame)
menu_driver_ctx->frame(menu_userdata, video_info);
}

View File

@ -427,7 +427,7 @@ const char *menu_driver_ident(void);
bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data);
void menu_driver_frame(video_frame_info_t *video_info);
void menu_driver_frame(bool menu_is_alive, video_frame_info_t *video_info);
bool menu_driver_get_load_content_animation_data(
uintptr_t *icon, char **playlist_name);