QuickRenderer Class Reference

#include <offscrn.h>

Inheritance diagram for QuickRenderer:

GRenderRegionWrapper CCObject SimpleCCObject ConcurrentRenderer List of all members.

Public Member Functions

 QuickRenderer ()
 ~QuickRenderer ()
virtual BOOL Initialise (GRenderRegion *pActiveRR, double ResFactor, DocRect AreaOfDocumentToRender, UINT32 bpp, BOOL NeedsTransp)
virtual BOOL RestorePreviousRendererState ()
virtual GRenderRegionGetRenderRegion ()

Static Public Member Functions

static GRenderDIBCreateGRenderDIB (double ResFactor, DocRect AreaOfDocumentToRender, UINT32 bpp, BOOL NeedsTransp, Matrix *pMat=NULL)

Protected Member Functions

void RestoreSimple ()

Protected Attributes

GRenderDIBm_pNewRR

Detailed Description

Definition at line 221 of file offscrn.h.


Constructor & Destructor Documentation

QuickRenderer::QuickRenderer  ) 
 

Definition at line 429 of file offscrn.cpp.

00430 {
00431     m_pNewRR = NULL;
00432 }

QuickRenderer::~QuickRenderer  ) 
 

Definition at line 441 of file offscrn.cpp.

00442 {
00443     ENSURE(m_pNewRR==NULL,"Deconstructor not meant to be called like this. Use RestorePreviousRendererState()");
00444 }


Member Function Documentation

GRenderDIB * QuickRenderer::CreateGRenderDIB double  ResFactor,
DocRect  AreaOfDocumentToRender,
UINT32  bpp,
BOOL  NeedsTransp,
Matrix pMat = NULL
[static]
 

Definition at line 531 of file offscrn.cpp.

00537 {
00539     //                              Setup a new GRenderDIB
00541     GRenderDIB* pNewGRR=NULL;
00542     BOOL DoWantBMPSmoothing = FALSE;
00543     BOOL ok;
00544 
00545     // Setup new GRenderDIB based on current Screen resolution and ResFactor multiplier
00546     View* pView = View::GetCurrent();
00547 
00548     // get the top spread
00549     Spread* pSpread = Document::GetSelectedSpread();
00550 
00551     // if we've been passed a source matrix, then we'll scale it up by ResFactor and use that.
00552 // DEBUG:
00553     // Note that we currently check whether the view is for printing, solely so that this code
00554     // can live on the net without breaking printing of shadows more than it already is.
00555     Matrix Mat;
00556     if (pSourceMat != NULL)
00557     {
00558         FIXED16 Scale;
00559         DocCoord dcTrans;
00560 
00561         pSourceMat->Decompose(&Scale, NULL, NULL, NULL, &dcTrans);
00562 
00563         // Karim 04/09/2000
00564         // BODGE, to cope with printing reflected images.
00565         // If the given matrix contains a reflection, then its determinant < 0.
00566         // If this is so, then we'll scale the matrix by -1, which corrects the output.
00567         if (pSourceMat->Det() < 0.0)
00568             Scale *= FIXED16(-1);
00569 
00570         Mat = Matrix(Scale * FIXED16(ResFactor), Scale * FIXED16(ResFactor));
00571         Mat.SetTranslation(dcTrans);
00572 
00573 //      Mat *= *pSourceMat;
00574     }
00575 
00576     // otherwise, we'll use the view's settings, scaled up by ResFactor.
00577     else
00578     {
00579         Mat = pView->ConstructScaledRenderingMatrix(pSpread, ResFactor);
00580     }
00581 
00582     // get the scale factor out of the matrix.
00583     FIXED16 Scale;
00584     Mat.Decompose(&Scale);
00585 
00586     //  double dpi = Scale.MakeDouble() * PIXELS_PER_INCH;
00587     double dpi = 0.0;   // use screen dpi (ie PIXELS_PER_INCH)
00588 
00589     // Create a new GRenderDIB region
00590     pNewGRR = new GRenderDIB(AreaOfDocumentToRender, Mat, Scale, bpp, dpi);
00591     ERROR2IF(pNewGRR == NULL,FALSE,"Failed to create a GRenderDIB!");
00592 
00593     // Ensure bmp mem is not allocated from limited memory
00594     NewWrappedRRCreated((GRenderRegion*) pNewGRR);
00595 
00596     // State flags + pixel width calculations
00597     if(!pNewGRR->AttachDevice(pView, NULL, pSpread))        // view and spread from previous RR rather than Current - nb in create bitmap copy case
00598     {
00599         ERROR3("Cannot attach devices");
00600         
00601         delete pNewGRR;
00602         pNewGRR = NULL;
00603         return NULL;
00604     }
00605 
00606     pNewGRR->m_DoCompression = NeedsTransp;
00607     
00608     ok = pNewGRR->InitDevice();
00609     if (!ok)
00610     {
00611         delete pNewGRR;
00612         pNewGRR = NULL;
00613         return NULL;
00614     }
00615     pNewGRR->InitAttributes();
00616     pNewGRR->RRQuality.SetQuality(QUALITY_MAX);
00617     pNewGRR->SetQualityLevel();
00618     pNewGRR->SetLineAttributes();
00619     pNewGRR->SetFillAttributes();
00620 
00621     // NB following call gets GRendRegion to create the bitmap into which GDraw will render
00622     BOOL Started = pNewGRR->StartRender();
00623 
00624 // Karim 06/07/2000
00625 // I'm commenting these pre-processor directives out, to fix a bug with the new shadowing
00626 // code, where shadows at anything other than 100% zoom are incorrectly scaled. This is a
00627 // BODGE, and this code should be revisited at a later date.
00628 
00629 //#ifdef _DEBUG
00630     // Set DIB dpi indicators correctly - so they are correct if adding to bitmap gallery (not required)
00631     double  PixPerMetre =   PIXELS_PER_INCH * INCHES_PER_METRE;
00632             PixPerMetre *=  Scale.MakeDouble();
00633 
00634     LPBITMAPINFO bi;
00635     LPBYTE by;
00636     GetBitmapPointers(pNewGRR,&bi,&by);
00637     if(bi)
00638     {
00639         bi->bmiHeader.biXPelsPerMeter = (INT32) (PixPerMetre + 0.5);
00640         bi->bmiHeader.biYPelsPerMeter = (INT32) (PixPerMetre + 0.5);
00641     }
00642 //#endif
00643 
00644     if(Started)
00645     {
00646         pNewGRR->SaveContext();
00647 
00648         if(DoWantBMPSmoothing)
00649         {
00650             (pNewGRR->GetDrawContext())->SetTileSmoothingFlag(TRUE);
00651         }
00652 
00653         return pNewGRR;
00654     }
00655     else
00656     {
00657 //      ENSURE(FALSE,"StartRender failed to alloc bmp for GDraw to render into.");
00658         delete pNewGRR;
00659         return NULL;
00660     }
00661 
00662 }

