mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 17:58:53 +01:00
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:
parent
a7f50c9b03
commit
a22bd1c6a1
@ -90,6 +90,17 @@ void Component::allocateGraphicsMemory()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Component::deInitializeFonts()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Component::initializeFonts()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Component::triggerEvent(std::string event, int menuIndex)
|
void Component::triggerEvent(std::string event, int menuIndex)
|
||||||
{
|
{
|
||||||
animationRequestedType_ = event;
|
animationRequestedType_ = event;
|
||||||
|
|||||||
@ -31,6 +31,8 @@ public:
|
|||||||
virtual ~Component();
|
virtual ~Component();
|
||||||
virtual void freeGraphicsMemory();
|
virtual void freeGraphicsMemory();
|
||||||
virtual void allocateGraphicsMemory();
|
virtual void allocateGraphicsMemory();
|
||||||
|
virtual void deInitializeFonts();
|
||||||
|
virtual void initializeFonts();
|
||||||
void triggerEvent(std::string event, int menuIndex = -1);
|
void triggerEvent(std::string event, int menuIndex = -1);
|
||||||
void setPlaylist(std::string name );
|
void setPlaylist(std::string name );
|
||||||
void setNewItemSelected();
|
void setNewItemSelected();
|
||||||
|
|||||||
@ -101,7 +101,6 @@ void ReloadableScrollingText::update(float dt)
|
|||||||
void ReloadableScrollingText::allocateGraphicsMemory( )
|
void ReloadableScrollingText::allocateGraphicsMemory( )
|
||||||
{
|
{
|
||||||
Component::allocateGraphicsMemory( );
|
Component::allocateGraphicsMemory( );
|
||||||
fontInst_->initialize( );
|
|
||||||
reloadTexture( );
|
reloadTexture( );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,11 +108,22 @@ void ReloadableScrollingText::allocateGraphicsMemory( )
|
|||||||
void ReloadableScrollingText::freeGraphicsMemory( )
|
void ReloadableScrollingText::freeGraphicsMemory( )
|
||||||
{
|
{
|
||||||
Component::freeGraphicsMemory( );
|
Component::freeGraphicsMemory( );
|
||||||
fontInst_->deInitialize( );
|
|
||||||
text_.clear( );
|
text_.clear( );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ReloadableScrollingText::deInitializeFonts( )
|
||||||
|
{
|
||||||
|
fontInst_->deInitialize( );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ReloadableScrollingText::initializeFonts( )
|
||||||
|
{
|
||||||
|
fontInst_->initialize( );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ReloadableScrollingText::reloadTexture( )
|
void ReloadableScrollingText::reloadTexture( )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,8 @@ public:
|
|||||||
void draw( );
|
void draw( );
|
||||||
void allocateGraphicsMemory( );
|
void allocateGraphicsMemory( );
|
||||||
void freeGraphicsMemory( );
|
void freeGraphicsMemory( );
|
||||||
|
void deInitializeFonts();
|
||||||
|
void initializeFonts();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reloadTexture( );
|
void reloadTexture( );
|
||||||
|
|||||||
@ -71,8 +71,6 @@ void ReloadableText::allocateGraphicsMemory()
|
|||||||
{
|
{
|
||||||
ReloadTexture();
|
ReloadTexture();
|
||||||
|
|
||||||
fontInst_->initialize();
|
|
||||||
|
|
||||||
// NOTICE! needs to be done last to prevent flags from being missed
|
// NOTICE! needs to be done last to prevent flags from being missed
|
||||||
Component::allocateGraphicsMemory();
|
Component::allocateGraphicsMemory();
|
||||||
}
|
}
|
||||||
@ -87,7 +85,17 @@ void ReloadableText::freeGraphicsMemory()
|
|||||||
delete imageInst_;
|
delete imageInst_;
|
||||||
imageInst_ = NULL;
|
imageInst_ = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ReloadableText::initializeFonts()
|
||||||
|
{
|
||||||
|
fontInst_->initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ReloadableText::deInitializeFonts()
|
||||||
|
{
|
||||||
fontInst_->deInitialize();
|
fontInst_->deInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,52 +1,53 @@
|
|||||||
/* This file is part of RetroFE.
|
/* This file is part of RetroFE.
*
|
||||||
*
|
* RetroFE is free software: you can redistribute it and/or modify
|
||||||
* RetroFE is free software: you can redistribute it and/or modify
|
* it under the terms of the GNU General Public License as published by
|
||||||
* it under the terms of the GNU General Public License as published by
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* (at your option) any later version.
|
||||||
* (at your option) any later version.
|
*
|
||||||
*
|
* RetroFE is distributed in the hope that it will be useful,
|
||||||
* RetroFE is distributed in the hope that it will be useful,
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* GNU General Public License for more details.
|
||||||
* GNU General Public License for more details.
|
*
|
||||||
*
|
* You should have received a copy of the GNU General Public License
|
||||||
* You should have received a copy of the GNU General Public License
|
* along with RetroFE. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* along with RetroFE. If not, see <http://www.gnu.org/licenses/>.
|
*/
|
||||||
*/
|
#pragma once
|
||||||
#pragma once
|
#include "Component.h"
|
||||||
#include "Component.h"
|
#include "Text.h"
|
||||||
#include "Text.h"
|
#include "../Font.h"
|
||||||
#include "../Font.h"
|
#include "../Page.h"
|
||||||
#include "../Page.h"
|
#include "../../Collection/Item.h"
|
||||||
#include "../../Collection/Item.h"
|
#include <SDL2/SDL.h>
|
||||||
#include <SDL2/SDL.h>
|
#include <string>
|
||||||
#include <string>
|
|
||||||
|
class ReloadableText : public Component
|
||||||
class ReloadableText : public Component
|
{
|
||||||
{
|
public:
|
||||||
public:
|
ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, std::string textFormat, std::string singlePrefix, std::string singlePostfix, std::string pluralPrefix, std::string pluralPostfix, float scaleX, float scaleY);
|
||||||
ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, std::string textFormat, std::string singlePrefix, std::string singlePostfix, std::string pluralPrefix, std::string pluralPostfix, float scaleX, float scaleY);
|
virtual ~ReloadableText();
|
||||||
virtual ~ReloadableText();
|
void update(float dt);
|
||||||
void update(float dt);
|
void draw();
|
||||||
void draw();
|
void freeGraphicsMemory();
|
||||||
void freeGraphicsMemory();
|
void allocateGraphicsMemory();
|
||||||
void allocateGraphicsMemory();
|
void deInitializeFonts();
|
||||||
|
void initializeFonts();
|
||||||
private:
|
|
||||||
void ReloadTexture();
|
private:
|
||||||
|
void ReloadTexture();
|
||||||
Configuration &config_;
|
|
||||||
Text *imageInst_;
|
Configuration &config_;
|
||||||
std::string type_;
|
Text *imageInst_;
|
||||||
std::string layoutKey_;
|
std::string type_;
|
||||||
Font *fontInst_;
|
std::string layoutKey_;
|
||||||
std::string timeFormat_;
|
Font *fontInst_;
|
||||||
std::string textFormat_;
|
std::string timeFormat_;
|
||||||
std::string singlePrefix_;
|
std::string textFormat_;
|
||||||
std::string singlePostfix_;
|
std::string singlePrefix_;
|
||||||
std::string pluralPrefix_;
|
std::string singlePostfix_;
|
||||||
std::string pluralPostfix_;
|
std::string pluralPrefix_;
|
||||||
|
std::string pluralPostfix_;
|
||||||
float scaleX_;
|
|
||||||
float scaleY_;
|
float scaleX_;
|
||||||
};
|
float scaleY_;
|
||||||
|
};
|
||||||
|
|||||||
@ -38,13 +38,21 @@ Text::~Text()
|
|||||||
void Text::freeGraphicsMemory()
|
void Text::freeGraphicsMemory()
|
||||||
{
|
{
|
||||||
Component::freeGraphicsMemory();
|
Component::freeGraphicsMemory();
|
||||||
fontInst_->deInitialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::allocateGraphicsMemory()
|
void Text::allocateGraphicsMemory()
|
||||||
{
|
{
|
||||||
//todo: make the font blend color a parameter that is passed in
|
//todo: make the font blend color a parameter that is passed in
|
||||||
Component::allocateGraphicsMemory();
|
Component::allocateGraphicsMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Text::deInitializeFonts()
|
||||||
|
{
|
||||||
|
fontInst_->deInitialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Text::initializeFonts()
|
||||||
|
{
|
||||||
fontInst_->initialize();
|
fontInst_->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,41 +1,42 @@
|
|||||||
/* This file is part of RetroFE.
|
/* This file is part of RetroFE.
*
|
||||||
*
|
* RetroFE is free software: you can redistribute it and/or modify
|
||||||
* RetroFE is free software: you can redistribute it and/or modify
|
* it under the terms of the GNU General Public License as published by
|
||||||
* it under the terms of the GNU General Public License as published by
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* (at your option) any later version.
|
||||||
* (at your option) any later version.
|
*
|
||||||
*
|
* RetroFE is distributed in the hope that it will be useful,
|
||||||
* RetroFE is distributed in the hope that it will be useful,
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* GNU General Public License for more details.
|
||||||
* GNU General Public License for more details.
|
*
|
||||||
*
|
* You should have received a copy of the GNU General Public License
|
||||||
* You should have received a copy of the GNU General Public License
|
* along with RetroFE. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* along with RetroFE. If not, see <http://www.gnu.org/licenses/>.
|
*/
|
||||||
*/
|
#pragma once
|
||||||
#pragma once
|
|
||||||
|
#include "Component.h"
|
||||||
#include "Component.h"
|
#include "../Page.h"
|
||||||
#include "../Page.h"
|
#include <SDL2/SDL.h>
|
||||||
#include <SDL2/SDL.h>
|
#include <vector>
|
||||||
#include <vector>
|
|
||||||
|
class Font;
|
||||||
class Font;
|
|
||||||
|
class Text : public Component
|
||||||
class Text : public Component
|
{
|
||||||
{
|
public:
|
||||||
public:
|
//todo: should have a Font flass that references fontcache, pass that in as an argument
|
||||||
//todo: should have a Font flass that references fontcache, pass that in as an argument
|
Text(std::string text, Page &p, Font *font, float scaleX, float scaleY);
|
||||||
Text(std::string text, Page &p, Font *font, float scaleX, float scaleY);
|
virtual ~Text();
|
||||||
virtual ~Text();
|
void setText(std::string text);
|
||||||
void setText(std::string text);
|
void allocateGraphicsMemory();
|
||||||
void allocateGraphicsMemory();
|
void freeGraphicsMemory();
|
||||||
void freeGraphicsMemory();
|
void deInitializeFonts();
|
||||||
void draw();
|
void initializeFonts();
|
||||||
|
void draw();
|
||||||
private:
|
|
||||||
std::string textData_;
|
private:
|
||||||
Font *fontInst_;
|
std::string textData_;
|
||||||
float scaleX_;
|
Font *fontInst_;
|
||||||
float scaleY_;
|
float scaleX_;
|
||||||
};
|
float scaleY_;
|
||||||
|
};
|
||||||
|
|||||||
@ -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()
|
void Page::launchEnter()
|
||||||
{
|
{
|
||||||
if(selectSoundChunk_)
|
if(selectSoundChunk_)
|
||||||
|
|||||||
@ -87,6 +87,8 @@ public:
|
|||||||
void draw();
|
void draw();
|
||||||
void freeGraphicsMemory();
|
void freeGraphicsMemory();
|
||||||
void allocateGraphicsMemory();
|
void allocateGraphicsMemory();
|
||||||
|
void deInitializeFonts( );
|
||||||
|
void initializeFonts( );
|
||||||
void launchEnter();
|
void launchEnter();
|
||||||
std::string getCollectionName();
|
std::string getCollectionName();
|
||||||
void setMinShowTime(float value);
|
void setMinShowTime(float value);
|
||||||
|
|||||||
@ -187,6 +187,7 @@ void RetroFE::freeGraphicsMemory( )
|
|||||||
config_.getProperty( "unloadSDL", unloadSDL );
|
config_.getProperty( "unloadSDL", unloadSDL );
|
||||||
if ( unloadSDL )
|
if ( unloadSDL )
|
||||||
{
|
{
|
||||||
|
currentPage_->deInitializeFonts( );
|
||||||
SDL::deInitialize( );
|
SDL::deInitialize( );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,6 +204,7 @@ void RetroFE::allocateGraphicsMemory( )
|
|||||||
if ( unloadSDL )
|
if ( unloadSDL )
|
||||||
{
|
{
|
||||||
SDL::initialize( config_ );
|
SDL::initialize( config_ );
|
||||||
|
currentPage_->initializeFonts( );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate textures
|
// Allocate textures
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user