GRenderDIB Class Reference

A GDraw render region that uses normal DIBs for the bitmap. More...

#include <grnddib.h>

Inheritance diagram for GRenderDIB:

GRenderRegion RenderRegion ListItem CCObject SimpleCCObject GRenderBitmap GRenderBrush GRenderClick GRenderPrint GRenderOptPalette MaskedRenderRegion GRenderClickColour PrintingMaskedRenderRegion GRenderClickColourNoPaper List of all members.

Public Member Functions

 GRenderDIB (DocRect ClipRegion, Matrix ConvertMatrix, FIXED16 ViewScale, UINT32 Depth, double dpi)
 GRenderDIB constructor. Doesn't do anything actually, just calls base class. INT32 dpi changed to double dpi (12/12/95) to improve the range of values allowed at the < 1000dpi settings that we will be using.
 ~GRenderDIB ()
 GRenderDIB destructor. Frees up the bitmap.
virtual BOOL SetFirstBand ()
 This determines if banding is needed for this render region and sets up ready for it. If this region is already banded, then this function does nothing - it is safe to call this even if it has been called before.
virtual BOOL GetNextBand ()
 This function decides if there are more bands to do. If there are it sets them up and returns TRUE.
virtual void ResizeRegion (DocRect &NewClipRect)
 Called when a Region is changed in size (eg. clipped to the client area).

Protected Member Functions

LPBITMAPINFO GetLPBits (INT32 Width, INT32 Height, INT32 Depth, LPBYTE *)
 Allocates a bitmap header and the bitmap bytes.
virtual void FreeLPBits (LPBITMAPINFO, LPBYTE)
 Frees up a bitmap allocated with GetLPBits.
LPBYTE ResizeBits (LPBYTE, INT32)
 Reallocates the bitmap to be a new size.
virtual BOOL DisplayBits (LPBITMAPINFO lpDisplayBitmapInfo=NULL, LPBYTE lpDisplayBits=NULL)
 Plots the DIB onto the owner device.

Protected Attributes

INT32 m_test

Detailed Description

A GDraw render region that uses normal DIBs for the bitmap.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/6/94

Definition at line 116 of file grnddib.h.


Constructor & Destructor Documentation

GRenderDIB::GRenderDIB DocRect  ClipRegion,
Matrix  ConvertMatrix,
FIXED16  ViewScale,
UINT32  Depth,
double  dpi
 

GRenderDIB constructor. Doesn't do anything actually, just calls base class. INT32 dpi changed to double dpi (12/12/95) to improve the range of values allowed at the < 1000dpi settings that we will be using.

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

Errors: -

See also:
GRenderRegion::GRenderRegion

Definition at line 129 of file grnddib.cpp.

00130     : GRenderRegion( ClipRegion, ConvertMatrix, ViewScale, Depth, dpi)
00131 {
00132     m_test = 1;
00133 }

GRenderDIB::~GRenderDIB  ) 
 

GRenderDIB destructor. Frees up the bitmap.

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

Errors: -

Definition at line 226 of file grnddib.cpp.

00227 {
00228     if (LocalBitmap)
00229     {
00230         FreeOffscreenState();
00231         pBitmapInfo = NULL;
00232         pBits = NULL;
00233     }
00234     // will call GRenderRegions destructor here
00235 }


Member Function Documentation

BOOL GRenderDIB::DisplayBits LPBITMAPINFO  lpDisplayBitmapInfo = NULL,
LPBYTE  lpDisplayBits = NULL
[protected, virtual]
 

Plots the DIB onto the owner device.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if worked, FALSE if failed.

Errors: -

Implements GRenderRegion.

Reimplemented in GRenderBitmap, GRenderClick, and GRenderPrint.

Definition at line 251 of file grnddib.cpp.