virtual GRenderRegion* QuickRenderer::GetRenderRegion void   )  [inline, virtual]
 

Implements GRenderRegionWrapper.

Definition at line 236 of file offscrn.h.

00236 { return (GRenderRegion*) m_pNewRR; }

BOOL QuickRenderer::Initialise GRenderRegion pActiveRR,
double  ResFactor,
DocRect  AreaOfDocumentToRender,
UINT32  bpp,
BOOL  NeedsTransp
[virtual]
 

Implements GRenderRegionWrapper.

Reimplemented in ConcurrentRenderer.

Definition at line 458 of file offscrn.cpp.

00464 {
00465     ENSURE(pActiveRR==NULL,"GDraw state about to be change unrevocably, and it appears there is a render region active");
00466 
00467     // Setup a new GRenderDIB (NB also initialises memory)
00468     m_pNewRR = CreateGRenderDIB(ResFactor, AreaOfDocumentToRender, bpp, NeedsTransp);
00469 
00470     if(m_pNewRR)
00471         return TRUE;
00472     else
00473         return FALSE;
00474 }

BOOL QuickRenderer::RestorePreviousRendererState  )  [virtual]
 

Implements GRenderRegionWrapper.

Reimplemented in ConcurrentRenderer.

Definition at line 510 of file offscrn.cpp.

00511 {
00512     RestoreSimple();
00513 
00514     delete this;
00515     return TRUE;
00516 }

void QuickRenderer::RestoreSimple  )  [protected]
 

Definition at line 487 of file offscrn.cpp.

00488 {
00489     // assumes you have already got pointers to the rendered bitmap, and don't want it to be deleted
00490     SetBitmapPointers(NULL,NULL);       // NB now that we are using GRenderDIB need to be careful not to DisplayBits() in StopRender()
00491     if (m_pNewRR)
00492     {
00493         m_pNewRR->StopRender();
00494         delete m_pNewRR;
00495         m_pNewRR = NULL;
00496     }
00497 }


Member Data Documentation

GRenderDIB* QuickRenderer::m_pNewRR [protected]
 

Definition at line 247 of file offscrn.h.


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