ZengGengSen 1 жил өмнө
parent
commit
b49a403f6c

+ 2 - 2
app/src/main/cpp/CMakeLists.txt

@@ -63,7 +63,7 @@ endif ()
 target_compile_definitions(${PROJECT_NAME} PRIVATE
         RARCH_MOBILE
         HAVE_GRIFFIN
-        HAVE_STB_VORBIS
+        # HAVE_STB_VORBIS
         ANDROID
         HAVE_DYNAMIC
         HAVE_OPENGL
@@ -103,7 +103,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
         # HAVE_OZONE
         HAVE_SHADERPIPELINE
         HAVE_LIBRETRODB
-        HAVE_STB_FONT
+        # HAVE_STB_FONT
         HAVE_IMAGEVIEWER
         # HAVE_ONLINE_UPDATER
         # HAVE_UPDATE_ASSETS

+ 2 - 0
app/src/main/cpp/gfx/common/vulkan_common.h

@@ -48,7 +48,9 @@
 #include <libretro_vulkan.h>
 
 #include "../video_defines.h"
+#ifdef HAVE_FONT
 #include "../font_driver.h"
+#endif
 #include "../drivers_shader/shader_vulkan.h"
 #include "../include/vulkan/vulkan.h"
 

+ 16 - 0
app/src/main/cpp/gfx/drivers/gl2.c

@@ -64,7 +64,9 @@
 #include "../video_thread_wrapper.h"
 #endif
 
+#ifdef HAVE_FONT
 #include "../font_driver.h"
+#endif
 
 #ifdef HAVE_GLSL
 #include "../drivers_shader/shader_glsl.h"
@@ -2350,7 +2352,11 @@ static void gl2_render_osd_background(gl2_t *gl, const char *msg)
    settings_t *settings    = config_get_ptr();
    float video_font_size   = settings->floats.video_font_size;
    int msg_width           =
+#if HAVE_FONT
       font_driver_get_message_width(NULL, msg, strlen(msg), 1.0f);
+#else
+      0;
+#endif
 
    /* shader driver expects vertex coords as 0..1 */
    float x                 = settings->floats.video_msg_pos_x;
@@ -2858,12 +2864,14 @@ static bool gl2_frame(void *data, const void *frame,
       gfx_widgets_frame(video_info);
 #endif
 
+#if HAVE_FONT
    if (!string_is_empty(msg))
    {
       if (msg_bgcolor_enable)
          gl2_render_osd_background(gl, msg);
       font_driver_render_msg(gl, msg, NULL, NULL);
    }
+#endif
 
    if (gl->ctx_driver->update_window_title)
       gl->ctx_driver->update_window_title(gl->ctx_data);
@@ -2976,7 +2984,9 @@ static void gl2_free(void *data)
             (gl2_renderchain_data_t*)
             gl->renderchain_data);
 
+#if HAVE_FONT
    font_driver_free_osd();
+#endif
 
    gl->shader->deinit(gl->shader_data);
 
@@ -3800,11 +3810,13 @@ static void *gl2_init(const video_info_t *video,
             input, input_data);
    }
 
+#if HAVE_FONT
    if (video->font_enable)
       font_driver_init_osd(gl, video,
             false,
             video->is_threaded,
             FONT_DRIVER_RENDER_OPENGL_API);
+#endif
 
    /* Only bother with PBO readback if we're doing GPU recording.
     * Check recording_st->enable and not
@@ -4458,7 +4470,11 @@ static const video_poke_interface_t gl2_poke_interface = {
    gl2_apply_state_changes,
    gl2_set_texture_frame,
    gl2_set_texture_enable,
+#ifdef HAVE_FONT
    font_driver_render_msg,
+#else
+   NULL,
+#endif
    gl2_show_mouse,
    NULL,
    gl2_get_current_shader,

+ 14 - 0
app/src/main/cpp/gfx/drivers/vulkan.c

@@ -39,7 +39,9 @@
 #include "../gfx_widgets.h"
 #endif
 
+#ifdef HAVE_FONT
 #include "../font_driver.h"
+#endif
 
 #include "../common/vulkan_common.h"
 
@@ -1193,7 +1195,9 @@ static void vulkan_free(void *data)
       /* No need to init this since textures are create on-demand. */
       vulkan_deinit_menu(vk);
 
+#ifdef HAVE_FONT
       font_driver_free_osd();
+#endif
 
       vulkan_deinit_static_resources(vk);
 #ifdef HAVE_OVERLAY
@@ -1610,12 +1614,14 @@ static void *vulkan_init(const video_info_t *video,
             input, input_data);
    }
 
+#if HAVE_FONT
    if (video->font_enable)
       font_driver_init_osd(vk,
             video,
             false,
             video->is_threaded,
             FONT_DRIVER_RENDER_VULKAN_API);
+#endif
 
 #if OSX
    // The MoltenVK driver needs this, particularly after driver reinit
