mirror of
https://github.com/libretro/RetroArch
synced 2025-03-23 10:20:57 +00:00
Revert "Free font data inside gfx/font_driver.c's free function"
This reverts commit b3f1bbc15e8f8c08531c3661041d0ded9bfeca51.
This commit is contained in:
parent
a73a90b701
commit
c875d95f7a
@ -59,6 +59,7 @@ static void *caca_init_font(void *data,
|
|||||||
|
|
||||||
static void caca_render_free_font(void *data)
|
static void caca_render_free_font(void *data)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int caca_get_message_width(void *data, const char *msg,
|
static int caca_get_message_width(void *data, const char *msg,
|
||||||
|
@ -109,6 +109,7 @@ static void ctr_font_free_font(void* data)
|
|||||||
#else
|
#else
|
||||||
linearFree(font->texture.data);
|
linearFree(font->texture.data);
|
||||||
#endif
|
#endif
|
||||||
|
free(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ctr_font_get_message_width(void* data, const char* msg,
|
static int ctr_font_get_message_width(void* data, const char* msg,
|
||||||
|
@ -88,6 +88,9 @@ static void d3dfonts_w32_free_font(void *data)
|
|||||||
if (d3dfonts->font)
|
if (d3dfonts->font)
|
||||||
d3dfonts->font->Release();
|
d3dfonts->font->Release();
|
||||||
d3dfonts->font = NULL;
|
d3dfonts->font = NULL;
|
||||||
|
|
||||||
|
free(d3dfonts);
|
||||||
|
d3dfonts = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void d3dfonts_w32_render_msg(void *data, const char *msg,
|
static void d3dfonts_w32_render_msg(void *data, const char *msg,
|
||||||
|
@ -57,6 +57,8 @@ typedef struct
|
|||||||
video_font_raster_block_t *block;
|
video_font_raster_block_t *block;
|
||||||
} gl_raster_t;
|
} gl_raster_t;
|
||||||
|
|
||||||
|
static void gl_raster_font_free_font(void *data);
|
||||||
|
|
||||||
static bool gl_raster_font_upload_atlas(gl_raster_t *font)
|
static bool gl_raster_font_upload_atlas(gl_raster_t *font)
|
||||||
{
|
{
|
||||||
unsigned i, j;
|
unsigned i, j;
|
||||||
@ -142,21 +144,6 @@ static bool gl_raster_font_upload_atlas(gl_raster_t *font)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gl_raster_font_free_font(void *data)
|
|
||||||
{
|
|
||||||
gl_raster_t *font = (gl_raster_t*)data;
|
|
||||||
if (!font)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (font->font_driver && font->font_data)
|
|
||||||
font->font_driver->free(font->font_data);
|
|
||||||
|
|
||||||
if (video_driver_is_threaded())
|
|
||||||
video_context_driver_make_current(true);
|
|
||||||
|
|
||||||
glDeleteTextures(1, &font->tex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *gl_raster_font_init_font(void *data,
|
static void *gl_raster_font_init_font(void *data,
|
||||||
const char *font_path, float font_size)
|
const char *font_path, float font_size)
|
||||||
{
|
{
|
||||||
@ -169,7 +156,11 @@ static void *gl_raster_font_init_font(void *data,
|
|||||||
|
|
||||||
if (!font_renderer_create_default((const void**)&font->font_driver,
|
if (!font_renderer_create_default((const void**)&font->font_driver,
|
||||||
&font->font_data, font_path, font_size))
|
&font->font_data, font_path, font_size))
|
||||||
goto error;
|
{
|
||||||
|
RARCH_WARN("Couldn't initialize font renderer.\n");
|
||||||
|
free(font);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (video_driver_is_threaded())
|
if (video_driver_is_threaded())
|
||||||
video_context_driver_make_current(false);
|
video_context_driver_make_current(false);
|
||||||
@ -195,13 +186,28 @@ static void *gl_raster_font_init_font(void *data,
|
|||||||
return font;
|
return font;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
RARCH_WARN("Couldn't initialize font renderer.\n");
|
|
||||||
gl_raster_font_free_font(font);
|
gl_raster_font_free_font(font);
|
||||||
free(font);
|
font = NULL;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gl_raster_font_free_font(void *data)
|
||||||
|
{
|
||||||
|
gl_raster_t *font = (gl_raster_t*)data;
|
||||||
|
if (!font)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (font->font_driver && font->font_data)
|
||||||
|
font->font_driver->free(font->font_data);
|
||||||
|
|
||||||
|
if (video_driver_is_threaded())
|
||||||
|
video_context_driver_make_current(true);
|
||||||
|
|
||||||
|
glDeleteTextures(1, &font->tex);
|
||||||
|
|
||||||
|
free(font);
|
||||||
|
}
|
||||||
|
|
||||||
static int gl_get_message_width(void *data, const char *msg,
|
static int gl_get_message_width(void *data, const char *msg,
|
||||||
unsigned msg_len, float scale)
|
unsigned msg_len, float scale)
|
||||||
|
@ -98,6 +98,8 @@ static void vita2d_font_free_font(void *data)
|
|||||||
vita2d_wait_rendering_done();
|
vita2d_wait_rendering_done();
|
||||||
#endif
|
#endif
|
||||||
vita2d_free_texture(font->texture);
|
vita2d_free_texture(font->texture);
|
||||||
|
|
||||||
|
free(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vita2d_font_get_message_width(void *data, const char *msg,
|
static int vita2d_font_get_message_width(void *data, const char *msg,
|
||||||
|
@ -85,6 +85,8 @@ static void vulkan_raster_font_free_font(void *data)
|
|||||||
vkQueueWaitIdle(font->vk->context->queue);
|
vkQueueWaitIdle(font->vk->context->queue);
|
||||||
vulkan_destroy_texture(
|
vulkan_destroy_texture(
|
||||||
font->vk->context->device, &font->texture);
|
font->vk->context->device, &font->texture);
|
||||||
|
|
||||||
|
free(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vulkan_get_message_width(void *data, const char *msg,
|
static int vulkan_get_message_width(void *data, const char *msg,
|
||||||
|
@ -55,6 +55,12 @@ static void *xfonts_init_font(void *video_data,
|
|||||||
|
|
||||||
static void xfonts_free_font(void *data)
|
static void xfonts_free_font(void *data)
|
||||||
{
|
{
|
||||||
|
xfonts_t *font = (xfonts_t*)data;
|
||||||
|
|
||||||
|
if (font)
|
||||||
|
free(font);
|
||||||
|
|
||||||
|
font = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xfonts_render_msg(void *data, const char *msg,
|
static void xfonts_render_msg(void *data, const char *msg,
|
||||||
|
@ -58,18 +58,18 @@ enum
|
|||||||
class PackedResource
|
class PackedResource
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
BYTE* m_pSysMemData; /* Allocated memory for resource headers etc. */
|
BYTE* m_pSysMemData; // Alloc'ed memory for resource headers etc.
|
||||||
DWORD m_dwSysMemDataSize;
|
DWORD m_dwSysMemDataSize;
|
||||||
|
|
||||||
BYTE* m_pVidMemData; /* Allocated memory for resource data, etc. */
|
BYTE* m_pVidMemData; // Alloc'ed memory for resource data, etc.
|
||||||
DWORD m_dwVidMemDataSize;
|
DWORD m_dwVidMemDataSize;
|
||||||
|
|
||||||
XBRESOURCE* m_pResourceTags; /* Tags to associate names with the resources */
|
XBRESOURCE* m_pResourceTags; // Tags to associate names with the resources
|
||||||
DWORD m_dwNumResourceTags; /* Number of resource tags */
|
DWORD m_dwNumResourceTags; // Number of resource tags
|
||||||
BOOL m_bInitialized; /* Resource is fully initialized */
|
BOOL m_bInitialized; // Resource is fully initialized
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* Loads the resources out of the specified bundle */
|
// Loads the resources out of the specified bundle
|
||||||
#if defined(_XBOX1)
|
#if defined(_XBOX1)
|
||||||
HRESULT Create( const char *strFilename, DWORD dwNumResourceTags = 0L,
|
HRESULT Create( const char *strFilename, DWORD dwNumResourceTags = 0L,
|
||||||
XBRESOURCE* pResourceTags = NULL );
|
XBRESOURCE* pResourceTags = NULL );
|
||||||
@ -82,21 +82,20 @@ class PackedResource
|
|||||||
BOOL Initialized() const;
|
BOOL Initialized() const;
|
||||||
|
|
||||||
#ifdef _XBOX360
|
#ifdef _XBOX360
|
||||||
/* Retrieves the resource tags */
|
// Retrieves the resource tags
|
||||||
void GetResourceTags( DWORD* pdwNumResourceTags, XBRESOURCE** ppResourceTags );
|
void GetResourceTags( DWORD* pdwNumResourceTags, XBRESOURCE** ppResourceTags );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Helper function to make sure a resource is registered */
|
// Helper function to make sure a resource is registered
|
||||||
LPDIRECT3DRESOURCE RegisterResource( LPDIRECT3DRESOURCE pResource ) const
|
LPDIRECT3DRESOURCE RegisterResource( LPDIRECT3DRESOURCE pResource ) const
|
||||||
{
|
{
|
||||||
#ifdef _XBOX1
|
#ifdef _XBOX1
|
||||||
/* Register the resource, if it has not yet been registered. We mark
|
// Register the resource, if it has not yet been registered. We mark
|
||||||
* a resource as registered by upping it's reference count. */
|
// a resource as registered by upping it's reference count.
|
||||||
if( pResource && ( pResource->Common & D3DCOMMON_REFCOUNT_MASK ) == 1 )
|
if( pResource && ( pResource->Common & D3DCOMMON_REFCOUNT_MASK ) == 1 )
|
||||||
{
|
{
|
||||||
|
// Special case CPU-copy push buffers (which live in system memory)
|
||||||
/* Special case CPU-copy push buffers (which live in system memory) */
|
if( ( pResource->Common & D3DCOMMON_TYPE_PUSHBUFFER ) &&
|
||||||
if( ( pResource->Common & D3DCOMMON_TYPE_PUSHBUFFER ) &&
|
|
||||||
( pResource->Common & D3DPUSHBUFFER_RUN_USING_CPU_COPY ) )
|
( pResource->Common & D3DPUSHBUFFER_RUN_USING_CPU_COPY ) )
|
||||||
pResource->Data += (DWORD)m_pSysMemData;
|
pResource->Data += (DWORD)m_pSysMemData;
|
||||||
else
|
else
|
||||||
@ -108,46 +107,32 @@ class PackedResource
|
|||||||
return pResource;
|
return pResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Functions to retrieve resources by their offset */
|
// Functions to retrieve resources by their offset
|
||||||
void *GetData( DWORD dwOffset ) const
|
void *GetData( DWORD dwOffset ) const
|
||||||
{
|
{ return &m_pSysMemData[dwOffset]; }
|
||||||
return &m_pSysMemData[dwOffset];
|
|
||||||
}
|
|
||||||
|
|
||||||
LPDIRECT3DRESOURCE GetResource( DWORD dwOffset ) const
|
LPDIRECT3DRESOURCE GetResource( DWORD dwOffset ) const
|
||||||
{
|
{ return RegisterResource( (LPDIRECT3DRESOURCE)GetData(dwOffset) ); }
|
||||||
return RegisterResource( (LPDIRECT3DRESOURCE)GetData(dwOffset) );
|
|
||||||
}
|
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE GetTexture( DWORD dwOffset ) const
|
LPDIRECT3DTEXTURE GetTexture( DWORD dwOffset ) const
|
||||||
{
|
{ return (LPDIRECT3DTEXTURE)GetResource( dwOffset ); }
|
||||||
return (LPDIRECT3DTEXTURE)GetResource( dwOffset );
|
|
||||||
}
|
|
||||||
|
|
||||||
LPDIRECT3DVERTEXBUFFER GetVertexBuffer( DWORD dwOffset ) const
|
LPDIRECT3DVERTEXBUFFER GetVertexBuffer( DWORD dwOffset ) const
|
||||||
{
|
{ return (LPDIRECT3DVERTEXBUFFER)GetResource( dwOffset ); }
|
||||||
return (LPDIRECT3DVERTEXBUFFER)GetResource( dwOffset );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Functions to retrieve resources by their name */
|
// Functions to retrieve resources by their name
|
||||||
void *GetData( const char* strName ) const;
|
void *GetData( const char* strName ) const;
|
||||||
|
|
||||||
LPDIRECT3DRESOURCE GetResource( const char* strName ) const
|
LPDIRECT3DRESOURCE GetResource( const char* strName ) const
|
||||||
{
|
{ return RegisterResource( (LPDIRECT3DRESOURCE)GetData( strName ) ); }
|
||||||
return RegisterResource( (LPDIRECT3DRESOURCE)GetData(strName));
|
|
||||||
}
|
|
||||||
|
|
||||||
LPDIRECT3DTEXTURE GetTexture( const char* strName ) const
|
LPDIRECT3DTEXTURE GetTexture( const char* strName ) const
|
||||||
{
|
{ return (LPDIRECT3DTEXTURE)GetResource( strName ); }
|
||||||
return (LPDIRECT3DTEXTURE)GetResource( strName );
|
|
||||||
}
|
|
||||||
|
|
||||||
LPDIRECT3DVERTEXBUFFER GetVertexBuffer( const char* strName ) const
|
LPDIRECT3DVERTEXBUFFER GetVertexBuffer( const char* strName ) const
|
||||||
{
|
{ return (LPDIRECT3DVERTEXBUFFER)GetResource( strName ); }
|
||||||
return (LPDIRECT3DVERTEXBUFFER)GetResource( strName );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Constructor/destructor */
|
// Constructor/destructor
|
||||||
PackedResource();
|
PackedResource();
|
||||||
~PackedResource();
|
~PackedResource();
|
||||||
};
|
};
|
||||||
@ -158,13 +143,13 @@ class PackedResource
|
|||||||
|
|
||||||
PackedResource::PackedResource()
|
PackedResource::PackedResource()
|
||||||
{
|
{
|
||||||
m_pSysMemData = NULL;
|
m_pSysMemData = NULL;
|
||||||
m_dwSysMemDataSize = 0L;
|
m_dwSysMemDataSize = 0L;
|
||||||
m_pVidMemData = NULL;
|
m_pVidMemData = NULL;
|
||||||
m_dwVidMemDataSize = 0L;
|
m_dwVidMemDataSize = 0L;
|
||||||
m_pResourceTags = NULL;
|
m_pResourceTags = NULL;
|
||||||
m_dwNumResourceTags = 0L;
|
m_dwNumResourceTags = 0L;
|
||||||
m_bInitialized = FALSE;
|
m_bInitialized = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -250,8 +235,8 @@ HRESULT PackedResource::Create(const char *strFilename)
|
|||||||
XPR_HEADER xprh;
|
XPR_HEADER xprh;
|
||||||
bool retval;
|
bool retval;
|
||||||
#ifdef _XBOX1
|
#ifdef _XBOX1
|
||||||
char strResourcePath[512];
|
|
||||||
BOOL bHasResourceOffsetsTable = FALSE;
|
BOOL bHasResourceOffsetsTable = FALSE;
|
||||||
|
char strResourcePath[512];
|
||||||
|
|
||||||
if (FAILED(FindMediaFile(strResourcePath, strFilename, sizeof(strResourcePath))))
|
if (FAILED(FindMediaFile(strResourcePath, strFilename, sizeof(strResourcePath))))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
@ -285,7 +270,7 @@ HRESULT PackedResource::Create(const char *strFilename)
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute memory requirements */
|
// Compute memory requirements
|
||||||
#if defined(_XBOX1)
|
#if defined(_XBOX1)
|
||||||
m_dwSysMemDataSize = xprh.dwHeaderSize - sizeof(XPR_HEADER);
|
m_dwSysMemDataSize = xprh.dwHeaderSize - sizeof(XPR_HEADER);
|
||||||
m_dwVidMemDataSize = xprh.dwTotalSize - xprh.dwHeaderSize;
|
m_dwVidMemDataSize = xprh.dwTotalSize - xprh.dwHeaderSize;
|
||||||
@ -294,7 +279,7 @@ HRESULT PackedResource::Create(const char *strFilename)
|
|||||||
m_dwVidMemDataSize = xprh.dwDataSize;
|
m_dwVidMemDataSize = xprh.dwDataSize;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Allocate memory */
|
// Allocate memory
|
||||||
m_pSysMemData = (BYTE*)malloc(m_dwSysMemDataSize);
|
m_pSysMemData = (BYTE*)malloc(m_dwSysMemDataSize);
|
||||||
if (m_pSysMemData == NULL)
|
if (m_pSysMemData == NULL)
|
||||||
{
|
{
|
||||||
@ -319,7 +304,7 @@ HRESULT PackedResource::Create(const char *strFilename)
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read in the data from the file */
|
// Read in the data from the file
|
||||||
if( !ReadFile( hFile, m_pSysMemData, m_dwSysMemDataSize, &dwNumBytesRead, NULL) ||
|
if( !ReadFile( hFile, m_pSysMemData, m_dwSysMemDataSize, &dwNumBytesRead, NULL) ||
|
||||||
!ReadFile( hFile, m_pVidMemData, m_dwVidMemDataSize, &dwNumBytesRead, NULL))
|
!ReadFile( hFile, m_pVidMemData, m_dwVidMemDataSize, &dwNumBytesRead, NULL))
|
||||||
{
|
{
|
||||||
@ -327,7 +312,7 @@ HRESULT PackedResource::Create(const char *strFilename)
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Done with the file */
|
// Done with the file
|
||||||
CloseHandle( hFile);
|
CloseHandle( hFile);
|
||||||
|
|
||||||
#ifdef _XBOX1
|
#ifdef _XBOX1
|
||||||
@ -386,17 +371,16 @@ void PackedResource::GetResourceTags(DWORD* pdwNumResourceTags,
|
|||||||
void PackedResource::Destroy()
|
void PackedResource::Destroy()
|
||||||
{
|
{
|
||||||
free(m_pSysMemData);
|
free(m_pSysMemData);
|
||||||
|
m_pSysMemData = NULL;
|
||||||
|
m_dwSysMemDataSize = 0L;
|
||||||
|
|
||||||
if (m_pVidMemData)
|
if (m_pVidMemData != NULL)
|
||||||
FreeContiguousMemory(m_pVidMemData);
|
FreeContiguousMemory(m_pVidMemData);
|
||||||
|
|
||||||
m_pSysMemData = NULL;
|
m_pVidMemData = NULL;
|
||||||
m_dwSysMemDataSize = 0L;
|
m_dwVidMemDataSize = 0L;
|
||||||
|
|
||||||
m_pVidMemData = NULL;
|
m_pResourceTags = NULL;
|
||||||
m_dwVidMemDataSize = 0L;
|
|
||||||
|
|
||||||
m_pResourceTags = NULL;
|
|
||||||
m_dwNumResourceTags = 0L;
|
m_dwNumResourceTags = 0L;
|
||||||
|
|
||||||
m_bInitialized = FALSE;
|
m_bInitialized = FALSE;
|
||||||
@ -546,6 +530,8 @@ static void *xdk360_init_font(void *video_data,
|
|||||||
if (!font)
|
if (!font)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
(void)font_size;
|
||||||
|
|
||||||
font->d3d = (d3d_video_t*)video_data;
|
font->d3d = (d3d_video_t*)video_data;
|
||||||
|
|
||||||
font->m_pFontTexture = NULL;
|
font->m_pFontTexture = NULL;
|
||||||
@ -613,10 +599,10 @@ static void xdk360_free_font(void *data)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Destroy the font */
|
/* Destroy the font */
|
||||||
font->m_pFontTexture = NULL;
|
font->m_pFontTexture = NULL;
|
||||||
font->m_dwNumGlyphs = 0L;
|
font->m_dwNumGlyphs = 0L;
|
||||||
font->m_Glyphs = NULL;
|
font->m_Glyphs = NULL;
|
||||||
font->m_cMaxGlyph = 0;
|
font->m_cMaxGlyph = 0;
|
||||||
font->m_TranslatorTable = NULL;
|
font->m_TranslatorTable = NULL;
|
||||||
|
|
||||||
if (font->s_FontLocals.m_pFontPixelShader)
|
if (font->s_FontLocals.m_pFontPixelShader)
|
||||||
@ -626,12 +612,15 @@ static void xdk360_free_font(void *data)
|
|||||||
if (font->s_FontLocals.m_pFontVertexDecl)
|
if (font->s_FontLocals.m_pFontVertexDecl)
|
||||||
font->s_FontLocals.m_pFontVertexDecl->Release();
|
font->s_FontLocals.m_pFontVertexDecl->Release();
|
||||||
|
|
||||||
font->s_FontLocals.m_pFontPixelShader = NULL;
|
font->s_FontLocals.m_pFontPixelShader = NULL;
|
||||||
font->s_FontLocals.m_pFontVertexShader = NULL;
|
font->s_FontLocals.m_pFontVertexShader = NULL;
|
||||||
font->s_FontLocals.m_pFontVertexDecl = NULL;
|
font->s_FontLocals.m_pFontVertexDecl = NULL;
|
||||||
|
|
||||||
if (m_xprResource.Initialized())
|
if (m_xprResource.Initialized())
|
||||||
m_xprResource.Destroy();
|
m_xprResource.Destroy();
|
||||||
|
|
||||||
|
free(font);
|
||||||
|
font = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdk360_render_msg_post(xdk360_video_font_t * font)
|
static void xdk360_render_msg_post(xdk360_video_font_t * font)
|
||||||
@ -655,7 +644,7 @@ static void xdk360_render_msg_pre(xdk360_video_font_t * font)
|
|||||||
d3dr->GetRenderState( D3DRS_VIEWPORTENABLE, (DWORD*)&font->m_dwSavedState );
|
d3dr->GetRenderState( D3DRS_VIEWPORTENABLE, (DWORD*)&font->m_dwSavedState );
|
||||||
|
|
||||||
/* Set the texture scaling factor as a vertex shader constant. */
|
/* Set the texture scaling factor as a vertex shader constant. */
|
||||||
D3DTexture_GetLevelDesc(font->m_pFontTexture, 0, &TextureDesc); /* Get the description */
|
D3DTexture_GetLevelDesc(font->m_pFontTexture, 0, &TextureDesc); // Get the description
|
||||||
|
|
||||||
/* Set render state. */
|
/* Set render state. */
|
||||||
d3d_set_texture(d3dr, 0, font->m_pFontTexture);
|
d3d_set_texture(d3dr, 0, font->m_pFontTexture);
|
||||||
@ -696,11 +685,11 @@ static void xdk360_draw_text(xdk360_video_font_t *font,
|
|||||||
* the vColor array. */
|
* the vColor array. */
|
||||||
d3dr->SetVertexShaderConstantF(1, vColor, 1);
|
d3dr->SetVertexShaderConstantF(1, vColor, 1);
|
||||||
|
|
||||||
m_fCursorX = floorf(x);
|
m_fCursorX = floorf(x);
|
||||||
m_fCursorY = floorf(y);
|
m_fCursorY = floorf(y);
|
||||||
|
|
||||||
/* Adjust for padding. */
|
/* Adjust for padding. */
|
||||||
y -= font->m_fFontTopPadding;
|
y -= font->m_fFontTopPadding;
|
||||||
|
|
||||||
/* Begin drawing the vertices
|
/* Begin drawing the vertices
|
||||||
* Declared as volatile to force writing in ascending
|
* Declared as volatile to force writing in ascending
|
||||||
@ -710,7 +699,7 @@ static void xdk360_draw_text(xdk360_video_font_t *font,
|
|||||||
* memory.
|
* memory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dwNumChars = wcslen(strText);
|
dwNumChars = wcslen(strText);
|
||||||
d3dr->BeginVertices(D3DPT_QUADLIST, 4 * dwNumChars,
|
d3dr->BeginVertices(D3DPT_QUADLIST, 4 * dwNumChars,
|
||||||
sizeof(XMFLOAT4), (void**)&pVertex);
|
sizeof(XMFLOAT4), (void**)&pVertex);
|
||||||
|
|
||||||
@ -721,8 +710,8 @@ static void xdk360_draw_text(xdk360_video_font_t *font,
|
|||||||
#ifdef MSB_FIRST
|
#ifdef MSB_FIRST
|
||||||
uint32_t tu1, tu2, tv1, tv2;
|
uint32_t tu1, tu2, tv1, tv2;
|
||||||
#endif
|
#endif
|
||||||
const GLYPH_ATTR *pGlyph = NULL;
|
const GLYPH_ATTR *pGlyph;
|
||||||
wchar_t letter = *strText++; /* Get the current letter in the string */
|
wchar_t letter = *strText++; /* Get the current letter in the string */
|
||||||
|
|
||||||
/* Handle the newline character. */
|
/* Handle the newline character. */
|
||||||
if (letter == L'\n')
|
if (letter == L'\n')
|
||||||
@ -743,16 +732,16 @@ static void xdk360_draw_text(xdk360_video_font_t *font,
|
|||||||
fWidth = FONT_SCALE(font->d3d) * (float)pGlyph->wWidth;
|
fWidth = FONT_SCALE(font->d3d) * (float)pGlyph->wWidth;
|
||||||
fHeight = FONT_SCALE(font->d3d) * font->m_fFontHeight;
|
fHeight = FONT_SCALE(font->d3d) * font->m_fFontHeight;
|
||||||
|
|
||||||
m_fCursorX += fOffset;
|
m_fCursorX += fOffset;
|
||||||
|
|
||||||
/* Add the vertices to draw this glyph. */
|
/* Add the vertices to draw this glyph. */
|
||||||
|
|
||||||
#ifdef MSB_FIRST
|
#ifdef MSB_FIRST
|
||||||
/* Convert shorts to 32 bit longs for in register merging */
|
/* Convert shorts to 32 bit longs for in register merging */
|
||||||
tu1 = pGlyph->tu1;
|
tu1 = pGlyph->tu1;
|
||||||
tv1 = pGlyph->tv1;
|
tv1 = pGlyph->tv1;
|
||||||
tu2 = pGlyph->tu2;
|
tu2 = pGlyph->tu2;
|
||||||
tv2 = pGlyph->tv2;
|
tv2 = pGlyph->tv2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* NOTE: The vertexes are 2 floats for the screen coordinates,
|
/* NOTE: The vertexes are 2 floats for the screen coordinates,
|
||||||
@ -771,27 +760,27 @@ static void xdk360_draw_text(xdk360_video_font_t *font,
|
|||||||
|
|
||||||
/* Setup the vertex/screen coordinates */
|
/* Setup the vertex/screen coordinates */
|
||||||
|
|
||||||
pVertex[0] = m_fCursorX;
|
pVertex[0] = m_fCursorX;
|
||||||
pVertex[1] = m_fCursorY;
|
pVertex[1] = m_fCursorY;
|
||||||
pVertex[3] = 0;
|
pVertex[3] = 0;
|
||||||
pVertex[4] = m_fCursorX + fWidth;
|
pVertex[4] = m_fCursorX + fWidth;
|
||||||
pVertex[5] = m_fCursorY;
|
pVertex[5] = m_fCursorY;
|
||||||
pVertex[7] = 0;
|
pVertex[7] = 0;
|
||||||
pVertex[8] = m_fCursorX + fWidth;
|
pVertex[8] = m_fCursorX + fWidth;
|
||||||
pVertex[9] = m_fCursorY + fHeight;
|
pVertex[9] = m_fCursorY + fHeight;
|
||||||
pVertex[11] = 0;
|
pVertex[11] = 0;
|
||||||
pVertex[12] = m_fCursorX;
|
pVertex[12] = m_fCursorX;
|
||||||
pVertex[13] = m_fCursorY + fHeight;
|
pVertex[13] = m_fCursorY + fHeight;
|
||||||
#ifdef MSB_FIRST
|
#ifdef MSB_FIRST
|
||||||
((volatile uint32_t *)pVertex)[2] = (tu1 << 16) | tv1; /* Merged using big endian rules */
|
((volatile uint32_t *)pVertex)[2] = (tu1 << 16) | tv1; // Merged using big endian rules
|
||||||
((volatile uint32_t *)pVertex)[6] = (tu2 << 16) | tv1; /* Merged using big endian rules */
|
((volatile uint32_t *)pVertex)[6] = (tu2 << 16) | tv1; // Merged using big endian rules
|
||||||
((volatile uint32_t*)pVertex)[10] = (tu2 << 16) | tv2; /* Merged using big endian rules */
|
((volatile uint32_t*)pVertex)[10] = (tu2 << 16) | tv2; // Merged using big endian rules
|
||||||
((volatile uint32_t*)pVertex)[14] = (tu1 << 16) | tv2; /* Merged using big endian rules */
|
((volatile uint32_t*)pVertex)[14] = (tu1 << 16) | tv2; // Merged using big endian rules
|
||||||
#endif
|
#endif
|
||||||
pVertex[15] = 0;
|
pVertex[15] = 0;
|
||||||
|
pVertex += 16;
|
||||||
|
|
||||||
pVertex += 16;
|
m_fCursorX += fAdvance;
|
||||||
m_fCursorX += fAdvance;
|
|
||||||
|
|
||||||
dwNumChars--;
|
dwNumChars--;
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,6 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <string/stdstring.h>
|
|
||||||
|
|
||||||
#include "font_driver.h"
|
#include "font_driver.h"
|
||||||
#include "video_thread_wrapper.h"
|
#include "video_thread_wrapper.h"
|
||||||
|
|
||||||
@ -28,6 +24,8 @@
|
|||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
static const font_renderer_driver_t *font_backends[] = {
|
static const font_renderer_driver_t *font_backends[] = {
|
||||||
#ifdef HAVE_FREETYPE
|
#ifdef HAVE_FREETYPE
|
||||||
&freetype_font_renderer,
|
&freetype_font_renderer,
|
||||||
@ -194,8 +192,7 @@ static bool vulkan_font_init_first(
|
|||||||
|
|
||||||
for (i = 0; vulkan_font_backends[i]; i++)
|
for (i = 0; vulkan_font_backends[i]; i++)
|
||||||
{
|
{
|
||||||
void *data = vulkan_font_backends[i]->init(
|
void *data = vulkan_font_backends[i]->init(video_data, font_path, font_size);
|
||||||
video_data, font_path, font_size);
|
|
||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
continue;
|
continue;
|
||||||
@ -356,9 +353,6 @@ void font_driver_free(void *font_data)
|
|||||||
if (font->renderer && font->renderer->free)
|
if (font->renderer && font->renderer->free)
|
||||||
font->renderer->free(font->renderer_data);
|
font->renderer->free(font->renderer_data);
|
||||||
|
|
||||||
if (font->renderer_data)
|
|
||||||
free(font->renderer_data);
|
|
||||||
|
|
||||||
font->renderer = NULL;
|
font->renderer = NULL;
|
||||||
font->renderer_data = NULL;
|
font->renderer_data = NULL;
|
||||||
|
|
||||||
@ -370,9 +364,9 @@ font_data_t *font_driver_init_first(
|
|||||||
void *video_data, const char *font_path, float font_size,
|
void *video_data, const char *font_path, float font_size,
|
||||||
bool threading_hint, enum font_driver_render_api api)
|
bool threading_hint, enum font_driver_render_api api)
|
||||||
{
|
{
|
||||||
const void *font_driver = NULL;
|
const void *font_driver;
|
||||||
void *font_handle = NULL;
|
void *font_handle;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
if (threading_hint
|
if (threading_hint
|
||||||
@ -401,15 +395,12 @@ font_data_t *font_driver_init_first(
|
|||||||
void font_driver_init_osd(void *video_data, bool threading_hint, enum font_driver_render_api api)
|
void font_driver_init_osd(void *video_data, bool threading_hint, enum font_driver_render_api api)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
const char *path = settings->path.font;
|
|
||||||
|
|
||||||
if (video_font_driver)
|
if (video_font_driver)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
video_font_driver = font_driver_init_first(video_data,
|
video_font_driver = font_driver_init_first(video_data,
|
||||||
(!string_is_empty(path)) ? path : NULL,
|
*settings->path.font ? settings->path.font : NULL,
|
||||||
settings->video.font_size,
|
settings->video.font_size, threading_hint, api);
|
||||||
threading_hint, api);
|
|
||||||
|
|
||||||
if (!video_font_driver)
|
if (!video_font_driver)
|
||||||
RARCH_ERR("[font]: Failed to initialize OSD font.\n");
|
RARCH_ERR("[font]: Failed to initialize OSD font.\n");
|
||||||
|
@ -1482,10 +1482,14 @@ void video_driver_set_viewport_core(void)
|
|||||||
|
|
||||||
/* Fallback to 1:1 pixel ratio if none provided */
|
/* Fallback to 1:1 pixel ratio if none provided */
|
||||||
if (geom->aspect_ratio > 0.0f)
|
if (geom->aspect_ratio > 0.0f)
|
||||||
|
{
|
||||||
aspectratio_lut[ASPECT_RATIO_CORE].value = geom->aspect_ratio;
|
aspectratio_lut[ASPECT_RATIO_CORE].value = geom->aspect_ratio;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
aspectratio_lut[ASPECT_RATIO_CORE].value =
|
aspectratio_lut[ASPECT_RATIO_CORE].value =
|
||||||
(float)geom->base_width / geom->base_height;
|
(float)geom->base_width / geom->base_height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void video_driver_reset_custom_viewport(void)
|
void video_driver_reset_custom_viewport(void)
|
||||||
@ -1648,7 +1652,8 @@ bool video_driver_find_driver(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned d;
|
unsigned d;
|
||||||
RARCH_ERR("Couldn't find any video driver named \"%s\"\n", settings->video.driver);
|
RARCH_ERR("Couldn't find any video driver named \"%s\"\n",
|
||||||
|
settings->video.driver);
|
||||||
RARCH_LOG_OUTPUT("Available video drivers are:\n");
|
RARCH_LOG_OUTPUT("Available video drivers are:\n");
|
||||||
for (d = 0; video_driver_find_handle(d); d++)
|
for (d = 0; video_driver_find_handle(d); d++)
|
||||||
RARCH_LOG_OUTPUT("\t%s\n", video_driver_find_ident(d));
|
RARCH_LOG_OUTPUT("\t%s\n", video_driver_find_ident(d));
|
||||||
@ -1964,7 +1969,7 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
|
|||||||
* geometry for the "normal" case. */
|
* geometry for the "normal" case. */
|
||||||
struct retro_system_av_info *av_info =
|
struct retro_system_av_info *av_info =
|
||||||
video_viewport_get_system_av_info();
|
video_viewport_get_system_av_info();
|
||||||
unsigned base_height = 0;
|
unsigned base_height = 0;
|
||||||
|
|
||||||
if (av_info)
|
if (av_info)
|
||||||
base_height = av_info->geometry.base_height;
|
base_height = av_info->geometry.base_height;
|
||||||
@ -2225,20 +2230,20 @@ bool video_driver_translate_coord_viewport(
|
|||||||
if (scaled_screen_y < -0x7fff || scaled_screen_y > 0x7fff)
|
if (scaled_screen_y < -0x7fff || scaled_screen_y > 0x7fff)
|
||||||
scaled_screen_y = -0x8000; /* OOB */
|
scaled_screen_y = -0x8000; /* OOB */
|
||||||
|
|
||||||
mouse_x -= vp->x;
|
mouse_x -= vp->x;
|
||||||
mouse_y -= vp->y;
|
mouse_y -= vp->y;
|
||||||
|
|
||||||
scaled_x = (2 * mouse_x * 0x7fff) / norm_full_vp_width - 0x7fff;
|
scaled_x = (2 * mouse_x * 0x7fff) / norm_full_vp_width - 0x7fff;
|
||||||
scaled_y = (2 * mouse_y * 0x7fff) / norm_full_vp_height - 0x7fff;
|
scaled_y = (2 * mouse_y * 0x7fff) / norm_full_vp_height - 0x7fff;
|
||||||
if (scaled_x < -0x7fff || scaled_x > 0x7fff)
|
if (scaled_x < -0x7fff || scaled_x > 0x7fff)
|
||||||
scaled_x = -0x8000; /* OOB */
|
scaled_x = -0x8000; /* OOB */
|
||||||
if (scaled_y < -0x7fff || scaled_y > 0x7fff)
|
if (scaled_y < -0x7fff || scaled_y > 0x7fff)
|
||||||
scaled_y = -0x8000; /* OOB */
|
scaled_y = -0x8000; /* OOB */
|
||||||
|
|
||||||
*res_x = scaled_x;
|
*res_x = scaled_x;
|
||||||
*res_y = scaled_y;
|
*res_y = scaled_y;
|
||||||
*res_screen_x = scaled_screen_x;
|
*res_screen_x = scaled_screen_x;
|
||||||
*res_screen_y = scaled_screen_y;
|
*res_screen_y = scaled_screen_y;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user