2015-04-21 12:44:14 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "menu.h"
|
|
|
|
#include "menu_display.h"
|
|
|
|
#include "menu_animation.h"
|
|
|
|
#include "../dynamic.h"
|
|
|
|
#include "../../retroarch.h"
|
2015-04-24 14:42:27 +00:00
|
|
|
#include "../../config.def.h"
|
2015-04-21 13:45:03 +00:00
|
|
|
#include "../gfx/video_context_driver.h"
|
2015-05-05 18:09:29 +00:00
|
|
|
#include "menu_list.h"
|
2015-04-21 12:44:14 +00:00
|
|
|
|
2015-05-18 21:02:04 +00:00
|
|
|
bool menu_display_fb_in_use(void)
|
|
|
|
{
|
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
|
|
|
if (!menu)
|
|
|
|
return false;
|
|
|
|
return menu->frame_buf.data != NULL;
|
|
|
|
}
|
|
|
|
|
2015-05-18 21:14:56 +00:00
|
|
|
void menu_display_fb_set_dirty(void)
|
|
|
|
{
|
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
|
|
|
if (!menu)
|
2015-05-18 21:21:32 +00:00
|
|
|
return;
|
2015-05-18 21:14:56 +00:00
|
|
|
if (!menu_display_fb_in_use())
|
2015-05-18 21:21:32 +00:00
|
|
|
return;
|
2015-05-18 21:14:56 +00:00
|
|
|
menu->framebuf.dirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void menu_display_fb_unset_dirty(void)
|
|
|
|
{
|
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
|
|
|
if (!menu)
|
2015-05-18 21:21:32 +00:00
|
|
|
return;
|
2015-05-18 21:14:56 +00:00
|
|
|
if (!menu_display_fb_in_use())
|
2015-05-18 21:21:32 +00:00
|
|
|
return;
|
2015-05-18 21:14:56 +00:00
|
|
|
menu->framebuf.dirty = false;
|
|
|
|
}
|
|
|
|
|
2015-04-21 12:44:14 +00:00
|
|
|
/**
|
|
|
|
** menu_display_fb:
|
|
|
|
*
|
|
|
|
* Draws menu graphics onscreen.
|
|
|
|
**/
|
|
|
|
void menu_display_fb(void)
|
|
|
|
{
|
|
|
|
driver_t *driver = driver_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
video_driver_set_texture_enable(true, false);
|
|
|
|
|
|
|
|
if (!settings->menu.pause_libretro)
|
|
|
|
{
|
|
|
|
if (global->main_is_init && !global->libretro_dummy)
|
|
|
|
{
|
|
|
|
bool block_libretro_input = driver->block_libretro_input;
|
|
|
|
driver->block_libretro_input = true;
|
|
|
|
pretro_run();
|
|
|
|
driver->block_libretro_input = block_libretro_input;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-20 19:06:44 +00:00
|
|
|
video_driver_cached_frame();
|
2015-04-21 12:44:14 +00:00
|
|
|
}
|
|
|
|
|
2015-05-18 21:16:03 +00:00
|
|
|
bool menu_display_update_pending(void)
|
|
|
|
{
|
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
|
|
|
if (menu)
|
|
|
|
{
|
|
|
|
if (menu->animation_is_active || menu->label.is_updated || menu->framebuf.dirty)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-04-22 23:21:43 +00:00
|
|
|
void menu_display_free(menu_handle_t *menu)
|
2015-04-21 12:44:14 +00:00
|
|
|
{
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
menu_animation_free(menu->animation);
|
|
|
|
menu->animation = NULL;
|
|
|
|
}
|
|
|
|
|
2015-04-22 23:21:43 +00:00
|
|
|
bool menu_display_init(menu_handle_t *menu)
|
2015-04-21 12:44:14 +00:00
|
|
|
{
|
|
|
|
if (!menu)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
menu->animation = (animation_t*)calloc(1, sizeof(animation_t));
|
|
|
|
|
|
|
|
if (!menu->animation)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-04-21 13:45:03 +00:00
|
|
|
|
2015-05-12 12:41:01 +00:00
|
|
|
float menu_display_get_dpi(void)
|
2015-04-21 13:45:03 +00:00
|
|
|
{
|
2015-05-01 14:05:50 +00:00
|
|
|
float dpi = menu_dpi_override_value;
|
2015-04-24 14:37:09 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-04-21 13:45:03 +00:00
|
|
|
|
2015-05-12 12:41:01 +00:00
|
|
|
if (!settings)
|
2015-05-01 14:05:50 +00:00
|
|
|
return dpi;
|
|
|
|
|
|
|
|
if (settings->menu.dpi.override_enable)
|
|
|
|
dpi = settings->menu.dpi.override_value;
|
|
|
|
#if defined(HAVE_OPENGL) || defined(HAVE_GLES)
|
|
|
|
else if (!gfx_ctx_get_metrics(DISPLAY_METRIC_DPI, &dpi))
|
|
|
|
dpi = menu_dpi_override_value;
|
|
|
|
#endif
|
2015-04-21 13:45:03 +00:00
|
|
|
|
|
|
|
return dpi;
|
|
|
|
}
|
2015-04-24 20:01:33 +00:00
|
|
|
|
|
|
|
bool menu_display_font_init_first(const void **font_driver,
|
|
|
|
void **font_handle, void *video_data, const char *font_path,
|
|
|
|
float font_size)
|
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
2015-05-20 17:56:12 +00:00
|
|
|
const struct retro_hw_render_callback *hw_render =
|
|
|
|
(const struct retro_hw_render_callback*)video_driver_callback();
|
2015-04-24 20:01:33 +00:00
|
|
|
|
2015-05-20 17:56:12 +00:00
|
|
|
if (settings->video.threaded && !hw_render->context_type)
|
2015-04-24 20:01:33 +00:00
|
|
|
{
|
|
|
|
driver_t *driver = driver_get_ptr();
|
|
|
|
thread_video_t *thr = (thread_video_t*)driver->video_data;
|
2015-05-20 19:58:22 +00:00
|
|
|
thread_packet_t pkt;
|
2015-04-24 20:01:33 +00:00
|
|
|
|
|
|
|
if (!thr)
|
|
|
|
return false;
|
|
|
|
|
2015-05-20 19:58:22 +00:00
|
|
|
pkt.type = CMD_FONT_INIT;
|
|
|
|
pkt.data.font_init.method = font_init_first;
|
|
|
|
pkt.data.font_init.font_driver = (const void**)font_driver;
|
|
|
|
pkt.data.font_init.font_handle = font_handle;
|
|
|
|
pkt.data.font_init.video_data = video_data;
|
|
|
|
pkt.data.font_init.font_path = font_path;
|
|
|
|
pkt.data.font_init.font_size = font_size;
|
|
|
|
pkt.data.font_init.api = FONT_DRIVER_RENDER_OPENGL_API;
|
2015-04-24 20:01:33 +00:00
|
|
|
|
2015-05-20 19:58:22 +00:00
|
|
|
thr->send_and_wait(thr, &pkt);
|
2015-04-24 20:01:33 +00:00
|
|
|
|
2015-05-20 19:58:22 +00:00
|
|
|
return pkt.data.font_init.return_value;
|
2015-04-24 20:01:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return font_init_first(font_driver, font_handle, video_data,
|
|
|
|
font_path, font_size, FONT_DRIVER_RENDER_OPENGL_API);
|
|
|
|
}
|
2015-04-24 21:22:47 +00:00
|
|
|
|
2015-04-24 21:28:25 +00:00
|
|
|
bool menu_display_font_bind_block(menu_handle_t *menu,
|
|
|
|
const struct font_renderer *font_driver, void *userdata)
|
2015-04-24 21:22:47 +00:00
|
|
|
{
|
2015-04-24 21:28:25 +00:00
|
|
|
if (!font_driver || !font_driver->bind_block)
|
2015-04-24 21:22:47 +00:00
|
|
|
return false;
|
|
|
|
|
2015-04-24 21:28:25 +00:00
|
|
|
font_driver->bind_block(menu->font.buf, userdata);
|
|
|
|
|
2015-04-24 21:22:47 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-24 21:28:25 +00:00
|
|
|
bool menu_display_font_flush_block(menu_handle_t *menu,
|
|
|
|
const struct font_renderer *font_driver)
|
2015-04-24 21:22:47 +00:00
|
|
|
{
|
2015-04-24 21:28:25 +00:00
|
|
|
if (!font_driver || !font_driver->flush)
|
2015-04-24 21:22:47 +00:00
|
|
|
return false;
|
|
|
|
|
2015-04-24 21:28:25 +00:00
|
|
|
font_driver->flush(menu->font.buf);
|
2015-04-24 21:22:47 +00:00
|
|
|
|
2015-04-24 21:28:25 +00:00
|
|
|
return menu_display_font_bind_block(menu,
|
|
|
|
font_driver, NULL);
|
2015-04-24 21:22:47 +00:00
|
|
|
}
|
2015-04-26 14:46:56 +00:00
|
|
|
|
2015-05-01 12:00:03 +00:00
|
|
|
void menu_display_free_main_font(menu_handle_t *menu)
|
|
|
|
{
|
|
|
|
driver_t *driver = driver_get_ptr();
|
2015-05-11 07:56:13 +00:00
|
|
|
|
2015-05-01 12:00:03 +00:00
|
|
|
if (menu->font.buf)
|
|
|
|
{
|
|
|
|
driver->font_osd_driver->free(menu->font.buf);
|
|
|
|
menu->font.buf = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool menu_display_init_main_font(menu_handle_t *menu,
|
|
|
|
const char *font_path, float font_size)
|
|
|
|
{
|
|
|
|
driver_t *driver = driver_get_ptr();
|
|
|
|
void *video = video_driver_get_ptr(NULL);
|
|
|
|
bool result;
|
|
|
|
|
|
|
|
if (menu->font.buf)
|
|
|
|
menu_display_free_main_font(menu);
|
|
|
|
|
|
|
|
result = menu_display_font_init_first(
|
|
|
|
(const void**)&driver->font_osd_driver, &menu->font.buf, video,
|
|
|
|
font_path, font_size);
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
menu->font.size = font_size;
|
|
|
|
else
|
|
|
|
menu->font.buf = NULL;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-05-19 22:26:50 +00:00
|
|
|
void menu_display_set_viewport(void)
|
|
|
|
{
|
|
|
|
unsigned width, height;
|
2015-05-19 22:29:46 +00:00
|
|
|
video_driver_get_size(&width, &height);
|
2015-04-26 14:46:56 +00:00
|
|
|
|
2015-05-19 22:26:50 +00:00
|
|
|
video_driver_set_viewport(width, height, true, false);
|
2015-04-26 14:46:56 +00:00
|
|
|
}
|
2015-04-26 16:08:17 +00:00
|
|
|
|
2015-05-12 12:41:01 +00:00
|
|
|
void menu_display_unset_viewport(void)
|
2015-04-26 16:08:17 +00:00
|
|
|
{
|
2015-05-19 22:26:50 +00:00
|
|
|
unsigned width, height;
|
2015-05-19 22:29:46 +00:00
|
|
|
video_driver_get_size(&width, &height);
|
2015-04-26 16:08:17 +00:00
|
|
|
|
2015-05-19 22:26:50 +00:00
|
|
|
video_driver_set_viewport(width,
|
|
|
|
height, false, true);
|
2015-04-26 16:08:17 +00:00
|
|
|
}
|