@@ -2586,8 +2592,10 @@ static bool vulkan_frame(void *data, const void *frame,
          vulkan_render_overlay(vk, video_width, video_height);
 #endif
 
+#if HAVE_FONT
       if (!string_is_empty(msg))
          font_driver_render_msg(vk, msg, NULL, NULL);
+#endif
 
 #ifdef HAVE_GFX_WIDGETS
       if (widgets_active)
@@ -3428,7 +3436,13 @@ static const video_poke_interface_t vulkan_poke_interface = {
    vulkan_apply_state_changes,
    vulkan_set_texture_frame,
    vulkan_set_texture_enable,
+
+#if HAVE_FONT
    font_driver_render_msg,
+#else
+   NULL,
+#endif
+
    vulkan_show_mouse,
    NULL,                               /* grab_mouse_toggle */
    vulkan_get_current_shader,

+ 0 - 524
app/src/main/cpp/gfx/drivers_font/gl2_raster_font.c

@@ -1,524 +0,0 @@
-/*  RetroArch - A frontend for libretro.
- *  Copyright (C) 2010-2014 - Hans-Kristian Arntzen
- *  Copyright (C) 2011-2017 - Daniel De Matteis
- *  Copyright (C) 2016-2019 - Brad Parker
- *
- *  RetroArch is free software: you can redistribute it and/or modify it under the terms
- *  of the GNU General Public License as published by the Free Software Found-
- *  ation, either version 3 of the License, or (at your option) any later version.
- *
- *  RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- *  PURPOSE.  See the GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along with RetroArch.
- *  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdlib.h>
-
-#include <encodings/utf.h>
-#include <string/stdstring.h>
-#include <retro_math.h>
-
-#include "../common/gl2_common.h"
-#include "../font_driver.h"
-#include "../../configuration.h"
-
-/* TODO: Move viewport side effects to the caller: it's a source of bugs. */
-
-#define GL_RASTER_FONT_EMIT(c, vx, vy) \
-   font_vertex[     2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
-   font_vertex[     2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
-   font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
-   font_tex_coords[ 2 * (6 * i + c) + 1] = (tex_y + vy * height) * inv_tex_size_y; \
-   font_color[      4 * (6 * i + c) + 0] = color[0]; \
-   font_color[      4 * (6 * i + c) + 1] = color[1]; \
-   font_color[      4 * (6 * i + c) + 2] = color[2]; \
-   font_color[      4 * (6 * i + c) + 3] = color[3]; \
-   font_lut_tex_coord[    2 * (6 * i + c) + 0] = gl->coords.lut_tex_coord[0]; \
-   font_lut_tex_coord[    2 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]
-
-#define MAX_MSG_LEN_CHUNK 64
-
-typedef struct
-{
-   gl2_t *gl;
-   GLuint tex;
-   unsigned tex_width, tex_height;
-
-   const font_renderer_driver_t *font_driver;
-   void *font_data;
-   struct font_atlas *atlas;
-
-   video_font_raster_block_t *block;
-} gl2_raster_t;
-
-static void gl2_raster_font_free(void *data,
-      bool is_threaded)
-{
-   gl2_raster_t *font = (gl2_raster_t*)data;
-   if (!font)
-      return;
-
-   if (font->font_driver && font->font_data)
-      font->font_driver->free(font->font_data);
-
-   if (is_threaded)
-   {
-      if (
-            font->gl && 
-            font->gl->ctx_driver &&
-            font->gl->ctx_driver->make_current)
-         font->gl->ctx_driver->make_current(true);
-   }
-
-   if (font->tex)
-   {
-      glDeleteTextures(1, &font->tex);
-      font->tex = 0;
-   }
-
-   free(font);
-}
-
-static void gl2_raster_font_upload_atlas(gl2_raster_t *font)
-{
-   int i, j;
-   GLint  gl_internal          = GL_LUMINANCE_ALPHA;
-   GLenum gl_format            = GL_LUMINANCE_ALPHA;
-   size_t ncomponents          = 2;
-   uint8_t *tmp                = (uint8_t*)calloc(font->tex_height, font->tex_width * ncomponents);
-
-   switch (ncomponents)
-   {
-      case 1:
-         for (i = 0; i < (int)font->atlas->height; ++i)
-         {
-            const uint8_t *src = &font->atlas->buffer[i * font->atlas->width];
-            uint8_t       *dst = &tmp[i * font->tex_width * ncomponents];
-
-            memcpy(dst, src, font->atlas->width);
-         }
-         break;
-      case 2:
-         for (i = 0; i < (int)font->atlas->height; ++i)
-         {
-            const uint8_t *src = &font->atlas->buffer[i * font->atlas->width];
-            uint8_t       *dst = &tmp[i * font->tex_width * ncomponents];
-
-            for (j = 0; j < (int)font->atlas->width; ++j)
-            {
-               *dst++ = 0xff;
-               *dst++ = *src++;
-            }
-         }
-         break;
-   }
-
-   glTexImage2D(GL_TEXTURE_2D, 0, gl_internal,
-         font->tex_width, font->tex_height,
-         0, gl_format, GL_UNSIGNED_BYTE, tmp);
-
-   free(tmp);
-}
-
-static void *gl2_raster_font_init(void *data,
-      const char *font_path, float font_size,
-      bool is_threaded)
-{
-   gl2_raster_t   *font  = (gl2_raster_t*)calloc(1, sizeof(*font));
-
-   if (!font)
-      return NULL;
-
-   font->gl              = (gl2_t*)data;
-
-   if (!font_renderer_create_default(
-            &font->font_driver,
-            &font->font_data, font_path, font_size))
-   {
-      free(font);
-      return NULL;
-   }
-
-   if (is_threaded)
-      if (
-            font->gl && 
-            font->gl->ctx_driver &&
-            font->gl->ctx_driver->make_current)
-         font->gl->ctx_driver->make_current(false);
-
-   glGenTextures(1, &font->tex);
-
-   GL2_BIND_TEXTURE(font->tex, GL_CLAMP_TO_EDGE, GL_LINEAR, GL_LINEAR);
-
-   font->atlas      = font->font_driver->get_atlas(font->font_data);
-   font->tex_width  = next_pow2(font->atlas->width);
-   font->tex_height = next_pow2(font->atlas->height);
-
-   gl2_raster_font_upload_atlas(font);
-
-   font->atlas->dirty = false;
-
-   if (font->gl)
-      glBindTexture(GL_TEXTURE_2D, font->gl->texture[font->gl->tex_index]);
-
-   return font;
-}
-
-static int gl2_raster_font_get_message_width(void *data, const char *msg,
-      size_t msg_len, float scale)
-{
-   const struct font_glyph* glyph_q = NULL;
-   gl2_raster_t *font               = (gl2_raster_t*)data;
-   const char* msg_end              = msg + msg_len;
-   int delta_x                      = 0;
-
-   if (     !font
-         || !font->font_driver
-         || !font->font_driver->get_glyph
-         || !font->font_data )
-      return 0;
-
-   glyph_q = font->font_driver->get_glyph(font->font_data, '?');
-
-   while (msg < msg_end)
-   {
-      const struct font_glyph *glyph;
-      unsigned code                  = utf8_walk(&msg);
-
-      /* Do something smarter here ... */
-      if (!(glyph = font->font_driver->get_glyph(
-            font->font_data, code)))
-         if (!(glyph = glyph_q))
-            continue;
-
-      delta_x += glyph->advance_x;
-   }
-
-   return delta_x * scale;
-}
-
-static void gl2_raster_font_draw_vertices(gl2_raster_t *font,
-      const video_coords_t *coords)
-{
-   if (font->atlas->dirty)
-   {
-      gl2_raster_font_upload_atlas(font);
-      font->atlas->dirty   = false;
-   }
-
-   if (font->gl && font->gl->shader)
-   {
-      font->gl->shader->set_coords(font->gl->shader_data, coords);
-      font->gl->shader->set_mvp(font->gl->shader_data,
-            &font->gl->mvp_no_rot);
-   }
-
-   glDrawArrays(GL_TRIANGLES, 0, coords->vertices);
-}
-
-static void gl2_raster_font_render_line(gl2_t *gl,
-      gl2_raster_t *font, const char *msg, size_t msg_len,
-      GLfloat scale, const GLfloat color[4], GLfloat pos_x,
-      GLfloat pos_y, unsigned text_align)
-{
-   int i;
-   struct video_coords coords;
-   const struct font_glyph* glyph_q = NULL;
-   GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK];
-   GLfloat font_vertex[2 * 6 * MAX_MSG_LEN_CHUNK];
-   GLfloat font_color[4 * 6 * MAX_MSG_LEN_CHUNK];
-   GLfloat font_lut_tex_coord[2 * 6 * MAX_MSG_LEN_CHUNK];
-   const char* msg_end  = msg + msg_len;
-   int x                = roundf(pos_x * gl->vp.width);
-   int y                = roundf(pos_y * gl->vp.height);
-   int delta_x          = 0;
-   int delta_y          = 0;
-   float inv_tex_size_x = 1.0f / font->tex_width;
-   float inv_tex_size_y = 1.0f / font->tex_height;
-   float inv_win_width  = 1.0f / gl->vp.width;
-   float inv_win_height = 1.0f / gl->vp.height;
-
-   switch (text_align)
-   {
-      case TEXT_ALIGN_RIGHT:
-         x -= gl2_raster_font_get_message_width(font, msg, msg_len, scale);
-         break;
-      case TEXT_ALIGN_CENTER:
-         x -= gl2_raster_font_get_message_width(font, msg, msg_len, scale) / 2.0;
-         break;
-   }
-
-   glyph_q = font->font_driver->get_glyph(font->font_data, '?');
-
-   while (msg < msg_end)
-   {
-      i = 0;
-      while ((i < MAX_MSG_LEN_CHUNK) && (msg < msg_end))
-      {
-         const struct font_glyph *glyph;
-         int off_x, off_y, tex_x, tex_y, width, height;
-         unsigned                  code = utf8_walk(&msg);
-
-         /* Do something smarter here ... */
-         if (!(glyph = font->font_driver->get_glyph(
-               font->font_data, code)))
-            if (!(glyph = glyph_q))
-               continue;
-
-         off_x  = glyph->draw_offset_x;
-         off_y  = glyph->draw_offset_y;
-         tex_x  = glyph->atlas_offset_x;
-         tex_y  = glyph->atlas_offset_y;
-         width  = glyph->width;
-         height = glyph->height;
-
-         GL_RASTER_FONT_EMIT(0, 0, 1); /* Bottom-left */
-         GL_RASTER_FONT_EMIT(1, 1, 1); /* Bottom-right */
-         GL_RASTER_FONT_EMIT(2, 0, 0); /* Top-left */
-
-         GL_RASTER_FONT_EMIT(3, 1, 0); /* Top-right */
-         GL_RASTER_FONT_EMIT(4, 0, 0); /* Top-left */
-         GL_RASTER_FONT_EMIT(5, 1, 1); /* Bottom-right */
-
-         i++;
-
-         delta_x += glyph->advance_x;
-         delta_y -= glyph->advance_y;
-      }
-
-      coords.tex_coord     = font_tex_coords;
-      coords.vertex        = font_vertex;
-      coords.color         = font_color;
-      coords.vertices      = i * 6;
-      coords.lut_tex_coord = font_lut_tex_coord;
-
-      if (font->block)
-         video_coord_array_append(&font->block->carr, &coords, coords.vertices);
-      else
-         gl2_raster_font_draw_vertices(font, &coords);
-   }
-}
-
-static void gl2_raster_font_render_message(
-      gl2_raster_t *font, const char *msg, GLfloat scale,
-      const GLfloat color[4], GLfloat pos_x, GLfloat pos_y,
-      unsigned text_align)
-{
-   struct font_line_metrics *line_metrics = NULL;
-   int lines                              = 0;
-   float line_height;
-
-   /* If font line metrics are not supported just draw as usual */
-   if (!font->font_driver->get_line_metrics ||
-       !font->font_driver->get_line_metrics(font->font_data, &line_metrics))
-   {
-      gl2_raster_font_render_line(font->gl, font,
-            msg, strlen(msg), scale, color, pos_x,
-            pos_y, text_align);
-      return;
-   }
-
-   line_height = line_metrics->height * scale / font->gl->vp.height;
-
-   for (;;)
-   {
-      const char *delim = strchr(msg, '\n');
-      size_t msg_len    = delim
-         ? (delim - msg) : strlen(msg);
-
-      /* Draw the line */
-      gl2_raster_font_render_line(font->gl, font,
-            msg, msg_len, scale, color, pos_x,
-            pos_y - (float)lines*line_height, text_align);
-
-      if (!delim)
-         break;
-
-      msg += msg_len + 1;
-      lines++;
-   }
-}
-
-static void gl2_raster_font_setup_viewport(
-      gl2_raster_t *font,
-      unsigned width, unsigned height,
-      bool full_screen)
-{
-   video_driver_set_viewport(width, height, full_screen, false);
-
-   glEnable(GL_BLEND);
-   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-   glBlendEquation(GL_FUNC_ADD);
-
-   glBindTexture(GL_TEXTURE_2D, font->tex);
-
-   if (font->gl && font->gl->shader && font->gl->shader->use)
-      font->gl->shader->use(font->gl,
-            font->gl->shader_data, VIDEO_SHADER_STOCK_BLEND, true);
-}
-
-static void gl2_raster_font_render_msg(
-      void *userdata,
-      void *data,
-      const char *msg,
-      const struct font_params *params)
-{
-   GLfloat color[4];
-   int drop_x, drop_y;
-   GLfloat x, y, scale, drop_mod, drop_alpha;
-   enum text_alignment text_align    = TEXT_ALIGN_LEFT;
-   bool full_screen                  = false ;
-   gl2_raster_t                *font = (gl2_raster_t*)data;
-   unsigned width                    = font->gl->video_width;
-   unsigned height                   = font->gl->video_height;
-
-   if (!font || string_is_empty(msg))
-      return;
-
-   if (params)
-   {
-      x           = params->x;
-      y           = params->y;
-      scale       = params->scale;
-      full_screen = params->full_screen;
-      text_align  = params->text_align;
-      drop_x      = params->drop_x;
-      drop_y      = params->drop_y;
-      drop_mod    = params->drop_mod;
-      drop_alpha  = params->drop_alpha;
-
-      color[0]    = FONT_COLOR_GET_RED(params->color)   / 255.0f;
-      color[1]    = FONT_COLOR_GET_GREEN(params->color) / 255.0f;
-      color[2]    = FONT_COLOR_GET_BLUE(params->color)  / 255.0f;
-      color[3]    = FONT_COLOR_GET_ALPHA(params->color) / 255.0f;
-
-      /* If alpha is 0.0f, turn it into default 1.0f */
-      if (color[3] <= 0.0f)
-         color[3] = 1.0f;
-   }
-   else
-   {
-      settings_t *settings     = config_get_ptr();
-      float video_msg_pos_x    = settings->floats.video_msg_pos_x;
-      float video_msg_pos_y    = settings->floats.video_msg_pos_y;
-      float video_msg_color_r  = settings->floats.video_msg_color_r;
-      float video_msg_color_g  = settings->floats.video_msg_color_g;
-      float video_msg_color_b  = settings->floats.video_msg_color_b;
-      x                        = video_msg_pos_x;
-      y                        = video_msg_pos_y;
-      scale                    = 1.0f;
-      full_screen              = true;
-      text_align               = TEXT_ALIGN_LEFT;
-
-      color[0]                 = video_msg_color_r;
-      color[1]                 = video_msg_color_g;
-      color[2]                 = video_msg_color_b;
-      color[3]                 = 1.0f;
-
-      drop_x                   = -2;
-      drop_y                   = -2;
-      drop_mod                 = 0.3f;
-      drop_alpha               = 1.0f;
-   }
-
-   if (font->block)
-      font->block->fullscreen  = full_screen;
-   else
-      gl2_raster_font_setup_viewport(font, width, height, full_screen);
-
-   if (font->gl)
-   {
-      if (    !string_is_empty(msg)
-            && font->font_data  
-            && font->font_driver)
-      {
-         if (drop_x || drop_y)
-         {
-            GLfloat color_dark[4];
-            color_dark[0] = color[0] * drop_mod;
-            color_dark[1] = color[1] * drop_mod;
-            color_dark[2] = color[2] * drop_mod;
-            color_dark[3] = color[3] * drop_alpha;
-
-            gl2_raster_font_render_message(font, msg, scale, color_dark,
-                  x + scale * drop_x / font->gl->vp.width, y +
-                      scale * drop_y / font->gl->vp.height, text_align);
-         }
-
-         gl2_raster_font_render_message(font, msg, scale, color,
-               x, y, text_align);
-      }
-
-      if (!font->block)
-      {
-         /* restore viewport */
-         glBindTexture(GL_TEXTURE_2D,
-               font->gl->texture[font->gl->tex_index]);
-         glDisable(GL_BLEND);
-         video_driver_set_viewport(width, height, false, true);
-      }
-   }
-}
-
-static const struct font_glyph *gl2_raster_font_get_glyph(
-      void *data, uint32_t code)
-{
-   gl2_raster_t *font = (gl2_raster_t*)data;
-   if (font && font->font_driver && font->font_driver->ident)
-      return font->font_driver->get_glyph((void*)font->font_driver, code);
-   return NULL;
-}
-
-static void gl2_raster_font_flush_block(unsigned width, unsigned height,
-      void *data)
-{
-   gl2_raster_t          *font       = (gl2_raster_t*)data;
-   video_font_raster_block_t *block = font ? font->block : NULL;
-
-   if (!font || !block || !block->carr.coords.vertices)
-      return;
-
-   gl2_raster_font_setup_viewport(font, width, height, block->fullscreen);
-   gl2_raster_font_draw_vertices(font, (video_coords_t*)&block->carr.coords);
-
-   if (font->gl)
-   {
-      /* restore viewport */
-      glBindTexture(GL_TEXTURE_2D, font->gl->texture[font->gl->tex_index]);
-
-      glDisable(GL_BLEND);
-      video_driver_set_viewport(width, height, block->fullscreen, true);
-   }
-}
-
-static void gl2_raster_font_bind_block(void *data, void *userdata)
-{
-   gl2_raster_t                *font = (gl2_raster_t*)data;
-   video_font_raster_block_t *block = (video_font_raster_block_t*)userdata;
-
-   if (font)
-      font->block = block;
-}
-
-static bool gl2_raster_font_get_line_metrics(void* data, struct font_line_metrics **metrics)
-{
-   gl2_raster_t *font   = (gl2_raster_t*)data;
-   if (font && font->font_driver && font->font_data)
-      return font->font_driver->get_line_metrics(font->font_data, metrics);
-   return false;
-}
-
-font_renderer_t gl2_raster_font = {
-   gl2_raster_font_init,
-   gl2_raster_font_free,
-   gl2_raster_font_render_msg,
-   "gl2_raster_font",
-   gl2_raster_font_get_glyph,
-   gl2_raster_font_bind_block,
-   gl2_raster_font_flush_block,
-   gl2_raster_font_get_message_width,
-   gl2_raster_font_get_line_metrics
-};

+ 0 - 490
app/src/main/cpp/gfx/drivers_font/vulkan_raster_font.c

@@ -1,490 +0,0 @@
-/*  RetroArch - A frontend for libretro.
- *  Copyright (C) 2016-2017 - Hans-Kristian Arntzen
- *
- *  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 <string.h>
-
-#include <encodings/utf.h>
-#include <compat/strl.h>
-
-#include "../common/vulkan_common.h"
-
-#include "../font_driver.h"
-
-#include "../../configuration.h"
-
-typedef struct
-{
-   vk_t *vk;
-   void *font_data;
-   struct font_atlas *atlas;
-   const font_renderer_driver_t *font_driver;
-   struct vk_vertex *pv;
-   struct vk_texture texture;
-   struct vk_texture texture_optimal;
-   struct vk_buffer_range range;
-   unsigned vertices;
-
-   bool needs_update;
-} vulkan_raster_t;
-
-static INLINE void vulkan_font_update_glyph(
-      vulkan_raster_t *font, const struct font_glyph *glyph)
-{
-   unsigned row;
-   for (row = glyph->atlas_offset_y; row < (glyph->atlas_offset_y + glyph->height); row++)
-   {
-      uint8_t *src = font->atlas->buffer + row * font->atlas->width + glyph->atlas_offset_x;
-      uint8_t *dst = (uint8_t*)font->texture.mapped + row * font->texture.stride + glyph->atlas_offset_x;
-      memcpy(dst, src, glyph->width);
-   }
-}
-
-static void vulkan_font_free(void *data, bool is_threaded)
-{
-   vulkan_raster_t *font = (vulkan_raster_t*)data;
-   if (!font)
-      return;
-
-   if (font->font_driver && font->font_data)
-      font->font_driver->free(font->font_data);
-
-   vkQueueWaitIdle(font->vk->context->queue);
-   vulkan_destroy_texture(
-         font->vk->context->device, &font->texture);
-   vulkan_destroy_texture(
-         font->vk->context->device, &font->texture_optimal);
-
-   free(font);
-}
-
-static void *vulkan_font_init(void *data,
-      const char *font_path, float font_size,
-      bool is_threaded)
-{
-   vulkan_raster_t *font          =
-      (vulkan_raster_t*)calloc(1, sizeof(*font));
-
-   if (!font)
-      return NULL;
-
-   font->vk = (vk_t*)data;
-
-   if (!font_renderer_create_default(
-            &font->font_driver,
-            &font->font_data, font_path, font_size))
-   {
-      free(font);
-      return NULL;
-   }
-
-   font->atlas   = font->font_driver->get_atlas(font->font_data);
-   font->texture = vulkan_create_texture(font->vk, NULL,
-         font->atlas->width, font->atlas->height, VK_FORMAT_R8_UNORM, font->atlas->buffer,
-         NULL, VULKAN_TEXTURE_STAGING);
-
-   {
-      struct vk_texture *texture = &font->texture;
-      VK_MAP_PERSISTENT_TEXTURE(font->vk->context->device, texture);
-   }
-
-   font->texture_optimal = vulkan_create_texture(font->vk, NULL,
-         font->atlas->width, font->atlas->height, VK_FORMAT_R8_UNORM, NULL,
-         NULL, VULKAN_TEXTURE_DYNAMIC);
-
-   font->needs_update = true;
-
-   return font;
-}
-
-static int vulkan_get_message_width(void *data, const char *msg,
-      size_t msg_len, float scale)
-{
-   const struct font_glyph* glyph_q = NULL;
-   vulkan_raster_t *font = (vulkan_raster_t*)data;
-   const char* msg_end   = msg + msg_len;
-   int delta_x           = 0;
-
-   if (     !font
-         || !font->font_driver
-         || !font->font_driver->get_glyph
-         || !font->font_data )
-      return 0;
-
-   glyph_q = font->font_driver->get_glyph(font->font_data, '?');
-
-   while (msg < msg_end)
-   {
-      const struct font_glyph *glyph;
-      uint32_t code                  = utf8_walk(&msg);
-
-      /* Do something smarter here ... */
-      if (!(glyph = font->font_driver->get_glyph(
-                  font->font_data, code)))
-         if (!(glyph = glyph_q))
-            continue;
-
-      if (font->atlas->dirty)
-      {
-         vulkan_font_update_glyph(font, glyph);
-         font->atlas->dirty = false;
-         font->needs_update = true;
-      }
-      delta_x += glyph->advance_x;
-   }
-
-   return delta_x * scale;
-}
-
-static void vulkan_font_render_line(vk_t *vk,
-      vulkan_raster_t *font, const char *msg, size_t msg_len,
-      float scale, const float color[4], float pos_x,
-      float pos_y, unsigned text_align)
-{
-   struct vk_color vk_color;
-   const struct font_glyph* glyph_q = NULL;
-   const char* msg_end              = msg + msg_len;
-   int x                            = roundf(pos_x * vk->vp.width);
-   int y                            = roundf((1.0f - pos_y) * vk->vp.height);
-   int delta_x                      = 0;
-   int delta_y                      = 0;
-   float inv_tex_size_x             = 1.0f / font->texture.width;
-   float inv_tex_size_y             = 1.0f / font->texture.height;
-   float inv_win_width              = 1.0f / font->vk->vp.width;
-   float inv_win_height             = 1.0f / font->vk->vp.height;
-
-   vk_color.r                       = color[0];
-   vk_color.g                       = color[1];
-   vk_color.b                       = color[2];
-   vk_color.a                       = color[3];
-
-   switch (text_align)
-   {
-      case TEXT_ALIGN_RIGHT:
-         x -= vulkan_get_message_width(font, msg, msg_len, scale);
-         break;
-      case TEXT_ALIGN_CENTER:
-         x -= vulkan_get_message_width(font, msg, msg_len, scale) / 2;
-         break;
-   }
-
-   glyph_q = font->font_driver->get_glyph(font->font_data, '?');
-
-   while (msg < msg_end)
-   {
-      const struct font_glyph *glyph;
-      int off_x, off_y, tex_x, tex_y, width, height;
-      unsigned code = utf8_walk(&msg);
-
-      /* Do something smarter here ... */
-      if (!(glyph =
-               font->font_driver->get_glyph(font->font_data, code)))
-         if (!(glyph = glyph_q))
-            continue;
-
-      if (font->atlas->dirty)
-      {
-         vulkan_font_update_glyph(font, glyph);
-         font->atlas->dirty = false;
-         font->needs_update = true;
-      }
-
-      off_x  = glyph->draw_offset_x;
-      off_y  = glyph->draw_offset_y;
-      tex_x  = glyph->atlas_offset_x;
-      tex_y  = glyph->atlas_offset_y;
-      width  = glyph->width;
-      height = glyph->height;
-
-      {
-         struct vk_vertex *pv          = font->pv + font->vertices;
-         float _x                      = (x + (off_x + delta_x) * scale)
-            * inv_win_width;
-         float _y                      = (y + (off_y + delta_y) * scale)
-            * inv_win_height;
-         float _width                  = width  * scale * inv_win_width;
-         float _height                 = height * scale * inv_win_height;
-         float _tex_x                  = tex_x * inv_tex_size_x;
-         float _tex_y                  = tex_y * inv_tex_size_y;
-         float _tex_width              = width * inv_tex_size_x;
-         float _tex_height             = height * inv_tex_size_y;
-         const struct vk_color *_color = &vk_color;
-
-         VULKAN_WRITE_QUAD_VBO(pv, _x, _y, _width, _height, _tex_x, _tex_y, _tex_width, _tex_height, _color);
-      }
-
-      font->vertices += 6;
-
-      delta_x        += glyph->advance_x;
-      delta_y        += glyph->advance_y;
-   }
-}
-
-static void vulkan_font_render_message(
-      vulkan_raster_t *font, const char *msg, float scale,
-      const float color[4], float pos_x, float pos_y,
-      unsigned text_align)
-{
-   struct font_line_metrics *line_metrics = NULL;
-   int lines                              = 0;
-   float line_height;
-
-   if (!msg || !*msg || !font->vk)
-      return;
-
-   /* If font line metrics are not supported just draw as usual */
-   if (!font->font_driver->get_line_metrics ||
-       !font->font_driver->get_line_metrics(font->font_data, &line_metrics))
-   {
-      vulkan_font_render_line(font->vk, font, msg, strlen(msg),
-            scale, color, pos_x, pos_y, text_align);
-      return;
-   }
-
-   line_height = line_metrics->height * scale / font->vk->vp.height;
-
-   for (;;)
-   {
-      const char *delim = strchr(msg, '\n');
-      size_t msg_len    = delim
-         ? (delim - msg) : strlen(msg);
-
-      /* Draw the line */
-      vulkan_font_render_line(font->vk, font, msg, msg_len,
-            scale, color, pos_x, pos_y - (float)lines * line_height,
-            text_align);
-
-      if (!delim)
-         break;
-
-      msg += msg_len + 1;
-      lines++;
-   }
-}
-
-static void vulkan_font_flush(vulkan_raster_t *font)
-{
-   struct vk_draw_triangles call;
-
-   call.pipeline     = font->vk->pipelines.font;
-   call.texture      = &font->texture_optimal;
-   call.sampler      = font->vk->samplers.mipmap_linear;
-   call.uniform      = &font->vk->mvp;
-   call.uniform_size = sizeof(font->vk->mvp);
-   call.vbo          = &font->range;
-   call.vertices     = font->vertices;
-
-   if (font->needs_update)
-   {
-      VkCommandBuffer staging;
-      VkSubmitInfo submit_info;
-      VkCommandBufferAllocateInfo cmd_info;
-      VkCommandBufferBeginInfo begin_info;
-      struct vk_texture *dynamic_tex  = NULL;
-      struct vk_texture *staging_tex  = NULL;
-
-      cmd_info.sType              = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
-      cmd_info.pNext              = NULL;
-      cmd_info.commandPool        = font->vk->staging_pool;
-      cmd_info.level              = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
-      cmd_info.commandBufferCount = 1;
-      vkAllocateCommandBuffers(font->vk->context->device, &cmd_info, &staging);
-
-      begin_info.sType            = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
-      begin_info.pNext            = NULL;
-      begin_info.flags            = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
-      begin_info.pInheritanceInfo = NULL;
-      vkBeginCommandBuffer(staging, &begin_info);
-
-      VULKAN_SYNC_TEXTURE_TO_GPU_COND_OBJ(font->vk, font->texture);
-
-      dynamic_tex                 = &font->texture_optimal;
-      staging_tex                 = &font->texture;
-
-      vulkan_copy_staging_to_dynamic(font->vk, staging,
-            dynamic_tex, staging_tex);
-
-      vkEndCommandBuffer(staging);
-
-#ifdef HAVE_THREADS
-      slock_lock(font->vk->context->queue_lock);
-#endif
-
-      submit_info.sType                = VK_STRUCTURE_TYPE_SUBMIT_INFO;
-      submit_info.pNext                = NULL;
-      submit_info.waitSemaphoreCount   = 0;
-      submit_info.pWaitSemaphores      = NULL;
-      submit_info.pWaitDstStageMask    = NULL;
-      submit_info.commandBufferCount   = 1;
-      submit_info.pCommandBuffers      = &staging;
-      submit_info.signalSemaphoreCount = 0;
-      submit_info.pSignalSemaphores    = NULL;
-      vkQueueSubmit(font->vk->context->queue,
-            1, &submit_info, VK_NULL_HANDLE);
-
-      vkQueueWaitIdle(font->vk->context->queue);
-
-#ifdef HAVE_THREADS
-      slock_unlock(font->vk->context->queue_lock);
-#endif
-
-      vkFreeCommandBuffers(font->vk->context->device,
-            font->vk->staging_pool, 1, &staging);
-
-      font->needs_update = false;
-   }
-
-   vulkan_draw_triangles(font->vk, &call);
-}
-
-static void vulkan_font_render_msg(
-      void *userdata,
-      void *data,
-      const char *msg,
-      const struct font_params *params)
-{
-   float color[4];
-   int drop_x, drop_y;
-   bool full_screen;
-   size_t max_glyphs;
-   unsigned width, height;
-   enum text_alignment text_align;
-   float x, y, scale, drop_mod, drop_alpha;
-   vk_t *vk                         = NULL;
-   vulkan_raster_t *font            = (vulkan_raster_t*)data;
-   settings_t *settings             = config_get_ptr();
-   float video_msg_pos_x            = settings->floats.video_msg_pos_x;
-   float video_msg_pos_y            = settings->floats.video_msg_pos_y;
-   float video_msg_color_r          = settings->floats.video_msg_color_r;
-   float video_msg_color_g          = settings->floats.video_msg_color_g;
-   float video_msg_color_b          = settings->floats.video_msg_color_b;
-
-   if (!font || !msg || !*msg)
-      return;
-
-   vk             = font->vk;
-
-   width          = vk->video_width;
-   height         = vk->video_height;
-
-   if (params)
-   {
-      x           = params->x;
-      y           = params->y;
-      scale       = params->scale;
-      full_screen = params->full_screen;
-      text_align  = params->text_align;
-      drop_x      = params->drop_x;
-      drop_y      = params->drop_y;
-      drop_mod    = params->drop_mod;
-      drop_alpha  = params->drop_alpha;
-
-      color[0]    = FONT_COLOR_GET_RED(params->color)   / 255.0f;
-      color[1]    = FONT_COLOR_GET_GREEN(params->color) / 255.0f;
-      color[2]    = FONT_COLOR_GET_BLUE(params->color)  / 255.0f;
-      color[3]    = FONT_COLOR_GET_ALPHA(params->color) / 255.0f;
-
-      /* If alpha is 0.0f, turn it into default 1.0f */
-      if (color[3] <= 0.0f)
-         color[3] = 1.0f;
-   }
-   else
-   {
-      x           = video_msg_pos_x;
-      y           = video_msg_pos_y;
-      scale       = 1.0f;
-      full_screen = true;
-      text_align  = TEXT_ALIGN_LEFT;
-      drop_x      = -2;
-      drop_y      = -2;
-      drop_mod    = 0.3f;
-      drop_alpha  = 1.0f;
-
-      color[0]    = video_msg_color_r;
-      color[1]    = video_msg_color_g;
-      color[2]    = video_msg_color_b;
-      color[3]    = 1.0f;
-   }
-
-   video_driver_set_viewport(width, height, full_screen, false);
-
-   max_glyphs = strlen(msg);
-   if (drop_x || drop_y)
-      max_glyphs *= 2;
-
-   if (!vulkan_buffer_chain_alloc(font->vk->context, &font->vk->chain->vbo,
-         6 * sizeof(struct vk_vertex) * max_glyphs, &font->range))
-      return;
-
-   font->vertices   = 0;
-   font->pv         = (struct vk_vertex*)font->range.data;
-
-   if (drop_x || drop_y)
-   {
-      float color_dark[4];
-      color_dark[0] = color[0] * drop_mod;
-      color_dark[1] = color[1] * drop_mod;
-      color_dark[2] = color[2] * drop_mod;
-      color_dark[3] = color[3] * drop_alpha;
-
-      vulkan_font_render_message(font, msg, scale, color_dark,
-            x + scale * drop_x / vk->vp.width, y +
-            scale * drop_y / vk->vp.height, text_align);
-   }
-
-   vulkan_font_render_message(font, msg, scale,
-         color, x, y, text_align);
-   vulkan_font_flush(font);
-}
-
-static const struct font_glyph *vulkan_font_get_glyph(
-      void *data, uint32_t code)
-{
-   const struct font_glyph* glyph;
-   vulkan_raster_t *font = (vulkan_raster_t*)data;
-
-   if (!font || !font->font_driver || !font->font_driver->ident)
-      return NULL;
-
-   glyph = font->font_driver->get_glyph((void*)font->font_driver, code);
-
-   if (glyph && font->atlas->dirty)
-   {
-      vulkan_font_update_glyph(font, glyph);
-      font->atlas->dirty = false;
-      font->needs_update = true;
-   }
-   return glyph;
-}
-
-static bool vulkan_get_line_metrics(void* data,
-      struct font_line_metrics **metrics)
-{
-   vulkan_raster_t *font = (vulkan_raster_t*)data;
-   if (font && font->font_driver && font->font_data)
-      return font->font_driver->get_line_metrics(font->font_data, metrics);
-   return false;
-}
-
-font_renderer_t vulkan_raster_font = {
-   vulkan_font_init,
-   vulkan_font_free,
-   vulkan_font_render_msg,
-   "vulkan_font",
-   vulkan_font_get_glyph,
-   NULL,                            /* bind_block */
-   NULL,                            /* flush_block */
-   vulkan_get_message_width,
-   vulkan_get_line_metrics
-};

+ 0 - 310
app/src/main/cpp/gfx/drivers_font_renderer/bitmap.h

@@ -1,310 +0,0 @@
-/*  RetroArch - A frontend for libretro.
- *  Copyright (C) 2010-2014 - Hans-Kristian Arntzen
- *  Copyright (C) 2011-2017 - 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/>.
- */
-
-#ifndef __RARCH_FONT_BITMAP_H
-#define __RARCH_FONT_BITMAP_H
-
-#include <stdint.h>
-
-#define FONT_WIDTH 5
-#define FONT_HEIGHT 10
-/* FONT_HEIGHT_BASELINE_OFFSET:
- * Distance in pixels from top of character
- * to baseline */
-#define FONT_HEIGHT_BASELINE_OFFSET 8
-#define FONT_WIDTH_STRIDE (FONT_WIDTH + 1)
-#define FONT_HEIGHT_STRIDE (FONT_HEIGHT + 1)
-
-#define FONT_OFFSET(x) ((x) * ((FONT_HEIGHT * FONT_WIDTH + 7) / 8))
-
-static const unsigned char bitmap_bin[1792] = {
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x00 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x01 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x02 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x03 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x04 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x05 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x06 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x07 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x08 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x09 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x0a */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x0b */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x0c */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x0d */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x0e */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x0f */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x10 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x11 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x12 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x13 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x14 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x15 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x16 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x17 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x18 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x19 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x1a */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x1b */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x1c */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x1d */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x1e */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x1f */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x20 */
-   0x80,0x10,0x42,0x08,0x20,0x00,0x00, /* code=0x21 */
-   0x4A,0x29,0x00,0x00,0x00,0x00,0x00, /* code=0x22 */
-   0x00,0xA8,0xAF,0xD4,0x57,0x00,0x00, /* code=0x23 */
-   0x80,0xF8,0xE2,0xE8,0x23,0x00,0x00, /* code=0x24 */
-   0x60,0x4E,0x44,0x44,0xCE,0x00,0x00, /* code=0x25 */
-   0xC0,0xA4,0x64,0x6A,0xB2,0x00,0x00, /* code=0x26 */
-   0x84,0x10,0x00,0x00,0x00,0x00,0x00, /* code=0x27 */
-   0x88,0x08,0x21,0x84,0x20,0x08,0x00, /* code=0x28 */
-   0x82,0x20,0x84,0x10,0x22,0x02,0x00, /* code=0x29 */
-   0x00,0x90,0xEA,0x2A,0x01,0x00,0x00, /* code=0x2a */
-   0x00,0x10,0xF2,0x09,0x01,0x00,0x00, /* code=0x2b */
-   0x00,0x00,0x00,0x00,0x20,0x02,0x00, /* code=0x2c */
-   0x00,0x00,0xF0,0x01,0x00,0x00,0x00, /* code=0x2d */
-   0x00,0x00,0x00,0x00,0x20,0x00,0x00, /* code=0x2e */
-   0x10,0x22,0x44,0x88,0x10,0x01,0x00, /* code=0x2f */
-   0xC0,0xC5,0x58,0x63,0x74,0x00,0x00, /* code=0x30 */
-   0x80,0x18,0x42,0x08,0x71,0x00,0x00, /* code=0x31 */
-   0xC0,0x45,0xC8,0x44,0xF8,0x00,0x00, /* code=0x32 */
-   0xC0,0x45,0xC8,0x60,0x74,0x00,0x00, /* code=0x33 */
-   0x00,0x31,0x95,0x3E,0x42,0x00,0x00, /* code=0x34 */
-   0xE0,0x87,0xF0,0x60,0x74,0x00,0x00, /* code=0x35 */
-   0x80,0x89,0xF0,0x62,0x74,0x00,0x00, /* code=0x36 */
-   0xE0,0x43,0x84,0x08,0x11,0x00,0x00, /* code=0x37 */
-   0xC0,0xC5,0xE8,0x62,0x74,0x00,0x00, /* code=0x38 */
-   0xC0,0xC5,0xE8,0x21,0x32,0x00,0x00, /* code=0x39 */
-   0x00,0x00,0x02,0x00,0x01,0x00,0x00, /* code=0x3a */
-   0x00,0x00,0x02,0x00,0x11,0x00,0x00, /* code=0x3b */
-   0x00,0x40,0x36,0x18,0x04,0x00,0x00, /* code=0x3c */
-   0x00,0x80,0x0F,0x3E,0x00,0x00,0x00, /* code=0x3d */
-   0x00,0x04,0x83,0x4D,0x00,0x00,0x00, /* code=0x3e */
-   0xC0,0x45,0x88,0x08,0x20,0x00,0x00, /* code=0x3f */
-   0xC0,0xC5,0x5A,0x7B,0xF0,0x00,0x00, /* code=0x40 */
-   0x80,0x10,0xA5,0x5C,0x8C,0x00,0x00, /* code=0x41 */
-   0xE0,0xC5,0xF8,0x62,0x7C,0x00,0x00, /* code=0x42 */
-   0xC0,0xC5,0x10,0x42,0x74,0x00,0x00, /* code=0x43 */
-   0xE0,0xA4,0x18,0x63,0x3A,0x00,0x00, /* code=0x44 */
-   0xE0,0x87,0xF0,0x42,0xF8,0x00,0x00, /* code=0x45 */
-   0xE0,0x87,0xF0,0x42,0x08,0x00,0x00, /* code=0x46 */
-   0xC0,0xC5,0x90,0x63,0xF4,0x00,0x00, /* code=0x47 */
-   0x20,0xC6,0xF8,0x63,0x8C,0x00,0x00, /* code=0x48 */
-   0xC0,0x11,0x42,0x08,0x71,0x00,0x00, /* code=0x49 */
-   0x80,0x43,0x08,0x21,0x7C,0x00,0x00, /* code=0x4a */
-   0x20,0xA6,0x32,0x4A,0x8A,0x00,0x00, /* code=0x4b */
-   0x20,0x84,0x10,0x42,0xF8,0x00,0x00, /* code=0x4c */
-   0x20,0xC6,0xBD,0x6B,0x8D,0x00,0x00, /* code=0x4d */
-   0x60,0xCE,0x5A,0x6B,0xCE,0x00,0x00, /* code=0x4e */
-   0xC0,0xC5,0x18,0x63,0x74,0x00,0x00, /* code=0x4f */
-   0xE0,0xC5,0xF8,0x42,0x08,0x00,0x00, /* code=0x50 */
-   0xC0,0xC5,0x18,0x63,0xF6,0x00,0x00, /* code=0x51 */
-   0xE0,0xC5,0xF8,0x62,0x8C,0x00,0x00, /* code=0x52 */
-   0xC0,0xC5,0xE0,0x60,0x74,0x00,0x00, /* code=0x53 */
-   0xE0,0x13,0x42,0x08,0x21,0x00,0x00, /* code=0x54 */
-   0x20,0xC6,0x18,0x63,0x74,0x00,0x00, /* code=0x55 */
-   0x20,0xC6,0xA8,0x14,0x21,0x00,0x00, /* code=0x56 */
-   0x20,0xD6,0x5A,0x95,0x52,0x00,0x00, /* code=0x57 */
-   0x20,0x46,0x45,0x54,0x8C,0x00,0x00, /* code=0x58 */
-   0x20,0xC6,0xE8,0x08,0x21,0x00,0x00, /* code=0x59 */
-   0xE0,0x43,0x44,0x44,0xF8,0x00,0x00, /* code=0x5a */
-   0x4E,0x08,0x21,0x84,0x10,0x0E,0x00, /* code=0x5b */
-   0x21,0x08,0x41,0x08,0x42,0x10,0x00, /* code=0x5c */
-   0x0E,0x21,0x84,0x10,0x42,0x0E,0x00, /* code=0x5d */
-   0x80,0xA8,0x08,0x00,0x00,0x00,0x00, /* code=0x5e */
-   0x00,0x00,0x00,0x00,0x00,0x1F,0x00, /* code=0x5f */
-   0x80,0x20,0x00,0x00,0x00,0x00,0x00, /* code=0x60 */
-   0x00,0x00,0x07,0x7D,0xF4,0x00,0x00, /* code=0x61 */
-   0x21,0x84,0x17,0x63,0x7C,0x00,0x00, /* code=0x62 */
-   0x00,0x00,0x1F,0x42,0xF0,0x00,0x00, /* code=0x63 */
-   0x10,0x42,0x1F,0x63,0xF4,0x00,0x00, /* code=0x64 */
-   0x00,0x00,0x17,0x7F,0xF0,0x00,0x00, /* code=0x65 */
-   0x5C,0x88,0x27,0x84,0x10,0x00,0x00, /* code=0x66 */
-   0x00,0x00,0x17,0x63,0xF4,0xD0,0x01, /* code=0x67 */
-   0x21,0x84,0x17,0x63,0x8C,0x00,0x00, /* code=0x68 */
-   0x80,0x00,0x43,0x08,0x21,0x00,0x00, /* code=0x69 */
-   0x00,0x01,0x86,0x10,0x42,0xE8,0x00, /* code=0x6a */
-   0x42,0x08,0xA9,0x8C,0x92,0x00,0x00, /* code=0x6b */
-   0x86,0x10,0x42,0x08,0x21,0x00,0x00, /* code=0x6c */
-   0x00,0x80,0x55,0x6B,0xAD,0x00,0x00, /* code=0x6d */
-   0x00,0x80,0x17,0x63,0x8C,0x00,0x00, /* code=0x6e */
-   0x00,0x00,0x17,0x63,0x74,0x00,0x00, /* code=0x6f */
-   0x00,0x80,0x17,0x63,0x7C,0x21,0x00, /* code=0x70 */
-   0x00,0x00,0x1F,0x63,0xF4,0x10,0x02, /* code=0x71 */
-   0x00,0x80,0x36,0x43,0x08,0x00,0x00, /* code=0x72 */
-   0x00,0x00,0x1F,0x1C,0x7C,0x00,0x00, /* code=0x73 */
-   0x40,0x08,0x27,0x84,0xE0,0x00,0x00, /* code=0x74 */
-   0x00,0x80,0x18,0x63,0xF4,0x00,0x00, /* code=0x75 */
-   0x00,0x80,0x18,0x95,0x22,0x00,0x00, /* code=0x76 */
-   0x00,0x80,0x58,0xAB,0x52,0x00,0x00, /* code=0x77 */
-   0x00,0x80,0xA8,0x88,0x8A,0x00,0x00, /* code=0x78 */
-   0x00,0x80,0x18,0x63,0xF4,0xD0,0x01, /* code=0x79 */
-   0x00,0x80,0x8F,0x88,0xF8,0x00,0x00, /* code=0x7a */
-   0x88,0x10,0x22,0x08,0x21,0x08,0x00, /* code=0x7b */
-   0x84,0x10,0x42,0x08,0x21,0x04,0x00, /* code=0x7c */
-   0x82,0x10,0x82,0x08,0x21,0x02,0x00, /* code=0x7d */
-   0x00,0x00,0x60,0x1B,0x00,0x00,0x00, /* code=0x7e */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x7f */
-   0x3F,0xC6,0x18,0x63,0x8C,0xF1,0x03, /* code=0x80 */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x81 */
-   0x00,0x00,0x00,0x00,0x40,0x04,0x00, /* code=0x82 */
-   0x98,0x10,0x47,0x08,0x21,0x44,0x00, /* code=0x83 */
-   0x00,0x00,0x00,0x00,0x50,0x0A,0x00, /* code=0x84 */
-   0x00,0x00,0x00,0x00,0xA8,0x00,0x00, /* code=0x85 */
-   0x84,0x7C,0x42,0x08,0x21,0x04,0x00, /* code=0x86 */
-   0x84,0x7C,0xF2,0x09,0x21,0x04,0x00, /* code=0x87 */
-   0x44,0x01,0x00,0x00,0x00,0x00,0x00, /* code=0x88 */
-   0x60,0x4E,0x44,0x44,0xAD,0x00,0x00, /* code=0x89 */
-   0x8A,0x00,0x1F,0x3E,0x7C,0x00,0x00, /* code=0x8a */
-   0x00,0x00,0x44,0x04,0x41,0x00,0x00, /* code=0x8b */
-   0x40,0x97,0xD2,0x4A,0xD1,0x00,0x00, /* code=0x8c */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x8d */
-   0x8A,0x80,0x8F,0x88,0xF8,0x00,0x00, /* code=0x8e */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x8f */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x90 */
-   0x84,0x20,0x00,0x00,0x00,0x00,0x00, /* code=0x91 */
-   0x08,0x11,0x00,0x00,0x00,0x00,0x00, /* code=0x92 */
-   0x4A,0x51,0x00,0x00,0x00,0x00,0x00, /* code=0x93 */
-   0x94,0x2A,0x00,0x00,0x00,0x00,0x00, /* code=0x94 */
-   0x00,0x00,0xC0,0x18,0x00,0x00,0x00, /* code=0x95 */
-   0x00,0x00,0x00,0x3E,0x00,0x00,0x00, /* code=0x96 */
-   0x00,0x00,0x00,0x3E,0x00,0x00,0x00, /* code=0x97 */
-   0x00,0x00,0x40,0x15,0x00,0x00,0x00, /* code=0x98 */
-   0x00,0x80,0xAF,0xB5,0x06,0x00,0x00, /* code=0x99 */
-   0x8A,0x00,0x1F,0x1C,0x7C,0x00,0x00, /* code=0x9a */
-   0x00,0x00,0x82,0x20,0x22,0x00,0x00, /* code=0x9b */
-   0x00,0x00,0x5D,0x5A,0xD1,0x00,0x00, /* code=0x9c */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0x9d */
-   0x8A,0x80,0x8F,0x88,0xF8,0x00,0x00, /* code=0x9e */
-   0x0A,0xC4,0x18,0x1D,0x21,0x00,0x00, /* code=0x9f */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0xa0 */
-   0x00,0x00,0x02,0x08,0x21,0x84,0x00, /* code=0xa1 */
-   0x00,0x20,0xAE,0x14,0x47,0x00,0x00, /* code=0xa2 */
-   0x98,0x10,0x4F,0x44,0xF8,0x00,0x00, /* code=0xa3 */
-   0x00,0x44,0xA7,0x5C,0x04,0x00,0x00, /* code=0xa4 */
-   0x20,0x46,0x47,0x3E,0x21,0x00,0x00, /* code=0xa5 */
-   0x84,0x10,0x02,0x08,0x21,0x04,0x00, /* code=0xa6 */
-   0x98,0x10,0x17,0xA3,0x23,0x64,0x00, /* code=0xa7 */
-   0x40,0x01,0x00,0x00,0x00,0x00,0x00, /* code=0xa8 */
-   0xC0,0xC5,0x3B,0x6F,0x74,0x00,0x00, /* code=0xa9 */
-   0x04,0x31,0xC5,0x00,0x00,0x00,0x00, /* code=0xaa */
-   0x00,0x00,0xAA,0x8A,0xA2,0x00,0x00, /* code=0xab */
-   0x00,0x00,0xE0,0x21,0x84,0x00,0x00, /* code=0xac */
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0xad */
-   0xC0,0xC5,0x3A,0x67,0x74,0x00,0x00, /* code=0xae */
-   0xE0,0x03,0x00,0x00,0x00,0x00,0x00, /* code=0xaf */
-   0x80,0x38,0x02,0x00,0x00,0x00,0x00, /* code=0xb0 */
-   0x00,0x10,0xF2,0x09,0xF9,0x00,0x00, /* code=0xb1 */
-   0x06,0x11,0xE1,0x00,0x00,0x00,0x00, /* code=0xb2 */
-   0x06,0x19,0x64,0x00,0x00,0x00,0x00, /* code=0xb3 */
-   0x88,0x00,0x00,0x00,0x00,0x00,0x00, /* code=0xb4 */
-   0x00,0x80,0x94,0x52,0xBA,0x21,0x00, /* code=0xb5 */
-   0xC0,0xDF,0x6B,0x29,0xA5,0x94,0x02, /* code=0xb6 */
-   0x00,0x00,0x40,0x00,0x00,0x00,0x00, /* code=0xb7 */
-   0x00,0x00,0x00,0x00,0x60,0x88,0x00, /* code=0xb8 */
-   0xC4,0x10,0xE2,0x00,0x00,0x00,0x00, /* code=0xb9 */
-   0x44,0x29,0x02,0x00,0x00,0x00,0x00, /* code=0xba */
-   0x00,0x80,0xA2,0xA8,0x2A,0x00,0x00, /* code=0xbb */
-   0x30,0xC6,0x44,0x75,0x8F,0x01,0x00, /* code=0xbc */
-   0x30,0xA6,0xA2,0x63,0xCA,0x01,0x00, /* code=0xbd */
-   0x51,0x4E,0x55,0x75,0x8F,0x01,0x00, /* code=0xbe */
-   0x00,0x00,0x02,0x88,0x08,0xD1,0x01, /* code=0xbf */
-   0x82,0x00,0xE2,0x5C,0x8C,0x00,0x00, /* code=0xc0 */
-   0x88,0x00,0xE2,0x5C,0x8C,0x00,0x00, /* code=0xc1 */
-   0x44,0x01,0xE2,0x5C,0x8C,0x00,0x00, /* code=0xc2 */
-   0x54,0x01,0xE2,0x5C,0x8C,0x00,0x00, /* code=0xc3 */
-   0x40,0x01,0xE2,0x5C,0x8C,0x00,0x00, /* code=0xc4 */
-   0xC4,0x11,0xE2,0x5C,0x8C,0x00,0x00, /* code=0xc5 */
-   0xC0,0x1B,0xE3,0x4A,0xE9,0x00,0x00, /* code=0xc6 */
-   0xC0,0xC5,0x10,0x42,0x74,0x44,0x00, /* code=0xc7 */
-   0x82,0x80,0x1F,0x5E,0xF8,0x00,0x00, /* code=0xc8 */
-   0x88,0x80,0x1F,0x5E,0xF8,0x00,0x00, /* code=0xc9 */
-   0x44,0x81,0x1F,0x5E,0xF8,0x00,0x00, /* code=0xca */
-   0x40,0x81,0x1F,0x5E,0xF8,0x00,0x00, /* code=0xcb */
-   0x82,0x00,0x47,0x08,0x71,0x00,0x00, /* code=0xcc */
-   0x88,0x00,0x47,0x08,0x71,0x00,0x00, /* code=0xcd */
-   0x44,0x01,0x47,0x08,0x71,0x00,0x00, /* code=0xce */
-   0x40,0x01,0x47,0x08,0x71,0x00,0x00, /* code=0xcf */
-   0xC0,0x28,0x79,0xA5,0x32,0x00,0x00, /* code=0xd0 */
-   0x54,0x81,0x59,0x6B,0xCE,0x00,0x00, /* code=0xd1 */
-   0x82,0x00,0x17,0x63,0x74,0x00,0x00, /* code=0xd2 */
-   0x88,0x00,0x17,0x63,0x74,0x00,0x00, /* code=0xd3 */
-   0x44,0x01,0x17,0x63,0x74,0x00,0x00, /* code=0xd4 */
-   0x54,0x01,0x17,0x63,0x74,0x00,0x00, /* code=0xd5 */
-   0x40,0x01,0x17,0x63,0x74,0x00,0x00, /* code=0xd6 */
-   0x00,0x44,0x45,0x54,0x04,0x00,0x00, /* code=0xd7 */
-   0xC0,0xC5,0x5C,0x67,0x74,0x00,0x00, /* code=0xd8 */
-   0x82,0x80,0x18,0x63,0x74,0x00,0x00, /* code=0xd9 */
-   0x88,0x80,0x18,0x63,0x74,0x00,0x00, /* code=0xda */
-   0x44,0x81,0x18,0x63,0x74,0x00,0x00, /* code=0xdb */
-   0x40,0x81,0x18,0x63,0x74,0x00,0x00, /* code=0xdc */
-   0x88,0xC4,0x18,0x1D,0x21,0x00,0x00, /* code=0xdd */
-   0x40,0x08,0x27,0xA5,0x13,0x02,0x00, /* code=0xde */
-   0xC0,0x49,0xE9,0xA4,0x74,0x01,0x00, /* code=0xdf */
-   0x82,0x00,0x07,0x7D,0xF4,0x00,0x00, /* code=0xe0 */
-   0x88,0x00,0x07,0x7D,0xF4,0x00,0x00, /* code=0xe1 */
-   0x44,0x01,0x07,0x7D,0xF4,0x00,0x00, /* code=0xe2 */
-   0x54,0x01,0x07,0x7D,0xF4,0x00,0x00, /* code=0xe3 */
-   0x40,0x01,0x07,0x7D,0xF4,0x00,0x00, /* code=0xe4 */
-   0xC4,0x11,0x07,0x7D,0xF4,0x00,0x00, /* code=0xe5 */
-   0x00,0x00,0x45,0x5D,0xD1,0x00,0x00, /* code=0xe6 */
-   0x00,0x00,0x1F,0x42,0xF0,0x44,0x00, /* code=0xe7 */
-   0x82,0x00,0x17,0x7F,0xF0,0x00,0x00, /* code=0xe8 */
-   0x88,0x00,0x17,0x7F,0xF0,0x00,0x00, /* code=0xe9 */
-   0x44,0x01,0x17,0x7F,0xF0,0x00,0x00, /* code=0xea */
-   0x40,0x01,0x17,0x7F,0xF0,0x00,0x00, /* code=0xeb */
-   0x82,0x00,0x43,0x08,0x21,0x00,0x00, /* code=0xec */
-   0x88,0x00,0x43,0x08,0x21,0x00,0x00, /* code=0xed */
-   0x44,0x01,0x43,0x08,0x21,0x00,0x00, /* code=0xee */
-   0x40,0x01,0x43,0x08,0x21,0x00,0x00, /* code=0xef */
-   0xC0,0x22,0xE8,0x63,0x74,0x00,0x00, /* code=0xf0 */
-   0x54,0x81,0x17,0x63,0x8C,0x00,0x00, /* code=0xf1 */
-   0x82,0x00,0x17,0x63,0x74,0x00,0x00, /* code=0xf2 */
-   0x88,0x00,0x17,0x63,0x74,0x00,0x00, /* code=0xf3 */
-   0x44,0x01,0x17,0x63,0x74,0x00,0x00, /* code=0xf4 */
-   0xAA,0x00,0x17,0x63,0x74,0x00,0x00, /* code=0xf5 */
-   0x40,0x01,0x17,0x63,0x74,0x00,0x00, /* code=0xf6 */
-   0x00,0x10,0xF0,0x01,0x01,0x00,0x00, /* code=0xf7 */
-   0x00,0x00,0x97,0xEB,0x74,0x00,0x00, /* code=0xf8 */
-   0x82,0x80,0x18,0x63,0xF4,0x00,0x00, /* code=0xf9 */
-   0x88,0x80,0x18,0x63,0xF4,0x00,0x00, /* code=0xfa */
-   0x44,0x81,0x18,0x63,0xF4,0x00,0x00, /* code=0xfb */
-   0x40,0x81,0x18,0x63,0xF4,0x00,0x00, /* code=0xfc */
-   0x88,0x80,0x18,0x63,0xF4,0xD0,0x01, /* code=0xfd */
-   0x20,0x84,0x17,0x63,0x7C,0x21,0x00, /* code=0xfe */
-   0x40,0x81,0x18,0x63,0xF4,0xD0,0x01  /* code=0xff */
-};
-
-typedef struct
-{
-   bool **lut;
-   uint16_t glyph_min;
-   uint16_t glyph_max;
-} bitmapfont_lut_t;
-
-/* Generates a boolean LUT:
- *   lut[num_glyphs][glyph_width * glyph_height]
- * LUT value is 'true' if glyph pixel has a
- * non-zero value.
- * Returned object must be freed using
- * bitmapfont_free_lut().
- * Returns NULL in the event of an error. */
-bitmapfont_lut_t *bitmapfont_get_lut(void);
-
-void bitmapfont_free_lut(bitmapfont_lut_t *font);
-
-#endif

+ 0 - 252
app/src/main/cpp/gfx/drivers_font_renderer/bitmapfont.c

@@ -1,252 +0,0 @@
-/*  RetroArch - A frontend for libretro.
- *  Copyright (C) 2010-2014 - Hans-Kristian Arntzen
- *  Copyright (C) 2011-2017 - 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 <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include <boolean.h>
-
-#include "bitmap.h"
-
-#include "../font_driver.h"
-
-#define BMP_ATLAS_COLS 16
-#define BMP_ATLAS_ROWS 16
-#define BMP_ATLAS_SIZE (BMP_ATLAS_COLS * BMP_ATLAS_ROWS)
-
-/* Padding is required between each glyph in
- * the atlas to prevent texture bleed when
- * drawing with linear filtering enabled */
-#define BMP_ATLAS_PADDING 1
-
-typedef struct bm_renderer
-{
-   unsigned scale_factor;
-   struct font_glyph glyphs[BMP_ATLAS_SIZE];
-   struct font_atlas atlas;
-   struct font_line_metrics line_metrics;
-} bm_renderer_t;
-
-/* Generates a boolean LUT:
- *   lut[num_glyphs][glyph_width * glyph_height]
- * LUT value is 'true' if glyph pixel has a
- * non-zero value.
- * Returned object must be freed using
- * bitmapfont_free_lut().
- * Returns NULL in the event of an error. */
-bitmapfont_lut_t *bitmapfont_get_lut(void)
-{
-   bitmapfont_lut_t *font = NULL;
-   size_t symbol_index;
-   size_t i, j;
-
-   /* Initialise font struct */
-   font = (bitmapfont_lut_t*)calloc(1, sizeof(bitmapfont_lut_t));
-   if (!font)
-      goto error;
-
-   font->glyph_min = 0;
-   font->glyph_max = BMP_ATLAS_SIZE - 1;
-
-   /* Note: Need to use a calloc() here, otherwise
-    * we'll get undefined behaviour when calling
-    * bitmapfont_free_lut() if the following loop fails */
-   font->lut = (bool**)calloc(1, BMP_ATLAS_SIZE * sizeof(bool*));
-   if (!font->lut)
-      goto error;
-
-   /* Loop over all possible characters */
-   for (symbol_index = 0; symbol_index < BMP_ATLAS_SIZE; symbol_index++)
-   {
-      /* Allocate memory for current symbol */
-      font->lut[symbol_index] = (bool*)malloc(FONT_WIDTH *
-            FONT_HEIGHT * sizeof(bool));
-      if (!font->lut[symbol_index])
-         goto error;
-
-      for (j = 0; j < FONT_HEIGHT; j++)
-      {
-         for (i = 0; i < FONT_WIDTH; i++)
-         {
-            uint8_t rem     = 1 << ((i + j * FONT_WIDTH) & 7);
-            size_t offset   = (i + j * FONT_WIDTH) >> 3;
-
-            /* LUT value is 'true' if specified glyph
-             * position contains a pixel */
-            font->lut[symbol_index][i + (j * FONT_WIDTH)] =
-                  (bitmap_bin[FONT_OFFSET(symbol_index) + offset] & rem) > 0;
-         }
-      }
-   }
-
-   return font;
-
-error:
-   if (font)
-      bitmapfont_free_lut(font);
-
-   return NULL;
-}
-
-void bitmapfont_free_lut(bitmapfont_lut_t *font)
-{
-   if (!font)
-      return;
-
-   if (font->lut)
-   {
-      size_t num_glyphs = (font->glyph_max - font->glyph_min) + 1;
-      size_t i;
-
-      for (i = 0; i < num_glyphs; i++)
-      {
-         if (font->lut[i])
-            free(font->lut[i]);
-         font->lut[i] = NULL;
-      }
-
-      free(font->lut);
-   }
-
-   free(font);
-}
-
-static struct font_atlas *font_renderer_bmp_get_atlas(void *data)
-{
-   bm_renderer_t *handle = (bm_renderer_t*)data;
-   if (!handle)
-      return NULL;
-   return &handle->atlas;
-}
-
-static const struct font_glyph *font_renderer_bmp_get_glyph(
-      void *data, uint32_t code)
-{
-   bm_renderer_t *handle = (bm_renderer_t*)data;
-   if (!handle)
-      return NULL;
-   return code < BMP_ATLAS_SIZE ? &handle->glyphs[code] : NULL;
-}
-
-static void char_to_texture(bm_renderer_t *handle, uint8_t letter,
-      unsigned atlas_x, unsigned atlas_y)
-{
-   unsigned y, x;
-   uint8_t *target = handle->atlas.buffer + atlas_x +
-      atlas_y * handle->atlas.width;
-
-   for (y = 0; y < FONT_HEIGHT; y++)
-   {
-      for (x = 0; x < FONT_WIDTH; x++)
-      {
-         unsigned xo, yo;
-         unsigned font_pixel = x + y * FONT_WIDTH;
-         uint8_t rem         = 1 << (font_pixel & 7);
-         unsigned offset     = font_pixel >> 3;
-         uint8_t col         = (bitmap_bin[FONT_OFFSET(letter) + offset] & rem) ? 0xff : 0;
-         uint8_t *dst        = target;
-
-         dst                += x * handle->scale_factor;
-         dst                += y * handle->scale_factor * handle->atlas.width;
-
-         for (yo = 0; yo < handle->scale_factor; yo++)
-            for (xo = 0; xo < handle->scale_factor; xo++)
-               dst[xo + yo * handle->atlas.width] = col;
-      }
-   }
-   handle->atlas.dirty = true;
-}
-
-static void *font_renderer_bmp_init(const char *font_path, float font_size)
-{
-   unsigned i;
-   bm_renderer_t *handle = (bm_renderer_t*)calloc(1, sizeof(*handle));
-
-   if (!handle)
-      return NULL;
-
-   (void)font_path;
-
-   handle->scale_factor    = (unsigned)roundf(font_size / FONT_HEIGHT);
-   if (!handle->scale_factor)
-      handle->scale_factor = 1;
-
-   handle->atlas.width  = (BMP_ATLAS_PADDING + (FONT_WIDTH  * handle->scale_factor)) * BMP_ATLAS_COLS;
-   handle->atlas.height = (BMP_ATLAS_PADDING + (FONT_HEIGHT * handle->scale_factor)) * BMP_ATLAS_ROWS;
-   handle->atlas.buffer = (uint8_t*)calloc(handle->atlas.width * handle->atlas.height, 1);
-
-   for (i = 0; i < BMP_ATLAS_SIZE; i++)
-   {
-      unsigned x                       = (i % BMP_ATLAS_COLS) *
-         (BMP_ATLAS_PADDING + (handle->scale_factor * FONT_WIDTH));
-      unsigned y                       = (i / BMP_ATLAS_COLS) *
-         (BMP_ATLAS_PADDING + (handle->scale_factor * FONT_HEIGHT));
-
-      char_to_texture(handle, i, x, y);
-
-      handle->glyphs[i].width          = FONT_WIDTH * handle->scale_factor;
-      handle->glyphs[i].height         = FONT_HEIGHT * handle->scale_factor;
-      handle->glyphs[i].atlas_offset_x = x;
-      handle->glyphs[i].atlas_offset_y = y;
-      handle->glyphs[i].draw_offset_x  = 0;
-      handle->glyphs[i].draw_offset_y  = -FONT_HEIGHT_BASELINE_OFFSET * handle->scale_factor;
-      handle->glyphs[i].advance_x      = FONT_WIDTH_STRIDE * handle->scale_factor;
-      handle->glyphs[i].advance_y      = 0;
-   }
-
-   handle->line_metrics.ascender       = (float)FONT_HEIGHT_BASELINE_OFFSET * handle->scale_factor;
-   handle->line_metrics.descender      = (float)(FONT_HEIGHT - FONT_HEIGHT_BASELINE_OFFSET) * handle->scale_factor;
-   handle->line_metrics.height         = (float)FONT_HEIGHT_STRIDE * handle->scale_factor;
-
-   return handle;
-}
-
-static void font_renderer_bmp_free(void *data)
-{
-   bm_renderer_t *handle = (bm_renderer_t*)data;
-   if (!handle)
-      return;
-   free(handle->atlas.buffer);
-   free(handle);
-}
-
-static const char *font_renderer_bmp_get_default_font(void)
-{
-   return "";
-}
-
-static bool font_renderer_bmp_get_line_metrics(
-      void* data, struct font_line_metrics **metrics)
-{
-   bm_renderer_t *handle = (bm_renderer_t*)data;
-
-   if (!handle)
-      return false;
-
-   *metrics = &handle->line_metrics;
-   return true;
-}
-
-font_renderer_driver_t bitmap_font_renderer = {
-   font_renderer_bmp_init,
-   font_renderer_bmp_get_atlas,
-   font_renderer_bmp_get_glyph,
-   font_renderer_bmp_free,
-   font_renderer_bmp_get_default_font,
-   "font_renderer_bmp",
-   font_renderer_bmp_get_line_metrics
-};

+ 0 - 253
app/src/main/cpp/gfx/drivers_font_renderer/stb.c

@@ -1,253 +0,0 @@
-/*  RetroArch - A frontend for libretro.
- *  Copyright (C) 2015-2014 - Hans-Kristian Arntzen
- *  Copyright (C) 2011-2017 - 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 <ctype.h>
-
-#include <file/file_path.h>
-#include <streams/file_stream.h>
-#include <retro_miscellaneous.h>
-#include <string/stdstring.h>
-
-#include "../font_driver.h"
-
-#ifndef STB_TRUETYPE_IMPLEMENTATION
-#define STB_TRUETYPE_IMPLEMENTATION
-#define STB_RECT_PACK_IMPLEMENTATION
-#define STBTT_STATIC
-#define STBRP_STATIC
-#define STATIC static INLINE
-#include "../../deps/stb/stb_rect_pack.h"
-#include "../../deps/stb/stb_truetype.h"
-#undef STATIC
-#endif
-
-typedef struct
-{
-   struct font_atlas atlas;               /* ptr   alignment */
-   struct font_glyph glyphs[256];         /* unsigned alignment */
-   struct font_line_metrics line_metrics; /* float alignment */
-} stb_font_renderer_t;
-
-static struct font_atlas *font_renderer_stb_get_atlas(void *data)
-{
-   stb_font_renderer_t *self = (stb_font_renderer_t*)data;
-   return &self->atlas;
-}
-
-static const struct font_glyph *font_renderer_stb_get_glyph(
-      void *data, uint32_t code)
-{
-   stb_font_renderer_t *self = (stb_font_renderer_t*)data;
-   return code < 256 ? &self->glyphs[code] : NULL;
-}
-
-static void font_renderer_stb_free(void *data)
-{
-   stb_font_renderer_t *self = (stb_font_renderer_t*)data;
-
-   free(self->atlas.buffer);
-   free(self);
-}
-
-static bool font_renderer_stb_create_atlas(stb_font_renderer_t *self,
-      uint8_t *font_data, float font_size, unsigned width, unsigned height)
-{
-   int i;
-   stbtt_packedchar   chardata[256];
-   stbtt_pack_context pc = {NULL};
-
-   if (width > 2048 || height > 2048)
-      goto error;
-
-   if (self->atlas.buffer)
-      free(self->atlas.buffer);
-
-   self->atlas.buffer = (uint8_t*)calloc(height, width);
-   self->atlas.width  = width;
-   self->atlas.height = height;
-
-   if (!self->atlas.buffer)
-      goto error;
-
-   /* Note: 1 pixel of padding is added to
-    * prevent texture bleed when drawing with
-    * linear filtering enabled */
-   stbtt_PackBegin(&pc, self->atlas.buffer,
-         self->atlas.width, self->atlas.height,
-         self->atlas.width, 1, NULL);
-
-   stbtt_PackFontRange(&pc, font_data, 0, font_size, 0, 256, chardata);
-   stbtt_PackEnd(&pc);
-
-   self->atlas.dirty = true;
-
-   for (i = 0; i < 256; ++i)
-   {
-      struct font_glyph *g = &self->glyphs[i];
-      stbtt_packedchar  *c = &chardata[i];
-
-      g->advance_x         = c->xadvance;
-      g->atlas_offset_x    = c->x0;
-      g->atlas_offset_y    = c->y0;
-      g->draw_offset_x     = c->xoff;
-      g->draw_offset_y     = c->yoff;
-      g->width             = c->x1 - c->x0;
-      g->height            = c->y1 - c->y0;
-
-      /* Make sure important characters fit */
-      if (ISALNUM(i) && (!g->width || !g->height))
-      {
-         int new_width  = width  * 1.2;
-         int new_height = height * 1.2;
-
-         /* Limit growth to 2048x2048 unless we already reached that */
-         if (width < 2048 || height < 2048)
-         {
-            new_width  = MIN(new_width,  2048);
-            new_height = MIN(new_height, 2048);
-         }
-
-         return font_renderer_stb_create_atlas(self, font_data, font_size,
-               new_width, new_height);
-      }
-   }
-
-   return true;
-
-error:
-   self->atlas.width = self->atlas.height = 0;
-
-   if (self->atlas.buffer)
-      free(self->atlas.buffer);
-
-   self->atlas.buffer = NULL;
-
-   return false;
-}
-
-static void *font_renderer_stb_init(const char *font_path, float font_size)
-{
-   int ascent, descent, line_gap;
-   float scale_factor;
-   stbtt_fontinfo info;
-   uint8_t *font_data = NULL;
-   stb_font_renderer_t *self = (stb_font_renderer_t*) calloc(1, sizeof(*self));
-
-   /* See https://github.com/nothings/stb/blob/master/stb_truetype.h#L539 */
-   font_size = STBTT_POINT_SIZE(font_size);
-
-   if (!self)
-      goto error;
-
-   if (!path_is_valid(font_path) || !filestream_read_file(font_path, (void**)&font_data, NULL))
-      goto error;
-
-   if (!font_renderer_stb_create_atlas(self, font_data, font_size, 512, 512))
-      goto error;
-
-   if (!stbtt_InitFont(&info, font_data, stbtt_GetFontOffsetForIndex(font_data, 0)))
-      goto error;
-
-   stbtt_GetFontVMetrics(&info, &ascent, &descent, &line_gap);
-
-   scale_factor = (font_size < 0) ?
-         stbtt_ScaleForMappingEmToPixels(&info, -font_size) :
-         stbtt_ScaleForPixelHeight(&info, font_size);
-
-   /* Ascender, descender and line_gap values always
-    * end up ~0.5 pixels too small when scaled...
-    * > Add a manual correction factor */
-   self->line_metrics.ascender  = 0.5f + (float)ascent * scale_factor;
-   self->line_metrics.descender = 0.5f + (float)(-descent) * scale_factor;
-   self->line_metrics.height    = 0.5f + (float)(ascent - descent + line_gap) * scale_factor;
-
-   free(font_data);
-
-   return self;
-
-error:
-   if (font_data)
-      free(font_data);
-
-   if (self)
-      font_renderer_stb_free(self);
-   return NULL;
-}
-
-static const char *font_renderer_stb_get_default_font(void)
-{
-   static const char *paths[] = {
-#if defined(_WIN32) && !defined(__WINRT__)
-      "C:\\Windows\\Fonts\\consola.ttf",
-      "C:\\Windows\\Fonts\\verdana.ttf",
-#elif defined(__APPLE__)
-      "/Library/Fonts/Microsoft/Candara.ttf",
-      "/Library/Fonts/Verdana.ttf",
-      "/Library/Fonts/Tahoma.ttf",
-      "/Library/Fonts/Andale Mono.ttf",
-      "/Library/Fonts/Courier New.ttf",
-#elif defined(__ANDROID_API__)
-      "/system/fonts/DroidSansMono.ttf",
-      "/system/fonts/CutiveMono.ttf",
-      "/system/fonts/DroidSans.ttf",
-#elif defined(VITA)
-      "vs0:data/external/font/pvf/c041056ts.ttf",
-      "vs0:data/external/font/pvf/d013013ds.ttf",
-      "vs0:data/external/font/pvf/e046323ms.ttf",
-      "vs0:data/external/font/pvf/e046323ts.ttf",
-      "vs0:data/external/font/pvf/k006004ds.ttf",
-      "vs0:data/external/font/pvf/n023055ms.ttf",
-      "vs0:data/external/font/pvf/n023055ts.ttf",
-#elif !defined(__WINRT__)
-      "/usr/share/fonts/TTF/DejaVuSansMono.ttf",
-      "/usr/share/fonts/TTF/DejaVuSans.ttf",
-      "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf",
-      "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf",
-      "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf",
-      "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
-      "osd-font.ttf",
-#endif
-      NULL
-   };
-
-   const char **p;
-
-   for (p = paths; *p; ++p)
-      if (path_is_valid(*p))
-         return *p;
-
-   return NULL;
-}
-
-static bool font_renderer_stb_get_line_metrics(
-      void* data, struct font_line_metrics **metrics)
-{
-   stb_font_renderer_t *handle = (stb_font_renderer_t*)data;
-   if (!handle)
-      return false;
-   *metrics = &handle->line_metrics;
-   return true;
-}
-
-font_renderer_driver_t stb_font_renderer = {
-   font_renderer_stb_init,
-   font_renderer_stb_get_atlas,
-   font_renderer_stb_get_glyph,
-   font_renderer_stb_free,
-   font_renderer_stb_get_default_font,
-   "font_renderer_stb",
-   font_renderer_stb_get_line_metrics
-};

