This commit is contained in:
parent
9bd6bfaa2c
commit
c1cb9f37dc
@ -54,6 +54,43 @@ int CActorCache::GetSizeType(int Size)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int CActorCache::ReAllocSlot(int W,int H)
|
||||
{
|
||||
int i;
|
||||
int Slot=-1;
|
||||
int SlotW=+32000,SlotH=+32000;
|
||||
|
||||
// Find best slot which fits in
|
||||
|
||||
// ASSERT(!"ReAlloc");
|
||||
for (i=0;i<SlotCount; i++)
|
||||
{
|
||||
int ThisW=(SlotList[i].Width-W);
|
||||
int ThisH=(SlotList[i].Height-H);
|
||||
|
||||
if (ThisW<SlotW || ThisH<SlotH)
|
||||
{
|
||||
Slot=i;
|
||||
SlotW=ThisW;
|
||||
SlotH=ThisH;
|
||||
}
|
||||
}
|
||||
|
||||
if (SlotList[Slot].Width<W)
|
||||
{
|
||||
// printf("Adjusted Slot Width from %i to %i\n",SlotList[Slot].Width,W);
|
||||
SlotList[Slot].Width=W;
|
||||
}
|
||||
if (SlotList[Slot].Height<H)
|
||||
{
|
||||
// printf("Adjusted Slot Height from %i to %i\n",SlotList[Slot].Height,H);
|
||||
SlotList[Slot].Height=H;
|
||||
}
|
||||
|
||||
return(Slot);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int CActorCache::GetSlot(int W,int H)
|
||||
{
|
||||
@ -70,16 +107,18 @@ int Slot=0;
|
||||
|
||||
if (!Slot)
|
||||
{ // Use New Slot
|
||||
ASSERT(SlotCount!=CACHE_TYPE_MAX);
|
||||
if (SlotCount>=CACHE_TYPE_MAX)
|
||||
{ // No free slots, grab an existing one, and alter size to fit
|
||||
Slot=ReAllocSlot(W,H);
|
||||
}
|
||||
else
|
||||
{
|
||||
Slot=SlotCount;
|
||||
SlotList[Slot].Width=W;
|
||||
SlotList[Slot].Height=H;
|
||||
|
||||
printf("Get Slot %i Slots\n",SlotCount);
|
||||
|
||||
/*bodge*/ //if (SlotCount<CACHE_W-1)
|
||||
SlotCount++;
|
||||
}
|
||||
}
|
||||
SlotList[Slot].RefCount++;
|
||||
|
||||
return(Slot);
|
||||
@ -179,7 +218,7 @@ int MaxH=0;
|
||||
|
||||
/* if (TPW<1) */TPW=1;
|
||||
|
||||
ASSERT(SlotCount<CACHE_W);
|
||||
ASSERT(SlotCount<=CACHE_W);
|
||||
|
||||
for (int i=0; i<SlotCount; i++)
|
||||
{
|
||||
|
@ -95,6 +95,7 @@ static void AddNodeList(sNodeList *Src,sNodeList *Dst);
|
||||
static u8 *UnpackBuffer;
|
||||
|
||||
protected:
|
||||
int ReAllocSlot(int W,int H);
|
||||
int GetSlot(int W,int H);
|
||||
void InitCache(int Type,int Count);
|
||||
int GetSizeType(int Size);
|
||||
|
Loading…
Reference in New Issue
Block a user