00252 {
00253     LPBITMAPINFO lpLocalInfo = pBitmapInfo;
00254     LPBYTE lpLocalBits = pBits;
00255 
00256     if (lpDisplayBitmapInfo && lpDisplayBits)
00257     {
00258         lpLocalInfo = lpDisplayBitmapInfo;
00259         lpLocalBits = lpDisplayBits;
00260     }
00261 
00262     if (lpLocalInfo && lpLocalBits && RenderDC)
00263     {
00264         // If we are doing a colour separation and are not in Mono mode
00265         // then we need to convert the bitmap from 32 bpp platescale to 
00266         // simulated printer colours
00267         // We do this conversion in place as separations are not background rendered
00268         // so we wont be rendering anything else into the bitmap
00269 PORTNOTE("other","GRenderDIB::DisplayBits - removed separation code")
00270 #ifndef EXCLUDE_FROM_XARALX
00271         ColourPlate* pPlate = CurrentColContext->GetColourPlate();
00272         if (pPlate && !pPlate->IsDisabled())
00273         {
00274             ColourPlateType Type = pPlate->GetType();
00275             if (Type != COLOURPLATE_COMPOSITE &&
00276                 Type != COLOURPLATE_SPOT &&
00277                 Type != COLOURPLATE_KEY && 
00278                 Type != COLOURPLATE_NONE && 
00279                 !(pPlate->IsMonochrome()))
00280             {
00281                 if (BitmapDepth == 32)
00282                 {
00283                     // First we set up a colour conversion table from platescale value
00284                     // to real RGB value
00285                     RGBQUAD Lookup[256];
00286                     DocColour temp;
00287                     PColourRGBT Converted;
00288                     DWORD* pLookup = (DWORD*)Lookup;
00289 
00290                     XaraCMS* lpCMSMan = GetApplication()->GetCMSManager();
00291                     if (lpCMSMan != NULL)
00292                     {
00293                         ColourRGBT Def;
00294 
00295                         for (DWORD i = 0; i < 256; i++)
00296                         {
00297                             switch (Type)
00298                             {
00299                             case COLOURPLATE_CYAN:
00300                                 Def.Blue = 1;
00301                                 Def.Green = 1;
00302                                 Def.Red = (i / 255.0);
00303                                 Def.Transparent = 0;
00304                                 break;
00305                             case COLOURPLATE_MAGENTA:
00306                                 Def.Blue = 1;
00307                                 Def.Green = (i / 255.0);
00308                                 Def.Red = 1;
00309                                 Def.Transparent = 0;
00310                                 break;
00311                             case COLOURPLATE_YELLOW:
00312                                 Def.Blue = (i / 255.0);
00313                                 Def.Green = 1;
00314                                 Def.Red = 1;
00315                                 Def.Transparent = 0;
00316                                 break;
00317                             }
00318                             lpCMSMan->ConvertColourForPaperView(&Def);
00319                             Lookup[i].rgbRed        = Def.Red.MakeDouble() * 0xFF;
00320                             Lookup[i].rgbGreen      = Def.Green.MakeDouble() * 0xFF;
00321                             Lookup[i].rgbBlue       = Def.Blue.MakeDouble() * 0xFF;
00322                             Lookup[i].rgbReserved   = 0;
00323                         }
00324                     }
00325 
00326                     DWORD PixMask = 0;
00327                     INT32 ByteOffset = 0;
00328                     switch (Type)
00329                     {
00330                     case COLOURPLATE_CYAN:
00331                         PixMask = 0x00FFFF;
00332                         ByteOffset = 2;
00333                         break;
00334                     case COLOURPLATE_MAGENTA:
00335                         PixMask = 0xFF00FF;
00336                         ByteOffset = 1;
00337                         break;
00338                     case COLOURPLATE_YELLOW:
00339                         PixMask = 0xFFFF00;
00340                         ByteOffset = 0;
00341                         break;
00342                     }
00343                     INT32 Width = lpLocalInfo->bmiHeader.biWidth;
00344                     INT32 Height = lpLocalInfo->bmiHeader.biHeight;
00345                     INT32 NumPixels = Width * Height;
00346                     DWORD* pPixel = (DWORD*)lpLocalBits;
00347                     INT32 Pix;
00348                     for (Pix = 0; Pix < NumPixels; Pix++)
00349                     {
00350                         if ((*pPixel & PixMask) == PixMask)
00351                         {
00352                             BYTE Val = *(((BYTE*)pPixel) + ByteOffset);
00353                             *pPixel = pLookup[Val];
00354                         }
00355                         pPixel++;
00356                     }
00357                 }
00358             }
00359         }
00360 #endif
00361 // TEMP BODGE to avoid rewriting all these function to take LP bitmap info/bits parameters!
00362 LPBITMAPINFO lpStoredInfo = pBitmapInfo;
00363 LPBYTE lpStoredBits = pBits;
00364 pBitmapInfo = lpLocalInfo;
00365 pBits = lpLocalBits;
00366 
00367         if ( uBitmapDepth == (UINT32)ScreenDepth )
00368             Display1to1Bitmap();
00369 //          Display1to1Bitmap(lpLocalInfo, lpLocalBits);
00370 PORTNOTE("other","GRenderDIB::DisplayBits - removed BitmapDepth tests")
00371 #ifdef EXCLUDE_FROM_XARALX
00372         else
00373             DisplayLtoHBitmap();
00374 //          DisplayLtoHBitmap(lpLocalInfo, lpLocalBits);
00375 #else
00376         else if ( BitmapDepth < ScreenDepth )
00377             DisplayLtoHBitmap();
00378 //          DisplayLtoHBitmap(lpLocalInfo, lpLocalBits);
00379         else if ( (ScreenDepth==8 ) || (ScreenDepth==4) )
00380             DisplayHto8Bitmap();            // high-colour to 256/16 is special
00381 //          DisplayHto8Bitmap(lpLocalInfo, lpLocalBits);            // high-colour to 256/16 is special
00382         else
00383             DisplayLtoHBitmap();            // fallback code to general blit
00384 //          DisplayLtoHBitmap(lpLocalInfo, lpLocalBits);            // fallback code to general blit
00385 #endif
00386 pBitmapInfo = lpStoredInfo;
00387 pBits = lpStoredBits;
00388     }
00389     return TRUE;
00390 }

