Fonts only need to be reloaded when launching a game with unloadSDL = true.

Reloading it every time the graphics are reallocated has a huge performance
impact.
This commit is contained in:
Pieter Hulshoff 2017-06-30 12:57:20 +02:00
parent a7f50c9b03
commit a22bd1c6a1
11 changed files with 181 additions and 98 deletions

View File

@ -90,6 +90,17 @@ void Component::allocateGraphicsMemory()
}
}
void Component::deInitializeFonts()
{
}
void Component::initializeFonts()
{
}
void Component::triggerEvent(std::string event, int menuIndex)
{
animationRequestedType_ = event;

View File

@ -31,6 +31,8 @@ public:
virtual ~Component();
virtual void freeGraphicsMemory();
virtual void allocateGraphicsMemory();
virtual void deInitializeFonts();
virtual void initializeFonts();
void triggerEvent(std::string event, int menuIndex = -1);
void setPlaylist(std::string name );
void setNewItemSelected();

View File

@ -101,7 +101,6 @@ void ReloadableScrollingText::update(float dt)
void ReloadableScrollingText::allocateGraphicsMemory( )
{
Component::allocateGraphicsMemory( );
fontInst_->initialize( );
reloadTexture( );
}
@ -109,11 +108,22 @@ void ReloadableScrollingText::allocateGraphicsMemory( )
void ReloadableScrollingText::freeGraphicsMemory( )
{
Component::freeGraphicsMemory( );
fontInst_->deInitialize( );
text_.clear( );
}
void ReloadableScrollingText::deInitializeFonts( )
{
fontInst_->deInitialize( );
}
void ReloadableScrollingText::initializeFonts( )
{
fontInst_->initialize( );
}
void ReloadableScrollingText::reloadTexture( )
{

View File

@ -30,6 +30,8 @@ public:
void draw( );
void allocateGraphicsMemory( );
void freeGraphicsMemory( );
void deInitializeFonts();
void initializeFonts();
private:
void reloadTexture( );

View File

@ -71,8 +71,6 @@ void ReloadableText::allocateGraphicsMemory()
{
ReloadTexture();
fontInst_->initialize();
// NOTICE! needs to be done last to prevent flags from being missed
Component::allocateGraphicsMemory();
}
@ -87,7 +85,17 @@ void ReloadableText::freeGraphicsMemory()
delete imageInst_;
imageInst_ = NULL;
}
}
void ReloadableText::initializeFonts()
{
fontInst_->initialize();
}
void ReloadableText::deInitializeFonts()
{
fontInst_->deInitialize();
}

View File

@ -1,5 +1,4 @@
/* This file is part of RetroFE.
*
/* This file is part of RetroFE. *
* RetroFE 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 Foundation, either version 3 of the License, or
@ -31,6 +30,8 @@ public:
void draw();
void freeGraphicsMemory();
void allocateGraphicsMemory();
void deInitializeFonts();
void initializeFonts();
private:
void ReloadTexture();

View File

@ -38,13 +38,21 @@ Text::~Text()
void Text::freeGraphicsMemory()
{
Component::freeGraphicsMemory();
fontInst_->deInitialize();
}
void Text::allocateGraphicsMemory()
{
//todo: make the font blend color a parameter that is passed in
Component::allocateGraphicsMemory();
}
void Text::deInitializeFonts()
{
fontInst_->deInitialize();
}
void Text::initializeFonts()
{
fontInst_->initialize();
}

View File

@ -1,5 +1,4 @@
/* This file is part of RetroFE.
*
/* This file is part of RetroFE. *
* RetroFE 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 Foundation, either version 3 of the License, or
@ -31,6 +30,8 @@ public:
void setText(std::string text);
void allocateGraphicsMemory();
void freeGraphicsMemory();
void deInitializeFonts();
void initializeFonts();
void draw();
private:

View File

@ -1049,6 +1049,42 @@ void Page::allocateGraphicsMemory()
}
void Page::deInitializeFonts()
{
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
{
for(std::vector<ScrollingList *>::iterator it2 = menus_[std::distance(menus_.begin(), it)].begin(); it2 != menus_[std::distance(menus_.begin(), it)].end(); it2++)
{
ScrollingList *menu = *it2;
menu->deInitializeFonts( );
}
}
for(std::vector<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)
{
(*it)->deInitializeFonts();
}
}
void Page::initializeFonts()
{
for(MenuVector_T::iterator it = menus_.begin(); it != menus_.end(); it++)
{
for(std::vector<ScrollingList *>::iterator it2 = menus_[std::distance(menus_.begin(), it)].begin(); it2 != menus_[std::distance(menus_.begin(), it)].end(); it2++)
{
ScrollingList *menu = *it2;
menu->initializeFonts( );
}
}
for(std::vector<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)
{
(*it)->initializeFonts( );
}
}
void Page::launchEnter()
{
if(selectSoundChunk_)

View File

@ -87,6 +87,8 @@ public:
void draw();
void freeGraphicsMemory();
void allocateGraphicsMemory();
void deInitializeFonts( );
void initializeFonts( );
void launchEnter();
std::string getCollectionName();
void setMinShowTime(float value);

View File

@ -187,6 +187,7 @@ void RetroFE::freeGraphicsMemory( )
config_.getProperty( "unloadSDL", unloadSDL );
if ( unloadSDL )
{
currentPage_->deInitializeFonts( );
SDL::deInitialize( );
}
@ -203,6 +204,7 @@ void RetroFE::allocateGraphicsMemory( )
if ( unloadSDL )
{
SDL::initialize( config_ );
currentPage_->initializeFonts( );
}
// Allocate textures