Capture Class Reference

Hold current bitmap cacheing state during rendering and functionality to store bitmaps in cache, detect limits of cached spans, etc. More...

#include <capturemanager.h>

Inheritance diagram for Capture:

CCObject SimpleCCObject List of all members.

Public Member Functions

 CC_DECLARE_DYNAMIC (Capture)
 Capture ()
 Default Constructor for Capture Class.
 Capture (CCObject *pOwner, CAPTUREINFO cinfo, Matrix cMatrix, DocRect cRect, double PixelsPerInch, ColourContext *pcColourContext)
 New Capture Constructor for Capture Class.
 Capture (Capture *pSourceCapture, BOOL bCopyBitmap=FALSE)
 Copy Constructor for Capture Class.
 ~Capture ()
 Default Destructor for CaptureManager Class.
BOOL IsTransparent () const
BOOL IsMaster () const
BOOL IsDirect () const
BOOL HasFullCoverage () const
BOOL IsUnclipped () const
CCObjectGetOwner () const
BOOL OwnsBitmap () const
BOOL SetDIB (LPBITMAPINFO lpnewInfo, LPBYTE lpnewBits)
BOOL SetClipRect (DocRect NewClipRect)
void SetTransparent (BOOL bNewState)
 Change the transparency of a captured bitmap.
BOOL FreeDIB ()
 Default Destructor for CaptureManager Class Default Destructor for CaptureManager Class.
void SetDirectSupplier (NodeRenderableInk *pSupplier)
NodeRenderableInkGetDirectSupplier () const
BOOL ConsumeDirectBitmap (NodeRenderableInk *pSupplier)
 Consume the supplied bitmap if the supplier is right.
void SetClipRegionAttrValue (ClipRegionAttribute *pClipRegion)
const REGIONGetCachedClipRegion (ClipRegionAttribute *pClipAttr)
 

void SetCachedClipRegion (ClipRegionAttribute *pClipAttr, const REGION *pClipRegion)
 

void RemoveCachedClipRegion (ClipRegionAttribute *pClipAttr)
 

void RemoveAllCachedClipRegions ()
 


Public Attributes

DocRect CaptureRect
LPBITMAPINFO lpBitmapInfo
LPBYTE lpBits
Matrix CaptureMatrix
ColourContextpColContext
CAPTUREINFO info
double dPixelsPerInch

Private Attributes

CCObjectm_pOwner
NodeRenderableInkm_pDirectBitmapSupplier
ClipRegionMap m_ClipRegionMap
ClipRegionAttributem_pClipRegionAttrValue

Detailed Description

Hold current bitmap cacheing state during rendering and functionality to store bitmaps in cache, detect limits of cached spans, etc.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/07/2004
This class is instantiated while a chunk of the tree is being rendered with the intention of capturing it in the BitmapCache. When the chunk ends, the CaptureManager decides whether it can store the bitmap or not and then dies. The "chunk" of tree may be a single node, a subtree or an arbitrary span of nodes from point A to point B

A Capture may own a bitmap but doesn't always do so.

Note! This class replaces OffscreenState and CaptureManager. This is how it should have been implemented in the first place...!

See also:
RenderRegion; RenderRegion::RenderTree; Node::RenderSubtree

Definition at line 256 of file capturemanager.h.


Constructor & Destructor Documentation

Capture::Capture  ) 
 

Default Constructor for Capture Class.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/07/2004
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 134 of file capturemanager.cpp.

00135 {
00136     m_pOwner                = NULL;
00137     m_pDirectBitmapSupplier = NULL;
00138     m_pClipRegionAttrValue  = NULL;
00139 
00140     CaptureRect             = DocRect(0,0,0,0);
00141     lpBitmapInfo            = NULL;
00142     lpBits                  = NULL;
00143     CaptureMatrix           = Matrix();
00144     pColContext             = NULL;
00145     info                    = CAPTUREINFO(ctDISABLED, cfNONE);
00146     dPixelsPerInch          = 96;
00147 
00148 //  m_ClipRegionMap.InitHashTable(17, FALSE);
00149 }

Capture::Capture CCObject pOwner,
CAPTUREINFO  cinfo,
Matrix  cMatrix,
DocRect  cRect,
double  PixelsPerInch,
ColourContext pcColourContext
 

New Capture Constructor for Capture Class.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/07/2004
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 174 of file capturemanager.cpp.

00181 {
00182     m_pOwner            = pOwner;
00183     m_pDirectBitmapSupplier = NULL;
00184     m_pClipRegionAttrValue  = NULL;
00185 
00186     CaptureRect         = cRect;
00187     lpBitmapInfo        = NULL;
00188     lpBits              = NULL;
00189 PORTNOTE("other","Removed GRenderRegion::MakeGavinMatrix usage")
00190 #ifndef EXCLUDE_FROM_XARALX
00191     CaptureGMatrix      = GRenderRegion::MakeGavinMatrix(cMatrix, cRect, PixelsPerInch);
00192 #endif
00193     CaptureMatrix       = cMatrix;
00194     pColContext         = pcColourContext;
00195     info                = cinfo;
00196     dPixelsPerInch      = PixelsPerInch;
00197 }