void GRenderDIB::FreeLPBits LPBITMAPINFO  lpBMI,
LPBYTE  lpB
[protected, virtual]
 

Frees up a bitmap allocated with GetLPBits.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/6/94
Parameters:
Bitmap characteristics. [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
GRenderDIB::FreeLPBits

Implements GRenderRegion.

Reimplemented in GRenderBitmap, GRenderBrush, GRenderClick, and GRenderPrint.

Definition at line 182 of file grnddib.cpp.

00183 {
00184     // If we are banded, then free the memory from the limited heap
00185     FreeDIB(lpBMI, lpB, NULL, TRUE);
00186 }

LPBITMAPINFO GRenderDIB::GetLPBits INT32  Width,
INT32  Height,
INT32  Depth,
LPBYTE lplpBits
[protected, virtual]
 

Allocates a bitmap header and the bitmap bytes.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/6/94
Parameters:
Bitmap characteristics. [INPUTS]
*lplpBits is made to point to the bytes of the bitmap. [OUTPUTS]
Returns:
The bitmap header, or NULL if not enough memory.

Errors: -

See also:
GRenderDIB::FreeLPBits

Implements GRenderRegion.

Reimplemented in GRenderBitmap, GRenderClick, and GRenderPrint.

Definition at line 151 of file grnddib.cpp.

00152 {
00153     // Get a DIB out of the limited heap
00154     LPBITMAPINFO bmInfo = NULL;
00155 
00156     // Wrapped render regions are not used in the normal process of rendering to screen
00157     // So don't use limited mem
00158     if(IsWrapped)
00159         bmInfo = AllocDIB( Width, Height, Depth, lplpBits, NULL, FALSE);
00160     else
00161         bmInfo = AllocDIB( Width, Height, Depth, lplpBits, NULL, TRUE);
00162 
00163     // return it.
00164     return bmInfo;
00165 }

BOOL GRenderDIB::GetNextBand  )  [virtual]
 

This function decides if there are more bands to do. If there are it sets them up and returns TRUE.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/95
Returns:
TRUE if there is another band to do, FALSE if there are no more bands

Reimplemented from RenderRegion.

Reimplemented in GRenderBitmap, GRenderOptPalette, GRenderClick, and GRenderPrint.

Definition at line 522 of file grnddib.cpp.

