Jeck - Cache and resource manager merged, streamlined.

This is pretty major, so there'll probably be something wrong with it... even though I did spend a few hours looking.
NOTES:
 * If you've Retrieved it, don't delete it--- Use resources.Release(Whatever). 
    Textures automatically release subordinate quads.
 * Most of the time, use resources.RetrieveQuad to grab a quad. Should handle everything for you.
    RetrieveQuad will load the required texture, if needed.
    Only managed resources have a resource name ("back", "simon", etc). 
    Managed resources can be retrieved with GetTexture/GetQuad/GetWhatever.
    Non managed quads lookup by position/dimensions, defaulting to the whole texture.
 * Use resources.RetrieveTexture only when you need to do something special to it. 
    Calling retrieve texture with RETRIEVE_MANAGE will permanently add a texture to the manager
    RETRIEVE_LOCK and RETRIEVE_VRAM will lock a texture. It will not leave the cache until
    Release(JTexture*) is called, or as a last resort during cache overflow.
 * Try to only store (as a class member) pointers to textures retrieved with RETRIEVE_MANAGE. 
    All others may become invalid, although locked textures do have a high degree of stability. It's
    pretty safe to store a locked texture if you're not going to load much between uses.

There's a lot going on here, so I might have missed something... but it runs through the test suite alright.

TODO: 
 * When called without any arguments, RetrieveQuad sometimes leaves a thin border around the image. 
    This can be bypassed by specifying a quad one or two pixels less than the image size. Why?
 * I've had a crash while runing the Demo mode, something to do with receiveEventMinus? 
    This hasn't exactly reproduced on a clean SVN copy, (being a hang, rather than a crash) so 
    I've probably done something to worsen the problem somehow? I'll look into it tomorrow.
 * Clean up lock/unlock system, memory usage. Streamline interface, consider phasing out calls using GetWhatever() format.
This commit is contained in:
wagic.jeck
2009-09-03 09:28:16 +00:00
parent 7214248494
commit f220d2e9b9
49 changed files with 1587 additions and 1233 deletions

View File

@@ -46,7 +46,7 @@ OptionItem::OptionItem( string _id, string _displayValue) {
//Option Integer
void OptionInteger::Render(){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
JLBFont * mFont = resources.GetJLBFont("f3");
if (hasFocus){
mFont->SetColor(options[Metrics::OPTION_ITEM_TCH].asColor(ARGB(255,255,255,0)));
}else{
@@ -106,7 +106,7 @@ void OptionSelect::initSelections(){
}
void OptionSelect::Render(){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
JLBFont * mFont = resources.GetJLBFont("f3");
if (hasFocus){
mFont->SetColor(options[Metrics::OPTION_ITEM_TCH].asColor(ARGB(255,255,255,0)));
}else{
@@ -148,7 +148,7 @@ ostream& OptionSelect::toString(ostream& out) const
//OptionHeader
void OptionHeader::Render(){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
JLBFont * mFont = resources.GetJLBFont("f3");
mFont->SetColor(options[Metrics::OPTION_HEADER_TC].asColor());
JRenderer * renderer = JRenderer::GetInstance();
@@ -157,7 +157,7 @@ void OptionHeader::Render(){
}
void OptionText::Render(){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
JLBFont * mFont = resources.GetJLBFont("f3");
mFont->SetScale(.8);
mFont->SetColor(options[Metrics::OPTION_TEXT_TC].asColor());
@@ -245,7 +245,7 @@ void OptionProfile::populate(){
void OptionProfile::Render(){
JRenderer * renderer = JRenderer::GetInstance();
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
JLBFont * mFont = resources.GetJLBFont("f3");
mFont->SetScale(1);
int spacing = 2+(int)mFont->GetHeight();
@@ -430,7 +430,7 @@ void OptionsList::Render(){
//List is empty.
if (!nbitems && failMsg != ""){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
JLBFont * mFont = resources.GetJLBFont("f3");
mFont->SetColor(options[Metrics::MSG_FAIL_TC].asColor(ARGB(255,155,155,155)));
mFont->DrawString(failMsg.c_str(),SCREEN_WIDTH/2, 40, JGETEXT_RIGHT);
return;
@@ -623,7 +623,7 @@ void OptionsMenu::Update(float dt){
OptionsMenu::OptionsMenu(){
nbitems=0;
current=0;
mFont = GameApp::CommonRes->GetJLBFont("f3");
mFont = resources.GetJLBFont("f3");
for(int x=0;x<MAX_OPTION_TABS;x++)
tabs[x] = NULL;
}
@@ -705,7 +705,7 @@ void OptionsList::cancelSubmode()
void OptionString::Render(){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
JLBFont * mFont = resources.GetJLBFont("f3");
if (hasFocus){
mFont->SetColor(options[Metrics::OPTION_ITEM_TCH].asColor(ARGB(255,255,255,0)));
}else{