Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

BitmapList.h File Reference

#include "GeTypes.h"
#include "DCommon.h"
#include "Bitmap.h"

Go to the source code of this file.

Typedefs

typedef BitmapList BitmapList

Functions

BitmapListBitmapList_Create (void)
geBoolean BitmapList_Destroy (BitmapList *pList)
geBoolean BitmapList_SetGamma (BitmapList *pList, geFloat Gamma)
geBoolean BitmapList_AttachAll (BitmapList *pList, DRV_Driver *Drivera, geFloat Gamma)
geBoolean BitmapList_DetachAll (BitmapList *pList)
geBoolean BitmapList_Add (BitmapList *pList, geBitmap *Bitmap)
geBoolean BitmapList_Remove (BitmapList *pList, geBitmap *Bitmap)
geBoolean BitmapList_Has (BitmapList *pList, geBitmap *Bitmap)
int BitmapList_CountMembers (BitmapList *pList)
int BitmapList_CountMembersAttached (BitmapList *pList)


Typedef Documentation

typedef struct BitmapList BitmapList
 

Definition at line 29 of file BitmapList.h.


Function Documentation

geBoolean BitmapList_Add BitmapList pList,
geBitmap Bitmap
 

Definition at line 294 of file BitmapList.c.

References BitmapList::Adds, BitmapList_IsValid(), GE_FALSE, GE_TRUE, geBitmap_CreateRef(), geBoolean, BitmapList::Hash, Hash_Add(), Hash_Get(), HashNode_SetData(), BitmapList::Members, NULL, and uint32.

Referenced by geEngine_AddBitmap(), and geWorld_AddBitmap().

00295 {       
00296 HashNode *pNode;
00297 uint32 TimesAdded;
00298 
00299         assert(BitmapList_IsValid(pList));
00300         assert(Bitmap);
00301 
00302         // Increase reference count on this Bitmap
00303         geBitmap_CreateRef(Bitmap);
00304 
00305         pList->Adds ++;
00306 
00307         if ( (pNode = Hash_Get(pList->Hash, (uint32)Bitmap, &TimesAdded)) != NULL )
00308         {
00309                 HashNode_SetData(pNode,TimesAdded+1);
00310                 return GE_FALSE;
00311         }
00312         else
00313         {
00314                 pList->Members ++;
00315                 Hash_Add(pList->Hash,(uint32)Bitmap,1);
00316                 return GE_TRUE;
00317         }
00318 }

geBoolean BitmapList_AttachAll BitmapList pList,
DRV_Driver Drivera,
geFloat  Gamma
 

Definition at line 160 of file BitmapList.c.

References BitmapList_IsValid(), GE_FALSE, GE_TRUE, geBitmap_AttachToDriver(), geBitmap_SetGammaCorrection_DontChange(), geBoolean, geErrorLog_AddString, BitmapList::Hash, Hash_WalkNext(), HashNode_Key(), BitmapList::Members, and NULL.

Referenced by geEngine_AttachAll(), and geWorld_AttachAll().

00161 {
00162 HashNode *pNode;
00163 int MembersAttached;
00164 
00165         assert(BitmapList_IsValid(pList));
00166 
00167         //pushTSC();
00168 
00169         pNode = NULL;
00170         MembersAttached = 0;
00171         while( (pNode = Hash_WalkNext(pList->Hash,pNode)) != NULL )
00172         {
00173         geBitmap *Bmp;
00174 
00175                 Bmp = (geBitmap *)HashNode_Key(pNode);
00176 
00177                 if (!geBitmap_SetGammaCorrection_DontChange(Bmp, Gamma) )
00178                 {
00179                         geErrorLog_AddString(-1,"BitmapList_AttachAll : SetGamma failed", NULL);
00180                         return GE_FALSE;
00181                 }
00182 
00183                 if (!geBitmap_AttachToDriver(Bmp, Driver, 0) )
00184                 {
00185                         geErrorLog_AddString(-1,"BitmapList_AttachAll : AttachToDriver failed", NULL);
00186                         return GE_FALSE;
00187                 }
00188 
00189                 MembersAttached ++;
00190         }
00191 
00192         //showPopTSC("BitmapList_AttachAll");
00193 
00194         assert( MembersAttached == pList->Members );
00195 
00196         return GE_TRUE;
00197 }

int BitmapList_CountMembers BitmapList pList  ) 
 

Definition at line 230 of file BitmapList.c.

References BitmapList::Adds, BitmapList::Hash, Hash_WalkNext(), BitmapList::Members, and NULL.

Referenced by BitmapList_IsValid().