00523 {
00524     // if this is not a banded render region, then there are no more bands
00525     if (!IsBanded())
00526         return FALSE;
00527 
00528 //  ENSURE(GetCaptureDepth()==0, "Can't set a band while there are any captures running");
00529     ENSURE(GetCaptureDepth()==0 || MasterCaptureIsCurrent(), "Can't set a band while there are any non-master captures running\n");
00530 
00531     // ensure all offscreen rendering in previous band finished rendering
00532     // NB if it didn't then GetNextBand shouldn't have been called.
00533 //  if(IsUserName("Ilan"))
00534     ERROR3IF(!MasterCaptureIsCurrent(),"GetNextBand called before previous band finished!");
00535 
00536     // Free previous band's bmp memory
00537     FreeOffscreenState();
00538     pBitmapInfo = NULL;
00539     pBits = NULL;
00540 
00541     // See if we are out of bands
00542     if ((CurrentClipRect.hi.y>=RegionRect.hi.y) || (IsLastBand))
00543         return FALSE;
00544 
00545     // Go find the next band, if there is one.
00546     // ok, how much ram do we need and how much ram is there to use
00547     TunedMemory* pTunedMem = GetTunedMemManager();
00548 
00549     // we're going to need to be re-rendered
00550     IsPaperRendered = FALSE;
00551     IsInkRenderStarted = FALSE;
00552 
00553     // Find out how much free memory there is now
00554     size_t AvailableRAM = pTunedMem->GetAvailableTunedMem();
00555     
00556     // Work out a rough idea of the amount of ram needed
00557     INT32 ScanLineSize = DIBUtil::ScanlineSize(WRect.width, uBitmapDepth);
00558     if (ScanLineSize==0)
00559         return FALSE;
00560 
00561     // Work out how many scan lines we could fit into the available ram
00562     INT32 MaxScanLines = INT32(AvailableRAM / ScanLineSize);
00563 
00564     // Work out how many scan lines there are left to do
00565     double TruePixelHeight = 72000.0 / PixelsPerInch; //.MakeDouble();
00566     TruePixelHeight = TruePixelHeight / ScaleFactor.MakeDouble();
00567     INT32 Height = (INT32) ((double)(RegionRect.hi.y - CurrentClipRect.hi.y) / TruePixelHeight);
00568 
00569     // see if there are enought to bother with
00570     IsWaitingForRAM = FALSE;
00571     if ((Height>=16) && (MaxScanLines<16))
00572     {
00573         // Not really enough memory to bother
00574         IsWaitingForRAM = TRUE;
00575         return TRUE;
00576     }
00577 
00578     // Do what we can
00579     INT32 ScanLinesToDo = (MaxScanLines<Height) ? MaxScanLines : Height;
00580     if (ScanLinesToDo==Height)
00581         IsLastBand = TRUE;
00582     else
00583         IsLastBand = FALSE;
00584 
00585     // Find out how big in millipoints we can do
00586     MILLIPOINT MaxHeight = (MILLIPOINT) (TruePixelHeight * (double)ScanLinesToDo);
00587 
00588     // Set up the new clip rect ready
00589     DocRect NewClipRect = CurrentClipRect;
00590     NewClipRect.lo.y = CurrentClipRect.hi.y;
00591     NewClipRect.hi.y = NewClipRect.lo.y + MaxHeight;
00592 
00593     // Sanity check
00594     if ((NewClipRect.hi.y>RegionRect.hi.y) || (IsLastBand))
00595         NewClipRect.hi.y = RegionRect.hi.y;
00596         
00597     // Make sure that we are not dealing with an empty rect
00598     if (NewClipRect.Height()==0)
00599         return FALSE;
00600 
00601     // Set the new clip rect up ready for rendering
00602     SetClipRect(NewClipRect);
00603 
00604     // we're going to need to be re-rendered
00605     IsPaperRendered = FALSE;
00606     IsInkRenderStarted = FALSE;
00607     TRACEUSER("Gavin",_T("GRenderDIB::GetNextBand - RenderFlags.Rendering = FALSE;\n"));
00608     RenderFlags.Rendering = FALSE;
00609 
00610     // Say it all worked
00611     return TRUE;
00612 }

LPBYTE GRenderDIB::ResizeBits LPBYTE  lpBits,
INT32  NewSize
[protected]
 

Reallocates the bitmap to be a new size.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/7/95
Parameters:
Bitmap pointer, and the new size. [INPUTS]
Returns:
The newly resized bitmap data pointer.

Errors: -

See also:
GRenderDIB::FreeLPBits

Definition at line 202 of file grnddib.cpp.

