Consolidated some loose strings into constant declarations in order to reduce allocation thrashing on temporary string constructs. I'm sure there are more, but "back_thumb", "back", and "backdrop.jpg" were the ones that showed up most in memory profiling.
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
#include <JResourceManager.h>
|
||||
#include <JSoundSystem.h>
|
||||
|
||||
const std::string kGenericCardID = "back";
|
||||
const std::string kGenericCardThumbnailID = "back_thumb";
|
||||
|
||||
enum ENUM_WRES_INFO
|
||||
{
|
||||
WRES_UNLOCKED = 0, //Resource is unlocked.
|
||||
|
||||
@@ -164,12 +164,12 @@ void GameApp::Create()
|
||||
|
||||
LOG("--Loading back.jpg");
|
||||
WResourceManager::Instance()->RetrieveTexture("back.jpg", RETRIEVE_MANAGE);
|
||||
JQuadPtr jq = WResourceManager::Instance()->RetrieveQuad("back.jpg", 0, 0, 0, 0, "back", RETRIEVE_MANAGE);
|
||||
JQuadPtr jq = WResourceManager::Instance()->RetrieveQuad("back.jpg", 0, 0, 0, 0, kGenericCardID, RETRIEVE_MANAGE);
|
||||
if (jq.get())
|
||||
jq->SetHotSpot(jq->mWidth / 2, jq->mHeight / 2);
|
||||
|
||||
WResourceManager::Instance()->RetrieveTexture("back_thumb.jpg", RETRIEVE_MANAGE);
|
||||
WResourceManager::Instance()->RetrieveQuad("back_thumb.jpg", 0, 0, MTG_MINIIMAGE_WIDTH, MTG_MINIIMAGE_HEIGHT, "back_thumb", RETRIEVE_MANAGE);
|
||||
WResourceManager::Instance()->RetrieveQuad("back_thumb.jpg", 0, 0, MTG_MINIIMAGE_WIDTH, MTG_MINIIMAGE_HEIGHT, kGenericCardThumbnailID, RETRIEVE_MANAGE);
|
||||
|
||||
LOG("--Loading particles.png");
|
||||
WResourceManager::Instance()->RetrieveTexture("particles.png", RETRIEVE_MANAGE);
|
||||
|
||||
@@ -1316,7 +1316,7 @@ void GameStateDeckViewer::renderCard(int id, float rotation)
|
||||
|
||||
if (!WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
JQuadPtr backQuad = WResourceManager::Instance()->GetQuad("back");
|
||||
JQuadPtr backQuad = WResourceManager::Instance()->GetQuad(kGenericCardID);
|
||||
JQuadPtr quad;
|
||||
|
||||
int cacheError = CACHE_ERROR_NONE;
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "GameObserver.h"
|
||||
#include "Rules.h"
|
||||
|
||||
const std::string kBackdropFile = "backdrop.jpg";
|
||||
|
||||
GuiBackground::GuiBackground()
|
||||
{
|
||||
}
|
||||
@@ -24,7 +26,7 @@ void GuiBackground::Render()
|
||||
}
|
||||
if (!quad.get())
|
||||
{
|
||||
quad = WResourceManager::Instance()->RetrieveTempQuad("backdrop.jpg");
|
||||
quad = WResourceManager::Instance()->RetrieveTempQuad(kBackdropFile);
|
||||
}
|
||||
if (quad.get())
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ GuiHandOpponent::GuiHandOpponent(MTGHand* hand) :
|
||||
|
||||
void GuiHandOpponent::Render()
|
||||
{
|
||||
JQuadPtr quad = WResourceManager::Instance()->GetQuad("back_thumb");
|
||||
JQuadPtr quad = WResourceManager::Instance()->GetQuad(kGenericCardThumbnailID);
|
||||
|
||||
float x = 45;
|
||||
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||
|
||||
@@ -151,7 +151,7 @@ void GuiGameZone::toggleDisplay()
|
||||
void GuiGameZone::Render()
|
||||
{
|
||||
//Texture
|
||||
JQuadPtr quad = WResourceManager::Instance()->GetQuad("back_thumb");
|
||||
JQuadPtr quad = WResourceManager::Instance()->GetQuad(kGenericCardThumbnailID);
|
||||
float scale = defaultHeight / quad->mHeight;
|
||||
quad->SetColor(ARGB((int)(actA),255,255,255));
|
||||
|
||||
|
||||
@@ -1359,14 +1359,14 @@ void WGuiCardImage::Render()
|
||||
JQuadPtr q;
|
||||
if (bThumb)
|
||||
{
|
||||
q = WResourceManager::Instance()->GetQuad("back_thumb");
|
||||
q = WResourceManager::Instance()->GetQuad(kGenericCardThumbnailID);
|
||||
#if defined WIN32 || defined LINUX
|
||||
if(!q)
|
||||
q = WResourceManager::Instance()->GetQuad("back");
|
||||
q = WResourceManager::Instance()->GetQuad(kGenericCardID);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
q = WResourceManager::Instance()->GetQuad("back");
|
||||
q = WResourceManager::Instance()->GetQuad(kGenericCardID);
|
||||
float scale = p.actZ * 257.f / q->mHeight;
|
||||
q->SetColor(ARGB(255,255,255,255));
|
||||
renderer->RenderQuad(q.get(), p.x, p.y, 0, scale, scale);
|
||||
@@ -1429,14 +1429,14 @@ void WGuiCardDistort::Render()
|
||||
//Default to back.
|
||||
if (bThumb)
|
||||
{
|
||||
q = WResourceManager::Instance()->GetQuad("back_thumb");
|
||||
q = WResourceManager::Instance()->GetQuad(kGenericCardThumbnailID);
|
||||
#if defined WIN32 || defined LINUX
|
||||
if(!q)
|
||||
q = WResourceManager::Instance()->GetQuad("back");
|
||||
q = WResourceManager::Instance()->GetQuad(kGenericCardID);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
q = WResourceManager::Instance()->GetQuad("back");
|
||||
q = WResourceManager::Instance()->GetQuad(kGenericCardID);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user