CachedFractal Class Reference

A Fractal that has been cached. More...

#include <fraclist.h>

Inheritance diagram for CachedFractal:

ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 CachedFractal ()
 CachedFractal constructor.
 ~CachedFractal ()
 CachedFractal destructor.
virtual INT32 operator== (const FillGeometryAttribute &Attrib)
 

void SetCachedFractal (FillGeometryAttribute *)
 

FillGeometryAttributeGetCachedFractal ()
 

void IncUsageCount ()
 

void DecUsageCount ()
 

INT32 GetUsageCount ()
INT32 GetSize ()
 

KernelBitmapGetBitmap ()
 

void MakeFakeFractal ()
BOOL IsFakeFractal ()

Protected Attributes

FillGeometryAttributeFractal
INT32 UsageCount
BOOL m_bIsFake

Detailed Description

A Fractal that has been cached.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
See also:
-

Definition at line 120 of file fraclist.h.


Constructor & Destructor Documentation

CachedFractal::CachedFractal  ) 
 

CachedFractal constructor.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 132 of file fraclist.cpp.

00133 {
00134     Fractal     = NULL;
00135     UsageCount  = 0;
00136     m_bIsFake   = FALSE;
00137 }

CachedFractal::~CachedFractal  ) 
 

CachedFractal destructor.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 152 of file fraclist.cpp.

00153 {
00154     if (IsFakeFractal())
00155     {
00156         if (Fractal->GetBitmap())
00157         {
00158             delete Fractal->GetBitmapRef()->GetBitmap();
00159             Fractal->GetBitmapRef()->SetBitmap(NULL);
00160         }
00161 
00162         delete Fractal;
00163         return;
00164     }
00165     
00166     if (UsageCount > 0)
00167         TRACEUSER( "Mike", _T("Deleting cached fractal while it's still in use\n"));
00168 
00169     if (Fractal)
00170     {
00171         GlobalFractalList* pFracList = GetApplication()->GetGlobalFractalList();
00172         BOOL StillUsed = FALSE;
00173 
00174         if (pFracList)
00175         {
00176             CachedFractal* pCachedFractal = (CachedFractal*)pFracList->GetHead();
00177 
00178             while (pCachedFractal != NULL)
00179             {
00180                 OILBitmap* pBmp = NULL;
00181                 if (pCachedFractal->GetBitmap())
00182                     pBmp = pCachedFractal->GetBitmap()->ActualBitmap;
00183 
00184                 // Are the bitmaps the same ?
00185                 if (Fractal->GetBitmap() && 
00186                     Fractal->GetBitmap()->ActualBitmap == pBmp )
00187                 {
00188                     // This fractal bitmap is still being used
00189                     StillUsed = TRUE;
00190                     break;
00191                 }
00192 
00193                 pCachedFractal = (CachedFractal*)pFracList->GetNext(pCachedFractal);
00194             }   
00195         }
00196 
00197         if (Fractal->GetBitmap())
00198         {
00199             // Only delete the actual bitmap, if it's not used for any other fractals
00200             if (!StillUsed) 
00201             {
00202                 delete Fractal->GetBitmapRef()->GetBitmap()->ActualBitmap;
00203                 Fractal->GetBitmapRef()->GetBitmap()->ActualBitmap = NULL;
00204             }
00205 
00206             delete Fractal->GetBitmapRef()->GetBitmap();
00207             Fractal->GetBitmapRef()->SetBitmap(NULL);
00208         }
00209 
00210         delete Fractal;
00211     }
00212 }


Member Function Documentation

void CachedFractal::DecUsageCount  ) 
 

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94
Parameters:
Decreaments the usage count of this cached fractal. [OUTPUTS]

Definition at line 311 of file fraclist.cpp.

00312 {
00313     UsageCount--;
00314     TRACEUSER( "Mike", _T("Dec Cached Fractal @ %x, Usage to %d\n"),this, UsageCount);
00315 }