00203 {
00204     // Get the memory manager
00205     TunedMemory* pTuned = GetTunedMemManager();
00206     if (pTuned == NULL)
00207         return NULL;
00208 
00209     return (LPBYTE)pTuned->LimitedCCRealloc(lpBits, NewSize);
00210 }

void GRenderDIB::ResizeRegion DocRect NewClipRect  )  [virtual]
 

Called when a Region is changed in size (eg. clipped to the client area).

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/7/95

Reimplemented from RenderRegion.

Definition at line 627 of file grnddib.cpp.

00628 {
00629     DocRect NewRegionRect   = NewClipRect;
00630 
00631     BOOL HaveABitmap = TRUE;
00632 
00633     if (IsRegionBanded)
00634     {
00635         // The Region is banded.  That's gunna complicate things.
00636 
00637         if (CurrentClipRect.IsIntersectedWith(NewRegionRect))
00638         {
00639             // 'Clip' the current clip rect to the new Region Rect
00640             NewClipRect = CurrentClipRect.Intersection(NewRegionRect);
00641         }
00642         else
00643         {
00644             // The current band has disappeared outside the Region
00645             if (NewRegionRect.lo.y >= CurrentClipRect.hi.y)
00646             {
00647                 // The area visible, is completely un-rendered,
00648                 // so we may as well start again.
00649                 ResetRegion(NewRegionRect);
00650                 return;
00651             }
00652             else
00653             {
00654                 // We've already render everything beneath the band
00655                 // that has just gone outside the region, so this 
00656                 // region is finished with
00657 
00658                 // Fake it so it doesn't render anything, by setting
00659                 // the clip rect to zero height
00660                 NewClipRect = NewRegionRect;
00661                 NewClipRect.lo.y = NewClipRect.hi.y;                
00662 
00663                 ResetRegion(NewClipRect);
00664                 return;
00665             }
00666         }
00667 
00668         if (IsWaitingForRAM)
00669         {
00670             // This region is waiting for memory to be freed, 
00671             // so there is no bitmap to resize !!
00672             HaveABitmap = FALSE;
00673         }
00674     }
00675 
00676     if (!MasterCaptureIsCurrent())
00677     {
00678         // midway through offscreen rendering. Free memory and start again.
00679         ResetRegion(NewRegionRect);
00680         return;
00681     }
00682 
00683     // Make a new Render Matrix, in case the View has changed position
00684     Matrix ViewMatrix = RenderView->ConstructRenderingMatrix(RenderSpread);
00685 
00686     // Get windows rects, using the new RenderMatrix.
00687     wxRect NRect = OSRenderRegion::DocRectToWin( ViewMatrix, NewClipRect, PixelsPerInch );
00688     const INT32 NewWidth    = NRect.width;
00689     const INT32 NewHeight = NRect.height;
00690 
00691     if (HaveABitmap)
00692     {
00693         if (uBitmapDepth < 8)
00694         {
00695             // We are about to re-size the bitmap, but we can't
00696             // do this for anything less than 8bpp, so we'll just
00697             // reset instead.
00698             ResetRegion(NewClipRect);
00699             return;
00700         }
00701 
00702         // Get the current clip rect in windows coords
00703         wxRect ORect = OSRenderRegion::DocRectToWin( ViewMatrix, CurrentClipRect, PixelsPerInch );
00704 
00705         const INT32 OldWidth    = ORect.width;
00706         const INT32 OldHeight = ORect.height;
00707 
00708         // Its changed size, so we'll try and re-size the bitmap
00709         // If this fails, then we'll just re-set
00710         if (pBits!=NULL && pBitmapInfo!=NULL &&
00711             (NewWidth!=OldWidth || NewHeight!=OldHeight))
00712         {
00713 //          TRACEUSER("Gerry", _T("OldRect is (%d, %d) [%d, %d]\n"),ORect.x,ORect.y,ORect.width,ORect.height);
00714 //          TRACEUSER("Gerry", _T("NewRect is (%d, %d) [%d, %d]\n"),NRect.x,NRect.y,NRect.width,NRect.height);
00715 
00716             UINT32 BaseX = NRect.x> ORect.x ? OldWidth  - NewWidth  : 0;
00717             UINT32 BaseY = NRect.y> ORect.y ? OldHeight - NewHeight : 0;
00718 
00719             // DIB are upside down to windows rects, ie 0,0 is in the bottom left
00720             BaseY=OldHeight-NewHeight-BaseY; // Use Windows type origin from top left.
00721 
00722 //          TRACEUSER("Gerry", _T("Base X,Y is %d,%d\n"), BaseX, BaseY);
00723 
00724             if (DIBUtil::MakeBitmapSmaller(OldWidth, OldHeight, BaseX, BaseY, 
00725                                            NewWidth, NewHeight, uBitmapDepth, pBits))
00726             {
00727                 // Bitmap resized ok, so we can re-allocate the block to the new size
00728                 INT32 NewBitmapSize = 
00729                         DIBUtil::ScanlineSize(NewWidth, uBitmapDepth) * NewHeight;
00730 
00731                 pBitmapInfo->bmiHeader.biWidth      = NewWidth;
00732                 pBitmapInfo->bmiHeader.biHeight     = NewHeight;
00733                 pBitmapInfo->bmiHeader.biSizeImage  = NewBitmapSize;
00734 
00735                 // Gavin needs an extra bit of memory, on top of the actual
00736                 // bitmap size, so lets work out how much we need ...
00737                 INT32 size = NewBitmapSize;
00738 
00739                 #define DIB_DEBUG 0
00740 
00741                 #if DIB_DEBUG
00742                 const INT32 dbsize = DIBUtil::ScanlineSize( NewWidth, uBitmapDepth ) * DIB_DEBUG*2;
00743                 if (dbsize<16)
00744                     dbsize = 16;
00745                 #else
00746                 const INT32 dbsize = 0;
00747                 #endif
00748 
00749                 if (size==0)
00750                     size = 4;                                       // in case of zero w or h
00751 
00752                 // Added extra bit on
00753                 INT32 NewSize = size + dbsize + EXTRA_GAVIN_BYTES + DIBUtil::ScanlineSize(NewWidth, uBitmapDepth);
00754 
00755                 // Resize the DIB to the new size (always smaller)
00756                 pBits = ResizeBits(pBits, NewSize);
00757 //              TRACEUSER("Gerry", _T("ReAlloc called. Bits now at %x, size=%d\n"), pBits, NewSize);
00758 
00759                 if (pBits == NULL)
00760                 {
00761                     ResetRegion(NewRegionRect);
00762                     return;
00763                 }
00764 
00765                 // Set the new Gavin clip rect
00766                 GetDrawContext()->ClipRectangle( (LPRECT)&NewClipRect );
00767             }
00768             else
00769             {
00770                 // Make smaller failed, so we'll do it the old lazy way.
00771                 ResetRegion(NewRegionRect);
00772             }
00773         }
00774     }
00775 
00776     // set new rectangle size
00777     WRect = NRect;
00778 
00779     // Update the clip rect if one was given
00780     CurrentClipRect = NewClipRect;
00781     RegionRect      = NewRegionRect;
00782 
00783     // Update the master capture
00784     Capture* pMasterCapture = GetMasterCapture();
00785     pMasterCapture->CaptureRect = NewClipRect;
00786     pMasterCapture->CaptureMatrix = ViewMatrix;
00787     pMasterCapture->lpBitmapInfo = pBitmapInfo;
00788     pMasterCapture->lpBits = pBits;
00789 
00790     GMATRIX gmat = MakeGavinMatrix(RenderMatrix, CurrentClipRect, pMasterCapture->dPixelsPerInch, TRUE);
00791     SetGavinMatrix(&gmat);
00792 
00793     // Since we have changed the clipping rect the GDraw changed bounding box may no longer be
00794     // correct so we must enlarge it to be full size...
00795     RECT bbox;
00796     bbox.left = 0;
00797     bbox.right = NewWidth;
00798     bbox.top = 0;
00799     bbox.bottom = NewHeight;
00800     BOOL ok = GetDrawContext()->SetChangedBBox(&bbox);
00801     ERROR2IF(!ok, (void)0, "GDraw_SetChangedBBox failed");
00802 
00803 }