Capture::Capture Capture pSourceCapture,
BOOL  bCopyBitmap = FALSE
 

Copy Constructor for Capture Class.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/07/2004
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 218 of file capturemanager.cpp.

00220 {
00221     m_pOwner                = pSourceCapture->m_pOwner;
00222     m_pDirectBitmapSupplier = pSourceCapture->m_pDirectBitmapSupplier;
00223     m_pClipRegionAttrValue  = pSourceCapture->m_pClipRegionAttrValue;
00224 
00225     CaptureRect             = pSourceCapture->CaptureRect;
00226     lpBitmapInfo            = pSourceCapture->lpBitmapInfo;
00227     lpBits                  = pSourceCapture->lpBits;
00228     CaptureMatrix           = pSourceCapture->CaptureMatrix;
00229     pColContext             = pSourceCapture->pColContext;
00230     info                    = pSourceCapture->info;             // Note that copying a master will create a master!
00231     dPixelsPerInch          = pSourceCapture->dPixelsPerInch;
00232 
00233     if (bCopyBitmap && pSourceCapture->lpBitmapInfo && pSourceCapture->lpBits)
00234     {
00235         DIBUtil::CopyBitmap(pSourceCapture->lpBitmapInfo, pSourceCapture->lpBits,
00236                             &lpBitmapInfo, &lpBits);
00237     }
00238 
00239     // CopyBitmap doesn't copy compression flag correctly...
00240     lpBitmapInfo->bmiHeader.biCompression = pSourceCapture->lpBitmapInfo->bmiHeader.biCompression;
00241 }

Capture::~Capture  ) 
 

Default Destructor for CaptureManager Class.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/07/2004
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 338 of file capturemanager.cpp.

00339 {
00340     RemoveAllCachedClipRegions();
00341 
00342     if (m_pClipRegionAttrValue)
00343     {
00344         delete m_pClipRegionAttrValue;
00345         m_pClipRegionAttrValue = NULL;
00346     }
00347 }


Member Function Documentation

Capture::CC_DECLARE_DYNAMIC Capture   ) 
 

BOOL Capture::ConsumeDirectBitmap NodeRenderableInk pSupplier  ) 
 

Consume the supplied bitmap if the supplier is right.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/08/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 428 of file capturemanager.cpp.

00429 {
00430     if (m_pDirectBitmapSupplier!=pSupplier || info.caFlags.Direct==FALSE)
00431         return FALSE;
00432 
00433     // TODO: Could grab some info about the direct bitmap here?
00434 
00435     return TRUE;
00436 }

BOOL Capture::FreeDIB  ) 
 

Default Destructor for CaptureManager Class Default Destructor for CaptureManager Class.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/07/2004
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 311 of file capturemanager.cpp.

00312 {
00313 	::FreeDIB(lpBitmapInfo, lpBits, NULL, FALSE);
00314     lpBitmapInfo = NULL;                            // Owns bitmap will now return FALSE
00315     lpBits = NULL;
00316 
00317     return FALSE;
00318 }

const REGION * Capture::GetCachedClipRegion ClipRegionAttribute pClipAttr  ) 
 

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
03/10/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 456 of file capturemanager.cpp.

00457 {
00458     ClipRegionMap::const_iterator iter = m_ClipRegionMap.find( pClipAttr );
00459     if( m_ClipRegionMap.end() == iter )
00460         return NULL;
00461 
00462     return (REGION *)iter->second;
00463 }

NodeRenderableInk* Capture::GetDirectSupplier  )  const [inline]
 

Definition at line 288 of file capturemanager.h.

00288 {return m_pDirectBitmapSupplier;}

CCObject* Capture::GetOwner  )  const [inline]
 

Definition at line 280 of file capturemanager.h.

00280 {return m_pOwner;}

BOOL Capture::HasFullCoverage  )  const [inline]
 

Definition at line 278 of file capturemanager.h.

00278 {return info.caFlags.FullCoverage; }

BOOL Capture::IsDirect  )  const [inline]
 

Definition at line 277 of file capturemanager.h.

00277 {return info.caFlags.Direct; }

BOOL Capture::IsMaster  )  const [inline]
 

Definition at line 276 of file capturemanager.h.

00276 {return info.caFlags.Master; }

BOOL Capture::IsTransparent  )  const [inline]
 

Definition at line 275 of file capturemanager.h.

00275 {return (lpBitmapInfo && lpBitmapInfo->bmiHeader.biCompression==0x80000001);}

BOOL Capture::IsUnclipped  )  const [inline]
 

Definition at line 279 of file capturemanager.h.

00279 {return info.caFlags.UnClip; }

BOOL Capture::OwnsBitmap  )  const [inline]
 

Definition at line 281 of file capturemanager.h.

00281 {return lpBitmapInfo!=NULL && lpBits!=NULL;}

void Capture::RemoveAllCachedClipRegions  ) 
 

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
03/10/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 536 of file capturemanager.cpp.