+ 0 - 362
app/src/main/cpp/gfx/drivers_font_renderer/stb_unicode.c

@@ -1,362 +0,0 @@
-/*  RetroArch - A frontend for libretro.
- *  Copyright (C) 2015-2014 - Hans-Kristian Arntzen
- *  Copyright (C) 2011-2017 - 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 <ctype.h>
-
-#include <file/file_path.h>
-#include <streams/file_stream.h>
-#include <string/stdstring.h>
-#include <retro_miscellaneous.h>
-
-#ifdef WIIU
-#include <wiiu/os.h>
-#endif
-
-#include "../font_driver.h"
-
-#ifndef STB_TRUETYPE_IMPLEMENTATION
-#define STB_TRUETYPE_IMPLEMENTATION
-#define STB_RECT_PACK_IMPLEMENTATION
-#define STBTT_STATIC
-#define STBRP_STATIC
-#define STATIC static INLINE
-#include "../../deps/stb/stb_rect_pack.h"
-#include "../../deps/stb/stb_truetype.h"
-#undef STATIC
-#endif
-
-#define STB_UNICODE_ATLAS_ROWS 16
-#define STB_UNICODE_ATLAS_COLS 16
-#define STB_UNICODE_ATLAS_SIZE (STB_UNICODE_ATLAS_ROWS * STB_UNICODE_ATLAS_COLS)
-/* Padding is required between each glyph in
- * the atlas to prevent texture bleed when
- * drawing with linear filtering enabled */
-#define STB_UNICODE_ATLAS_PADDING 1
-
-typedef struct stb_unicode_atlas_slot
-{
-   struct stb_unicode_atlas_slot* next;
-   struct font_glyph glyph;      /* unsigned alignment */
-   unsigned charcode;
-   unsigned last_used;
-}stb_unicode_atlas_slot_t;
-
-typedef struct
-{
-   uint8_t *font_data;
-   struct font_atlas atlas;               /* ptr alignment */
-   stb_unicode_atlas_slot_t* uc_map[0x100];
-   stb_unicode_atlas_slot_t atlas_slots[STB_UNICODE_ATLAS_SIZE];
-   stbtt_fontinfo info;                   /* ptr alignment */
-   int max_glyph_width;
-   int max_glyph_height;
-   unsigned usage_counter;
-   float scale_factor;
-   struct font_line_metrics line_metrics; /* float alignment */
-} stb_unicode_font_renderer_t;
-
-static struct font_atlas *font_renderer_stb_unicode_get_atlas(void *data)
-{
-   stb_unicode_font_renderer_t *self = (stb_unicode_font_renderer_t*)data;
-   return &self->atlas;
-}
-
-static void font_renderer_stb_unicode_free(void *data)
-{
-   stb_unicode_font_renderer_t *self = (stb_unicode_font_renderer_t*)data;
-
-   free(self->atlas.buffer);
-   free(self->font_data);
-   free(self);
-}
-
-static stb_unicode_atlas_slot_t* font_renderer_stb_unicode_get_slot(stb_unicode_font_renderer_t *handle)
-{
-   int i, map_id;
-   unsigned oldest = 0;
-
-   for (i = 1; i < STB_UNICODE_ATLAS_SIZE; i++)
-      if ((handle->usage_counter - handle->atlas_slots[i].last_used) >
-         (handle->usage_counter - handle->atlas_slots[oldest].last_used))
-         oldest = i;
-
-   /* remove from map */
-   map_id = handle->atlas_slots[oldest].charcode & 0xFF;
-   if (handle->uc_map[map_id] == &handle->atlas_slots[oldest])
-      handle->uc_map[map_id] = handle->atlas_slots[oldest].next;
-   else if (handle->uc_map[map_id])
-   {
-      stb_unicode_atlas_slot_t* ptr = handle->uc_map[map_id];
-      while (ptr->next && ptr->next != &handle->atlas_slots[oldest])
-         ptr = ptr->next;
-      ptr->next = handle->atlas_slots[oldest].next;
-   }
-
-   return &handle->atlas_slots[oldest];
-}
-
-static const struct font_glyph *font_renderer_stb_unicode_get_glyph(
-      void *data, uint32_t charcode)
-{
-   int glyph_index                      = 0;
-   int x0                               = 0;
-   int y1                               = 0;
-   int advance_width                    = 0;
-   int left_side_bearing                = 0;
-   unsigned map_id                      = 0;
-   uint8_t *dst                         = NULL;
-   stb_unicode_atlas_slot_t* atlas_slot = NULL;
-   stb_unicode_font_renderer_t *self    = (stb_unicode_font_renderer_t*)data;
-   float glyph_advance_x                = 0.0f;
-   float glyph_draw_offset_y            = 0.0f;
-
-   if (!self)
-      return NULL;
-
-   map_id                               = charcode & 0xFF;
-   atlas_slot                           = self->uc_map[map_id];
-
-   while (atlas_slot)
-   {
-      if (atlas_slot->charcode == charcode)
-      {
-         atlas_slot->last_used = self->usage_counter++;
-         return &atlas_slot->glyph;
-      }
-      atlas_slot = atlas_slot->next;
-   }
-
-   atlas_slot             = font_renderer_stb_unicode_get_slot(self);
-   atlas_slot->charcode   = charcode;
-   atlas_slot->next       = self->uc_map[map_id];
-   self->uc_map[map_id]   = atlas_slot;
-
-   glyph_index            = stbtt_FindGlyphIndex(&self->info, charcode);
-
-   dst = (uint8_t*)self->atlas.buffer + atlas_slot->glyph.atlas_offset_x
-         + atlas_slot->glyph.atlas_offset_y * self->atlas.width;
-
-   stbtt_GetGlyphHMetrics(&self->info, glyph_index, &advance_width, &left_side_bearing);
-   if (stbtt_GetGlyphBox(&self->info, glyph_index, &x0, NULL, NULL, &y1))
-   {
-      stbtt_MakeGlyphBitmap(&self->info, dst, self->max_glyph_width, self->max_glyph_height,
-            self->atlas.width, self->scale_factor, self->scale_factor, glyph_index);
-   }
-   else
-   {
-      /* This means the glyph is empty. In this case, stbtt_MakeGlyphBitmap()
-       * fills the corresponding region of the atlas buffer with garbage,
-       * so just zero it */
-      int x, y;
-      for (x = 0; x < self->max_glyph_width; x++)
-         for (y = 0; y < self->max_glyph_height; y++)
-            dst[x + (y * self->atlas.width)] = 0;
-   }
-
-   atlas_slot->glyph.width          = self->max_glyph_width;
-   atlas_slot->glyph.height         = self->max_glyph_height;
-   /* advance_x must always be rounded to the
-    * *nearest* integer */
-   glyph_advance_x = (float)advance_width * self->scale_factor;
-   atlas_slot->glyph.advance_x      = (int)((glyph_advance_x > 0.0f) ?
-         (glyph_advance_x + 0.5f) : (glyph_advance_x - 0.5f));
-   /* advance_y is always zero */
-   atlas_slot->glyph.advance_y      = 0;
-   /* draw_offset_x must always be rounded *down*
-    * to the nearest integer */
-   atlas_slot->glyph.draw_offset_x  = (int)((float)x0 * self->scale_factor);
-   /* draw_offset_y must always be rounded *up*
-    * to the nearest integer */
-   glyph_draw_offset_y = (float)(-y1) * self->scale_factor;
-   atlas_slot->glyph.draw_offset_y  = (int)((glyph_draw_offset_y < 0.0f) ?
-         floor((double)glyph_draw_offset_y) : ceil((double)glyph_draw_offset_y));
-
-   self->atlas.dirty = true;
-   atlas_slot->last_used = self->usage_counter++;
-   return &atlas_slot->glyph;
-}
-
-static bool font_renderer_stb_unicode_create_atlas(
-      stb_unicode_font_renderer_t *self, float font_size)
-{
-   unsigned i, x, y;
-   stb_unicode_atlas_slot_t* slot = NULL;
-
-   self->max_glyph_width  = font_size < 0 ? -font_size : font_size;
-   self->max_glyph_height = font_size < 0 ? -font_size : font_size;
-
-   self->atlas.width      = (self->max_glyph_width  + STB_UNICODE_ATLAS_PADDING) * STB_UNICODE_ATLAS_COLS;
-   self->atlas.height     = (self->max_glyph_height + STB_UNICODE_ATLAS_PADDING) * STB_UNICODE_ATLAS_ROWS;
-
-   self->atlas.buffer     = (uint8_t*)
-      calloc(self->atlas.width * self->atlas.height, sizeof(uint8_t));
-
-   if (!self->atlas.buffer)
-      return false;
-
-   slot = self->atlas_slots;
-
-   for (y = 0; y < STB_UNICODE_ATLAS_ROWS; y++)
-   {
-      for (x = 0; x < STB_UNICODE_ATLAS_COLS; x++)
-      {
-         slot->glyph.atlas_offset_x = x * (self->max_glyph_width  + STB_UNICODE_ATLAS_PADDING);
-         slot->glyph.atlas_offset_y = y * (self->max_glyph_height + STB_UNICODE_ATLAS_PADDING);
-         slot++;
-      }
-   }
-
-   for (i = 0; i < 256; i++)
-      font_renderer_stb_unicode_get_glyph(self, i);
-
-   for (i = 0; i < 256; i++)
-   {
-      if (ISALNUM(i))
-         font_renderer_stb_unicode_get_glyph(self, i);
-   }
-
-   return true;
-}
-
-static void *font_renderer_stb_unicode_init(const char *font_path, float font_size)
-{
-   int ascent, descent, line_gap;
-   stb_unicode_font_renderer_t *self =
-      (stb_unicode_font_renderer_t*)calloc(1, sizeof(*self));
-
-   if (!self || font_size < 1.0)
-      goto error;
-
-   /* See https://github.com/nothings/stb/blob/master/stb_truetype.h#L539 */
-   font_size = STBTT_POINT_SIZE(font_size);
-
-#ifdef WIIU
-   if (!*font_path)
-   {
-      uint32_t size = 0;
-      if (!OSGetSharedData(SHARED_FONT_DEFAULT, 0, (void**)&self->font_data, &size))
-         goto error;
-   }
-   else
-#endif
-   if (!path_is_valid(font_path) || !filestream_read_file(font_path, (void**)&self->font_data, NULL))
-      goto error;
-
-   if (!stbtt_InitFont(&self->info, self->font_data,
-            stbtt_GetFontOffsetForIndex(self->font_data, 0)))
-      goto error;
-
-   stbtt_GetFontVMetrics(&self->info, &ascent, &descent, &line_gap);
-
-   if (font_size < 0)
-      self->scale_factor = stbtt_ScaleForMappingEmToPixels(&self->info, -font_size);
-   else
-      self->scale_factor = stbtt_ScaleForPixelHeight(&self->info, font_size);
-
-   /* Ascender, descender and line_gap values always
-    * end up ~0.5 pixels too small when scaled...
-    * > Add a manual correction factor */
-   self->line_metrics.ascender  = 0.5f + (float)ascent * self->scale_factor;
-   self->line_metrics.descender = 0.5f + ((float)(-descent) * self->scale_factor);
-   self->line_metrics.height    = 0.5f + (float)(ascent - descent + line_gap) * self->scale_factor;
-
-   if (!font_renderer_stb_unicode_create_atlas(self, font_size))
-      goto error;
-
-   return self;
-
-error:
-   if (self)
-      font_renderer_stb_unicode_free(self);
-   return NULL;
-}
-
-static const char *font_renderer_stb_unicode_get_default_font(void)
-{
-#ifdef WIIU
-   return "";
-#else
-   static const char *paths[] = {
-#if defined(_WIN32) && !defined(__WINRT__)
-      "C:\\Windows\\Fonts\\consola.ttf",
-      "C:\\Windows\\Fonts\\verdana.ttf",
-#elif defined(__APPLE__)
-      "/Library/Fonts/Microsoft/Candara.ttf",
-      "/Library/Fonts/Verdana.ttf",
-      "/Library/Fonts/Tahoma.ttf",
-      "/Library/Fonts/Andale Mono.ttf",
-      "/Library/Fonts/Courier New.ttf",
-#elif defined(__ANDROID_API__)
-      "/system/fonts/DroidSansMono.ttf",
-      "/system/fonts/CutiveMono.ttf",
-      "/system/fonts/DroidSans.ttf",
-#elif defined(VITA)
-      "vs0:data/external/font/pvf/c041056ts.ttf",
-      "vs0:data/external/font/pvf/d013013ds.ttf",
-      "vs0:data/external/font/pvf/e046323ms.ttf",
-      "vs0:data/external/font/pvf/e046323ts.ttf",
-      "vs0:data/external/font/pvf/k006004ds.ttf",
-      "vs0:data/external/font/pvf/n023055ms.ttf",
-      "vs0:data/external/font/pvf/n023055ts.ttf",
-#elif defined(ORBIS)
-      "/preinst/common/font/c041056ts.ttf",
-      "/preinst/common/font/d013013ds.ttf",
-      "/preinst/common/font/e046323ms.ttf",
-      "/preinst/common/font/e046323ts.ttf",
-      "/preinst/common/font/k006004ds.ttf",
-      "/preinst/common/font/n023055ms.ttf",
-      "/preinst/common/font/n023055ts.ttf",
-#elif !defined(__WINRT__)
-      "/usr/share/fonts/TTF/DejaVuSansMono.ttf",
-      "/usr/share/fonts/TTF/DejaVuSans.ttf",
-      "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf",
-      "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf",
-      "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf",
-      "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
-      "osd-font.ttf",
-#endif
-      NULL
-   };
-
-   const char **p;
-
-   for (p = paths; *p; ++p)
-      if (path_is_valid(*p))
-         return *p;
-
-   return NULL;
-#endif
-}
-
-static bool font_renderer_stb_unicode_get_line_metrics(
-      void* data, struct font_line_metrics **metrics)
-{
-   stb_unicode_font_renderer_t *handle = (stb_unicode_font_renderer_t*)data;
-   if (!handle)
-      return false;
-   *metrics = &handle->line_metrics;
-   return true;
-}
-
-font_renderer_driver_t stb_unicode_font_renderer = {
-   font_renderer_stb_unicode_init,
-   font_renderer_stb_unicode_get_atlas,
-   font_renderer_stb_unicode_get_glyph,
-   font_renderer_stb_unicode_free,
-   font_renderer_stb_unicode_get_default_font,
-   "font_renderer_stb_unicode",
-   font_renderer_stb_unicode_get_line_metrics
-};