BOOL GRenderDIB::SetFirstBand  )  [virtual]
 

This determines if banding is needed for this render region and sets up ready for it. If this region is already banded, then this function does nothing - it is safe to call this even if it has been called before.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/95
Returns:
TRUE if all went well. FALSE if it did not

Reimplemented from RenderRegion.

Reimplemented in GRenderBitmap, GRenderClick, and GRenderPrint.

Definition at line 409 of file grnddib.cpp.

00410 {
00411     // if we are already banded, or we already have a bitmap, then stop looking
00412     if (IsBanded() || pBitmapInfo!=NULL)
00413         return TRUE;
00414 
00415 //  ENSURE(GetCaptureDepth()==0, "Can't set a band while there are any captures running");
00416     ENSURE(GetCaptureDepth()==0 || MasterCaptureIsCurrent(), "Can't set a band while there are any non-master captures running\n");
00417 
00418     // They can be merged for the time being
00419     CanRegionBeMerged = TRUE;
00420 
00421     // Make sure the InitDevice has been called.
00422     if (!RenderFlags.ValidDevice)
00423     {
00424         // Device needs to be initialised
00425         if (!InitDevice())
00426         {
00427             // Something's gone wrong - inform the user.
00428             TRACE( _T("InitDevice failed in Render Region"));
00429             return FALSE;
00430         }
00431 
00432         // Make sure we don't do this again for this render region
00433         RenderFlags.ValidDevice = TRUE;
00434     }
00435 
00436     // ok, how much ram do we need and how much ram is there to use
00437     TunedMemory* pTunedMem = GetTunedMemManager();
00438     if (pTunedMem==NULL)
00439         return FALSE;
00440 
00441     // If we are not limited, then do not bother with the bands
00442     if (pTunedMem->IsMemSizeInfinite())
00443     {
00444         // No Banding needed
00445         IsRegionBanded = FALSE;
00446         IsWaitingForRAM = FALSE;
00447         IsLastBand = TRUE;
00448         return TRUE;
00449     }
00450 
00451     // We are limited, so find out how much we are allowed
00452     size_t AvailableRAM = pTunedMem->GetAvailableTunedMem();
00453     
00454     // Work out a rough idea of the amount of ram needed
00455     INT32 ScanLineSize = DIBUtil::ScanlineSize(WRect.width, uBitmapDepth);
00456     if (ScanLineSize==0)
00457         return FALSE;
00458 
00459     // Work out how many scan lines we could fit into the available ram
00460     INT32 MaxScanLines = INT32(AvailableRAM / ScanLineSize);
00461     INT32 Height = WRect.height;
00462 
00463     // see if there are enought to bother with
00464     if (MaxScanLines<16)
00465     {
00466         // Not really enough memory to bother
00467         IsWaitingForRAM = TRUE;
00468         return TRUE;
00469     }
00470 
00471     // See if we can do it
00472     if (MaxScanLines>=Height)
00473     {
00474         // No Banding needed
00475         IsRegionBanded = FALSE;
00476         IsWaitingForRAM = FALSE;
00477         IsLastBand = TRUE;
00478         return TRUE;
00479     }
00480     else
00481     {
00482         // Lets band this region then
00483         IsRegionBanded = TRUE;
00484         IsWaitingForRAM = FALSE;
00485         IsLastBand = FALSE;
00486         CanRegionBeMerged = FALSE;
00487 
00488         // Find out how big in millipoints we can do
00489         double TruePixelHeight = 72000.0 / PixelsPerInch; //.MakeDouble();
00490         TruePixelHeight = TruePixelHeight / ScaleFactor.MakeDouble();
00491         MILLIPOINT MaxHeight = (MILLIPOINT)(TruePixelHeight * (double)MaxScanLines);
00492 
00493         // Set up the new clip rect ready
00494         DocRect NewClipRect = CurrentClipRect;
00495         NewClipRect.hi.y = NewClipRect.lo.y + MaxHeight;
00496 
00497         // Sanity check
00498         if (NewClipRect.hi.y>CurrentClipRect.hi.y)
00499             NewClipRect.hi.y = CurrentClipRect.hi.y;
00500 
00501         // Set the new clip rect up ready for rendering
00502         SetClipRect(NewClipRect);       
00503         return TRUE;
00504     }
00505 }


Member Data Documentation

INT32 GRenderDIB::m_test [protected]
 

Definition at line 137 of file grnddib.h.


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