00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 #ifndef INC_GRNDRGN
00105 #define INC_GRNDRGN
00106
00107
00108
00109
00110
00111
00112 #include "gdrawcon.h"
00113
00114 #include "GDrawIntf.h"
00115
00116
00117 class GradFillAttribute;
00118 class BitmapFillAttribute;
00119 class BitmapTranspFillAttribute;
00120 class KernelBitmap;
00121 class TranspGradTable;
00122 class OffscreenAttrValue;
00123 class ClipRegionAttribute;
00124 class CaptureManager;
00125 class Capture;
00126
00127 enum BitmapConvertHint;
00128
00129 typedef struct {
00130 WORD palVersion;
00131 WORD palNumEntries;
00132 PALETTEENTRY palPalEntry[256];
00133 } RealLogPalette;
00134
00135 typedef CMapPtrToPtr ClipRegionMap;
00136 typedef CMapPtrToPtr ClipRectMap;
00137
00138 #define USE_wxBITMAP 0
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 class GRenderRegion : public RenderRegion
00155 {
00156 CC_DECLARE_DYNAMIC( GRenderRegion )
00157
00158 friend class GBrush;
00159 friend class OpGDraw;
00160
00161 friend class GRenderRegionWrapper;
00162 friend class ConcurrentRenderer;
00163 friend class GDrawBorrower;
00164
00165 public:
00166
00167 GRenderRegion();
00168 GRenderRegion(DocRect ClipRegion, Matrix ConvertMatrix, FIXED16 ViewScale, UINT32 Depth, double dpi);
00169 virtual ~GRenderRegion();
00170
00171 static BOOL Init();
00172
00173
00174 virtual BOOL CopyRenderInfo( const RenderRegion &Other);
00175 virtual BOOL AttachDevice(View*, wxDC *, Spread* = NULL, bool fOwned = false );
00176 virtual BOOL InitDevice();
00177
00178 BOOL StartRender();
00179 BOOL StopRender();
00180 virtual void SetClean(BOOL bResetChangedBounds, BOOL FillWhite);
00181 virtual BOOL IsClean() {return !HaveRenderedSomething;}
00182
00183 void DrawPathToOutputDevice(Path* PathToDraw, PathShape shapePath=PATHSHAPE_PATH);
00184 void DrawRect(DocRect *RectToRender);
00185 void DrawDragRect(DocRect *RectToRender);
00186 void DrawLine(const DocCoord &StartPoint, const DocCoord &EndPoint);
00187 void DrawBlob(DocCoord p, BlobType type);
00188 void DrawPixel(const DocCoord &Point);
00189 void DrawCross(const DocCoord &Point, const UINT32 Size);
00190
00191 void DrawBitmap(const DocCoord &Point, KernelBitmap* pBitmap);
00192 void DrawBitmap(const DocCoord &Point, UINT32 BitmapID, UINT32 ToolID = NULL);
00193 void DrawBitmap(const DocRect& rect, KernelBitmap* pBitmap);
00194
00195 void DrawBitmapBlob(const DocCoord &Point, KernelBitmap* BlobShape) {}
00196 void DrawBitmapBlob(const DocCoord &Point, ResourceID resID ) {}
00197
00198 void DrawFixedSystemText(StringBase *TheText, DocRect &BoundsRect, UINT32 uFormat = DEFAULT_TEXT_FORMATTING);
00199 void SetFixedSystemTextColours(DocColour *TextCol, DocColour *Background);
00200 void GetFixedSystemTextSize(StringBase *TheText, DocRect *BoundsRect, double* atDpi = NULL);
00201
00202 void InitClipping();
00203 void InitAttributes();
00204 void SetLineAttributes();
00205 void SetFillAttributes();
00206 void SetOSDrawingMode();
00207 void SetQualityLevel();
00208
00209 void Restore(RenderRegion*);
00210
00211 BOOL RenderGradFillPath(Path *, GradFillAttribute* );
00212
00213 BOOL RenderBitmapFill (Path *, BitmapFillAttribute* );
00214
00215 virtual void SetSolidColours(BOOL SetSolid);
00216
00217
00218 static RenderRegion* Create(DocRect ClipRegion, Matrix ConvertMatrix, FIXED16 ViewScale,
00219 RenderType, View* pView = NULL, BOOL bForce32BPP = FALSE);
00220 static BOOL Init(BOOL);
00221 static void DeInit();
00222 static BOOL CalcBlitMode( INT32 Wanted );
00223
00224 GDrawContext *GetDrawContext() const
00225 {
00226 return GD;
00227 };
00228
00229 static GDrawContext* SetTempDrawContext(GDrawContext* pContext)
00230 {
00231
00232 if (pContext == NULL)
00233 {
00234 TRACEUSER( "Gerry", _T("******** Trying to set a NULL GDrawContext\n") );
00235 pContext = pRealGD;
00236 }
00237
00238 GDrawContext* pOldCon = GD;
00239 GD = pContext;
00240
00241 return(pOldCon);
00242 };
00243
00244 static GDrawContext *GetStaticDrawContext()
00245 {
00246 #ifdef RALPH
00247 if (GDrawAsm::GetContextForCurrentThread() != NULL)
00248 return(GDrawAsm::GetContextForCurrentThread());
00249 #endif
00250
00251 return GD;
00252 };
00253
00254 static GDrawContext *GetStaticDrawContext(INT32 DitherType)
00255 {
00256 #ifdef RALPH
00257 if (GDrawAsm::GetContextForCurrentThread() != NULL)
00258 return(GDrawAsm::GetContextForCurrentThread());
00259 #endif
00260
00261 if ((DitherType == 0) || (DitherType == 3))
00262 return(ErrorDiffContext);
00263 else
00264 return(GD);
00265 }
00266
00267 static INT32 GetDefaultTransparency() { return WhichTransparency; }
00268
00269 static UINT32 SetPaletteEntries( LPBITMAPINFO lpBmi, wxDC* pOutputDC = NULL );
00270
00271
00272 virtual WinRect CalculateWinRect( Matrix& RenderMatrix, const DocRect& docrect,
00273 const double dpi);
00274
00275 virtual WinRect CalculateWinRect( const DocRect& docrect);
00276
00277 void SetDeepDIB(BOOL Value);
00278
00279
00280
00281
00282 const RGBQUAD* Get32BitRGBQuadData(){ return (RGBQUAD*)pBits;}
00283 UINT32 GetSizeOfRGBQuadData() { return pBitmapInfo ? pBitmapInfo->bmiHeader.biWidth * pBitmapInfo->bmiHeader.biHeight : 0; }
00284
00285 void SetDoCompression(BOOL bDoCompression) { m_DoCompression = bDoCompression; }
00286
00287 void SetDoBitmapConversion(BOOL bEnable) { m_bEnableConversion = bEnable; }
00288
00289 DocRect GetChangedRect();
00290
00291 void SetBitmapPointers(LPBITMAPINFO bi, LPBYTE by);
00292 BOOL GetBitmapPointers(LPBITMAPINFO* ppInfo, LPBYTE* ppBits, BOOL bCorrectTransparency = TRUE);
00293
00294 protected:
00295
00296 static GDrawContext *pRealGD;
00297 static GDrawContext *GD;
00298 static GDrawContext *ErrorDiffContext;
00299
00300 GMATRIX CurrentGMatrix;
00301
00302 GMATRIX SetGavinMatrix(GMATRIX* GMatrix);
00303 virtual GMATRIX MakeGavinMatrix(Matrix NewRenderMatrix, DocRect ClipRect, double PixelsPerInch, BOOL bMasterCapture);
00304 virtual double GetPixelsPerInch() {return PixelsPerInch;}
00305
00306 MILLIPOINT CalcPixelWidth();
00307 double CalcPixelWidthDouble();
00308 MILLIPOINT CalcScaledPixelWidth();
00309 double CalcScaledPixelWidthDouble();
00310
00311 RRCaps Caps;
00312
00313 public:
00314 double GetScaledPixelWidthDouble();
00315 void SetSimulatePrinting(UINT32 PrintType);
00316 virtual void GetRenderRegionCaps(RRCaps* pCaps);
00317
00318
00319
00320
00321 virtual SlowJobResult DrawMaskedBitmap(const DocRect &Rect, KernelBitmap* pBitmap,
00322 MaskedRenderRegion* pMask, ProgressDisplay *Progress);
00323 protected:
00324 BOOL GetTransparencyFill(TranspGradTable*, DWORD*);
00325
00326 virtual BOOL DrawArrowHead(ArrowRec &ArrowToDraw, DocCoord &Centre, DocCoord &Direction);
00327
00328 BOOL SetBitmapTransparencyFill(TranspFillAttribute*, DWORD*, TranspGradTable*);
00329
00330
00331
00332
00333 BOOL SetFractalFill(ColourFillAttribute*, DWORD*);
00334 BOOL SetFractalTransparencyFill(TranspFillAttribute*, DWORD*);
00335
00336
00337
00338 virtual LPBITMAPINFO GetLPBits( INT32 Width, INT32 Height, INT32 Depth, LPBYTE*) = 0;
00339 virtual void FreeLPBits( LPBITMAPINFO, LPBYTE ) = 0;
00340 virtual BOOL DisplayBits(LPBITMAPINFO lpDisplayBitmapInfo = NULL, LPBYTE lpDisplayBits = NULL) = 0;
00341
00342
00343 virtual void InitBmpBits();
00344 virtual BOOL StartRenderAfter(GMATRIX*);
00345 virtual BOOL StartRenderMiddle();
00346 virtual void DisplayCurrentState();
00347
00348
00349 LPBITMAPINFO pBitmapInfo;
00350 LPBYTE pBits;
00351
00352 UINT32 uBitmapDepth;
00353 UINT32 uLineSize;
00354
00355 #if USE_wxBITMAP
00356 wxBitmap* pBitmap;
00357 wxAlphaPixelData* pBitmapData;
00358
00359 LPBITMAPINFO AllocWxBitmap( UINT32 Width, UINT32 Height, UINT32 Depth );
00360 void FreeWxBitmap();
00361 #endif
00362
00363 wxRect WRect;
00364 wxRect ScreenRect;
00365
00366 double PixelsPerInch;
00367 double dScaledPixelWidth;
00368
00369 wxPalette* hPalette;
00370 wxPalette* hPrevPalette;
00371
00372 BOOL LocalBitmap;
00373
00374 BOOL UseSolidColours;
00375
00376 BOOL m_bForceBitmapSmoothing;
00377
00378 BOOL m_bEnableConversion;
00379 BOOL ForceInitBmpBits;
00380
00381 INT32 DitherStyle8Bit;
00382
00383 BOOL HaveRenderedSomething;
00384
00385 UINT32 m_ForcePrintingCaps;
00386
00387 void Display1to1Bitmap();
00388 void DisplayLtoHBitmap();
00389 void DisplayHto8Bitmap();
00390
00391 void PlotBitmap( UINT32 ColourFlag );
00392 void PlotBitmap( wxDC *pDC, UINT32 ColourFlag, INT32 Left, INT32 Top, UINT32 Width, UINT32 Height, wxPalette* hPal, INT32, INT32 );
00393 public:
00394 static LPBYTE StaticPlotBitmap( wxDC *pDC, UINT32 ColourFlag, LPBITMAPINFO lpBitmapInfo, LPBYTE lpBits, INT32 Left, INT32 Top, UINT32 Width, UINT32 Height, wxPalette* hPal, INT32, INT32 );
00395 protected:
00396
00397
00398
00399 static UINT32 ClickTranspLimit;
00400
00401
00402 static BOOL HighQualityAA;
00403
00404
00405 static INT32 BitmapConversion;
00406
00407 public:
00408
00409
00410
00411 void SetForceBitmapSmoothing(BOOL ForceSmoothing) { m_bForceBitmapSmoothing = ForceSmoothing; }
00412 BOOL IsForcingBitmapSmoothing() { return m_bForceBitmapSmoothing; }
00413
00414 private:
00415 BOOL SetGCol( DocColour& ) const;
00416 BOOL SetFillGCol( DocColour& ) const;
00417
00418 DocCoord DocCoordToG(const DocCoord& DocPoint);
00419 void DocCoordToG( DocCoord *DocPoint );
00420 BOOL StrokePath( const DocCoord *, const PathVerb*, UINT32,
00421 const DocCoord *, const PathVerb*, UINT32, BOOL DrawArrows = FALSE);
00422
00423
00424 protected:
00425
00426
00427 static BOOL WantDoGDraw;
00428 static UINT32 WantGDrawDepth;
00429
00430
00431 static BOOL WantHighColourDirect;
00432 static BOOL WantDeepGDraw;
00433
00434 static INT32 WhichPalette;
00435 static INT32 WhichDither;
00436 static INT32 WhichTransparency;
00437 static INT32 ViewDither;
00438
00439 static BOOL CanDoGDraw;
00440
00441 static BOOL CanDoPalIndices;
00442 static BOOL CanSetPalette;
00443
00444
00445 static INT32 ScreenDepth;
00446 static INT32 ScreenWidth;
00447 static INT32 ScreenHeight;
00448 static INT32 LogPixelsX;
00449 static INT32 LogPixelsY;
00450
00451
00452
00453
00454
00455 static LPRGBQUAD Fixed256Palette;
00456
00457 static BitmapConvertHint ScreenHinting;
00458
00459 static INT32 LastPaletteFlag;
00460
00461 static RealLogPalette ErrorDiffPalette;
00462
00463 protected:
00464 static void UpdateErrorDiffPalette(void);
00465
00466 public:
00467
00468
00469
00470
00471
00472 public:
00473 static const LOGPALETTE* GetRecommendedPalette();
00474
00475 static BOOL StrokePathAvailable();
00476 static INT32 StrokePathToPath(
00477 CONST DocCoord *IPoints,
00478 CONST BYTE FAR *ITypes,
00479 size_t ILength,
00480 DocCoord *OPoints,
00481 BYTE *OTypes,
00482 DWORD OLength,
00483 BOOL Close,
00484 DWORD LineWidth,
00485 DWORD Flattening,
00486 LineCapType LineCaps,
00487 JointType LineJoin,
00488 CONST DashType *Dash);
00489 static void GColInit( wxDC *, BOOL = FALSE );
00490 static void PaletteHasChanged();
00491 static void EnsurePalette(INT32 PaletteFlag);
00492 static LPLOGPALETTE GetErrorDiffPalette(void)
00493 {
00494 return((LPLOGPALETTE)&ErrorDiffPalette);
00495 };
00496
00497 static void SetViewDither(INT32 dither){ViewDither = dither;};
00498
00499 static DWORD GetMaxBitmapWidth(void);
00500 static DWORD GetMaxBitmapDepth(void);
00501 static INT32 GetDefaultDPI()
00502 {
00503 return LogPixelsX;
00504 };
00505
00506 public:
00507 void SetDitherStyle8Bit(INT32 DitherStyle)
00508 {
00509 DitherStyle8Bit = DitherStyle;
00510 };
00511
00512
00513 virtual void ResetRegion(DocRect &NewClipRect);
00514
00515 public:
00516 void FreeOffscreenState();
00517
00518 public:
00519 virtual void SetOffscreen(OffscreenAttrValue*);
00520 virtual void RestoreOffscreen(OffscreenAttrValue*);
00521 BOOL RenderBitmapWithTransparency(
00522 Path*,
00523 BitmapFillAttribute*,
00524 BitmapTranspFillAttribute*
00525 );
00526 virtual BOOL IsWrappedRender() const {return IsWrapped;}
00527 virtual BOOL TranspTypeIsRGBTCompatible(UINT32 ttype) const;
00528 TransparencyEnum MapTranspTypeToGDraw(UINT32 ttype, BOOL bGraduated) const;
00529
00530
00532
00533
00534
00535 public:
00536 virtual Capture* StartCapture(CCObject* pOwner,
00537 DocRect CaptureRect,
00538 CAPTUREINFO cinfo,
00539 BOOL bTransparent = TRUE,
00540 BOOL bCaptureBackground = FALSE,
00541 double mpPixelWidth = 0,
00542 NodeRenderableInk* pDirectSupplier = NULL
00543 );
00544 virtual BOOL StopCapture(CCObject* pOwner,
00545 BOOL bRender = TRUE,
00546 BOOL bReleaseBitmap = FALSE,
00547 LPBITMAPINFO* plpBitmapInfo = NULL,
00548 LPBYTE* plpBits = NULL,
00549 DocRect* pCaptureRect = NULL,
00550 Matrix* pmatTransform = NULL,
00551 double* pdResolution = NULL
00552 );
00553 virtual BOOL ChangeCapture(CAPTUREINFO cinfo,
00554 BOOL bTransparent = TRUE,
00555 BOOL bCaptureBackground = FALSE
00556 );
00557
00558 virtual BOOL MasterCaptureIsCurrent() const {return (!m_CaptureStack.Empty() && GetTopCaptureBitmap() && GetTopCaptureBitmap()->IsMaster());}
00559
00560
00561 virtual BOOL RenderCurrentCaptureState(BOOL bStartFromMaster = FALSE);
00562 virtual Capture* GetTopCaptureBitmap(Capture* pFromCapture = NULL) const;
00563 virtual BOOL TopCaptureIsDirect() {return (GetTopCapture() && GetTopCapture()->IsDirect());}
00564
00565
00566 protected:
00567 virtual BOOL SetRenderToCapture(Capture* pCapture, BOOL bApplyClipRegion = FALSE, BOOL bSetBitmap = TRUE);
00568 virtual BOOL SetupDirectCapture(Capture* pNewCapture, NodeRenderableInk* pSupplier);
00569
00570
00571
00572
00573
00574
00576
00577 protected:
00578 BOOL IsWrapped;
00579 void SetIsWrapped(BOOL flag) { IsWrapped = flag; }
00580
00582
00583
00584 public:
00585 virtual void SetClipRegion (ClipRegionAttribute * pClipAttr, BOOL Temp);
00586 virtual void RestoreClipRegion (ClipRegionAttribute * pClipAttr, BOOL Temp);
00587
00588 private:
00589
00590
00591 protected:
00592 const REGION* MakeClipRegionFromClipAttr(ClipRegionAttribute* pClipAttr);
00593 BOOL ApplyCurrentClipRegion();
00594 void FreeStoredClipRegions();
00596
00597 public:
00598 void OffsetByHalfPixel();
00599 virtual BOOL GrabBitmap(DocRect* rectGrab, LPBITMAPINFO* plpBitmapInfo, LPBYTE* plpBits);
00600
00601 #ifdef _DEBUG
00602 virtual void DebugTrace();
00603 BOOL DumpCaptureStack();
00604 #endif
00605
00606 protected:
00607
00608
00609 BOOL IsScaledUp(FillGeometryAttribute *Fill);
00610 BOOL IsAt100Percent(FillGeometryAttribute *Fill);
00611 BOOL IsDistorted(FillGeometryAttribute *Fill);
00612 BOOL NeedToSmooth(FillGeometryAttribute *Fill,BOOL bAlreadyScaled);
00613 virtual BOOL SetSmoothingFlags(FillGeometryAttribute *Fill);
00614 };
00615
00616
00617 class OpDescriptor;
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631 class OpGDraw : public Operation
00632 {
00633 CC_DECLARE_DYNCREATE( OpGDraw )
00634
00635 public:
00636 OpGDraw();
00637
00638 void Do(OpDescriptor*);
00639
00640 static BOOL Init();
00641 static OpState GetState(String_256*, OpDescriptor*);
00642 };
00643
00644 #define OPTOKEN_GDRAW _T("GDrawToggle")
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657 #endif