00231 {
00232 #ifdef NDEBUG
00233         return pList->Members;
00234 #else
00235 HashNode *pNode;
00236 int Count;
00237 
00238         Count = 0;
00239         pNode = NULL;
00240         while( (pNode = Hash_WalkNext(pList->Hash,pNode)) != NULL )
00241         {
00242                 Count ++;
00243         }
00244 
00245         assert( Count == pList->Members );
00246         assert( pList->Adds >= pList->Members );
00247 
00248 return Count;
00249 #endif
00250 }

int BitmapList_CountMembersAttached BitmapList pList  ) 
 

Definition at line 251 of file BitmapList.c.

References BitmapList::Adds, geBitmap_GetTHandle(), BitmapList::Hash, Hash_WalkNext(), HashNode_GetData(), BitmapList::Members, NULL, and uint32.

Referenced by geEngine_BitmapListShutdown().

00252 {
00253 HashNode *pNode;
00254 int Count;
00255 
00256         Count = 0;
00257         pNode = NULL;
00258         while( (pNode = Hash_WalkNext(pList->Hash,pNode)) != NULL )
00259         {
00260         geBitmap *Bmp;
00261         uint32 TimesAdded;
00262 
00263                 HashNode_GetData(pNode,(uint32 *)&Bmp,&TimesAdded);
00264 
00265                 if ( geBitmap_GetTHandle(Bmp) )
00266                         Count ++;
00267         }
00268 
00269         assert( pList->Adds >= pList->Members && pList->Members >= Count );
00270 
00271 return Count;
00272 }

BitmapList* BitmapList_Create void   ) 
 

Definition at line 57 of file BitmapList.c.

References geRam_Allocate, geRam_Free, BitmapList::Hash, Hash_Create(), and NULL.

Referenced by geEngine_BitmapListInit(), and geWorld_BitmapListInit().

00058 {
00059 BitmapList * pList;
00060         pList = geRam_Allocate(sizeof(*pList));
00061         if (! pList )
00062                 return NULL;
00063         memset(pList,0,sizeof(*pList));
00064         pList->Hash = Hash_Create();
00065         if ( ! pList->Hash )
00066         {
00067                 geRam_Free(pList);
00068                 return NULL;
00069         }
00070         #ifdef _DEBUG
00071         pList->MySelf = pList;
00072         #endif
00073 return pList;
00074 }

geBoolean BitmapList_Destroy BitmapList pList  ) 
 

Definition at line 79 of file BitmapList.c.

References BitmapList::Adds, GE_FALSE, GE_TRUE, geBitmap_Destroy(), geBitmap_DetachDriver(), geBoolean, geRam_Free, BitmapList::Hash, Hash_Destroy(), Hash_WalkNext(), HashNode_GetData(), BitmapList::Members, NULL, and uint32.

Referenced by geEngine_BitmapListShutdown(), and geWorld_BitmapListShutdown().

00080 {
00081 geBoolean       Ret = GE_TRUE;
00082 
00083         if ( ! pList )
00084                 return GE_TRUE;
00085 
00086         if ( pList->Hash )
00087         {
00088         HashNode        *pNode;
00089                 pNode = NULL;
00090                 
00091                 while( (pNode = Hash_WalkNext(pList->Hash,pNode)) != NULL )
00092                 {
00093                 geBitmap *Bmp;
00094                 uint32 TimesAdded;
00095 
00096                         HashNode_GetData(pNode,(uint32 *)&Bmp,&TimesAdded);
00097 
00098                         if (!geBitmap_DetachDriver(Bmp, GE_TRUE))
00099                                 Ret = GE_FALSE;
00100 
00101                         assert( pList->Members >= 1 && pList->Adds >= (int)TimesAdded );
00102 
00103                         pList->Members --;
00104 
00105                         assert( TimesAdded >= 1 );
00106 
00107                         while(TimesAdded --)
00108                         {
00109                                 assert(Bmp);
00110                                 geBitmap_Destroy(&Bmp);
00111                                 pList->Adds --;
00112                         }
00113                 }
00114 
00115                 // Finally, destroy the entire hash table
00116                 Hash_Destroy(pList->Hash);
00117         }
00118 
00119         geRam_Free(pList);
00120 
00121         return Ret;
00122 }

geBoolean BitmapList_DetachAll BitmapList pList  ) 
 

Definition at line 202 of file BitmapList.c.

References BitmapList_IsValid(), GE_FALSE, GE_TRUE, geBitmap_DetachDriver(), geBoolean, BitmapList::Hash, Hash_WalkNext(), HashNode_GetData(), NULL, and uint32.

Referenced by geEngine_DetachAll(), and geWorld_DetachAll().