KernelBitmap * CachedFractal::GetBitmap void   ) 
 

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/8/96
Returns:
The fractal bitmap

Definition at line 356 of file fraclist.cpp.

00357 {
00358     if (Fractal == NULL)
00359         return NULL;
00360 
00361     return Fractal->GetBitmap();
00362 }

FillGeometryAttribute * CachedFractal::GetCachedFractal  ) 
 

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 278 of file fraclist.cpp.

00279 {
00280     return Fractal;
00281 }

INT32 CachedFractal::GetSize  ) 
 

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94
Returns:
The memory used by this fractal.

Definition at line 328 of file fraclist.cpp.

00329 {
00330     ERROR2IF(Fractal->GetBitmap() == NULL ||
00331              Fractal->GetBitmap()->ActualBitmap == NULL, 0, "GetSize called when bitmap is NULL");
00332 
00333     BitmapInfo Info;
00334     Info.MemoryUsed = 0;
00335 
00336     if (Fractal->GetBitmap() &&
00337         Fractal->GetBitmap()->ActualBitmap)
00338     {
00339         Fractal->GetBitmap()->ActualBitmap->GetInfo(&Info);
00340     }
00341 
00342     return Info.MemoryUsed;
00343 }

INT32 CachedFractal::GetUsageCount  )  [inline]
 

Definition at line 136 of file fraclist.h.

00136 { return UsageCount; }

void CachedFractal::IncUsageCount  ) 
 

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94
Parameters:
Increaments the usage count of this cached fractal. [OUTPUTS]

Definition at line 294 of file fraclist.cpp.

00295 {
00296     UsageCount++;
00297     TRACEUSER( "Mike", _T("Inc Cached Fractal @ %x, Usage to %d\n"),this, UsageCount);
00298 }

BOOL CachedFractal::IsFakeFractal  )  [inline]
 

Definition at line 143 of file fraclist.h.

00143 { return m_bIsFake; }

void CachedFractal::MakeFakeFractal  )  [inline]
 

Definition at line 142 of file fraclist.h.

00142 { m_bIsFake = TRUE; }

INT32 CachedFractal::operator== const FillGeometryAttribute Attrib  )  [virtual]
 

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 227 of file fraclist.cpp.

00228 {
00229     FillGeometryAttribute* CachedFrac = GetCachedFractal();
00230     FillGeometryAttribute* OtherFrac = (FillGeometryAttribute*)&Attrib;
00231 
00232     if (OtherFrac->GetRuntimeClass() != CachedFrac->GetRuntimeClass())
00233         return FALSE;
00234 
00235     return ( OtherFrac->IsSameAsCachedFractal(CachedFrac) );
00236 }

void CachedFractal::SetCachedFractal FillGeometryAttribute NewFrac  ) 
 

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 251 of file fraclist.cpp.

00252 {
00253     CCRuntimeClass* ObjectType = NewFrac->GetRuntimeClass();
00254     FillGeometryAttribute* FracClone = (FillGeometryAttribute*)ObjectType->CreateObject();
00255 
00256     NewFrac->CacheFractalData(FracClone);
00257 
00258     KernelBitmap* Bmp = new KernelBitmap(NewFrac->GetBitmap()->ActualBitmap, TRUE);
00259     FracClone->GetBitmapRef()->SetBitmap(Bmp);
00260 //  Bmp->IncUsageCount();
00261 
00262     Fractal = FracClone;
00263 }


Member Data Documentation

FillGeometryAttribute* CachedFractal::Fractal [protected]
 

Definition at line 146 of file fraclist.h.

BOOL CachedFractal::m_bIsFake [protected]
 

Definition at line 149 of file fraclist.h.

INT32 CachedFractal::UsageCount [protected]
 

Definition at line 147 of file fraclist.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:51:43 2007 for Camelot by  doxygen 1.4.4