mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 09:48:51 +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)
|
||||
{
|
||||
animationRequestedType_ = event;
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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( )
|
||||
{
|
||||
|
||||
|
||||
@ -30,6 +30,8 @@ public:
|
||||
void draw( );
|
||||
void allocateGraphicsMemory( );
|
||||
void freeGraphicsMemory( );
|
||||
void deInitializeFonts();
|
||||
void initializeFonts();
|
||||
|
||||
private:
|
||||
void reloadTexture( );
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -1,52 +1,53 @@
|
||||
/* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* RetroFE 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 RetroFE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include "Component.h"
|
||||
#include "Text.h"
|
||||
#include "../Font.h"
|
||||
#include "../Page.h"
|
||||
#include "../../Collection/Item.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <string>
|
||||
|
||||
class ReloadableText : public Component
|
||||
{
|
||||
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);
|
||||
virtual ~ReloadableText();
|
||||
void update(float dt);
|
||||
void draw();
|
||||
void freeGraphicsMemory();
|
||||
void allocateGraphicsMemory();
|
||||
|
||||
private:
|
||||
void ReloadTexture();
|
||||
|
||||
Configuration &config_;
|
||||
Text *imageInst_;
|
||||
std::string type_;
|
||||
std::string layoutKey_;
|
||||
Font *fontInst_;
|
||||
std::string timeFormat_;
|
||||
std::string textFormat_;
|
||||
std::string singlePrefix_;
|
||||
std::string singlePostfix_;
|
||||
std::string pluralPrefix_;
|
||||
std::string pluralPostfix_;
|
||||
|
||||
float scaleX_;
|
||||
float scaleY_;
|
||||
};
|
||||
/* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* RetroFE 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 RetroFE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include "Component.h"
|
||||
#include "Text.h"
|
||||
#include "../Font.h"
|
||||
#include "../Page.h"
|
||||
#include "../../Collection/Item.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <string>
|
||||
|
||||
class ReloadableText : public Component
|
||||
{
|
||||
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);
|
||||
virtual ~ReloadableText();
|
||||
void update(float dt);
|
||||
void draw();
|
||||
void freeGraphicsMemory();
|
||||
void allocateGraphicsMemory();
|
||||
void deInitializeFonts();
|
||||
void initializeFonts();
|
||||
|
||||
private:
|
||||
void ReloadTexture();
|
||||
|
||||
Configuration &config_;
|
||||
Text *imageInst_;
|
||||
std::string type_;
|
||||
std::string layoutKey_;
|
||||
Font *fontInst_;
|
||||
std::string timeFormat_;
|
||||
std::string textFormat_;
|
||||
std::string singlePrefix_;
|
||||
std::string singlePostfix_;
|
||||
std::string pluralPrefix_;
|
||||
std::string pluralPostfix_;
|
||||
|
||||
float scaleX_;
|
||||
float scaleY_;
|
||||
};
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -1,41 +1,42 @@
|
||||
/* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* RetroFE 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 RetroFE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Component.h"
|
||||
#include "../Page.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <vector>
|
||||
|
||||
class Font;
|
||||
|
||||
class Text : public Component
|
||||
{
|
||||
public:
|
||||
//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);
|
||||
virtual ~Text();
|
||||
void setText(std::string text);
|
||||
void allocateGraphicsMemory();
|
||||
void freeGraphicsMemory();
|
||||
void draw();
|
||||
|
||||
private:
|
||||
std::string textData_;
|
||||
Font *fontInst_;
|
||||
float scaleX_;
|
||||
float scaleY_;
|
||||
};
|
||||
/* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* RetroFE 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 RetroFE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Component.h"
|
||||
#include "../Page.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <vector>
|
||||
|
||||
class Font;
|
||||
|
||||
class Text : public Component
|
||||
{
|
||||
public:
|
||||
//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);
|
||||
virtual ~Text();
|
||||
void setText(std::string text);
|
||||
void allocateGraphicsMemory();
|
||||
void freeGraphicsMemory();
|
||||
void deInitializeFonts();
|
||||
void initializeFonts();
|
||||
void draw();
|
||||
|
||||
private:
|
||||
std::string textData_;
|
||||
Font *fontInst_;
|
||||
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()
|
||||
{
|
||||
if(selectSoundChunk_)
|
||||
|
||||
@ -87,6 +87,8 @@ public:
|
||||
void draw();
|
||||
void freeGraphicsMemory();
|
||||
void allocateGraphicsMemory();
|
||||
void deInitializeFonts( );
|
||||
void initializeFonts( );
|
||||
void launchEnter();
|
||||
std::string getCollectionName();
|
||||
void setMinShowTime(float value);
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user