00537 {
00538     ClipRegionMap::const_iterator iter = m_ClipRegionMap.begin();
00539     for( ; iter != m_ClipRegionMap.end(); ++iter )
00540     {
00541         if( iter->second != NULL )
00542             delete []( (BYTE *)iter->second );
00543     }
00544     m_ClipRegionMap.clear();
00545 }

void Capture::RemoveCachedClipRegion ClipRegionAttribute pClipAttr  ) 
 

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
03/10/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 506 of file capturemanager.cpp.

00507 {
00508     ClipRegionMap::iterator iter = m_ClipRegionMap.find( pClipAttr );
00509     if( m_ClipRegionMap.end() != iter )
00510     {
00511         if (iter->second != NULL)
00512             delete []( (BYTE *)iter->second );
00513 
00514         m_ClipRegionMap.erase( iter );
00515     }
00516 }

void Capture::SetCachedClipRegion ClipRegionAttribute pClipAttr,
const REGION pClipRegion
 

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
03/10/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 483 of file capturemanager.cpp.

00484 {
00485     m_ClipRegionMap[pClipAttr] = (void *)pClipRegion;
00486 }

BOOL Capture::SetClipRect DocRect  NewClipRect  )  [inline]
 

Definition at line 284 of file capturemanager.h.

00284 {CaptureRect = NewClipRect; return TRUE;}

void Capture::SetClipRegionAttrValue ClipRegionAttribute pClipRegion  )  [inline]
 

Definition at line 290 of file capturemanager.h.

00290 {m_pClipRegionAttrValue = pClipRegion;}

BOOL Capture::SetDIB LPBITMAPINFO  lpnewInfo,
LPBYTE  lpnewBits
[inline]
 

Definition at line 283 of file capturemanager.h.

00283 {lpBitmapInfo = lpnewInfo; lpBits = lpnewBits; return TRUE;}

void Capture::SetDirectSupplier NodeRenderableInk pSupplier  )  [inline]
 

Definition at line 287 of file capturemanager.h.

00287 {m_pDirectBitmapSupplier = pSupplier;}

void Capture::SetTransparent BOOL  bNewState  ) 
 

Change the transparency of a captured bitmap.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/07/2004
Parameters:
bNewState - TRUE if captured bitmap should be made transparent [INPUTS] FALSE if captured bitmap should be made opaque
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 368 of file capturemanager.cpp.

00369 {
00370     if (lpBitmapInfo && lpBits && lpBitmapInfo->bmiHeader.biBitCount==32)
00371     {
00372         lpBitmapInfo->bmiHeader.biCompression = bNewState ? 0x80000001 : BI_RGB;
00373         UINT32 BmpSize = GetDIBBitsSize(&lpBitmapInfo->bmiHeader);
00374         UINT32 Index = 0;
00375         LPBYTE pSetBits = lpBits;
00376 
00377         if (bNewState)
00378         {
00379             // ReInit bitmap to be fully transparent
00380             while(Index < BmpSize)
00381             {
00382                 // initial values for using internal alpha channelled format
00383                 // fully transparent black bacground
00384 
00385                 pSetBits[Index++] = 0x00;
00386                 pSetBits[Index++] = 0x00;
00387                 pSetBits[Index++] = 0x00;
00388                 pSetBits[Index++] = 0xFF;
00389             }
00390         }
00391         else
00392         {
00393             // ReInit bitmap to be fully opaque
00394             while(Index < BmpSize)
00395             {
00396                 // fully opaque white background
00397                 pSetBits[Index++] = 0xFF;
00398                 pSetBits[Index++] = 0xFF;
00399                 pSetBits[Index++] = 0xFF;
00400                 pSetBits[Index++] = 0x00;
00401             }
00402         }
00403     }
00404     else
00405     {
00406         ERROR3("SetTransparency called on empty/non-32BPP bitmap");
00407     }
00408 }


Member Data Documentation

Matrix Capture::CaptureMatrix
 

Definition at line 304 of file capturemanager.h.

DocRect Capture::CaptureRect
 

Definition at line 301 of file capturemanager.h.

double Capture::dPixelsPerInch
 

Definition at line 307 of file capturemanager.h.

CAPTUREINFO Capture::info
 

Definition at line 306 of file capturemanager.h.

LPBITMAPINFO Capture::lpBitmapInfo
 

Definition at line 302 of file capturemanager.h.

LPBYTE Capture::lpBits
 

Definition at line 303 of file capturemanager.h.

ClipRegionMap Capture::m_ClipRegionMap [private]
 

Definition at line 313 of file capturemanager.h.

ClipRegionAttribute* Capture::m_pClipRegionAttrValue [private]
 

Definition at line 314 of file capturemanager.h.

NodeRenderableInk* Capture::m_pDirectBitmapSupplier [private]
 

Definition at line 312 of file capturemanager.h.

CCObject* Capture::m_pOwner [private]
 

Definition at line 311 of file capturemanager.h.

ColourContext* Capture::pColContext
 

Definition at line 305 of file capturemanager.h.


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