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 <JResourceManager.h>
|
||||||
#include <JSoundSystem.h>
|
#include <JSoundSystem.h>
|
||||||
|
|
||||||
|
const std::string kGenericCardID = "back";
|
||||||
|
const std::string kGenericCardThumbnailID = "back_thumb";
|
||||||
|
|
||||||
enum ENUM_WRES_INFO
|
enum ENUM_WRES_INFO
|
||||||
{
|
{
|
||||||
WRES_UNLOCKED = 0, //Resource is unlocked.
|
WRES_UNLOCKED = 0, //Resource is unlocked.
|
||||||
|
|||||||
@@ -164,12 +164,12 @@ void GameApp::Create()
|
|||||||
|
|
||||||
LOG("--Loading back.jpg");
|
LOG("--Loading back.jpg");
|
||||||
WResourceManager::Instance()->RetrieveTexture("back.jpg", RETRIEVE_MANAGE);
|
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())
|
if (jq.get())
|
||||||
jq->SetHotSpot(jq->mWidth / 2, jq->mHeight / 2);
|
jq->SetHotSpot(jq->mWidth / 2, jq->mHeight / 2);
|
||||||
|
|
||||||
WResourceManager::Instance()->RetrieveTexture("back_thumb.jpg", RETRIEVE_MANAGE);
|
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");
|
LOG("--Loading particles.png");
|
||||||
WResourceManager::Instance()->RetrieveTexture("particles.png", RETRIEVE_MANAGE);
|
WResourceManager::Instance()->RetrieveTexture("particles.png", RETRIEVE_MANAGE);
|
||||||
|
|||||||
@@ -1316,7 +1316,7 @@ void GameStateDeckViewer::renderCard(int id, float rotation)
|
|||||||
|
|
||||||
if (!WResourceManager::Instance()->IsThreaded())
|
if (!WResourceManager::Instance()->IsThreaded())
|
||||||
{
|
{
|
||||||
JQuadPtr backQuad = WResourceManager::Instance()->GetQuad("back");
|
JQuadPtr backQuad = WResourceManager::Instance()->GetQuad(kGenericCardID);
|
||||||
JQuadPtr quad;
|
JQuadPtr quad;
|
||||||
|
|
||||||
int cacheError = CACHE_ERROR_NONE;
|
int cacheError = CACHE_ERROR_NONE;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include "GameObserver.h"
|
#include "GameObserver.h"
|
||||||
#include "Rules.h"
|
#include "Rules.h"
|
||||||
|
|
||||||
|
const std::string kBackdropFile = "backdrop.jpg";
|
||||||
|
|
||||||
GuiBackground::GuiBackground()
|
GuiBackground::GuiBackground()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -24,7 +26,7 @@ void GuiBackground::Render()
|
|||||||
}
|
}
|
||||||
if (!quad.get())
|
if (!quad.get())
|
||||||
{
|
{
|
||||||
quad = WResourceManager::Instance()->RetrieveTempQuad("backdrop.jpg");
|
quad = WResourceManager::Instance()->RetrieveTempQuad(kBackdropFile);
|
||||||
}
|
}
|
||||||
if (quad.get())
|
if (quad.get())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ GuiHandOpponent::GuiHandOpponent(MTGHand* hand) :
|
|||||||
|
|
||||||
void GuiHandOpponent::Render()
|
void GuiHandOpponent::Render()
|
||||||
{
|
{
|
||||||
JQuadPtr quad = WResourceManager::Instance()->GetQuad("back_thumb");
|
JQuadPtr quad = WResourceManager::Instance()->GetQuad(kGenericCardThumbnailID);
|
||||||
|
|
||||||
float x = 45;
|
float x = 45;
|
||||||
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ void GuiGameZone::toggleDisplay()
|
|||||||
void GuiGameZone::Render()
|
void GuiGameZone::Render()
|
||||||
{
|
{
|
||||||
//Texture
|
//Texture
|
||||||
JQuadPtr quad = WResourceManager::Instance()->GetQuad("back_thumb");
|
JQuadPtr quad = WResourceManager::Instance()->GetQuad(kGenericCardThumbnailID);
|
||||||
float scale = defaultHeight / quad->mHeight;
|
float scale = defaultHeight / quad->mHeight;
|
||||||
quad->SetColor(ARGB((int)(actA),255,255,255));
|
quad->SetColor(ARGB((int)(actA),255,255,255));
|
||||||
|
|
||||||
|
|||||||
@@ -1359,14 +1359,14 @@ void WGuiCardImage::Render()
|
|||||||
JQuadPtr q;
|
JQuadPtr q;
|
||||||
if (bThumb)
|
if (bThumb)
|
||||||
{
|
{
|
||||||
q = WResourceManager::Instance()->GetQuad("back_thumb");
|
q = WResourceManager::Instance()->GetQuad(kGenericCardThumbnailID);
|
||||||
#if defined WIN32 || defined LINUX
|
#if defined WIN32 || defined LINUX
|
||||||
if(!q)
|
if(!q)
|
||||||
q = WResourceManager::Instance()->GetQuad("back");
|
q = WResourceManager::Instance()->GetQuad(kGenericCardID);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
q = WResourceManager::Instance()->GetQuad("back");
|
q = WResourceManager::Instance()->GetQuad(kGenericCardID);
|
||||||
float scale = p.actZ * 257.f / q->mHeight;
|
float scale = p.actZ * 257.f / q->mHeight;
|
||||||
q->SetColor(ARGB(255,255,255,255));
|
q->SetColor(ARGB(255,255,255,255));
|
||||||
renderer->RenderQuad(q.get(), p.x, p.y, 0, scale, scale);
|
renderer->RenderQuad(q.get(), p.x, p.y, 0, scale, scale);
|
||||||
@@ -1429,14 +1429,14 @@ void WGuiCardDistort::Render()
|
|||||||
//Default to back.
|
//Default to back.
|
||||||
if (bThumb)
|
if (bThumb)
|
||||||
{
|
{
|
||||||
q = WResourceManager::Instance()->GetQuad("back_thumb");
|
q = WResourceManager::Instance()->GetQuad(kGenericCardThumbnailID);
|
||||||
#if defined WIN32 || defined LINUX
|
#if defined WIN32 || defined LINUX
|
||||||
if(!q)
|
if(!q)
|
||||||
q = WResourceManager::Instance()->GetQuad("back");
|
q = WResourceManager::Instance()->GetQuad(kGenericCardID);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
q = WResourceManager::Instance()->GetQuad("back");
|
q = WResourceManager::Instance()->GetQuad(kGenericCardID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user