+ 1 - 0
app/src/main/cpp/gfx/drivers_shader/shader_vulkan.cpp

@@ -33,6 +33,7 @@
 #include "slang_reflection.h"
 #include "slang_reflection.hpp"
 
+#include "../video_driver.h"
 #include "../common/vulkan_common.h"
 #include "../../retroarch.h"
 #include "../../verbosity.h"

+ 0 - 946
app/src/main/cpp/gfx/font_driver.c

@@ -1,946 +0,0 @@
-/*  RetroArch - A frontend for libretro.
- *  Copyright (C) 2010-2014 - Hans-Kristian Arntzen
- *  Copyright (C) 2011-2017 - 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 <stdlib.h>
-#include <math.h>
-
-#ifdef HAVE_CONFIG_H
-#include "../config.h"
-#endif
-
-#include "font_driver.h"
-#include "video_thread_wrapper.h"
-
-/* TODO/FIXME - global */
-static void *video_font_driver = NULL;
-
-int font_renderer_create_default(
-      const font_renderer_driver_t **drv,
-      void **handle, const char *font_path, unsigned font_size)
-{
-   static const font_renderer_driver_t *font_backends[] = {
-#ifdef HAVE_FREETYPE
-      &freetype_font_renderer,
-#endif
-#if defined(__APPLE__) && defined(HAVE_CORETEXT)
-      &coretext_font_renderer,
-#endif
-#ifdef HAVE_STB_FONT
-#if defined(VITA) || defined(ORBIS) || defined(WIIU) || defined(ANDROID) || (defined(_WIN32) && !defined(_XBOX) && !defined(_MSC_VER) && _MSC_VER >= 1400) || (defined(_WIN32) && !defined(_XBOX) && defined(_MSC_VER)) || defined(HAVE_LIBNX) || defined(__linux__) || defined (HAVE_EMSCRIPTEN) || defined(__APPLE__) || defined(HAVE_ODROIDGO2) || defined(__PS3__)
-      &stb_unicode_font_renderer,
-#else
-      &stb_unicode_font_renderer,
-#endif
-#endif
-      &bitmap_font_renderer,
-      NULL
-   };
-   unsigned i;
-
-   for (i = 0; font_backends[i]; i++)
-   {
-      const char *path = font_path;
-
-      if (!path)
-         path = font_backends[i]->get_default_font();
-      if (!path)
-         continue;
-
-      *handle = font_backends[i]->init(path, font_size);
-      if (*handle)
-      {
-         *drv = font_backends[i];
-         return 1;
-      }
-   }
-
-   *drv    = NULL;
-   *handle = NULL;
-
-   return 0;
-}
-
-static bool font_init_first(
-      const void **font_driver, void **font_handle,
-      void *video_data, const char *font_path, float font_size,
-      enum font_driver_render_api api, bool is_threaded)
-{
-   if (font_path && !font_path[0])
-      font_path = NULL;
-
-   switch (api)
-   {
-#ifdef HAVE_OPENGL1
-      case FONT_DRIVER_RENDER_OPENGL1_API:
-         {
-            void *data = gl1_raster_font.init(
-                  video_data, font_path, font_size, is_threaded);
-            if (data)
-            {
-               *font_driver = &gl1_raster_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef HAVE_OPENGL
-      case FONT_DRIVER_RENDER_OPENGL_API:
-         {
-            void *data = gl2_raster_font.init(
-                  video_data, font_path, font_size, is_threaded);
-            if (data)
-            {
-               *font_driver = &gl2_raster_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef HAVE_OPENGL_CORE
-      case FONT_DRIVER_RENDER_OPENGL_CORE_API:
-         {
-            void *data = gl3_raster_font.init(
-                  video_data, font_path, font_size, is_threaded);
-            if (data)
-            {
-               *font_driver = &gl3_raster_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef HAVE_VULKAN
-      case FONT_DRIVER_RENDER_VULKAN_API:
-         {
-            void *data = vulkan_raster_font.init(video_data,
-                  font_path, font_size, is_threaded);
-            if (data)
-            {
-               *font_driver = &vulkan_raster_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef HAVE_METAL
-   case FONT_DRIVER_RENDER_METAL_API:
-         {
-            void *data = metal_raster_font.init(video_data,
-                  font_path, font_size, is_threaded);
-            if (data)
-            {
-               *font_driver = &metal_raster_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-#endif
-#ifdef HAVE_D3D8
-      case FONT_DRIVER_RENDER_D3D8_API:
-      {
-         static const font_renderer_t *d3d8_font_backends[] = {
-#if defined(_XBOX1)
-            &d3d_xdk1_font,
-#endif
-            NULL
-         };
-         unsigned i;
-
-         for (i = 0; i < ARRAY_SIZE(d3d8_font_backends); i++)
-         {
-            void *data = d3d8_font_backends[i] ? d3d8_font_backends[i]->init(
-                  video_data, font_path, font_size, is_threaded) : NULL;
-            if (data)
-            {
-               *font_driver = d3d8_font_backends[i];
-               *font_handle = data;
-
-               return true;
-            }
-         }
-      }
-      break;
-#endif
-#ifdef HAVE_D3D9
-      case FONT_DRIVER_RENDER_D3D9_API:
-      {
-         static const font_renderer_t *d3d9_font_backends[] = {
-#if defined(_WIN32) && defined(HAVE_D3DX)
-            &d3d_win32_font,
-#endif
-            NULL
-         };
-         unsigned i;
-
-         for (i = 0; i < ARRAY_SIZE(d3d9_font_backends); i++)
-         {
-            void *data = d3d9_font_backends[i] ? d3d9_font_backends[i]->init(
-                  video_data, font_path, font_size, is_threaded) : NULL;
-            if (data)
-            {
-               *font_driver = d3d9_font_backends[i];
-               *font_handle = data;
-
-               return true;
-            }
-         }
-      }
-      break;
-#endif
-#ifdef HAVE_D3D10
-      case FONT_DRIVER_RENDER_D3D10_API:
-         {
-            void *data = d3d10_font.init(video_data,
-                  font_path, font_size, is_threaded);
-            if (data)
-            {
-               *font_driver = &d3d10_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef HAVE_D3D11
-      case FONT_DRIVER_RENDER_D3D11_API:
-         {
-            void *data = d3d11_font.init(video_data,
-                  font_path, font_size, is_threaded);
-            if (data)
-            {
-               *font_driver = &d3d11_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef HAVE_D3D12
-      case FONT_DRIVER_RENDER_D3D12_API:
-         {
-            void *data = d3d12_font.init(video_data,
-                  font_path, font_size, is_threaded);
-            if (data)
-            {
-               *font_driver = &d3d12_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef HAVE_VITA2D
-      case FONT_DRIVER_RENDER_VITA2D:
-         {
-            void *data = vita2d_vita_font.init(
-                  video_data, font_path, font_size, is_threaded);
-            if (data)
-            {
-               *font_driver = &vita2d_vita_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef PS2
-      case FONT_DRIVER_RENDER_PS2:
-         {
-            void *data = ps2_font.init(
-                  video_data, font_path, font_size,
-                  is_threaded);
-            if (data)
-            {
-               *font_driver = &ps2_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef _3DS
-      case FONT_DRIVER_RENDER_CTR:
-         {
-            void *data = ctr_font.init(
-                  video_data, font_path, font_size,
-                  is_threaded);
-            if (data)
-            {
-               *font_driver = &ctr_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef WIIU
-      case FONT_DRIVER_RENDER_WIIU:
-         {
-            void *data = wiiu_font.init(
-                  video_data, font_path, font_size, is_threaded);
-            if (data)
-            {
-               *font_driver = &wiiu_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef HAVE_CACA
-      case FONT_DRIVER_RENDER_CACA:
-         {
-            void *data = caca_font.init(
-                  video_data, font_path, font_size,
-                  is_threaded);
-            if (data)
-            {
-               *font_driver = &caca_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef HAVE_SIXEL
-      case FONT_DRIVER_RENDER_SIXEL:
-         {
-            void *data = sixel_font.init(
-                  video_data, font_path, font_size,
-                  is_threaded);
-            if (data)
-            {
-               *font_driver = &sixel_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef HAVE_LIBNX
-      case FONT_DRIVER_RENDER_SWITCH:
-         {
-            void *data = switch_font.init(
-                  video_data, font_path, font_size,
-                  is_threaded);
-            if (data)
-            {
-               *font_driver = &switch_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef HAVE_GCM
-      case FONT_DRIVER_RENDER_RSX:
-         {
-            void *data = rsx_font.init(
-                  video_data, font_path, font_size,
-                  is_threaded);
-            if (data)
-            {
-               *font_driver = &rsx_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#ifdef HAVE_GDI
-#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
-      case FONT_DRIVER_RENDER_GDI:
-         {
-            void *data = gdi_font.init(
-                  video_data, font_path, font_size,
-                  is_threaded);
-            if (data)
-            {
-               *font_driver = &gdi_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-#endif
-#ifdef DJGPP
-      case FONT_DRIVER_RENDER_VGA:
-         {
-            void *data = vga_font.init(
-                  video_data, font_path, font_size,
-                  is_threaded);
-            if (data)
-            {
-               *font_driver = &vga_font;
-               *font_handle = data;
-               return true;
-            }
-         }
-         break;
-#endif
-      case FONT_DRIVER_RENDER_DONT_CARE:
-         /* TODO/FIXME - lookup graphics driver's 'API' */
-         break;
-      default:
-         break;
-   }
-
-   return false;
-}
-
-#ifdef HAVE_LANGEXTRA
-/* ASCII:       0xxxxxxx  (c & 0x80) == 0x00
- * other start: 11xxxxxx  (c & 0xC0) == 0xC0
- * other cont:  10xxxxxx  (c & 0xC0) == 0x80
- * Neutral:
- * 0020 - 002F: 001xxxxx (c & 0xE0) == 0x20
- * misc. white space:
- * 2000 - 200D: 11100010 10000000 1000xxxx (c[2] < 0x8E) (3 bytes)
- * Hebrew:
- * 0591 - 05F4: 1101011x (c & 0xFE) == 0xD6 (2 bytes)
- * Arabic:
- * 0600 - 06FF: 110110xx (c & 0xFC) == 0xD8 (2 bytes)
- */
-
-/* clang-format off */
-#define IS_ASCII(p)        ((*(p)&0x80) == 0x00)
-#define IS_MBSTART(p)      ((*(p)&0xC0) == 0xC0)
-#define IS_MBCONT(p)       ((*(p)&0xC0) == 0x80)
-#define IS_DIR_NEUTRAL(p)  ((*(p)&0xE0) == 0x20)
-#define IS_HEBREW(p)       ((*(p)&0xFE) == 0xD6)
-#define IS_ARABIC(p)       ((*(p)&0xFC) == 0xD8)
-#define IS_RTL(p)          (IS_HEBREW(p) || IS_ARABIC(p))
-#define GET_ID_ARABIC(p)   (((unsigned char)(p)[0] << 6) | ((unsigned char)(p)[1] & 0x3F))
-
-
-/* Checks for miscellaneous whitespace characters in the range U+2000 to U+200D */
-static INLINE unsigned is_misc_ws(const unsigned char* src)
-{
-   unsigned res = 0;
-   if (*(src) == 0xE2) /* first byte */
-   {
-      src++;
-      if (*(src) == 0x80) /* second byte */
-      {
-         src++;
-         res = (*(src) < 0x8E); /* third byte */
-      }
-   }
-   return res;
-}
-
-static INLINE unsigned font_get_arabic_replacement(
-      const char* src, const char* start)
-{
-   /* 0x0620 to 0x064F */
-   static const unsigned arabic_shape_map[0x100][0x4] = {
-      { 0 }, { 0 }, { 0 }, { 0 },          /* 0x0600 */
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-      { 0 }, { 0 }, { 0 }, { 0 },          /* 0x0610 */
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-      { 0 },                               /* 0x0620 */
-      { 0xFE80 },
-      { 0xFE81, 0xFE82 },
-      { 0xFE83, 0xFE84 },
-      { 0xFE85, 0xFE86 },
-      { 0xFE87, 0xFE88 },
-      { 0xFE89, 0xFE8A, 0xFE8B, 0xFE8C },
-      { 0xFE8D, 0xFE8E },
-
-      { 0xFE8F, 0xFE90, 0xFE91, 0xFE92 },
-      { 0xFE93, 0xFE94 },
-      { 0xFE95, 0xFE96, 0xFE97, 0xFE98 },
-      { 0xFE99, 0xFE9A, 0xFE9B, 0xFE9C },
-      { 0xFE9D, 0xFE9E, 0xFE9F, 0xFEA0 },
-      { 0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4 },
-      { 0xFEA5, 0xFEA6, 0xFEA7, 0xFEA8 },
-      { 0xFEA9, 0xFEAA },
-
-      { 0xFEAB, 0xFEAC },                  /* 0x0630 */
-      { 0xFEAD, 0xFEAE },
-      { 0xFEAF, 0xFEB0 },
-      { 0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4 },
-      { 0xFEB5, 0xFEB6, 0xFEB7, 0xFEB8 },
-      { 0xFEB9, 0xFEBA, 0xFEBB, 0xFEBC },
-      { 0xFEBD, 0xFEBE, 0xFEBF, 0xFEC0 },
-      { 0xFEC1, 0xFEC2, 0xFEC3, 0xFEC4 },
-
-      { 0xFEC5, 0xFEC6, 0xFEC7, 0xFEC8 },
-      { 0xFEC9, 0xFECA, 0xFECB, 0xFECC },
-      { 0xFECD, 0xFECE, 0xFECF, 0xFED0 },
-      { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-      { 0 },                               /* 0x0640 */
-      { 0xFED1, 0xFED2, 0xFED3, 0xFED4 },
-      { 0xFED5, 0xFED6, 0xFED7, 0xFED8 },
-      { 0xFED9, 0xFEDA, 0xFEDB, 0xFEDC },
-      { 0xFEDD, 0xFEDE, 0xFEDF, 0xFEE0 },
-      { 0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4 },
-      { 0xFEE5, 0xFEE6, 0xFEE7, 0xFEE8 },
-      { 0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC },
-
-      { 0xFEED, 0xFEEE },
-      { 0xFEEF, 0xFEF0, 0xFBE8, 0xFBE9 },
-      { 0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4 },
-      { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-      { 0 }, { 0 }, { 0 }, { 0 },          /* 0x0650 */
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-
-      { 0 }, { 0 }, { 0 }, { 0 },          /* 0x0660 */
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-
-      { 0 }, { 0 }, { 0 }, { 0 },          /* 0x0670 */
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-      { 0 }, { 0 },
-      { 0xFB56, 0xFB57, 0xFB58, 0xFB59 },
-      { 0 },
-
-
-      { 0 }, { 0 }, { 0 }, { 0 },          /* 0x0680 */
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-
-      { 0 }, { 0 }, { 0 }, { 0 },          /* 0x0690 */
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-
-      { 0 }, { 0 }, { 0 }, { 0 },          /* 0x06A0 */
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-      { 0 },
-      { 0xFB8E, 0xFB8F, 0xFB90, 0xFB91 },
-      { 0 }, { 0 },
-
-      { 0 }, { 0 }, { 0 },
-      { 0xFB92, 0xFB93, 0xFB94, 0xFB95 },
-
-
-      { 0 }, { 0 }, { 0 }, { 0 },          /* 0x06B0 */
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-
-      { 0 }, { 0 }, { 0 }, { 0 },          /* 0x06C0 */
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-      { 0xFBFC, 0xFBFD, 0xFBFE, 0xFBFF },
-      { 0 }, { 0 }, { 0 },
-
-
-      { 0 }, { 0 }, { 0 }, { 0 },          /* 0x06D0 */
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-
-      { 0 }, { 0 }, { 0 }, { 0 },          /* 0x06E0 */
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-
-
-      { 0 }, { 0 }, { 0 }, { 0 },          /* 0x06F0 */
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-      { 0 }, { 0 }, { 0 }, { 0 },
-   };
-   unsigned      result         = 0;
-   bool          prev_connected = false;
-   bool          next_connected = false;
-   unsigned char id             = GET_ID_ARABIC(src);
-   const char*   prev           = src - 2;
-   const char*   next           = src + 2;
-
-   if (IS_ARABIC(prev) && (prev >= start))
-   {
-      unsigned char prev_id = GET_ID_ARABIC(prev);
-
-      /* nonspacing diacritics 0x4b -- 0x5f */
-      while (prev_id > 0x4A && prev_id < 0x60)
-      {
-         prev -= 2;
-         if ((prev >= start) && IS_ARABIC(prev))
-            prev_id = GET_ID_ARABIC(prev);
-         else
-            break;
-      }
-
-      if (prev_id == 0x44) /* Arabic Letter Lam */
-      {
-         unsigned char prev2_id = 0;
-         const char*   prev2    = prev - 2;
-
-         if (prev2 >= start)
-            prev2_id            = (prev2[0] << 6) | (prev2[1] & 0x3F);
-
-         /* nonspacing diacritics 0x4b -- 0x5f */
-         while (prev2_id > 0x4A && prev2_id < 0x60)
-         {
-            prev2 -= 2;
-            if ((prev2 >= start) && IS_ARABIC(prev2))
-               prev2_id = GET_ID_ARABIC(prev2);
-            else
-               break;
-         }
-
-         prev_connected = !!arabic_shape_map[prev2_id][2];
-
-         switch (id)
-         {
-            case 0x22: /* Arabic Letter Alef with Madda Above */
-               return 0xFEF5 + prev_connected;
-            case 0x23: /* Arabic Letter Alef with Hamza Above */
-               return 0xFEF7 + prev_connected;
-            case 0x25: /* Arabic Letter Alef with Hamza Below */
-               return 0xFEF9 + prev_connected;
-            case 0x27: /* Arabic Letter Alef */
-               return 0xFEFB + prev_connected;
-         }
-      }
-      prev_connected = !!arabic_shape_map[prev_id][2];
-   }
-
-   if (IS_ARABIC(next))
-   {
-      unsigned char next_id = GET_ID_ARABIC(next);
-
-      /* nonspacing diacritics 0x4b -- 0x5f */
-      while (next_id > 0x4A && next_id < 0x60)
-      {
-         next += 2;
-         if (!IS_ARABIC(next))
-            break;
-         next_id = GET_ID_ARABIC(next);
-      }
-
-      next_connected = !!arabic_shape_map[next_id][1];
-   }
-
-   if ((result = 
-            arabic_shape_map[id][prev_connected | (next_connected <<
-               1)]))
-      return result;
-   return arabic_shape_map[id][prev_connected];
-}
-/* clang-format on */
-
-static char* font_driver_reshape_msg(const char* msg, unsigned char *buffer, size_t buffer_size)
-{
-   const unsigned char *src        = (const unsigned char*)msg;
-   bool                 reverse    = false;
-   size_t              msg_size    = (strlen(msg) * 2) + 1;
-   /* Fallback to heap allocated buffer if the buffer is too small */
-   /* worst case transformations are 2 bytes to 4 bytes -- aliaspider */
-   unsigned char*       dst_buffer = (buffer_size < msg_size) 
-                                   ? (unsigned char*)malloc(msg_size)
-                                   : buffer;
-   unsigned char *dst              = (unsigned char*)dst_buffer;
-
-   while (*src || reverse)
-   {
-      if (reverse)
-      {
-         src--;
-         while (src > (const unsigned char*)msg && IS_MBCONT(src))
-            src--;
-
-         if (src >= (const unsigned char*)msg && (IS_RTL(src) || IS_DIR_NEUTRAL(src) || is_misc_ws(src)))
-         {
-            if (IS_ARABIC(src))
-            {
-               unsigned replacement = font_get_arabic_replacement(
-                     (const char*)src, msg);
-
-               if (replacement)
-               {
-                  if (replacement < 0x80)
-                     *dst++ = replacement;
-                  else if (replacement < 0x800)
-                  {
-                     *dst++ = 0xC0 | (replacement >> 6);
-                     *dst++ = 0x80 | (replacement & 0x3F);
-                  }
-                  else if (replacement < 0x10000)
-                  {
-                     /* merged glyphs */
-                     if ((replacement >= 0xFEF5) && (replacement <= 0xFEFC))
-                        src -= 2;
-
-                     *dst++ = 0xE0 | ( replacement >> 12);
-                     *dst++ = 0x80 | ((replacement >> 6) & 0x3F);
-                     *dst++ = 0x80 | ( replacement       & 0x3F);
-                  }
-                  else
-                  {
-                     *dst++ = 0xF0 |  (replacement >> 18);
-                     *dst++ = 0x80 | ((replacement >> 12) & 0x3F);
-                     *dst++ = 0x80 | ((replacement >> 6)  & 0x3F);
-                     *dst++ = 0x80 | ( replacement        & 0x3F);
-                  }
-
-                  continue;
-               }
-            }
-
-            *dst++ = *src++;
-            while (IS_MBCONT(src))
-               *dst++ = *src++;
-            src--;
-
-            while (IS_MBCONT(src))
-               src--;
-         }
-         else
-         {
-            reverse = false;
-            src++;
-            while (  IS_MBCONT(src) 
-                  || IS_RTL(src) 
-                  || IS_DIR_NEUTRAL(src) 
-                  || is_misc_ws(src))
-               src++;
-         }
-      }
-      else
-      {
-         if (IS_RTL(src))
-         {
-            reverse = true;
-            while (  IS_MBCONT(src) 
-                  || IS_RTL(src)
-                  || IS_DIR_NEUTRAL(src)
-                  || is_misc_ws(src))
-               src++;
-         }
-         else
-            *dst++ = *src++;
-      }
-   }
-
-   *dst = '\0';
-
-   return (char*)dst_buffer;
-}
-#endif
-
-void font_driver_render_msg(void *data, const char *msg,
-      const struct font_params *params, void *font_data)
-{
-   font_data_t                *font = (font_data_t*)(font_data
-         ? font_data : video_font_driver);
-
-   if (msg && *msg && font && font->renderer && font->renderer->render_msg)
-   {
-#ifdef HAVE_LANGEXTRA
-      unsigned char tmp_buffer[64];
-      char *new_msg = font_driver_reshape_msg(msg, tmp_buffer, sizeof(tmp_buffer));
-#else
-      char *new_msg = (char*)msg;
-#endif
-      font->renderer->render_msg(data,
-            font->renderer_data, new_msg, params);
-#ifdef HAVE_LANGEXTRA
-      if (new_msg != (char*)tmp_buffer)
-         free(new_msg);
-#endif
-   }
-}
-
-void font_driver_bind_block(void *font_data, void *block)
-{
-   font_data_t *font = (font_data_t*)(font_data ? font_data : video_font_driver);
-
-   if (font && font->renderer && font->renderer->bind_block)
-      font->renderer->bind_block(font->renderer_data, block);
-}
-
-void font_driver_flush(unsigned width, unsigned height, void *font_data)
-{
-   font_data_t *font = (font_data_t*)(font_data ? font_data : video_font_driver);
-   if (font && font->renderer && font->renderer->flush)
-      font->renderer->flush(width, height, font->renderer_data);
-}
-
-int font_driver_get_message_width(void *font_data,
-      const char *msg, size_t len, float scale)
-{
-   font_data_t *font = (font_data_t*)(font_data ? font_data : video_font_driver);
-   if (len == 0 && msg)
-      len = strlen(msg);
-   if (font && font->renderer && font->renderer->get_message_width)
-      return font->renderer->get_message_width(font->renderer_data, msg, len, scale);
-   return -1;
-}
-
-int font_driver_get_line_height(font_data_t *font, float scale)
-{
-   struct font_line_metrics *metrics = NULL;
-   /* First try the line metrics implementation */
-   if (font && font->renderer && font->renderer->get_line_metrics)
-      if ((font->renderer->get_line_metrics(
-                  font->renderer_data, &metrics)))
-         return (int)roundf(metrics->height * scale);
-   /* Else return an approximation
-    * (uses a fudge of standard font metrics - mostly garbage...)
-    * > font_size = (width of 'a') / 0.6
-    * > line_height = font_size * 1.7f */
-   return (int)roundf(1.7f * (float)font_driver_get_message_width(font, "a", 1, scale) / 0.6f);
-}
-
-int font_driver_get_line_ascender(font_data_t *font, float scale)
-{
-   struct font_line_metrics *metrics = NULL;
-   /* First try the line metrics implementation */
-   if (font && font->renderer && font->renderer->get_line_metrics)
-      if ((font->renderer->get_line_metrics(font->renderer_data, &metrics)))
-         return (int)roundf(metrics->ascender * scale);
-   /* Else return an approximation
-    * (uses a fudge of standard font metrics - mostly garbage...)
-    * > font_size = (width of 'a') / 0.6
-    * > ascender = 1.58 * font_size * 0.75 */
-   return (int)roundf(1.58f * 0.75f * (float)font_driver_get_message_width(font, "a", 1, scale) / 0.6f);
-}
-
-int font_driver_get_line_descender(font_data_t *font, float scale)
-{
-   struct font_line_metrics *metrics = NULL;
-   /* First try the line metrics implementation */
-   if (font && font->renderer && font->renderer->get_line_metrics)
-      if ((font->renderer->get_line_metrics(font->renderer_data, &metrics)))
-         return (int)roundf(metrics->descender * scale);
-   /* Else return an approximation
-    * (uses a fudge of standard font metrics - mostly garbage...)
-    * > font_size = (width of 'a') / 0.6
-    * > descender = 1.58 * font_size * 0.25 */
-   return (int)roundf(1.58f * 0.25f * (float)font_driver_get_message_width(font, "a", 1, scale) / 0.6f);
-}
-
-int font_driver_get_line_centre_offset(font_data_t *font, float scale)
-{
-   struct font_line_metrics *metrics = NULL;
-   /* First try the line metrics implementation */
-   if (font && font->renderer && font->renderer->get_line_metrics)
-      if ((font->renderer->get_line_metrics(font->renderer_data, &metrics)))
-         return (int)roundf((metrics->ascender - metrics->descender) * 0.5f * scale);
-   /* Else return an approximation... */
-   return (int)roundf((1.58f * 0.5f * (float)font_driver_get_message_width(font, "a", 1, scale) / 0.6f) / 2.0f);
-}
-
-void font_driver_free(font_data_t *font)
-{
-   if (font)
-   {
-      bool is_threaded        = false;
-#ifdef HAVE_THREADS
-      bool *is_threaded_tmp   = video_driver_get_threaded();
-      is_threaded             = *is_threaded_tmp;
-#endif
-
-      if (font->renderer && font->renderer->free)
-         font->renderer->free(font->renderer_data, is_threaded);
-
-      font->renderer      = NULL;
-      font->renderer_data = NULL;
-
-      free(font);
-   }
-}
-
-font_data_t *font_driver_init_first(
-      void *video_data, const char *font_path, float font_size,
-      bool threading_hint, bool is_threaded,
-      enum font_driver_render_api api)
-{
-   const void *font_driver = NULL;
-   void *font_handle       = NULL;
-   bool ok                 = false;
-#ifdef HAVE_THREADS
-   if (     threading_hint
-         && is_threaded
-         && !video_driver_is_hw_context())
-      ok = video_thread_font_init(&font_driver, &font_handle,
-            video_data, font_path, font_size, api, font_init_first,
-            is_threaded);
-   else
-#endif
-   ok = font_init_first(&font_driver, &font_handle,
-         video_data, font_path, font_size, api, is_threaded);
-
-   if (ok)
-   {
-      font_data_t *font      = (font_data_t*)malloc(sizeof(*font));
-
-      if (font)
-      {
-         font->renderer      = (const font_renderer_t*)font_driver;
-         font->renderer_data = font_handle;
-         font->size          = font_size;
-         return font;
-      }
-   }
-
-   return NULL;
-}
-
-void font_driver_init_osd(
-      void *video_data,
-      const void *video_info_data,
-      bool threading_hint,
-      bool is_threaded,
-      enum font_driver_render_api api)
-{
-   const video_info_t *video_info = (const video_info_t*)video_info_data;
-   if (!video_font_driver && video_info)
-      video_font_driver = font_driver_init_first(video_data,
-            *video_info->path_font ? video_info->path_font : NULL,
-            video_info->font_size, threading_hint, is_threaded, api);
-}
-
-void font_driver_free_osd(void)
-{
-   if (video_font_driver)
-      font_driver_free(video_font_driver);
-
-   video_font_driver = NULL;
-}

+ 0 - 142
app/src/main/cpp/gfx/font_driver.h

@@ -1,142 +0,0 @@
-/*  RetroArch - A frontend for libretro.
- *  Copyright (C) 2010-2014 - Hans-Kristian Arntzen
- *  Copyright (C) 2011-2017 - 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/>.
- */
-
-#ifndef __FONT_DRIVER_H__
-#define __FONT_DRIVER_H__
-
-#include <stdint.h>
-
-#include <boolean.h>
-#include <retro_common_api.h>
-
-#include "../retroarch.h"
-
-#include "video_defines.h"
-
-RETRO_BEGIN_DECLS
-
-typedef struct font_renderer
-{
-   void *(*init)(void *data, const char *font_path,
-         float font_size, bool is_threaded);
-   void (*free)(void *data, bool is_threaded);
-   void (*render_msg)(void *userdata,
-         void *data, const char *msg,
-         const struct font_params *params);
-   const char *ident;
-
-   const struct font_glyph *(*get_glyph)(void *data, uint32_t code);
-   void (*bind_block)(void *data, void *block);
-   void (*flush)(unsigned width, unsigned height, void *data);
-
-   int (*get_message_width)(void *data, const char *msg, size_t msg_len, float scale);
-   bool (*get_line_metrics)(void* data, struct font_line_metrics **metrics);
-} font_renderer_t;
-
-typedef struct font_renderer_driver
-{
-   void *(*init)(const char *font_path, float font_size);
-
-   struct font_atlas *(*get_atlas)(void *data);
-
-   /* Returns NULL if no glyph for this code is found. */
-   const struct font_glyph *(*get_glyph)(void *data, uint32_t code);
-
-   void (*free)(void *data);
-
-   const char *(*get_default_font)(void);
-
-   const char *ident;
-
-   bool (*get_line_metrics)(void* data, struct font_line_metrics **metrics);
-} font_renderer_driver_t;
-
-typedef struct
-{
-   const font_renderer_t *renderer;
-   void *renderer_data;
-   float size;
-} font_data_t;
-
-/* font_path can be NULL for default font. */
-int font_renderer_create_default(
-      const font_renderer_driver_t **drv,
-      void **handle,
-      const char *font_path, unsigned font_size);
-
-void font_driver_render_msg(void *data,
-      const char *msg, const struct font_params *params, void *font_data);
-
-void font_driver_bind_block(void *font_data, void *block);
-
-int font_driver_get_message_width(void *font_data, const char *msg, size_t len, float scale);
-
-void font_driver_flush(unsigned width, unsigned height, void *font_data);
-
-void font_driver_free(font_data_t *font);
-
-font_data_t *font_driver_init_first(
-      void *video_data,
-      const char *font_path,
-      float font_size,
-      bool threading_hint,
-      bool is_threaded,
-      enum font_driver_render_api api);
-
-void font_driver_init_osd(
-      void *video_data,
-      const void *video_info_data,
-      bool threading_hint,
-      bool is_threaded,
-      enum font_driver_render_api api);
-
-void font_driver_free_osd(void);
-
-int font_driver_get_line_height(font_data_t *font, float scale);
-int font_driver_get_line_ascender(font_data_t *font, float scale);
-int font_driver_get_line_descender(font_data_t *font, float scale);
-int font_driver_get_line_centre_offset(font_data_t *font, float scale);
-
-extern font_renderer_t gl2_raster_font;
-extern font_renderer_t gl3_raster_font;
-extern font_renderer_t gl1_raster_font;
-extern font_renderer_t d3d_xdk1_font;
-extern font_renderer_t d3d_win32_font;
-extern font_renderer_t ps2_font;
-extern font_renderer_t vita2d_vita_font;
-extern font_renderer_t ctr_font;
-extern font_renderer_t wiiu_font;
-extern font_renderer_t vulkan_raster_font;
-extern font_renderer_t metal_raster_font;
-extern font_renderer_t d3d10_font;
-extern font_renderer_t d3d11_font;
-extern font_renderer_t d3d12_font;
-extern font_renderer_t caca_font;
-extern font_renderer_t gdi_font;
-extern font_renderer_t vga_font;
-extern font_renderer_t sixel_font;
-extern font_renderer_t switch_font;
-extern font_renderer_t rsx_font;
-
-extern font_renderer_driver_t stb_font_renderer;
-extern font_renderer_driver_t stb_unicode_font_renderer;
-extern font_renderer_driver_t freetype_font_renderer;
-extern font_renderer_driver_t coretext_font_renderer;
-extern font_renderer_driver_t bitmap_font_renderer;
-
-RETRO_END_DECLS
-
-#endif

+ 13 - 2
app/src/main/cpp/gfx/gfx_animation.c

@@ -1668,15 +1668,23 @@ bool gfx_animation_ticker_smooth(gfx_animation_ctx_ticker_smooth_t *ticker)
    /* Sanity check */
    if (string_is_empty(ticker->src_str) ||
        (ticker->dst_str_len < 1) ||
-       (ticker->field_width < 1) ||
-       (!ticker->font && (ticker->glyph_width < 1)))
+       (ticker->field_width < 1) || (
+#ifdef HAVE_FONT
+      !ticker->font &&
+#endif
+         (ticker->glyph_width < 1))
+    )
       goto end;
 
    /* If we are using a fixed width font (ticker->font == NULL),
     * switch to optimised code path */
+
+#ifdef HAVE_FONT
    if (!ticker->font)
+#endif
       return gfx_animation_ticker_smooth_fw(p_anim, ticker);
 
+#ifdef HAVE_FONT
    /* Find the display width of each character in
     * the src string + total width */
    if ((src_str_len = utf8len(ticker->src_str)) < 1)
@@ -1860,6 +1868,7 @@ bool gfx_animation_ticker_smooth(gfx_animation_ctx_ticker_smooth_t *ticker)
    success                  = true;
    is_active                = true;
    p_anim->flags           |= GFX_ANIM_FLAG_TICKER_IS_ACTIVE;
+#endif
 
 end:
 
@@ -2011,6 +2020,7 @@ bool gfx_animation_line_ticker_smooth(gfx_animation_ctx_line_ticker_smooth_t *li
    if (!line_ticker)
       return false;
 
+#ifdef HAVE_FONT
    if (!line_ticker->font ||
        string_is_empty(line_ticker->src_str) ||
        (line_ticker->field_width < 1) ||
@@ -2162,6 +2172,7 @@ bool gfx_animation_line_ticker_smooth(gfx_animation_ctx_line_ticker_smooth_t *li
    p_anim->flags           |= GFX_ANIM_FLAG_TICKER_IS_ACTIVE;
 
 end:
+#endif
 
    if (wrapped_str)
    {

+ 6 - 0
app/src/main/cpp/gfx/gfx_animation.h

@@ -23,7 +23,9 @@
 #include <boolean.h>
 #include <retro_common_api.h>
 
+#ifdef HAVE_FONT
 #include "font_driver.h"
+#endif
 
 RETRO_BEGIN_DECLS
 
@@ -128,7 +130,9 @@ typedef struct gfx_animation_ctx_ticker_smooth
    unsigned *dst_str_width; /* May be set to NULL 
                                (RGUI + XMB do not require this info) */
    unsigned *x_offset;
+#ifdef HAVE_FONT
    font_data_t *font;
+#endif
    size_t dst_str_len;
    unsigned glyph_width; /* Fallback if font == NULL */
    unsigned field_width;
@@ -151,7 +155,9 @@ typedef struct gfx_animation_ctx_line_ticker
 typedef struct gfx_animation_ctx_line_ticker_smooth
 {
    uint64_t idx;
+#ifdef HAVE_FONT
    font_data_t *font;
+#endif
    const char *src_str;
    float *y_offset;
    char *dst_str;

+ 6 - 0
app/src/main/cpp/gfx/gfx_display.c

@@ -457,6 +457,7 @@ void gfx_display_scissor_begin(
    }
 }
 
+#ifdef HAVE_FONT
 font_data_t *gfx_display_font_file(
       gfx_display_t *p_disp,
       char* fontpath, float menu_font_size, bool is_threaded)
@@ -522,6 +523,7 @@ void gfx_display_draw_text(
       video_st->poke->set_osd_msg(video_st->data,
             text, &params, (void*)font);
 }
+#endif
 
 void gfx_display_draw_bg(
       gfx_display_t *p_disp,
@@ -1041,6 +1043,7 @@ int gfx_display_osk_ptr_at_pos(void *data, int x, int y,
    return -1;
 }
 
+#if HAVE_FONT
 void gfx_display_draw_keyboard(
       gfx_display_t *p_disp,
       void *userdata,
@@ -1134,6 +1137,7 @@ void gfx_display_draw_keyboard(
             false, 0, false);
    }
 }
+#endif
 
 /* NOTE: Reads image from memory buffer */
 bool gfx_display_reset_textures_list_buffer(
@@ -1200,12 +1204,14 @@ bool gfx_display_reset_textures_list(
    return true;
 }
 
+#if HAVE_FONT
 /* Teardown; deinitializes and frees all
  * fonts associated to the display driver */
 void gfx_display_font_free(font_data_t *font)
 {
    font_driver_free(font);
 }
+#endif
 
 void gfx_display_deinit_white_texture(void)
 {

+ 10 - 0
app/src/main/cpp/gfx/gfx_display.h

@@ -30,7 +30,9 @@
 #include <gfx/math/matrix_4x4.h>
 
 #include "../retroarch.h"
+#ifdef HAVE_FONT
 #include "../gfx/font_driver.h"
+#endif
 
 RETRO_BEGIN_DECLS
 
@@ -223,12 +225,14 @@ void gfx_display_draw_cursor(
       float *color, float cursor_size, uintptr_t texture,
       float x, float y, unsigned width, unsigned height);
 
+#if HAVE_FONT
 void gfx_display_draw_text(
       const font_data_t *font, const char *text,
       float x, float y, int width, int height,
       uint32_t color, enum text_alignment text_align,
       float scale_factor, bool shadows_enable, float shadow_offset,
       bool draw_outside);
+#endif
 
 void gfx_display_scissor_begin(
       gfx_display_t *p_disp,
@@ -237,13 +241,16 @@ void gfx_display_scissor_begin(
       unsigned video_height,
       int x, int y, unsigned width, unsigned height);
 
+#if HAVE_FONT
 void gfx_display_font_free(font_data_t *font);
+#endif
 
 bool gfx_display_init_first_driver(gfx_display_t *p_disp,
       bool video_is_threaded);
 
 gfx_display_t *disp_get_ptr(void);
 
+#if HAVE_FONT
 void gfx_display_draw_keyboard(
       gfx_display_t *p_disp,
       void *userdata,
@@ -253,6 +260,7 @@ void gfx_display_draw_keyboard(
       const font_data_t *font,
       char *grid[], unsigned id,
       unsigned text_color);
+#endif
 
 void gfx_display_draw_bg(
       gfx_display_t *p_disp,
@@ -284,8 +292,10 @@ void gfx_display_draw_texture_slice(
 void gfx_display_rotate_z(gfx_display_t *p_disp,
       math_matrix_4x4 *matrix, float cosine, float sine, void *data);
 
+#ifdef HAVE_FONT
 font_data_t *gfx_display_font_file(gfx_display_t *p_disp,
       char* fontpath, float font_size, bool is_threaded);
+#endif
 
 bool gfx_display_reset_textures_list(
       const char *texture_path,

+ 0 - 2179
app/src/main/cpp/gfx/gfx_widgets.c

@@ -1,2179 +0,0 @@
-/*  RetroArch - A frontend for libretro.
- *  Copyright (C) 2014-2017 - Jean-André Santoni
- *  Copyright (C) 2015-2018 - Andre Leiradella
- *  Copyright (C) 2018-2020 - natinusala
- *
- *  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 <retro_miscellaneous.h>
-#include <retro_inline.h>
-
-#ifdef HAVE_CONFIG_H
-#include "../config.h"
-#endif
-
-#include <queues/fifo_queue.h>
-#include <file/file_path.h>
-#include <streams/file_stream.h>
-#include <string/stdstring.h>
-#include <retro_math.h>
-
-#include "gfx_display.h"
-#include "gfx_widgets.h"
-#include "font_driver.h"
-
-#include "../configuration.h"
-#include "../file_path_special.h"
-#include "../msg_hash.h"
-
-#include "../tasks/task_content.h"
-#include "../tasks/tasks_internal.h"
-
-#define BASE_FONT_SIZE 32.0f
-
-#define MSG_QUEUE_FONT_SIZE (BASE_FONT_SIZE * 0.69f)
-
-/* Icons */
-static const char 
-*gfx_widgets_icons_names[MENU_WIDGETS_ICON_LAST]         = {
-   "menu_pause.png",
-   "menu_frameskip.png",
-   "menu_rewind.png",
-   "resume.png",
-
-   "menu_hourglass.png",
-   "menu_check.png",
-
-   "menu_info.png",
-
-   "menu_achievements.png"
-};
-
-static dispgfx_widget_t dispwidget_st = {0}; /* uint64_t alignment */
-
-static void INLINE gfx_widgets_font_free(gfx_widget_font_data_t *font_data)
-{
-   if (font_data->font)
-      gfx_display_font_free(font_data->font);
-
-   font_data->font        = NULL;
-   font_data->usage_count = 0;
-}
-
-/* Widgets list */
-const static gfx_widget_t* const widgets[] = {
-#ifdef HAVE_NETWORKING
-   &gfx_widget_netplay_chat,
-   &gfx_widget_netplay_ping,
-#endif
-#ifdef HAVE_SCREENSHOTS
-   &gfx_widget_screenshot,
-#endif
-   &gfx_widget_volume,
-#ifdef HAVE_CHEEVOS
-   &gfx_widget_achievement_popup,
-   &gfx_widget_leaderboard_display,
-#endif
-   &gfx_widget_generic_message,
-   &gfx_widget_libretro_message,
-   &gfx_widget_progress_message,
-   &gfx_widget_load_content_animation
-};
-
-#if defined(HAVE_MENU) && defined(HAVE_XMB)
-static float gfx_display_get_widget_pixel_scale(
-      gfx_display_t *p_disp,
-      settings_t *settings,
-      unsigned width, unsigned height, bool fullscreen)
-{
-   static unsigned last_width                          = 0;
-   static unsigned last_height                         = 0;
-   static float scale                                  = 0.0f;
-   static bool scale_cached                            = false;
-   bool scale_updated                                  = false;
-   static float last_menu_scale_factor                 = 0.0f;
-   static enum menu_driver_id_type last_menu_driver_id = MENU_DRIVER_ID_UNKNOWN;
-   static float adjusted_scale                         = 1.0f;
-   bool gfx_widget_scale_auto                          = settings->bools.menu_widget_scale_auto;
-#if (defined(RARCH_CONSOLE) || defined(RARCH_MOBILE))
-   float menu_widget_scale_factor                      = settings->floats.menu_widget_scale_factor;
-#else
-   float menu_widget_scale_factor_fullscreen           = settings->floats.menu_widget_scale_factor;
-   float menu_widget_scale_factor_windowed             = settings->floats.menu_widget_scale_factor_windowed;
-   float menu_widget_scale_factor                      = fullscreen ?
-         menu_widget_scale_factor_fullscreen : menu_widget_scale_factor_windowed;
-#endif
-   float menu_scale_factor                             = menu_widget_scale_factor;
-
-   if (gfx_widget_scale_auto)
-   {
-#ifdef HAVE_RGUI
-      /* When using RGUI, _menu_scale_factor
-       * is ignored
-       * > If we are not using a widget scale factor override,
-       *   just set menu_scale_factor to 1.0 */
-      if (p_disp->menu_driver_id == MENU_DRIVER_ID_RGUI)
-         menu_scale_factor                             = 1.0f;
-      else
-#endif
-      {
-         float _menu_scale_factor                      = 
-            settings->floats.menu_scale_factor;
-         menu_scale_factor                             = _menu_scale_factor;
-      }
-   }
-
-   /* We need to perform a square root here, which
-    * can be slow on some platforms (not *slow*, but
-    * it involves enough work that it's worth trying
-    * to optimise). We therefore cache the pixel scale,
-    * and only update on first run or when the video
-    * size changes */
-   if (!scale_cached ||
-       (width  != last_width) ||
-       (height != last_height))
-   {
-      /* Baseline reference is a 1080p display */
-      scale = (float)(
-            sqrt((double)((width * width) + (height * height))) /
-            DIAGONAL_PIXELS_1080P);
-
-      scale_cached  = true;
-      scale_updated = true;
-      last_width    = width;
-      last_height   = height;
-   }
-
-   /* Adjusted scale calculation may also be slow, so
-    * only update if something changes */
-   if (scale_updated ||
-       (menu_scale_factor != last_menu_scale_factor) ||
-       (p_disp->menu_driver_id != last_menu_driver_id))
-   {
-      adjusted_scale         = gfx_display_get_adjusted_scale(
-            p_disp,
-            scale, menu_scale_factor, width);
-      last_menu_scale_factor = menu_scale_factor;
-      last_menu_driver_id    = p_disp->menu_driver_id;
-   }
-
-   return adjusted_scale;
-}
-#endif
-
-static void msg_widget_msg_transition_animation_done(void *userdata)
-{
-   disp_widget_msg_t *msg = (disp_widget_msg_t*)userdata;
-
-   if (msg->msg)
-      free(msg->msg);
-   msg->msg = NULL;
-
-   if (msg->msg_new)
-      msg->msg = strdup(msg->msg_new);
-
-   msg->msg_transition_animation = 0.0f;
-}
-
-void gfx_widgets_msg_queue_push(
-      retro_task_t *task,
-      const char *msg,
-      unsigned duration,
-      char *title,
-      enum message_queue_icon icon,
-      enum message_queue_category category,
-      unsigned prio, bool flush,
-      bool menu_is_alive)
-{
-   disp_widget_msg_t    *msg_widget = NULL;
-   dispgfx_widget_t *p_dispwidget   = &dispwidget_st;
-
-   if (FIFO_WRITE_AVAIL_NONPTR(p_dispwidget->msg_queue) > 0)
-   {
-      /* Get current msg if it exists */
-      if (task && task->frontend_userdata)
-      {
-         msg_widget           = (disp_widget_msg_t*)task->frontend_userdata;
-         /* msg_widgets can be passed between tasks */
-         msg_widget->task_ptr = task;
-      }
-
-      /* Spawn a new notification */
-      if (!msg_widget)
-      {
-         const char *title                      = msg;
-
-         msg_widget                             = (disp_widget_msg_t*)malloc(sizeof(*msg_widget));
-
-         msg_widget->msg                        = NULL;
-         msg_widget->msg_new                    = NULL;
-         msg_widget->msg_transition_animation   = 0.0f;
-         msg_widget->msg_len                    = 0;
-         msg_widget->duration                   = duration;
-
-         msg_widget->text_height                = 0;
-
-         msg_widget->offset_y                   = 0;
-         msg_widget->alpha                      = 1.0f;
-
-         msg_widget->width                      = 0;
-
-         msg_widget->expiration_timer           = 0;
-
-         msg_widget->task_ptr                   = task;
-         msg_widget->task_count                 = 0;
-
-         msg_widget->task_progress              = 0;
-         msg_widget->task_ident                 = 0;
-
-         msg_widget->unfold                     = 0.0f;
-
-         msg_widget->hourglass_rotation         = 0.0f;
-         msg_widget->hourglass_timer            = 0.0f;
-         msg_widget->flags                      = 0;
-
-         if (!(p_dispwidget->flags & DISPGFX_WIDGET_FLAG_MSG_QUEUE_HAS_ICONS))
-         {
-            msg_widget->flags                  |=  DISPWIDG_FLAG_UNFOLDED;
-            msg_widget->flags                  &= ~DISPWIDG_FLAG_UNFOLDING;
-            msg_widget->unfold                  = 1.0f;
-         }
-
-         if (task)
-         {
-            title = msg_widget->msg             = strdup(task->title);
-            msg_widget->msg_new                 = strdup(title);
-            msg_widget->msg_len                 = strlen(title);
-
-            if (!string_is_empty(task->error))
-               msg_widget->flags               |= DISPWIDG_FLAG_TASK_ERROR;
-            if (task->cancelled)
-               msg_widget->flags               |= DISPWIDG_FLAG_TASK_CANCELLED;
-            if (task->finished)
-               msg_widget->flags               |= DISPWIDG_FLAG_TASK_FINISHED;
-            msg_widget->task_progress           = task->progress;
-            msg_widget->task_ident              = task->ident;
-            msg_widget->task_count              = 1;
-
-            msg_widget->flags                  |= DISPWIDG_FLAG_UNFOLDED;
-
-            msg_widget->width                   = font_driver_get_message_width(
-                  p_dispwidget->gfx_widget_fonts.msg_queue.font,
-                  title,
-                  msg_widget->msg_len, 1.0f) +
-                  p_dispwidget->simple_widget_padding / 2;
-
-            task->frontend_userdata             = msg_widget;
-
-            msg_widget->hourglass_rotation      = 0;
-         }
-         else
-         {
-            /* Compute rect width, wrap if necessary */
-            /* Single line text > two lines text > two lines 
-             * text with expanded width */
-            size_t title_length                 = strlen(title);
-            char *msg                           = NULL;
-            size_t msg_len                      = 0;
-            unsigned width                      = menu_is_alive 
-               ? p_dispwidget->msg_queue_default_rect_width_menu_alive 
-               : p_dispwidget->msg_queue_default_rect_width;
-            unsigned text_width                 = font_driver_get_message_width(
-                  p_dispwidget->gfx_widget_fonts.msg_queue.font,
-                  title,
-                  title_length,
-                  1.0f);
-            msg_widget->text_height             = p_dispwidget->gfx_widget_fonts.msg_queue.line_height;
-            /* 1 byte uses for inserting '\n' */
-            msg_len                             = title_length + 1 + 1;
-            if (!(msg = (char *)malloc(msg_len)))
-               return;
-            msg[0] = '\0';
-
-            /* Text is too wide, split it into two lines */
-            if (text_width > width)
-            {
-               /* If the second line is too short, the widget may
-                * look unappealing - ensure that second line is at
-                * least 25% of the total width */
-               if ((text_width - (text_width >> 2)) < width)
-                  width = text_width - (text_width >> 2);
-
-               word_wrap(msg, msg_len, title, title_length,
-                     (int)((title_length * width) / text_width),
-                     100, 2);
-
-               msg_widget->text_height *= 2;
-            }
-            else
-            {
-               width                            = text_width;
-               strlcpy(msg, title, msg_len);
-            }
-
-            msg_widget->msg                     = msg;
-            msg_widget->msg_len                 = strlen(msg);
-            msg_widget->width                   = width + 
-               p_dispwidget->simple_widget_padding / 2;
-         }
-
-         fifo_write(&p_dispwidget->msg_queue,
-               &msg_widget, sizeof(msg_widget));
-      }
-      /* Update task info */
-      else
-      {
-         if (msg_widget->flags & DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED)
-         {
-            uintptr_t _tag     = (uintptr_t)&msg_widget->expiration_timer;
-            gfx_animation_kill_by_tag(&_tag);
-            msg_widget->flags &= ~DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED;
-         }
-
-         if (!string_is_equal(task->title, msg_widget->msg_new))
-         {
-            size_t len;
-            unsigned new_width;
-
-            if (msg_widget->msg_new)
-            {
-               free(msg_widget->msg_new);
-               msg_widget->msg_new                 = NULL;
-            }
-
-            title       = msg_widget->msg_new      = strdup(task->title);
-
-            len         = strlen(title);
-            new_width   = font_driver_get_message_width(
-                  p_dispwidget->gfx_widget_fonts.msg_queue.font,
-                  title,
-                  len,
-                  1.0f);
-
-            msg_widget->msg_len                    = len;
-            msg_widget->msg_transition_animation   = 0;
-
-            if (!task->alternative_look)
-            {
-               gfx_animation_ctx_entry_t entry;
-
-               entry.easing_enum    = EASING_OUT_QUAD;
-               entry.tag            = (uintptr_t)msg_widget;
-               entry.duration       = MSG_QUEUE_ANIMATION_DURATION*2;
-               entry.target_value   = p_dispwidget->msg_queue_height / 2.0f;
-               entry.subject        = &msg_widget->msg_transition_animation;
-               entry.cb             = msg_widget_msg_transition_animation_done;
-               entry.userdata       = msg_widget;
-
-               gfx_animation_push(&entry);
-            }
-            else
-               msg_widget_msg_transition_animation_done(msg_widget);
-
-            msg_widget->task_count++;
-
-            msg_widget->width = new_width;
-         }
-
-         if (!string_is_empty(task->error))
-            msg_widget->flags               |= DISPWIDG_FLAG_TASK_ERROR;
-         if (task->cancelled)
-            msg_widget->flags               |= DISPWIDG_FLAG_TASK_CANCELLED;
-         if (task->finished)
-            msg_widget->flags               |= DISPWIDG_FLAG_TASK_FINISHED;
-         msg_widget->task_progress     = task->progress;
-      }
-   }
-}
-
-static void gfx_widgets_unfold_end(void *userdata)
-{
-   disp_widget_msg_t *unfold        = (disp_widget_msg_t*)userdata;
-   dispgfx_widget_t *p_dispwidget   = &dispwidget_st;
-
-   unfold->flags                   &= ~DISPWIDG_FLAG_UNFOLDING;
-   p_dispwidget->flags             &= ~DISPGFX_WIDGET_FLAG_MOVING;
-}
-
-static void gfx_widgets_move_end(void *userdata)
-{
-   dispgfx_widget_t *p_dispwidget   = &dispwidget_st;
-
-   if (userdata)
-   {
-      gfx_animation_ctx_entry_t entry;
-      disp_widget_msg_t *unfold    = (disp_widget_msg_t*)userdata;
-
-      entry.cb                     = gfx_widgets_unfold_end;
-      entry.duration               = MSG_QUEUE_ANIMATION_DURATION;
-      entry.easing_enum            = EASING_OUT_QUAD;
-      entry.subject                = &unfold->unfold;
-      entry.tag                    = (uintptr_t)unfold;
-      entry.target_value           = 1.0f;
-      entry.userdata               = unfold;
-
-      gfx_animation_push(&entry);
-
-      unfold->flags               |= DISPWIDG_FLAG_UNFOLDED
-                                   | DISPWIDG_FLAG_UNFOLDING;
-   }
-   else
-      p_dispwidget->flags         &= ~DISPGFX_WIDGET_FLAG_MOVING;
-}
-
-static void gfx_widgets_msg_queue_expired(void *userdata)
-{
-   disp_widget_msg_t *msg = (disp_widget_msg_t *)userdata;
-
-   if (msg && !(msg->flags & DISPWIDG_FLAG_EXPIRED))
-      msg->flags  |= DISPWIDG_FLAG_EXPIRED;
-}
-
-static void gfx_widgets_msg_queue_move(dispgfx_widget_t *p_dispwidget)
-{
-   int i;
-   float y = 0;
-   /* there should always be one and only one unfolded message */
-   disp_widget_msg_t *unfold        = NULL; 
-
-#ifdef HAVE_THREADS
-   slock_lock(p_dispwidget->current_msgs_lock);
-#endif
-
-   for (i = (int)(p_dispwidget->current_msgs_size - 1); i >= 0; i--)
-   {
-      disp_widget_msg_t* msg = p_dispwidget->current_msgs[i];
-
-      if (!msg || (msg->flags & DISPWIDG_FLAG_DYING))
-         continue;
-
-      y += p_dispwidget->msg_queue_height 
-         / (msg->task_ptr ? 2 : 1) + p_dispwidget->msg_queue_spacing;
-
-      if (!(msg->flags & DISPWIDG_FLAG_UNFOLDED))
-         unfold = msg;
-
-      if (msg->offset_y != y)
-      {
-         gfx_animation_ctx_entry_t entry;
-
-         entry.cb             = (i == 0) ? gfx_widgets_move_end : NULL;
-         entry.duration       = MSG_QUEUE_ANIMATION_DURATION;
-         entry.easing_enum    = EASING_OUT_QUAD;
-         entry.subject        = &msg->offset_y;
-         entry.tag            = (uintptr_t)msg;
-         entry.target_value   = y;
-         entry.userdata       = unfold;
-
-         gfx_animation_push(&entry);
-
-         p_dispwidget->flags |= DISPGFX_WIDGET_FLAG_MOVING;
-      }
-   }
-
-#ifdef HAVE_THREADS
-   slock_unlock(p_dispwidget->current_msgs_lock);
-#endif
-}
-
-static void gfx_widgets_msg_queue_free(
-      dispgfx_widget_t *p_dispwidget,
-      disp_widget_msg_t *msg)
-{
-   uintptr_t tag = (uintptr_t)msg;
-   uintptr_t hourglass_timer_tag = (uintptr_t)&msg->hourglass_timer;
-
-   if (msg->task_ptr)
-   {
-      /* remove the reference the task has of ourself
-         only if the task is not finished already
-         (finished tasks are freed before the widget) */
-      if (     !(msg->flags & DISPWIDG_FLAG_TASK_FINISHED) 
-            && !(msg->flags & DISPWIDG_FLAG_TASK_ERROR) 
-            && !(msg->flags & DISPWIDG_FLAG_TASK_CANCELLED))
-         msg->task_ptr->frontend_userdata = NULL;
-
-      /* update tasks count */
-      p_dispwidget->msg_queue_tasks_count--;
-   }
-
-   /* Kill all animations */
-   gfx_animation_kill_by_tag(&hourglass_timer_tag);
-   gfx_animation_kill_by_tag(&tag);
-
-   /* Kill all timers */
-   if (msg->flags & DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED)
-   {
-      uintptr_t _tag = (uintptr_t)&msg->expiration_timer;
-      gfx_animation_kill_by_tag(&_tag);
-   }
-
-   /* Free it */
-   if (msg->msg)
-      free(msg->msg);
-
-   if (msg->msg_new)
-      free(msg->msg_new);
-
-   p_dispwidget->flags &= ~DISPGFX_WIDGET_FLAG_MOVING;
-}
-
-static void gfx_widgets_msg_queue_kill_end(void *userdata)
-{
-   disp_widget_msg_t* msg;
-   dispgfx_widget_t *p_dispwidget   = &dispwidget_st;
-
-#ifdef HAVE_THREADS
-   slock_lock(p_dispwidget->current_msgs_lock);
-#endif
-
-   if ((msg = p_dispwidget->current_msgs[p_dispwidget->msg_queue_kill]))
-   {
-      int i;
-      /* Remove it from the list */
-      for (i = p_dispwidget->msg_queue_kill; i < (int)(p_dispwidget->current_msgs_size - 1); i++)
-         p_dispwidget->current_msgs[i] = p_dispwidget->current_msgs[i + 1];
-
-      p_dispwidget->current_msgs_size--;
-      p_dispwidget->current_msgs[p_dispwidget->current_msgs_size] = NULL;
-
-      /* clean up the item */
-      gfx_widgets_msg_queue_free(p_dispwidget, msg);
-
-      /* free the associated memory */
-      free(msg);
-   }
-
-#ifdef HAVE_THREADS
-   slock_unlock(p_dispwidget->current_msgs_lock);
-#endif
-}
-
-static void gfx_widgets_msg_queue_kill(
-      dispgfx_widget_t *p_dispwidget,
-      unsigned idx)
-{
-   gfx_animation_ctx_entry_t entry;
-   disp_widget_msg_t *msg = p_dispwidget->current_msgs[idx];
-
-   if (!msg)
-      return;
-
-   p_dispwidget->flags         |= DISPGFX_WIDGET_FLAG_MOVING;
-   msg->flags                  |= DISPWIDG_FLAG_DYING;
-
-   p_dispwidget->msg_queue_kill = idx;
-
-   /* Drop down */
-   entry.cb                     = NULL;
-   entry.duration               = MSG_QUEUE_ANIMATION_DURATION;
-   entry.easing_enum            = EASING_OUT_QUAD;
-   entry.tag                    = (uintptr_t)msg;
-   entry.userdata               = NULL;
-   entry.subject                = &msg->offset_y;
-   entry.target_value           = msg->offset_y - 
-      p_dispwidget->msg_queue_height / 4;
-
-   gfx_animation_push(&entry);
-
-   /* Fade out */
-   entry.cb                     = gfx_widgets_msg_queue_kill_end;
-   entry.subject                = &msg->alpha;
-   entry.target_value           = 0.0f;
-
-   gfx_animation_push(&entry);
-
-   /* Move all messages back to their correct position */
-   if (p_dispwidget->current_msgs_size != 0)
-      gfx_widgets_msg_queue_move(p_dispwidget);
-}
-
-void gfx_widgets_draw_icon(
-      void *userdata,
-      void *data_disp,
-      unsigned video_width,
-      unsigned video_height,
-      unsigned icon_width,
-      unsigned icon_height,
-      uintptr_t texture,
-      float x, float y,
-      float radians,
-      float cosine,
-      float sine,
-      float *color)
-{
-   gfx_display_ctx_draw_t draw;
-   struct video_coords coords;
-   math_matrix_4x4 mymat;
-   gfx_display_t            *p_disp  = (gfx_display_t*)data_disp;
-   gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
-
-   if (!texture)
-      return;
-
-   if (!p_disp->dispctx->handles_transform)
-      gfx_display_rotate_z(p_disp, &mymat, cosine, sine, userdata);
-
-   coords.vertices      = 4;
-   coords.vertex        = NULL;
-   coords.tex_coord     = NULL;
-   coords.lut_tex_coord = NULL;
-   coords.color         = color;
-
-   draw.x               = x;
-   draw.y               = video_height - y - icon_height;
-   draw.width           = icon_width;
-   draw.height          = icon_height;
-   draw.scale_factor    = 1.0f;
-   draw.rotation        = radians;
-   draw.coords          = &coords;
-   draw.matrix_data     = &mymat;
-   draw.texture         = texture;
-   draw.prim_type       = GFX_DISPLAY_PRIM_TRIANGLESTRIP;
-   draw.pipeline_id     = 0;
-
-   if (draw.height > 0 && draw.width > 0)
-      if (dispctx->draw)
-         dispctx->draw(&draw, userdata, video_width, video_height);
-}
-
-void gfx_widgets_draw_text(
-      gfx_widget_font_data_t* font_data,
-      const char *text,
-      float x, float y,
-      int width, int height,
-      uint32_t color,
-      enum text_alignment text_align,
-      bool draw_outside)
-{
-   if (!font_data || string_is_empty(text))
-      return;
-
-   gfx_display_draw_text(
-         font_data->font,
-         text,
-         x, y,
-         width, height,
-         color,
-         text_align,
-         1.0f,
-         false,
-         0.0f,
-         draw_outside);
-
-   font_data->usage_count++;
-}
-
-void gfx_widgets_flush_text(
-      unsigned video_width, unsigned video_height,
-      gfx_widget_font_data_t* font_data)
-{
-   /* Flushing is slow - only do it if font
-    * has actually been used */
-   if (!font_data || (font_data->usage_count == 0))
-      return;
-
-   font_driver_flush(video_width, video_height, font_data->font);
-   font_data->raster_block.carr.coords.vertices = 0;
-   font_data->usage_count                       = 0;
-}
-
-float gfx_widgets_get_thumbnail_scale_factor(
-      const float dst_width, const float dst_height,
-      const float image_width, const float image_height)
-{
-   float dst_ratio      = dst_width   / dst_height;
-   float image_ratio    = image_width / image_height;
-
-   if (dst_ratio > image_ratio)
-      return (dst_height / image_height);
-   return (dst_width / image_width);
-}
-
-static void gfx_widgets_start_msg_expiration_timer(
-      disp_widget_msg_t *msg_widget, unsigned duration)
-{
-   gfx_timer_ctx_entry_t timer;
-
-   timer.cb       = gfx_widgets_msg_queue_expired;
-   timer.duration = duration;
-   timer.userdata = msg_widget;
-
-   gfx_animation_timer_start(&msg_widget->expiration_timer, &timer);
-
-   msg_widget->flags                   |=
-      DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED;
-}
-
-static void gfx_widgets_hourglass_tick(void *userdata);
-
-static void gfx_widgets_hourglass_end(void *userdata)
-{
-   gfx_timer_ctx_entry_t timer;
-   disp_widget_msg_t *msg  = (disp_widget_msg_t*)userdata;
-
-   msg->hourglass_rotation = 0.0f;
-
-   timer.cb                = gfx_widgets_hourglass_tick;
-   timer.duration          = HOURGLASS_INTERVAL;
-   timer.userdata          = msg;
-
-   gfx_animation_timer_start(&msg->hourglass_timer, &timer);
-}
-
-static void gfx_widgets_hourglass_tick(void *userdata)
-{
-   gfx_animation_ctx_entry_t entry;
-   disp_widget_msg_t *msg = (disp_widget_msg_t*)userdata;
-   uintptr_t          tag = (uintptr_t)msg;
-
-   entry.easing_enum      = EASING_OUT_QUAD;
-   entry.tag              = tag;
-   entry.duration         = HOURGLASS_DURATION;
-   entry.target_value     = -(2 * M_PI);
-   entry.subject          = &msg->hourglass_rotation;
-   entry.cb               = gfx_widgets_hourglass_end;
-   entry.userdata         = msg;
-
-   gfx_animation_push(&entry);
-}
-
-static void gfx_widgets_font_init(
-      gfx_display_t *p_disp,
-      dispgfx_widget_t *p_dispwidget,
-      gfx_widget_font_data_t *font_data,
-      bool is_threaded, char *font_path, float font_size)
-{
-   int                glyph_width   = 0;
-   float                scaled_size = font_size * 
-      p_dispwidget->last_scale_factor;
-
-   /* Free existing font */
-   if (font_data->font)
-   {
-      gfx_display_font_free(font_data->font);
-      font_data->font = NULL;
-   }
-
-   /* Get approximate glyph width */
-   font_data->glyph_width = scaled_size * (3.0f / 4.0f);
-
-   /* Create font */
-   font_data->font = gfx_display_font_file(p_disp,
-         font_path, scaled_size, is_threaded);
-
-   /* Get font metadata */
-   glyph_width = font_driver_get_message_width(font_data->font, "a", 1, 1.0f);
-   if (glyph_width > 0)
-      font_data->glyph_width     = (float)glyph_width;
-   font_data->line_height        = (float)font_driver_get_line_height(font_data->font, 1.0f);
-   font_data->line_ascender      = (float)font_driver_get_line_ascender(font_data->font, 1.0f);
-   font_data->line_descender     = (float)font_driver_get_line_descender(font_data->font, 1.0f);
-   font_data->line_centre_offset = (float)font_driver_get_line_centre_offset(font_data->font, 1.0f);
-
-   font_data->usage_count        = 0;
-}
-
-
-static void gfx_widgets_layout(
-      gfx_display_t *p_disp,
-      dispgfx_widget_t *p_dispwidget,
-      bool is_threaded, const char *dir_assets, char *font_path)
-{
-   size_t i;
-
-   /* Initialise fonts */
-   if (string_is_empty(font_path))
-   {
-      char font_file[PATH_MAX_LENGTH];
-      /* Create regular font */
-      gfx_widgets_font_init(p_disp, p_dispwidget,
-            &p_dispwidget->gfx_widget_fonts.regular,
-            is_threaded, p_dispwidget->ozone_regular_font_path, BASE_FONT_SIZE);
-      /* Create bold font */
-      gfx_widgets_font_init(p_disp, p_dispwidget,
-            &p_dispwidget->gfx_widget_fonts.bold,
-            is_threaded, p_dispwidget->ozone_bold_font_path, BASE_FONT_SIZE);
-
-      /* Create msg_queue font */
-      switch (*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE))
-      {
-         case RETRO_LANGUAGE_ARABIC:
-         case RETRO_LANGUAGE_PERSIAN:
-            fill_pathname_join_special(font_file, p_dispwidget->assets_pkg_dir, "fallback-font.ttf", sizeof(font_file));
-            break;
-         case RETRO_LANGUAGE_CHINESE_SIMPLIFIED:
-         case RETRO_LANGUAGE_CHINESE_TRADITIONAL:
-            fill_pathname_join_special(font_file, p_dispwidget->assets_pkg_dir, "chinese-fallback-font.ttf", sizeof(font_file));
-            break;
-         case RETRO_LANGUAGE_KOREAN:
-            fill_pathname_join_special(font_file, p_dispwidget->assets_pkg_dir, "korean-fallback-font.ttf", sizeof(font_file));
-            break;
-         default:
-            strlcpy(font_file, p_dispwidget->ozone_regular_font_path, sizeof(font_file));
-            break;
-      }
-      gfx_widgets_font_init(p_disp, p_dispwidget,
-            &p_dispwidget->gfx_widget_fonts.msg_queue,
-            is_threaded, font_file, MSG_QUEUE_FONT_SIZE);
-   }
-   else
-   {
-      /* Load fonts from user-supplied path */
-      gfx_widgets_font_init(p_disp, p_dispwidget,
-            &p_dispwidget->gfx_widget_fonts.regular,
-            is_threaded, font_path, BASE_FONT_SIZE);
-      gfx_widgets_font_init(p_disp, p_dispwidget,
-            &p_dispwidget->gfx_widget_fonts.bold,
-            is_threaded, font_path, BASE_FONT_SIZE);
-      gfx_widgets_font_init(p_disp, p_dispwidget,
-            &p_dispwidget->gfx_widget_fonts.msg_queue,
-            is_threaded, font_path, MSG_QUEUE_FONT_SIZE);
-   }
-
-   /* Calculate dimensions */
-   p_dispwidget->simple_widget_padding            = p_dispwidget->gfx_widget_fonts.regular.line_height * 2.0f/3.0f;
-   p_dispwidget->simple_widget_height             = p_dispwidget->gfx_widget_fonts.regular.line_height + p_dispwidget->simple_widget_padding;
-
-   p_dispwidget->msg_queue_height                 = p_dispwidget->gfx_widget_fonts.msg_queue.line_height * 2.5f * (BASE_FONT_SIZE / MSG_QUEUE_FONT_SIZE);
-
-   if (p_dispwidget->flags & DISPGFX_WIDGET_FLAG_MSG_QUEUE_HAS_ICONS)
-   {
-#if 0
-      p_dispwidget->msg_queue_icon_size_y         = p_dispwidget->msg_queue_height 
-         * 1.2347826087f; /* original image is 280x284 */
-      p_dispwidget->msg_queue_icon_size_x         = 0.98591549295f * p_dispwidget->msg_queue_icon_size_y;
-#else
-      p_dispwidget->msg_queue_icon_size_y         = p_dispwidget->msg_queue_height * 1.2f;
-      p_dispwidget->msg_queue_icon_size_x         = p_dispwidget->msg_queue_icon_size_y;
-#endif
-   }
-   else
-   {
-      p_dispwidget->msg_queue_icon_size_x         = p_dispwidget->simple_widget_padding * 1.5f;
-      p_dispwidget->msg_queue_icon_size_y         = 0;
-   }
-
-   p_dispwidget->msg_queue_spacing                = p_dispwidget->msg_queue_height / 3.3f;
-   p_dispwidget->msg_queue_rect_start_x           = p_dispwidget->msg_queue_spacing + p_dispwidget->msg_queue_icon_size_x;
-   p_dispwidget->msg_queue_internal_icon_size     = p_dispwidget->msg_queue_icon_size_y;
-   p_dispwidget->msg_queue_internal_icon_offset   = (p_dispwidget->msg_queue_icon_size_y - p_dispwidget->msg_queue_internal_icon_size) / 2;
-   p_dispwidget->msg_queue_icon_offset_y          = (p_dispwidget->msg_queue_icon_size_y - p_dispwidget->msg_queue_height) / 2;
-   p_dispwidget->msg_queue_scissor_start_x        = p_dispwidget->msg_queue_spacing + p_dispwidget->msg_queue_icon_size_x - (p_dispwidget->msg_queue_icon_size_x * 0.28928571428f);
-
-   if (p_dispwidget->flags & DISPGFX_WIDGET_FLAG_MSG_QUEUE_HAS_ICONS)
-      p_dispwidget->msg_queue_regular_padding_x   = p_dispwidget->simple_widget_padding / 2;
-   else
-      p_dispwidget->msg_queue_regular_padding_x   = p_dispwidget->simple_widget_padding;
-
-   p_dispwidget->msg_queue_task_rect_start_x      = p_dispwidget->msg_queue_rect_start_x - p_dispwidget->msg_queue_icon_size_x;
-
-   p_dispwidget->msg_queue_task_text_start_x      = p_dispwidget->msg_queue_task_rect_start_x + p_dispwidget->msg_queue_height / 2;
-
-   if (!p_dispwidget->gfx_widgets_icons_textures[MENU_WIDGETS_ICON_HOURGLASS])
-      p_dispwidget->msg_queue_task_text_start_x         -= 
-         p_dispwidget->gfx_widget_fonts.msg_queue.glyph_width * 2.0f;
-
-   p_dispwidget->msg_queue_regular_text_start            = p_dispwidget->msg_queue_rect_start_x;
-
-   p_dispwidget->msg_queue_task_hourglass_x              = p_dispwidget->msg_queue_rect_start_x - p_dispwidget->msg_queue_icon_size_x;
-
-   p_dispwidget->generic_message_height    = p_dispwidget->gfx_widget_fonts.regular.line_height * 2.0f;
-
-   p_dispwidget->msg_queue_default_rect_width_menu_alive = p_dispwidget
-      ->gfx_widget_fonts.msg_queue.glyph_width * 40.0f;
-   p_dispwidget->msg_queue_default_rect_width            = p_dispwidget->last_video_width 
-      - p_dispwidget->msg_queue_regular_text_start - (2 * p_dispwidget->simple_widget_padding);
-
-   p_dispwidget->divider_width_1px    = 1;
-   if (p_dispwidget->last_scale_factor > 1.0f)
-      p_dispwidget->divider_width_1px = (unsigned)(p_dispwidget->last_scale_factor + 0.5f);
-
-   for (i = 0; i < ARRAY_SIZE(widgets); i++)
-   {
-      const gfx_widget_t* widget = widgets[i];
-
-      if (widget->layout)
-         widget->layout(p_dispwidget,
-               is_threaded, dir_assets, font_path);
-   }
-}
-
-
-void gfx_widgets_iterate(
-      void *data_disp,
-      void *settings_data,
-      unsigned width, unsigned height, bool fullscreen,
-      const char *dir_assets, char *font_path,
-      bool is_threaded)
-{
-   size_t i;
-   dispgfx_widget_t *p_dispwidget   = &dispwidget_st;
-   /* c.f. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
-    * On some platforms (e.g. 32-bit x86 without SSE),
-    * gcc can produce inconsistent floating point results
-    * depending upon optimisation level. This can break
-    * floating point variable comparisons. A workaround is
-    * to declare the affected variable as 'volatile', which
-    * disables optimisations and removes excess precision
-    * (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323#c87) */
-   volatile float scale_factor      = 0.0f;
-   gfx_display_t *p_disp            = (gfx_display_t*)data_disp;
-   settings_t *settings             = (settings_t*)settings_data;
-#ifdef HAVE_XMB
-   enum menu_driver_id_type type    = p_disp->menu_driver_id;
-   if (type == MENU_DRIVER_ID_XMB)
-      scale_factor                  = gfx_display_get_widget_pixel_scale(p_disp, settings, width, height, fullscreen);
-   else
-#endif
-      scale_factor                  = gfx_display_get_dpi_scale(
-            p_disp,
-            settings, width, height, fullscreen, true);
-
-   /* Check whether screen dimensions or menu scale
-    * factor have changed */
-   if ((scale_factor != p_dispwidget->last_scale_factor) ||
-       (width        != p_dispwidget->last_video_width) ||
-       (height       != p_dispwidget->last_video_height))
-   {
-      p_dispwidget->last_scale_factor = scale_factor;
-      p_dispwidget->last_video_width  = width;
-      p_dispwidget->last_video_height = height;
-
-      /* Note: We don't need a full context reset here
-       * > Just rescale layout, and reset frame time counter */
-      gfx_widgets_layout(p_disp, p_dispwidget,
-            is_threaded, dir_assets, font_path);
-      video_driver_monitor_reset();
-   }
-
-   for (i = 0; i < ARRAY_SIZE(widgets); i++)
-   {
-      const gfx_widget_t* widget = widgets[i];
-
-      if (widget->iterate)
-         widget->iterate(p_dispwidget,
-               width, height, fullscreen,
-               dir_assets, font_path, is_threaded);
-   }
-
-   /* Messages queue */
-
-   /* Consume one message if available */
-   if ((FIFO_READ_AVAIL_NONPTR(p_dispwidget->msg_queue) > 0)
-         && !(p_dispwidget->flags & DISPGFX_WIDGET_FLAG_MOVING)
-         && (p_dispwidget->current_msgs_size < ARRAY_SIZE(p_dispwidget->current_msgs)))
-   {
-      disp_widget_msg_t *msg_widget = NULL;
-
-#ifdef HAVE_THREADS
-      slock_lock(p_dispwidget->current_msgs_lock);
-#endif
-
-      if (p_dispwidget->current_msgs_size < ARRAY_SIZE(p_dispwidget->current_msgs))
-      {
-         if (FIFO_READ_AVAIL_NONPTR(p_dispwidget->msg_queue) > 0)
-            fifo_read(&p_dispwidget->msg_queue,
-                  &msg_widget, sizeof(msg_widget));
-
-         if (msg_widget)
-         {
-            /* Task messages always appear from the bottom of the screen, append it */
-            if (p_dispwidget->msg_queue_tasks_count == 0 || msg_widget->task_ptr)
-               p_dispwidget->current_msgs[p_dispwidget->current_msgs_size] = msg_widget;
-            /* Regular messages are always above tasks, make room and insert it */
-            else
-            {
-               unsigned idx = (unsigned)(p_dispwidget->current_msgs_size -
-                  p_dispwidget->msg_queue_tasks_count);
-               for (i = p_dispwidget->current_msgs_size; i > idx; i--)
-                  p_dispwidget->current_msgs[i] = p_dispwidget->current_msgs[i - 1];
-               p_dispwidget->current_msgs[idx] = msg_widget;
-            }
-
-            p_dispwidget->current_msgs_size++;
-         }
-      }
-
-#ifdef HAVE_THREADS
-      slock_unlock(p_dispwidget->current_msgs_lock);
-#endif
-
-      if (msg_widget)
-      {
-         /* Start expiration timer if not associated to a task */
-         if (!msg_widget->task_ptr)
-         {
-            if (!(msg_widget->flags & DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED))
-               gfx_widgets_start_msg_expiration_timer(
-                  msg_widget, MSG_QUEUE_ANIMATION_DURATION * 2
-                  + msg_widget->duration);
-         }
-         /* Else, start hourglass animation timer */
-         else
-         {
-            p_dispwidget->msg_queue_tasks_count++;
-            gfx_widgets_hourglass_end(msg_widget);
-         }
-
-         if (p_dispwidget->current_msgs_size != 0)
-            gfx_widgets_msg_queue_move(p_dispwidget);
-      }
-   }
-
-   /* Kill first expired message */
-   /* Start expiration timer of dead tasks */
-   for (i = 0; i < p_dispwidget->current_msgs_size; i++)
-   {
-      disp_widget_msg_t *msg_widget = p_dispwidget->current_msgs[i];
-
-      if (!msg_widget)
-         continue;
-
-      if (msg_widget->task_ptr 
-            &&   ((msg_widget->flags & DISPWIDG_FLAG_TASK_FINISHED) 
-               || (msg_widget->flags & DISPWIDG_FLAG_TASK_CANCELLED)))
-         if (!(msg_widget->flags & DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED))
-            gfx_widgets_start_msg_expiration_timer(msg_widget, TASK_FINISHED_DURATION);
-
-      if (      (msg_widget->flags   & DISPWIDG_FLAG_EXPIRED)
-            && !(p_dispwidget->flags & DISPGFX_WIDGET_FLAG_MOVING))
-      {
-         gfx_widgets_msg_queue_kill(p_dispwidget,
-               (unsigned)i);
-         break;
-      }
-   }
-}
-
-static int gfx_widgets_draw_indicator(
-      dispgfx_widget_t *p_dispwidget,
-      gfx_display_t            *p_disp,
-      gfx_display_ctx_driver_t *dispctx,
-      void *userdata, 
-      unsigned video_width,
-      unsigned video_height,
-      uintptr_t icon, int y, int top_right_x_advance, 
-      enum msg_hash_enums msg)
-{
-   unsigned width;
-
-   gfx_display_set_alpha(p_dispwidget->backdrop_orig, DEFAULT_BACKDROP);
-
-   if (icon)
-   {
-      unsigned height = p_dispwidget->simple_widget_height * 2;
-      width           = height;
-
-      gfx_display_draw_quad(
-            p_disp,
-            userdata,
-            video_width, video_height,
-            top_right_x_advance - width, y,
-            width, height,
-            video_width, video_height,
-            p_dispwidget->backdrop_orig,
-            NULL
-      );
-
-      gfx_display_set_alpha(p_dispwidget->pure_white, 1.0f);
-
-      if (dispctx && dispctx->blend_begin)
-         dispctx->blend_begin(userdata);
-      gfx_widgets_draw_icon(
-            userdata,
-            p_disp,
-            video_width,
-            video_height,
-            width,
-            height,
-            icon,
-            top_right_x_advance - width, y,
-            0.0f, /* rad */
-            1.0f, /* cos(rad)   = cos(0)  = 1.0f */
-            0.0f, /* sine(rad)  = sine(0) = 0.0f */
-            p_dispwidget->pure_white
-            );
-      if (dispctx && dispctx->blend_end)
-         dispctx->blend_end(userdata);
-   }
-   else
-   {
-      unsigned height       = p_dispwidget->simple_widget_height;
-      const char *txt       = msg_hash_to_str(msg);
-
-      width = font_driver_get_message_width(
-            p_dispwidget->gfx_widget_fonts.regular.font,
-            txt,
-            strlen(txt), 1.0f) 
-         + p_dispwidget->simple_widget_padding * 2;
-
-      gfx_display_draw_quad(
-            p_disp,
-            userdata,
-            video_width, video_height,
-            top_right_x_advance - width, y,
-            width, height,
-            video_width, video_height,
-            p_dispwidget->backdrop_orig,
-            NULL
-      );
-
-      gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.regular,
-            txt,
-            top_right_x_advance - width 
-            + p_dispwidget->simple_widget_padding,
-            y + (height / 2.0f) + 
-            p_dispwidget->gfx_widget_fonts.regular.line_centre_offset,
-            video_width, video_height,
-            0xFFFFFFFF, TEXT_ALIGN_LEFT,
-            false);
-   }
-
-   return width;
-}
-
-static void gfx_widgets_draw_task_msg(
-      dispgfx_widget_t *p_dispwidget,
-      gfx_display_t            *p_disp,
-      gfx_display_ctx_driver_t *dispctx,
-      disp_widget_msg_t *msg,
-      void *userdata,
-      unsigned video_width,
-      unsigned video_height)
-{
-   /* Color of first progress bar in a task message */
-   static float msg_queue_task_progress_1[16]               = 
-      COLOR_HEX_TO_FLOAT(0x397869, 1.0f);
-   /* Color of second progress bar in a task message 
-    * (for multiple tasks with same message) */
-   static float msg_queue_task_progress_2[16]               = 
-      COLOR_HEX_TO_FLOAT(0x317198, 1.0f);
-   unsigned text_color;
-   unsigned bar_width;
-
-   unsigned rect_x;
-   unsigned rect_y;
-   unsigned rect_width;
-   unsigned rect_height;
-   float text_y_base;
-
-   float *msg_queue_current_background;
-   float *msg_queue_current_bar;
-
-   char task_percentage[256];
-   bool draw_msg_new                 = false;
-   unsigned task_percentage_offset   = 0;
-
-   if (msg->msg_new)
-      draw_msg_new                   = !string_is_equal(msg->msg_new, msg->msg);
-
-   task_percentage_offset            = 
-      p_dispwidget->gfx_widget_fonts.msg_queue.glyph_width 
-      * ((msg->flags & DISPWIDG_FLAG_TASK_ERROR) ? 12 : 5) 
-      + p_dispwidget->simple_widget_padding * 1.25f; /*11 = STRLEN_CONST("Task failed") + 1 */
-
-   if (msg->flags & DISPWIDG_FLAG_TASK_FINISHED)
-   {
-      if (msg->flags & DISPWIDG_FLAG_TASK_ERROR) /* TODO/FIXME - localize */
-         strlcpy(task_percentage, "Task failed", sizeof(task_percentage));
-      else
-      {
-         task_percentage[0] = ' ';
-         task_percentage[1] = '\0';
-      }
-   }
-   else if (msg->task_progress >= 0 && msg->task_progress <= 100)
-   {
-      task_percentage[0] = '\0';
-      snprintf(task_percentage, sizeof(task_percentage),
-            "%i%%", msg->task_progress);
-   }
-
-   rect_width = p_dispwidget->simple_widget_padding 
-      + msg->width 
-      + task_percentage_offset;
-   bar_width  = rect_width * msg->task_progress/100.0f;
-   text_color = COLOR_TEXT_ALPHA(0xFFFFFF00, (unsigned)(msg->alpha*255.0f));
-
-   /* Rect */
-   if (msg->flags & DISPWIDG_FLAG_TASK_FINISHED)
-      if (msg->task_count == 1)
-         msg_queue_current_background = msg_queue_task_progress_1;
-      else
-         msg_queue_current_background = msg_queue_task_progress_2;
-   else
-      if (msg->task_count == 1)
-         msg_queue_current_background = p_dispwidget->msg_queue_bg;
-      else
-         msg_queue_current_background = msg_queue_task_progress_1;
-
-   rect_x      = p_dispwidget->msg_queue_rect_start_x - p_dispwidget->msg_queue_icon_size_x;
-   rect_y      = video_height - msg->offset_y;
-   rect_height = p_dispwidget->msg_queue_height / 2;
-
-   gfx_display_set_alpha(msg_queue_current_background, msg->alpha);
-   gfx_display_draw_quad(
-         p_disp,
-         userdata,
-         video_width, video_height,
-         rect_x, rect_y,
-         rect_width, rect_height,
-         video_width, video_height,
-         msg_queue_current_background,
-         NULL
-         );
-
-   /* Progress bar */
-   if (    !(msg->flags & DISPWIDG_FLAG_TASK_FINISHED)
-         && (msg->task_progress >= 0) 
-         && (msg->task_progress <= 100))
-   {
-      if (msg->task_count == 1)
-         msg_queue_current_bar = msg_queue_task_progress_1;
-      else
-         msg_queue_current_bar = msg_queue_task_progress_2;
-
-      gfx_display_set_alpha(msg_queue_current_bar, 1.0f);
-      gfx_display_draw_quad(
-            p_disp,
-            userdata,
-            video_width, video_height,
-            p_dispwidget->msg_queue_task_rect_start_x, video_height - msg->offset_y,
-            bar_width, rect_height,
-            video_width, video_height,
-            msg_queue_current_bar,
-            NULL
-            );
-   }
-
-   /* Icon */
-   gfx_display_set_alpha(p_dispwidget->pure_white, msg->alpha);
-   if (dispctx && dispctx->blend_begin)
-      dispctx->blend_begin(userdata);
-   {
-      float radians = 0.0f; /* rad                        */
-      float cosine  = 1.0f; /* cos(rad)  = cos(0)  = 1.0f */
-      float sine    = 0.0f; /* sine(rad) = sine(0) = 0.0f */
-      if (!(msg->flags & DISPWIDG_FLAG_TASK_FINISHED))
-         radians    = msg->hourglass_rotation;
-      gfx_widgets_draw_icon(
-            userdata,
-            p_disp,
-            video_width,
-            video_height,
-            p_dispwidget->msg_queue_height / 2,
-            p_dispwidget->msg_queue_height / 2,
-            p_dispwidget->gfx_widgets_icons_textures[
-            (msg->flags & DISPWIDG_FLAG_TASK_FINISHED)
-            ? MENU_WIDGETS_ICON_CHECK 
-            : MENU_WIDGETS_ICON_HOURGLASS],
-            p_dispwidget->msg_queue_task_hourglass_x,
-            video_height - msg->offset_y,
-            radians,
-            cosine,
-            sine,
-            p_dispwidget->pure_white);
-   }
-   if (dispctx && dispctx->blend_end)
-      dispctx->blend_end(userdata);
-
-   /* Text */
-   text_y_base = video_height 
-      - msg->offset_y 
-      + p_dispwidget->msg_queue_height / 4.0f 
-      + p_dispwidget->gfx_widget_fonts.msg_queue.line_centre_offset;
-
-   if (draw_msg_new)
-   {
-      gfx_widgets_flush_text(video_width, video_height,
-            &p_dispwidget->gfx_widget_fonts.msg_queue);
-
-      gfx_display_scissor_begin(p_disp,
-            userdata,
-            video_width, video_height,
-            rect_x, rect_y, rect_width, rect_height);
-
-      gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.msg_queue,
-            msg->msg_new,
-            p_dispwidget->msg_queue_task_text_start_x,
-            text_y_base 
-            - p_dispwidget->msg_queue_height / 2.0f 
-            + msg->msg_transition_animation,
-            video_width, video_height,
-            text_color,
-            TEXT_ALIGN_LEFT,
-            true);
-   }
-
-   gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.msg_queue,
-         msg->msg,
-         p_dispwidget->msg_queue_task_text_start_x,
-         text_y_base + msg->msg_transition_animation,
-         video_width, video_height,
-         text_color,
-         TEXT_ALIGN_LEFT,
-         true);
-
-   if (draw_msg_new)
-   {
-      gfx_widgets_flush_text(video_width, video_height,
-            &p_dispwidget->gfx_widget_fonts.msg_queue);
-      if (dispctx && dispctx->scissor_end)
-         dispctx->scissor_end(userdata,
-               video_width, video_height);
-   }
-
-   /* Progress text */
-   text_color = COLOR_TEXT_ALPHA(0xFFFFFF00, (unsigned)(msg->alpha/2*255.0f));
-   gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.msg_queue,
-      task_percentage,
-      p_dispwidget->msg_queue_rect_start_x - p_dispwidget->msg_queue_icon_size_x + rect_width - 
-      p_dispwidget->gfx_widget_fonts.msg_queue.glyph_width,
-      text_y_base,
-      video_width, video_height,
-      text_color,
-      TEXT_ALIGN_RIGHT,
-      true);
-}
-
-static void gfx_widgets_draw_regular_msg(
-      dispgfx_widget_t *p_dispwidget,
-      gfx_display_t *p_disp,
-      gfx_display_ctx_driver_t *dispctx,
-      disp_widget_msg_t *msg,
-      void *userdata,
-      unsigned video_width,
-      unsigned video_height)
-{
-   static float msg_queue_info[16] = COLOR_HEX_TO_FLOAT(0x12ACF8, 1.0f);
-   static float msg_queue_bar[16]  = COLOR_HEX_TO_FLOAT(0xDDDDDD, 1.0f);
-   unsigned bar_width;
-   unsigned bar_margin;
-   unsigned text_color;
-   static float last_alpha = 0.0f;
-
-   msg->flags             &= ~DISPWIDG_FLAG_UNFOLDING;
-   msg->flags             |=  DISPWIDG_FLAG_UNFOLDED;
-
-   if (last_alpha != msg->alpha)
-   {
-      /* Icon */
-      gfx_display_set_alpha(msg_queue_info, msg->alpha);
-      gfx_display_set_alpha(p_dispwidget->pure_white, msg->alpha);
-      gfx_display_set_alpha(p_dispwidget->msg_queue_bg, msg->alpha);
-      last_alpha = msg->alpha;
-   }
-
-   if (    !(msg->flags & DISPWIDG_FLAG_UNFOLDED) 
-         || (msg->flags & DISPWIDG_FLAG_UNFOLDING))
-   {
-      gfx_widgets_flush_text(video_width, video_height,
-            &p_dispwidget->gfx_widget_fonts.regular);
-      gfx_widgets_flush_text(video_width, video_height,
-            &p_dispwidget->gfx_widget_fonts.bold);
-      gfx_widgets_flush_text(video_width, video_height,
-            &p_dispwidget->gfx_widget_fonts.msg_queue);
-
-     gfx_display_scissor_begin(p_disp,
-           userdata,
-           video_width, video_height,
-           p_dispwidget->msg_queue_scissor_start_x, 0,
-           (p_dispwidget->msg_queue_scissor_start_x + msg->width - 
-            p_dispwidget->simple_widget_padding * 2) 
-           * msg->unfold, video_height);
-   }
-
-   /* Background */
-   bar_width  = p_dispwidget->simple_widget_padding + msg->width + p_dispwidget->msg_queue_icon_size_x;
-   bar_margin = p_dispwidget->simple_widget_padding * 0.15f;
-
-   gfx_display_draw_quad(
-         p_disp,
-         userdata,
-         video_width,
-         video_height,
-         p_dispwidget->msg_queue_rect_start_x - p_dispwidget->msg_queue_icon_size_x,
-         video_height - msg->offset_y,
-         bar_width - bar_margin,
-         p_dispwidget->msg_queue_height,
-         video_width,
-         video_height,
-         p_dispwidget->msg_queue_bg,
-         NULL
-         );
-
-   gfx_display_draw_quad(
-         p_disp,
-         userdata,
-         video_width,
-         video_height,
-         p_dispwidget->msg_queue_rect_start_x - p_dispwidget->msg_queue_icon_size_x - bar_margin,
-         video_height - msg->offset_y,
-         bar_margin,
-         p_dispwidget->msg_queue_height,
-         video_width,
-         video_height,
-         msg_queue_bar,
-         NULL
-         );
-
-   /* Text */
-   text_color = COLOR_TEXT_ALPHA(0xFFFFFF00, (unsigned)(msg->alpha*255.0f));
-
-   gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.msg_queue,
-      msg->msg,
-      p_dispwidget->msg_queue_regular_text_start,
-      video_height - msg->offset_y + (p_dispwidget->msg_queue_height - msg->text_height)/2.0f + p_dispwidget->gfx_widget_fonts.msg_queue.line_ascender,
-      video_width, video_height,
-      text_color,
-      TEXT_ALIGN_LEFT,
-      true);
-
-   if (    !(msg->flags & DISPWIDG_FLAG_UNFOLDED) 
-         || (msg->flags & DISPWIDG_FLAG_UNFOLDING))
-   {
-      gfx_widgets_flush_text(video_width, video_height, &p_dispwidget->gfx_widget_fonts.regular);
-      gfx_widgets_flush_text(video_width, video_height, &p_dispwidget->gfx_widget_fonts.bold);
-      gfx_widgets_flush_text(video_width, video_height, &p_dispwidget->gfx_widget_fonts.msg_queue);
-
-      if (dispctx && dispctx->scissor_end)
-         dispctx->scissor_end(userdata,
-               video_width, video_height);
-   }
-
-   if (p_dispwidget->flags & DISPGFX_WIDGET_FLAG_MSG_QUEUE_HAS_ICONS)
-   {
-      if (dispctx && dispctx->blend_begin)
-         dispctx->blend_begin(userdata);
-
-      gfx_widgets_draw_icon(
-            userdata,
-            p_disp,
-            video_width,
-            video_height,
-            p_dispwidget->msg_queue_icon_size_x,
-            p_dispwidget->msg_queue_icon_size_y,
-            p_dispwidget->gfx_widgets_icons_textures[MENU_WIDGETS_ICON_INFO],
-            p_dispwidget->msg_queue_spacing,
-            video_height - msg->offset_y  - p_dispwidget->msg_queue_icon_offset_y,
-            0.0f, /* rad                         */
-            1.0f, /* cos(rad)   = cos(0)  = 1.0f */
-            0.0f, /* sine(rad)  = sine(0) = 0.0f */
-            msg_queue_info);
-
-      if (dispctx && dispctx->blend_end)
-         dispctx->blend_end(userdata);
-   }
-}
-
-static void INLINE gfx_widgets_font_bind(gfx_widget_font_data_t *font_data)
-{
-   font_driver_bind_block(font_data->font, &font_data->raster_block);
-   font_data->raster_block.carr.coords.vertices = 0;
-   font_data->usage_count                       = 0;
-}
-
-static void INLINE gfx_widgets_font_unbind(gfx_widget_font_data_t *font_data)
-{
-   font_driver_bind_block(font_data->font, NULL);
-}
-
-void gfx_widgets_frame(void *data)
-{
-   size_t i;
-   video_frame_info_t *video_info   = (video_frame_info_t*)data;
-   gfx_display_t            *p_disp = (gfx_display_t*)video_info->disp_userdata;
-   gfx_display_ctx_driver_t *dispctx= p_disp->dispctx;
-   dispgfx_widget_t *p_dispwidget   = (dispgfx_widget_t*)video_info->widgets_userdata;
-   bool fps_show                    = video_info->fps_show;
-   bool framecount_show             = video_info->framecount_show;
-   bool memory_show                 = video_info->memory_show;
-   bool core_status_msg_show        = video_info->core_status_msg_show;
-   void *userdata                   = video_info->userdata;
-   unsigned video_width             = video_info->width;
-   unsigned video_height            = video_info->height;
-   bool widgets_is_paused           = video_info->widgets_is_paused;
-   bool widgets_is_fastforwarding   = video_info->widgets_is_fast_forwarding;
-   bool widgets_is_rewinding        = video_info->widgets_is_rewinding;
-   bool runloop_is_slowmotion       = video_info->runloop_is_slowmotion;
-   bool menu_screensaver_active     = video_info->menu_screensaver_active;
-   bool notifications_hidden        = video_info->notifications_hidden ||
-         video_info->msg_queue_delay;
-   int top_right_x_advance          = video_width;
-
-   p_dispwidget->gfx_widgets_frame_count++;
-
-   /* If menu screensaver is active or notifications are hidden, draw nothing */
-   if (menu_screensaver_active || notifications_hidden)
-      return;
-
-   video_driver_set_viewport(video_width, video_height, true, false);
-
-   /* Font setup */
-   gfx_widgets_font_bind(&p_dispwidget->gfx_widget_fonts.regular);
-   gfx_widgets_font_bind(&p_dispwidget->gfx_widget_fonts.bold);
-   gfx_widgets_font_bind(&p_dispwidget->gfx_widget_fonts.msg_queue);
-
-#ifdef HAVE_TRANSLATE
-   /* AI Service overlay */
-   if (p_dispwidget->ai_service_overlay_state > 0)
-   {
-      float outline_color[16] = {
-      0.00, 1.00, 0.00, 1.00,
-      0.00, 1.00, 0.00, 1.00,
-      0.00, 1.00, 0.00, 1.00,
-      0.00, 1.00, 0.00, 1.00,
-      };
-      gfx_display_set_alpha(p_dispwidget->pure_white, 1.0f);
-
-      if (p_dispwidget->ai_service_overlay_texture)
-      {
-         if (dispctx->blend_begin)
-            dispctx->blend_begin(userdata);
-         gfx_widgets_draw_icon(
-               userdata,
-               p_disp,
-               video_width,
-               video_height,
-               video_width,
-               video_height,
-               p_dispwidget->ai_service_overlay_texture,
-               0,
-               0,
-               0.0f, /* rad                         */
-               1.0f, /* cos(rad)   = cos(0)  = 1.0f */
-               0.0f, /* sine(rad)  = sine(0) = 0.0f */
-               p_dispwidget->pure_white
-               );
-         if (dispctx->blend_end)
-            dispctx->blend_end(userdata);
-      }
-
-      /* top line */
-      gfx_display_draw_quad(
-            p_disp,
-            userdata,
-            video_width, video_height,
-            0, 0,
-            video_width,
-            p_dispwidget->divider_width_1px,
-            video_width,
-            video_height,
-            outline_color,
-            NULL
-            );
-      /* bottom line */
-      gfx_display_draw_quad(
-            p_disp,
-            userdata,
-            video_width, video_height,
-            0,
-            video_height - p_dispwidget->divider_width_1px,
-            video_width,
-            p_dispwidget->divider_width_1px,
-            video_width,
-            video_height,
-            outline_color,
-            NULL
-            );
-      /* left line */
-      gfx_display_draw_quad(
-            p_disp,
-            userdata,
-            video_width,
-            video_height,
-            0,
-            0,
-            p_dispwidget->divider_width_1px,
-            video_height,
-            video_width,
-            video_height,
-            outline_color,
-            NULL
-            );
-      /* right line */
-      gfx_display_draw_quad(
-            p_disp,
-            userdata,
-            video_width, video_height,
-            video_width - p_dispwidget->divider_width_1px,
-            0,
-            p_dispwidget->divider_width_1px,
-            video_height,
-            video_width,
-            video_height,
-            outline_color,
-            NULL
-            );
-
-      if (p_dispwidget->ai_service_overlay_state == 2)
-          p_dispwidget->ai_service_overlay_state = 3;
-   }
-#endif
-
-   /* Status Text (fps, framecount, memory, core status message) */
-   if (     fps_show
-         || framecount_show
-         || memory_show
-         || core_status_msg_show
-         )
-   {
-      const char *text      = *p_dispwidget->gfx_widgets_status_text == '\0'
-         ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE)
-         : p_dispwidget->gfx_widgets_status_text;
-
-      int text_width        = font_driver_get_message_width(
-            p_dispwidget->gfx_widget_fonts.regular.font,
-            text,
-            strlen(text), 1.0f);
-      int total_width       = text_width
-         + p_dispwidget->simple_widget_padding * 2;
-
-      int status_text_x     = top_right_x_advance
-         - p_dispwidget->simple_widget_padding - text_width;
-      /* Ensure that left hand side of text does
-       * not bleed off the edge of the screen */
-      if (status_text_x < 0)
-         status_text_x      = 0;
-
-      gfx_display_set_alpha(p_dispwidget->backdrop_orig, DEFAULT_BACKDROP);
-
-      gfx_display_draw_quad(
-            p_disp,
-            userdata,
-            video_width,
-            video_height,
-            top_right_x_advance - total_width, 0,
-            total_width,
-            p_dispwidget->simple_widget_height,
-            video_width,
-            video_height,
-            p_dispwidget->backdrop_orig,
-            NULL
-            );
-
-      gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.regular,
-            text,
-            status_text_x,
-            p_dispwidget->simple_widget_height / 2.0f
-            + p_dispwidget->gfx_widget_fonts.regular.line_centre_offset,
-            video_width, video_height,
-            0xFFFFFFFF,
-            TEXT_ALIGN_LEFT,
-            true);
-   }
-
-   /* Indicators */
-   if (widgets_is_paused)
-      top_right_x_advance -= gfx_widgets_draw_indicator(
-            p_dispwidget,
-            p_disp,
-            dispctx,
-            userdata,
-            video_width,
-            video_height,
-            p_dispwidget->gfx_widgets_icons_textures[
-            MENU_WIDGETS_ICON_PAUSED],
-            (fps_show 
-             ? p_dispwidget->simple_widget_height 
-             : 0),
-            top_right_x_advance,
-            MSG_PAUSED);
-
-   if (widgets_is_fastforwarding)
-      top_right_x_advance -= gfx_widgets_draw_indicator(
-            p_dispwidget,
-            p_disp,
-            dispctx,
-            userdata,
-            video_width,
-            video_height,
-            p_dispwidget->gfx_widgets_icons_textures[
-            MENU_WIDGETS_ICON_FAST_FORWARD],
-            (fps_show ? p_dispwidget->simple_widget_height : 0),
-            top_right_x_advance,
-            MSG_FAST_FORWARD);
-
-   if (widgets_is_rewinding)
-      top_right_x_advance -= gfx_widgets_draw_indicator(
-            p_dispwidget,
-            p_disp,
-            dispctx,
-            userdata,
-            video_width,
-            video_height,
-            p_dispwidget->gfx_widgets_icons_textures[
-            MENU_WIDGETS_ICON_REWIND],
-            (fps_show ? p_dispwidget->simple_widget_height : 0),
-            top_right_x_advance,
-            MSG_REWINDING);
-
-   if (runloop_is_slowmotion)
-   {
-      top_right_x_advance -= gfx_widgets_draw_indicator(
-            p_dispwidget,
-            p_disp,
-            dispctx,
-            userdata,
-            video_width,
-            video_height,
-            p_dispwidget->gfx_widgets_icons_textures[
-            MENU_WIDGETS_ICON_SLOW_MOTION],
-            (fps_show ? p_dispwidget->simple_widget_height : 0),
-            top_right_x_advance,
-            MSG_SLOW_MOTION);
-      (void)top_right_x_advance;
-   }
-
-   for (i = 0; i < ARRAY_SIZE(widgets); i++)
-   {
-      const gfx_widget_t* widget = widgets[i];
-
-      if (widget->frame)
-         widget->frame(data, p_dispwidget);
-   }
-
-   /* Draw all messages */
-   if (p_dispwidget->current_msgs_size)
-   {
-#ifdef HAVE_THREADS
-      slock_lock(p_dispwidget->current_msgs_lock);
-#endif
-
-      for (i = 0; i < p_dispwidget->current_msgs_size; i++)
-      {
-         disp_widget_msg_t* msg = p_dispwidget->current_msgs[i];
-
-         if (!msg)
-            continue;
-
-         if (msg->task_ptr)
-            gfx_widgets_draw_task_msg(
-               p_dispwidget,
-               p_disp,
-               dispctx,
-               msg, userdata,
-               video_width, video_height);
-         else
-            gfx_widgets_draw_regular_msg(
-               p_dispwidget,
-               p_disp,
-               dispctx,
-               msg, userdata,
-               video_width, video_height);
-      }
-
-#ifdef HAVE_THREADS
-      slock_unlock(p_dispwidget->current_msgs_lock);
-#endif
-   }
-
-   /* Ensure all text is flushed */
-   gfx_widgets_flush_text(video_width, video_height,
-         &p_dispwidget->gfx_widget_fonts.regular);
-   gfx_widgets_flush_text(video_width, video_height,
-         &p_dispwidget->gfx_widget_fonts.bold);
-   gfx_widgets_flush_text(video_width, video_height,
-         &p_dispwidget->gfx_widget_fonts.msg_queue);
-
-   /* Unbind fonts */
-   gfx_widgets_font_unbind(&p_dispwidget->gfx_widget_fonts.regular);
-   gfx_widgets_font_unbind(&p_dispwidget->gfx_widget_fonts.bold);
-   gfx_widgets_font_unbind(&p_dispwidget->gfx_widget_fonts.msg_queue);
-
-   video_driver_set_viewport(video_width, video_height, false, true);
-}
-
-static void gfx_widgets_free(dispgfx_widget_t *p_dispwidget)
-{
-   size_t i;
-
-   p_dispwidget->flags     &= ~DISPGFX_WIDGET_FLAG_INITED;
-
-   for (i = 0; i < ARRAY_SIZE(widgets); i++)
-   {
-      const gfx_widget_t* widget = widgets[i];
-
-      if (widget->free)
-         widget->free();
-   }
-
-   /* Kill all running animations */
-   gfx_animation_kill_by_tag(
-         &p_dispwidget->gfx_widgets_generic_tag);
-
-   /* Purge everything from the fifo */
-   while (FIFO_READ_AVAIL_NONPTR(p_dispwidget->msg_queue) > 0)
-   {
-      disp_widget_msg_t *msg_widget;
-
-      fifo_read(&p_dispwidget->msg_queue,
-            &msg_widget, sizeof(msg_widget));
-
-      /* Note: gfx_widgets_free() is only called when
-       * main_exit() is invoked. At this stage, we cannot
-       * guarantee that any task pointers are valid (the
-       * task may have been free()'d, but we can't know
-       * that here) - so all we can do is unset the task
-       * pointer associated with each message
-       * > If we don't do this, gfx_widgets_msg_queue_free()
-       *   will generate heap-use-after-free errors */
-      msg_widget->task_ptr = NULL;
-
-      gfx_widgets_msg_queue_free(p_dispwidget, msg_widget);
-      free(msg_widget);
-   }
-
-   fifo_deinitialize(&p_dispwidget->msg_queue);
-
-   /* Purge everything from the list */
-#ifdef HAVE_THREADS
-   slock_lock(p_dispwidget->current_msgs_lock);
-#endif
-
-   p_dispwidget->current_msgs_size = 0;
-   for (i = 0; i < ARRAY_SIZE(p_dispwidget->current_msgs); i++)
-   {
-      disp_widget_msg_t *msg = p_dispwidget->current_msgs[i];
-      if (!msg)
-         continue;
-
-      /* Note: gfx_widgets_free() is only called when
-         * main_exit() is invoked. At this stage, we cannot
-         * guarantee that any task pointers are valid (the
-         * task may have been free()'d, but we can't know
-         * that here) - so all we can do is unset the task
-         * pointer associated with each message
-         * > If we don't do this, gfx_widgets_msg_queue_free()
-         *   will generate heap-use-after-free errors */
-      msg->task_ptr = NULL;
-
-      gfx_widgets_msg_queue_free(p_dispwidget, msg);
-   }
-#ifdef HAVE_THREADS
-   slock_unlock(p_dispwidget->current_msgs_lock);
-
-   slock_free(p_dispwidget->current_msgs_lock);
-   p_dispwidget->current_msgs_lock = NULL;
-#endif
-
-   p_dispwidget->msg_queue_tasks_count = 0;
-
-   /* Font */
-   video_coord_array_free(
-         &p_dispwidget->gfx_widget_fonts.regular.raster_block.carr);
-   video_coord_array_free(
-         &p_dispwidget->gfx_widget_fonts.bold.raster_block.carr);
-   video_coord_array_free(
-         &p_dispwidget->gfx_widget_fonts.msg_queue.raster_block.carr);
-
-   font_driver_bind_block(NULL, NULL);
-}
-
-static void gfx_widgets_context_reset(
-      dispgfx_widget_t *p_dispwidget,
-      gfx_display_t *p_disp,
-      settings_t *settings,
-      bool is_threaded,
-      unsigned width, unsigned height, bool fullscreen,
-      const char *dir_assets, char *font_path)
-{
-   size_t i;
-
-   /* Load textures */
-   /* Icons */
-   for (i = 0; i < MENU_WIDGETS_ICON_LAST; i++)
-   {
-      gfx_display_reset_textures_list(
-            gfx_widgets_icons_names[i],
-            p_dispwidget->monochrome_png_path,
-            &p_dispwidget->gfx_widgets_icons_textures[i],
-            TEXTURE_FILTER_MIPMAP_LINEAR,
-            NULL,
-            NULL);
-   }
-
-   /* Message queue */
-   gfx_display_reset_textures_list(
-         "msg_queue_icon.png",
-         p_dispwidget->gfx_widgets_path,
-         &p_dispwidget->msg_queue_icon,
-         TEXTURE_FILTER_LINEAR,
-         NULL,
-         NULL);
-   gfx_display_reset_textures_list(
-         "msg_queue_icon_outline.png",
-         p_dispwidget->gfx_widgets_path,
-         &p_dispwidget->msg_queue_icon_outline,
-         TEXTURE_FILTER_LINEAR,
-         NULL,
-         NULL);
-   gfx_display_reset_textures_list(
-         "msg_queue_icon_rect.png",
-         p_dispwidget->gfx_widgets_path,
-         &p_dispwidget->msg_queue_icon_rect,
-         TEXTURE_FILTER_NEAREST,
-         NULL,
-         NULL);
-
-   if (  p_dispwidget->msg_queue_icon         
-      && p_dispwidget->msg_queue_icon_outline
-      && p_dispwidget->msg_queue_icon_rect)
-      p_dispwidget->flags |=  DISPGFX_WIDGET_FLAG_MSG_QUEUE_HAS_ICONS;
-   else
-      p_dispwidget->flags &= ~DISPGFX_WIDGET_FLAG_MSG_QUEUE_HAS_ICONS;
-
-   for (i = 0; i < ARRAY_SIZE(widgets); i++)
-   {
-      const gfx_widget_t* widget = widgets[i];
-
-      if (widget->context_reset)
-         widget->context_reset(is_threaded, width, height,
-               fullscreen, dir_assets, font_path,
-               p_dispwidget->monochrome_png_path,
-               p_dispwidget->gfx_widgets_path);
-   }
-
-   /* Update scaling/dimensions */
-   p_dispwidget->last_video_width     = width;
-   p_dispwidget->last_video_height    = height;
-#ifdef HAVE_XMB
-   if (p_disp->menu_driver_id == MENU_DRIVER_ID_XMB)
-      p_dispwidget->last_scale_factor = gfx_display_get_widget_pixel_scale(
-            p_disp, settings,
-            p_dispwidget->last_video_width,
-            p_dispwidget->last_video_height, fullscreen);
-   else
-#endif
-      p_dispwidget->last_scale_factor = gfx_display_get_dpi_scale(
-                     p_disp, settings,
-                     p_dispwidget->last_video_width,
-                     p_dispwidget->last_video_height,
-                     fullscreen, true);
-
-   gfx_widgets_layout(p_disp, p_dispwidget,
-         is_threaded, dir_assets, font_path);
-   video_driver_monitor_reset();
-}
-
-bool gfx_widgets_init(
-      void *data_disp,
-      void *data_anim,
-      void *settings_data,
-      uintptr_t widgets_active_ptr,
-      bool video_is_threaded,
-      unsigned width, unsigned height, bool fullscreen,
-      const char *dir_assets, char *font_path)
-{
-   size_t i;
-   unsigned color                              = 0x1A1A1A;
-   dispgfx_widget_t *p_dispwidget              = &dispwidget_st;
-   gfx_display_t *p_disp                       = (gfx_display_t*)data_disp;
-   gfx_animation_t *p_anim                     = (gfx_animation_t*)data_anim;
-   settings_t *settings                        = (settings_t*)settings_data;
-   p_dispwidget->divider_width_1px             = 1;
-   p_dispwidget->gfx_widgets_generic_tag       = (uintptr_t)widgets_active_ptr;
-
-   if (!gfx_display_init_first_driver(p_disp, video_is_threaded))
-      goto error;
-   gfx_display_set_alpha(p_dispwidget->backdrop_orig, 0.75f);
-   for (i = 0; i < 16; i++)
-      p_dispwidget->pure_white[i] = 1.00f;
-
-   p_dispwidget->msg_queue_bg[0]  = HEX_R(color);
-   p_dispwidget->msg_queue_bg[1]  = HEX_G(color);
-   p_dispwidget->msg_queue_bg[2]  = HEX_B(color);
-   p_dispwidget->msg_queue_bg[3]  = 1.0f;
-   p_dispwidget->msg_queue_bg[4]  = HEX_R(color);
-   p_dispwidget->msg_queue_bg[5]  = HEX_G(color);
-   p_dispwidget->msg_queue_bg[6]  = HEX_B(color);
-   p_dispwidget->msg_queue_bg[7]  = 1.0f;
-   p_dispwidget->msg_queue_bg[8]  = HEX_R(color);
-   p_dispwidget->msg_queue_bg[9]  = HEX_G(color);
-   p_dispwidget->msg_queue_bg[10] = HEX_B(color);
-   p_dispwidget->msg_queue_bg[11] = 1.0f;
-   p_dispwidget->msg_queue_bg[12] = HEX_R(color);
-   p_dispwidget->msg_queue_bg[13] = HEX_G(color);
-   p_dispwidget->msg_queue_bg[14] = HEX_B(color);
-   p_dispwidget->msg_queue_bg[15] = 1.0f;
-
-   if (!(p_dispwidget->flags & DISPGFX_WIDGET_FLAG_INITED))
-   {
-      char theme_path[PATH_MAX_LENGTH];
-      p_dispwidget->gfx_widgets_frame_count = 0;
-
-      for (i = 0; i < ARRAY_SIZE(widgets); i++)
-      {
-         const gfx_widget_t* widget = widgets[i];
-
-         if (widget->init)
-            widget->init(p_disp, p_anim, video_is_threaded, fullscreen);
-      }
-
-      if (!fifo_initialize(&p_dispwidget->msg_queue,
-            MSG_QUEUE_PENDING_MAX * sizeof(disp_widget_msg_t*)))
-         goto error;
-
-      memset(&p_dispwidget->current_msgs[0], 0, sizeof(p_dispwidget->current_msgs));
-      p_dispwidget->current_msgs_size = 0;
-
-#ifdef HAVE_THREADS
-      p_dispwidget->current_msgs_lock = slock_new();
-#endif
-
-      fill_pathname_join_special(
-            p_dispwidget->gfx_widgets_path,
-            dir_assets,
-            "menu_widgets",
-            sizeof(p_dispwidget->gfx_widgets_path)
-            );
-      fill_pathname_join_special(
-            p_dispwidget->xmb_path,
-            dir_assets,
-            "xmb",
-            sizeof(p_dispwidget->xmb_path)
-            );
-      /* Base path */
-      fill_pathname_join_special(p_dispwidget->ozone_path,
-            dir_assets,
-            "ozone",
-            sizeof(p_dispwidget->ozone_path));
-      fill_pathname_join_special(p_dispwidget->ozone_regular_font_path,
-            p_dispwidget->ozone_path, "regular.ttf",
-            sizeof(p_dispwidget->ozone_regular_font_path));
-      fill_pathname_join_special(p_dispwidget->ozone_bold_font_path,
-            p_dispwidget->ozone_path, "bold.ttf",
-            sizeof(p_dispwidget->ozone_bold_font_path));
-      fill_pathname_join_special(
-            theme_path,
-            p_dispwidget->xmb_path,
-            "monochrome",
-            sizeof(theme_path)
-            );
-      fill_pathname_join_special(
-            p_dispwidget->monochrome_png_path,
-            theme_path,
-            "png",
-            sizeof(p_dispwidget->monochrome_png_path)
-            );
-      fill_pathname_join_special(p_dispwidget->assets_pkg_dir,
-            settings->paths.directory_assets, "pkg",
-            sizeof(p_dispwidget->assets_pkg_dir));
-
-      p_dispwidget->flags |= DISPGFX_WIDGET_FLAG_INITED;
-   }
-
-   gfx_widgets_context_reset(
-         p_dispwidget,
-         p_disp,
-         settings,
-         video_is_threaded,
-         width, height, fullscreen,
-         dir_assets, font_path);
-
-   return true;
-
-error:
-   gfx_widgets_free(p_dispwidget);
-   return false;
-}
-
-static void gfx_widgets_context_destroy(dispgfx_widget_t *p_dispwidget)
-{
-   size_t i;
-
-   for (i = 0; i < ARRAY_SIZE(widgets); i++)
-   {
-      const gfx_widget_t* widget = widgets[i];
-
-      if (widget->context_destroy)
-         widget->context_destroy();
-   }
-
-   /* TODO: Dismiss onscreen notifications that have been freed */
-
-   /* Textures */
-   for (i = 0; i < MENU_WIDGETS_ICON_LAST; i++)
-      video_driver_texture_unload(&p_dispwidget->gfx_widgets_icons_textures[i]);
-
-   video_driver_texture_unload(&p_dispwidget->msg_queue_icon);
-   video_driver_texture_unload(&p_dispwidget->msg_queue_icon_outline);
-   video_driver_texture_unload(&p_dispwidget->msg_queue_icon_rect);
-
-   p_dispwidget->msg_queue_icon         = 0;
-   p_dispwidget->msg_queue_icon_outline = 0;
-   p_dispwidget->msg_queue_icon_rect    = 0;
-
-   /* Fonts */
-   gfx_widgets_font_free(&p_dispwidget->gfx_widget_fonts.regular);
-   gfx_widgets_font_free(&p_dispwidget->gfx_widget_fonts.bold);
-   gfx_widgets_font_free(&p_dispwidget->gfx_widget_fonts.msg_queue);
-}
-
-
-void gfx_widgets_deinit(bool widgets_persisting)
-{
-   dispgfx_widget_t *p_dispwidget = &dispwidget_st;
-
-   gfx_widgets_context_destroy(p_dispwidget);
-
-   if (!widgets_persisting)
-      gfx_widgets_free(p_dispwidget);
-}
-
-#ifdef HAVE_TRANSLATE
-bool gfx_widgets_ai_service_overlay_load(
-      char* buffer, unsigned buffer_len,
-      enum image_type_enum image_type)
-{
-   dispgfx_widget_t *p_dispwidget   = &dispwidget_st;
-   if (p_dispwidget->ai_service_overlay_state == 0)
-   {
-      if (!gfx_display_reset_textures_list_buffer(
-               &p_dispwidget->ai_service_overlay_texture, 
-               TEXTURE_FILTER_MIPMAP_LINEAR, 
-               (void *) buffer, buffer_len, image_type,
-               &p_dispwidget->ai_service_overlay_width,
-               &p_dispwidget->ai_service_overlay_height))
-         return false;
-      p_dispwidget->ai_service_overlay_state = 1;
-   }
-   return true;
-}
-
-void gfx_widgets_ai_service_overlay_unload(void)
-{
-   dispgfx_widget_t *p_dispwidget   = &dispwidget_st;
-   if (p_dispwidget->ai_service_overlay_state == 1)
-   {
-      video_driver_texture_unload(&p_dispwidget->ai_service_overlay_texture);
-      p_dispwidget->ai_service_overlay_texture = 0;
-      p_dispwidget->ai_service_overlay_state   = 0;
-   }
-}
-#endif
-
-dispgfx_widget_t *dispwidget_get_ptr(void)
-{
-   return &dispwidget_st;
-}
-
-bool gfx_widgets_ready(void)
-{
-#ifdef HAVE_GFX_WIDGETS
-   return dispwidget_st.active;
-#else
-   return false;
-#endif
-}

+ 0 - 424
app/src/main/cpp/gfx/gfx_widgets.h

@@ -1,424 +0,0 @@
-/*  RetroArch - A frontend for libretro.
- *  Copyright (C) 2018      - natinusala
- *
- *  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/>.
- */
-
-#ifndef _GFX_WIDGETS_H
-#define _GFX_WIDGETS_H
-
-#ifdef HAVE_CONFIG_H
-#include "../config.h"
-#endif
-
-#include <retro_common_api.h>
-#include <formats/image.h>
-#include <queues/task_queue.h>
-#include <queues/message_queue.h>
-#include <queues/fifo_queue.h>
-
-#ifdef HAVE_THREADS
-#include <rthreads/rthreads.h>
-#endif
-
-#include "gfx_animation.h"
-#include "gfx_display.h"
-
-#define DEFAULT_BACKDROP               0.75f
-
-#define MSG_QUEUE_PENDING_MAX          32
-#define MSG_QUEUE_ONSCREEN_MAX         4
-
-#define MSG_QUEUE_ANIMATION_DURATION      330
-#define TASK_FINISHED_DURATION            3000
-#define HOURGLASS_INTERVAL                5000
-#define HOURGLASS_DURATION                1000
-
-/* TODO: Colors for warning, error and success */
-
-#define TEXT_COLOR_INFO 0xD8EEFFFF
-#if 0
-#define TEXT_COLOR_SUCCESS 0x22B14CFF
-#define TEXT_COLOR_ERROR 0xC23B22FF
-#endif
-#define TEXT_COLOR_FAINT 0x878787FF
-
-RETRO_BEGIN_DECLS
-
-enum gfx_widgets_icon
-{
-   MENU_WIDGETS_ICON_PAUSED = 0,
-   MENU_WIDGETS_ICON_FAST_FORWARD,
-   MENU_WIDGETS_ICON_REWIND,
-   MENU_WIDGETS_ICON_SLOW_MOTION,
-
-   MENU_WIDGETS_ICON_HOURGLASS,
-   MENU_WIDGETS_ICON_CHECK,
-
-   MENU_WIDGETS_ICON_INFO,
-
-   MENU_WIDGETS_ICON_ACHIEVEMENT,
-
-   MENU_WIDGETS_ICON_LAST
-};
-
-enum notification_show_screenshot_duration
-{
-   NOTIFICATION_SHOW_SCREENSHOT_DURATION_NORMAL = 0,
-   NOTIFICATION_SHOW_SCREENSHOT_DURATION_FAST,
-   NOTIFICATION_SHOW_SCREENSHOT_DURATION_VERY_FAST,
-   NOTIFICATION_SHOW_SCREENSHOT_DURATION_INSTANT,
-   NOTIFICATION_SHOW_SCREENSHOT_DURATION_LAST
-};
-
-enum notification_show_screenshot_flash
-{
-   NOTIFICATION_SHOW_SCREENSHOT_FLASH_NORMAL = 0,
-   NOTIFICATION_SHOW_SCREENSHOT_FLASH_FAST,
-   NOTIFICATION_SHOW_SCREENSHOT_FLASH_OFF,
-   NOTIFICATION_SHOW_SCREENSHOT_FLASH_LAST
-};
-
-enum cheevos_appearance_anchor
-{
-   CHEEVOS_APPEARANCE_ANCHOR_TOPLEFT = 0,
-   CHEEVOS_APPEARANCE_ANCHOR_TOPCENTER,
-   CHEEVOS_APPEARANCE_ANCHOR_TOPRIGHT,
-   CHEEVOS_APPEARANCE_ANCHOR_BOTTOMLEFT,
-   CHEEVOS_APPEARANCE_ANCHOR_BOTTOMCENTER,
-   CHEEVOS_APPEARANCE_ANCHOR_BOTTOMRIGHT,
-   CHEEVOS_APPEARANCE_ANCHOR_LAST
-};
-
-/* This structure holds all objects + metadata
- * corresponding to a particular font */
-typedef struct
-{
-   font_data_t *font;
-   video_font_raster_block_t raster_block; /* ptr alignment */
-   size_t usage_count;
-   unsigned glyph_width;
-   float line_height;
-   float line_ascender;
-   float line_descender;
-   float line_centre_offset;
-} gfx_widget_font_data_t;
-
-/* Font data */
-typedef struct
-{
-   gfx_widget_font_data_t regular;
-   gfx_widget_font_data_t bold;
-   gfx_widget_font_data_t msg_queue;
-} gfx_widget_fonts_t;
-
-enum disp_widget_flags_enum
-{
-   DISPWIDG_FLAG_TASK_FINISHED             = (1 << 0),
-   DISPWIDG_FLAG_TASK_ERROR                = (1 << 1),
-   DISPWIDG_FLAG_TASK_CANCELLED            = (1 << 2),
-   DISPWIDG_FLAG_EXPIRATION_TIMER_STARTED  = (1 << 3),
-   /* Is it currently doing the fade out animation ? */
-   DISPWIDG_FLAG_DYING                     = (1 << 4),
-   /* Has the timer expired ? if so, should be set to dying */
-   DISPWIDG_FLAG_EXPIRED                   = (1 << 5),
-   /* Unfold animation */
-   DISPWIDG_FLAG_UNFOLDED                  = (1 << 6),
-   DISPWIDG_FLAG_UNFOLDING                 = (1 << 7)
-};
-
-typedef struct disp_widget_msg
-{
-   char *msg;
-   char *msg_new;
-   retro_task_t *task_ptr;
-
-   uint32_t task_ident;
-   size_t   msg_len;
-   unsigned duration;
-   unsigned text_height;
-   unsigned width;
-
-   float msg_transition_animation;
-   float offset_y;
-   float alpha;
-   float unfold;
-   float hourglass_rotation;
-   float hourglass_timer; /* float alignment */
-   float expiration_timer; /* float alignment */
-
-   uint16_t flags;
-   int8_t task_progress;
-   /* How many tasks have used this notification? */
-   uint8_t task_count;
-} disp_widget_msg_t;
-
-/* There can only be one message animation at a time to 
- * avoid confusing users */
-enum dispgfx_widget_flags
-{
-   DISPGFX_WIDGET_FLAG_MSG_QUEUE_HAS_ICONS = (1 << 0),
-   DISPGFX_WIDGET_FLAG_PERSISTING          = (1 << 1),
-   DISPGFX_WIDGET_FLAG_MOVING              = (1 << 2),
-   DISPGFX_WIDGET_FLAG_INITED              = (1 << 3)
-};
-
-typedef struct dispgfx_widget
-{
-   uint64_t gfx_widgets_frame_count;
-
-#ifdef HAVE_THREADS
-   slock_t* current_msgs_lock;
-#endif
-   fifo_buffer_t msg_queue;
-   disp_widget_msg_t* current_msgs[MSG_QUEUE_ONSCREEN_MAX];
-   gfx_widget_fonts_t gfx_widget_fonts; /* ptr alignment */
-
-#ifdef HAVE_TRANSLATE
-   uintptr_t ai_service_overlay_texture;
-#endif
-   uintptr_t msg_queue_icon;
-   uintptr_t msg_queue_icon_outline;
-   uintptr_t msg_queue_icon_rect;
-   uintptr_t gfx_widgets_icons_textures[
-   MENU_WIDGETS_ICON_LAST];
-   uintptr_t gfx_widgets_generic_tag;
-
-   size_t current_msgs_size;
-
-#ifdef HAVE_TRANSLATE
-   int ai_service_overlay_state;
-#endif
-
-   unsigned last_video_width;
-   unsigned last_video_height;
-   unsigned msg_queue_kill;
-   /* Count of messages bound to a task in current_msgs */
-   unsigned msg_queue_tasks_count;
-
-   unsigned simple_widget_padding;
-   unsigned simple_widget_height;
-
-   /* Used for both generic and libretro messages */
-   unsigned generic_message_height;
-
-   unsigned msg_queue_height;
-   unsigned msg_queue_spacing;
-   unsigned msg_queue_rect_start_x;
-   unsigned msg_queue_internal_icon_size;
-   unsigned msg_queue_internal_icon_offset;
-   unsigned msg_queue_icon_size_x;
-   unsigned msg_queue_icon_size_y;
-   unsigned msg_queue_icon_offset_y;
-   unsigned msg_queue_scissor_start_x;
-   unsigned msg_queue_default_rect_width_menu_alive;
-   unsigned msg_queue_default_rect_width;
-   unsigned msg_queue_regular_padding_x;
-   unsigned msg_queue_regular_text_start;
-   unsigned msg_queue_task_text_start_x;
-   unsigned msg_queue_task_rect_start_x;
-   unsigned msg_queue_task_hourglass_x;
-   unsigned divider_width_1px;
-
-   float last_scale_factor;
-   float backdrop_orig[16];
-   float msg_queue_bg[16];
-   float pure_white[16];
-#ifdef HAVE_TRANSLATE
-   unsigned ai_service_overlay_width;
-   unsigned ai_service_overlay_height;
-#endif
-
-   uint8_t flags;
-
-   char assets_pkg_dir[PATH_MAX_LENGTH];
-   char xmb_path[PATH_MAX_LENGTH];                /* TODO/FIXME - decouple from XMB */
-   char ozone_path[PATH_MAX_LENGTH];              /* TODO/FIXME - decouple from Ozone */
-   char ozone_regular_font_path[PATH_MAX_LENGTH]; /* TODO/FIXME - decouple from Ozone */
-   char ozone_bold_font_path[PATH_MAX_LENGTH];    /* TODO/FIXME - decouple from Ozone */
-
-   char monochrome_png_path[PATH_MAX_LENGTH];
-   char gfx_widgets_path[PATH_MAX_LENGTH];
-   char gfx_widgets_status_text[255];
-
-   bool active;
-} dispgfx_widget_t;
-
-
-/* A widget */
-/* TODO/FIXME: cleanup all unused parameters */
-struct gfx_widget
-{
-   /* called when the widgets system is initialized
-    * -> initialize the widget here */
-   bool (*init)(gfx_display_t *p_disp,
-         gfx_animation_t *p_anim,
-         bool video_is_threaded, bool fullscreen);
-
-   /* called when the widgets system is freed
-    * -> free the widget here */
-   void (*free)(void);
-
-   /* called when the graphics context is reset
-    * -> (re)load the textures here */
-   void (*context_reset)(bool is_threaded,
-      unsigned width, unsigned height, bool fullscreen,
-      const char *dir_assets, char *font_path,
-      char* menu_png_path,
-      char* widgets_png_path);
-
-   /* called when the graphics context is destroyed
-    * -> release the textures here */
-   void (*context_destroy)(void);
-
-   /* called when the window resolution changes
-    * -> (re)layout the widget here */
-   void (*layout)(void *data,
-         bool is_threaded, const char *dir_assets, char *font_path);
-
-   /* called every frame on the main thread
-    * -> update the widget logic here */
-   void (*iterate)(void *user_data,
-      unsigned width, unsigned height, bool fullscreen,
-      const char *dir_assets, char *font_path,
-      bool is_threaded);
-
-   /* called every frame
-    * (on the video thread if threaded video is on)
-    * -- data is a video_frame_info_t
-    * -- userdata is a dispgfx_widget_t
-    * -> draw the widget here */
-   void (*frame)(void* data, void *userdata);
-};
-
-float gfx_widgets_get_thumbnail_scale_factor(
-      const float dst_width, const float dst_height,
-      const float image_width, const float image_height);
-
-void gfx_widgets_draw_icon(
-      void *userdata,
-      void *data_disp,
-      unsigned video_width,
-      unsigned video_height,
-      unsigned icon_width,
-      unsigned icon_height,
-      uintptr_t texture,
-      float x, float y,
-      float radians,
-      float cosine,
-      float sine,
-      float *color);
-
-void gfx_widgets_draw_text(
-      gfx_widget_font_data_t* font_data,
-      const char *text,
-      float x, float y,
-      int width, int height,
-      uint32_t color,
-      enum text_alignment text_align,
-      bool draw_outside);
-
-void gfx_widgets_flush_text(
-      unsigned video_width, unsigned video_height,
-      gfx_widget_font_data_t* font_data);
-
-typedef struct gfx_widget gfx_widget_t;
-
-bool gfx_widgets_init(
-      void *data_disp,
-      void *data_anim,
-      void *settings_data,
-      uintptr_t widgets_active_ptr,
-      bool video_is_threaded,
-      unsigned width, unsigned height, bool fullscreen,
-      const char *dir_assets, char *font_path);
-
-void gfx_widgets_deinit(bool widgets_persisting);
-
-void gfx_widgets_msg_queue_push(
-      retro_task_t *task, const char *msg,
-      unsigned duration,
-      char *title,
-      enum message_queue_icon icon,
-      enum message_queue_category category,
-      unsigned prio, bool flush,
-      bool menu_is_alive);
-
-void gfx_widget_volume_update_and_show(float new_volume,
-      bool mute);
-
-void gfx_widgets_iterate(
-      void *data_disp,
-      void *settings_data,
-      unsigned width, unsigned height, bool fullscreen,
-      const char *dir_assets, char *font_path,
-      bool is_threaded);
-
-void gfx_widget_screenshot_taken(void *data,
-      const char *shotname, const char *filename);
-
-/* AI Service functions */
-#ifdef HAVE_TRANSLATE
-bool gfx_widgets_ai_service_overlay_load(
-      char* buffer, unsigned buffer_len,
-      enum image_type_enum image_type);
-
-void gfx_widgets_ai_service_overlay_unload(void);
-#endif
-
-#ifdef HAVE_CHEEVOS
-void gfx_widgets_update_cheevos_appearance(void);
-void gfx_widgets_push_achievement(const char *title, const char* subtitle, const char *badge);
-void gfx_widgets_set_leaderboard_display(unsigned id, const char* value);
-void gfx_widgets_set_challenge_display(unsigned id, const char* badge);
-void gfx_widget_set_achievement_progress(const char* badge, const char* progress);
-#endif
-
-/* TODO/FIXME/WARNING: Not thread safe! */
-void gfx_widget_set_generic_message(
-      const char *message, unsigned duration);
-void gfx_widget_set_libretro_message(
-      const char *message, unsigned duration);
-void gfx_widget_set_progress_message(
-      const char *message, unsigned duration,
-      unsigned priority, int8_t progress);
-bool gfx_widget_start_load_content_animation(void);
-
-/* All the functions below should be called in
- * the video driver - once they are all added, set
- * enable_menu_widgets to true for that driver */
-void gfx_widgets_frame(void *data);
-
-bool gfx_widgets_ready(void);
-
-dispgfx_widget_t *dispwidget_get_ptr(void);
-
-extern const gfx_widget_t gfx_widget_screenshot;
-extern const gfx_widget_t gfx_widget_volume;
-extern const gfx_widget_t gfx_widget_generic_message;
-extern const gfx_widget_t gfx_widget_libretro_message;
-extern const gfx_widget_t gfx_widget_progress_message;
-extern const gfx_widget_t gfx_widget_load_content_animation;
-
-#ifdef HAVE_NETWORKING
-extern const gfx_widget_t gfx_widget_netplay_chat;
-extern const gfx_widget_t gfx_widget_netplay_ping;
-#endif
-
-#ifdef HAVE_CHEEVOS
-extern const gfx_widget_t gfx_widget_achievement_popup;
-extern const gfx_widget_t gfx_widget_leaderboard_display;
-#endif
-
-RETRO_END_DECLS
-
-#endif

+ 13 - 2
app/src/main/cpp/gfx/video_driver.c

@@ -2647,7 +2647,13 @@ void video_driver_build_info(video_frame_info_t *video_info)
    video_info->menu_mouse_enable           = settings->bools.menu_mouse_enable;
    video_info->monitor_index               = settings->uints.video_monitor_index;
 
-   video_info->font_enable                 = settings->bools.video_font_enable;
+   video_info->font_enable                 =
+#if HAVE_FONT
+         settings->bools.video_font_enable;
+#else
+         false;
+#endif
+
    video_info->font_size                   = settings->floats.video_font_size;
    video_info->font_msg_pos_x              = settings->floats.video_msg_pos_x;
    video_info->font_msg_pos_y              = settings->floats.video_msg_pos_y;
@@ -3396,7 +3402,12 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
    video.smooth                      = settings->bools.video_smooth;
    video.ctx_scaling                 = settings->bools.video_ctx_scaling;
    video.input_scale                 = scale;
-   video.font_enable                 = settings->bools.video_font_enable;
+   video.font_enable                 =
+#if HAVE_FONT
+            settings->bools.video_font_enable;
+#else
+            false;
+#endif
    video.font_size                   = settings->floats.video_font_size;
    video.path_font                   = settings->paths.path_font;
 #ifdef HAVE_VIDEO_FILTER

+ 2 - 0
app/src/main/cpp/gfx/video_thread_wrapper.c

@@ -25,7 +25,9 @@
 
 #include "video_driver.h"
 #include "video_thread_wrapper.h"
+#ifdef HAVE_FONT
 #include "font_driver.h"
+#endif
 
 #include "../retroarch.h"
 #include "../runloop.h"

+ 2 - 0
app/src/main/cpp/gfx/video_thread_wrapper.h

@@ -24,7 +24,9 @@
 #include <rthreads/rthreads.h>
 #include <retro_miscellaneous.h>
 
+#ifdef HAVE_FONT
 #include "font_driver.h"
+#endif
 
 RETRO_BEGIN_DECLS
 

+ 2 - 0
app/src/main/cpp/griffin/griffin.c

@@ -573,6 +573,7 @@ VIDEO DRIVER
 FONTS
 ============================================================ */
 
+#ifdef HAVE_FONT
 #include "../gfx/drivers_font_renderer/bitmapfont.c"
 
 #ifdef HAVE_LANGEXTRA
@@ -664,6 +665,7 @@ FONTS
 #if defined(HAVE_D3D12)
 #include "../gfx/drivers_font/d3d12_font.c"
 #endif
+#endif
 
 /*============================================================
 INPUT