00203 {
00204 HashNode        *pNode;
00205 geBoolean       Ret = GE_TRUE;
00206 int MembersAttached;
00207 
00208         assert(BitmapList_IsValid(pList));
00209 
00210         pNode = NULL;
00211         while( (pNode = Hash_WalkNext(pList->Hash,pNode)) != NULL )
00212         {
00213         geBitmap *Bmp;
00214         uint32 TimesAdded;
00215 
00216                 HashNode_GetData(pNode,(uint32 *)&Bmp,&TimesAdded);
00217 
00218                 if (!geBitmap_DetachDriver(Bmp, GE_TRUE))
00219                         Ret = GE_FALSE;
00220         }
00221 
00222         MembersAttached = 0;
00223 
00224         return Ret;
00225 }

geBoolean BitmapList_Has BitmapList pList,
geBitmap Bitmap
 

Definition at line 277 of file BitmapList.c.

References BitmapList::Adds, GE_FALSE, GE_TRUE, geBoolean, BitmapList::Hash, Hash_Get(), and uint32.

Referenced by geEngine_DrawBitmap(), and geWorld_HasBitmap().

00278 {
00279 HashNode *pNode;
00280 uint32 TimesAdded;
00281 
00282         assert(pList && Bitmap);
00283 
00284         pNode = Hash_Get(pList->Hash,(uint32)Bitmap,&TimesAdded);
00285 
00286         assert( pList->Adds >= (int)TimesAdded );
00287 
00288 return (pNode && TimesAdded) ? GE_TRUE : GE_FALSE;
00289 }

geBoolean BitmapList_Remove BitmapList pList,
geBitmap Bitmap
 

Definition at line 323 of file BitmapList.c.

References BitmapList::Adds, BitmapList_IsValid(), GE_FALSE, GE_TRUE, geBitmap_Destroy(), geBitmap_DetachDriver(), geBoolean, geErrorLog_AddString, BitmapList::Hash, Hash_DeleteNode(), Hash_Get(), HashNode_SetData(), BitmapList::Members, NULL, and uint32.

Referenced by geEngine_RemoveBitmap(), and geWorld_RemoveBitmap().

00324 {
00325 HashNode *pNode;
00326 uint32 TimesAdded;
00327 uint32 Key;
00328 
00329         assert(BitmapList_IsValid(pList));
00330         assert(Bitmap);
00331 
00332         Key = (uint32) Bitmap;
00333         pNode = Hash_Get(pList->Hash,Key,&TimesAdded);
00334 
00335         assert(pNode);
00336 
00337         pList->Adds --;
00338         TimesAdded --;
00339 
00340         if ( TimesAdded <= 0 )
00341         {
00342                 if ( ! geBitmap_DetachDriver(Bitmap, GE_TRUE) )
00343                 {
00344                         geErrorLog_AddString(-1, "BitmapList_Remove:  geBitmap_DetachDriver failed.", NULL);
00345                         return GE_FALSE;
00346                 }
00347         }
00348 
00349         geBitmap_Destroy(&Bitmap);
00350 
00351         if ( TimesAdded <= 0 )
00352         {
00353                 pList->Members --;
00354                 Hash_DeleteNode(pList->Hash,pNode);
00355                 return GE_TRUE;
00356         }
00357         else
00358         {
00359                 HashNode_SetData(pNode,TimesAdded);
00360                 return GE_FALSE;
00361         }
00362 }

geBoolean BitmapList_SetGamma BitmapList pList,
geFloat  Gamma
 

Definition at line 127 of file BitmapList.c.

References BitmapList_IsValid(), GE_FALSE, GE_TRUE, geBitmap_SetGammaCorrection(), geBoolean, geErrorLog_AddString, BitmapList::Hash, Hash_WalkNext(), HashNode_Key(), and NULL.

Referenced by geEngine_UpdateGamma().

00128 {
00129 HashNode *pNode;
00130 
00131         assert(BitmapList_IsValid(pList));
00132 
00133 #ifdef _DEBUG
00134         //pushTSC();
00135 #endif
00136 
00137         pNode = NULL;
00138         while( (pNode = Hash_WalkNext(pList->Hash,pNode)) != NULL )
00139         {
00140         geBitmap *Bmp;
00141                 Bmp = (geBitmap *)HashNode_Key(pNode);
00142 
00143                 if (!geBitmap_SetGammaCorrection(Bmp, Gamma, GE_TRUE) )
00144                 {
00145                         geErrorLog_AddString(-1,"BitmapList_SetGamma : SetGamma failed.", NULL);
00146                         return GE_FALSE;
00147                 }
00148         }
00149         
00150 #ifdef _DEBUG
00151         //showPopTSCper("BitmapList_SetGamma",pList->MembersAttached,"bitmap");
00152 #endif
00153 
00154 return GE_TRUE;
00155 }


Generated on Tue Sep 30 12:37:07 2003 for GTestAndEngine by doxygen 1.3.2