[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-commits] Commit Complete
Commit by : alex
Repository : xara
Revision : 1398
Date : Sun Jul 2 20:23:27 BST 2006
Changed paths:
M /Trunk/XaraLX/Kernel/cameleps.h
M /Trunk/XaraLX/wxOil/grndprnt.cpp
M /Trunk/XaraLX/wxOil/printprg.cpp
M /Trunk/XaraLX/wxOil/printprg.h
Speed up printing by yielding less often
First attempt at doing final GRenderPrint blit through a postscript dc.
Diff:
Index: Trunk/XaraLX/Kernel/cameleps.h
===================================================================
--- Trunk/XaraLX/Kernel/cameleps.h (revision 1397)
+++ Trunk/XaraLX/Kernel/cameleps.h (revision 1398)
@@ -410,6 +410,9 @@
virtual void OutputStrokeColour ();
virtual void OutputFillColour ();
+ virtual BOOL DrawParallelogramBitmap(DocCoord *Coords, OILBitmap *pBitmap, EFFECTTYPE Effect = EFFECT_RGB,
+ DocColour *StartCol = NULL, DocColour *EndCol = NULL);
+
protected:
virtual BOOL WriteEPSBoundingBox ( void );
virtual BOOL WriteProlog(KernelDC*);
@@ -417,8 +420,6 @@
virtual BOOL WriteEPSTrailerComments ( void );
BOOL DrawClippedBitmap(Path *DrawPath);
- BOOL DrawParallelogramBitmap(DocCoord *Coords, OILBitmap *pBitmap, EFFECTTYPE Effect = EFFECT_RGB,
- DocColour *StartCol = NULL, DocColour *EndCol = NULL);
BOOL SelectNewFont(WORD Typeface, BOOL Bold, BOOL Italic, MILLIPOINT Size);
BOOL SelectNewFont(WORD Typeface, BOOL Bold, BOOL Italic, FIXED16 *abcd);
Index: Trunk/XaraLX/wxOil/grndprnt.cpp
===================================================================
--- Trunk/XaraLX/wxOil/grndprnt.cpp (revision 1397)
+++ Trunk/XaraLX/wxOil/grndprnt.cpp (revision 1398)
@@ -112,6 +112,8 @@
#include "osrndrgn.h"
#include "view.h"
#include "oilbitmap.h"
+#include "psdc.h"
+#include "psrndrgn.h"
CC_IMPLEMENT_DYNAMIC(GRenderPrint, GRenderDIB)
@@ -349,6 +351,49 @@
BOOL GRenderPrint::DisplayBits(LPBITMAPINFO lpDisplayBitmapInfo, LPBYTE lpDisplayBits)
{
+
+ CCDC * pCCDC = CCDC::ConvertFromNativeDC(RenderDC);
+ BOOL ToNativePS = (pCCDC->IsKindOf(CC_RUNTIME_CLASS(PSPrintDC)));
+
+ if (ToNativePS)
+ {
+ // wxPostscriptDC does not really support stretched blitting of bitmaps. On a good day
+ // when it works it scales the bitmap before outputting it, which means the PS is huge
+ // So we get our native DC to do it.
+
+ // Note that this colour corrects, and separates for us.
+
+ // Set up a PrintPSRenderRegion with the same parameters
+ PrintPSRenderRegion * pRender = new PrintPSRenderRegion(CurrentClipRect, RenderMatrix, ScaleFactor);
+ ERROR2IF(!pRender, FALSE, "Cannot create PrintPSRenderRegion");
+
+ // Try and create the bitmap etc
+ if (!pRender->AttachDevice(RenderView, RenderDC, NULL) || !pRender->StartRender())
+ {
+ delete pRender;
+ ERROR2(FALSE, "Cannot attach device or start rendering");
+ }
+
+ DocCoord Coords[4];
+ Coords[0]=DocCoord(CurrentClipRect.lo.x, CurrentClipRect.hi.y);
+ Coords[1]=CurrentClipRect.hi;
+ Coords[2]=DocCoord(CurrentClipRect.hi.x, CurrentClipRect.lo.y);
+ Coords[3]=CurrentClipRect.lo;
+
+ CWxBitmap oilbitmap(pBitmapInfo, pBits); // note this bitmap thinks it owns the bits and bitmap info
+ pRender->DrawParallelogramBitmap(Coords, &oilbitmap);
+ // now remove the bits and info so that the renderregion can delete them itself
+ LPBYTE DummypBits=NULL;
+ LPBITMAPINFO DummypBitmapInfo=NULL;
+ oilbitmap.ExtractBitsAndInfo(&DummypBits, &DummypBitmapInfo);
+
+ pRender->StopRender();
+
+ delete pRender;
+
+ return TRUE;
+ }
+
INT32 BitmapWidth = pBitmapInfo->bmiHeader.biWidth;
INT32 BitmapHeight = pBitmapInfo->bmiHeader.biHeight;
@@ -437,9 +482,8 @@
{
// Not colour separating, but if it's a 32bpp bitmap, we need to convert to something
// that StretchDIBits (below) can understand
-PORTNOTE("printing", "Do not convert down BPP")
-#ifndef EXCLUDE_FROM_XARALX
- if (uBitmapDepth == 32)
+PORTNOTE("printing", "Do not convert down BPP except under PS")
+ if (ToNativePS && (uBitmapDepth == 32))
{
// Can't plot 32bpp bitmaps to GDI as 16-bit GDI doesn't understand them,
// so we convert to 24bpp bitmap in-situ and render that...
@@ -465,7 +509,6 @@
pBitmapInfo->bmiHeader.biBitCount = 24;
pBitmapInfo->bmiHeader.biSizeImage = DestlineBytes * BitmapHeight;
}
-#endif
}
WinRect clip;
@@ -486,8 +529,32 @@
ERROR3IF(Scanlines == GDI_ERROR, "No scanlines copied in GRenderPrint::DisplayBits()!");
#else
- GRenderRegion::StaticPlotBitmap(RenderDC, DIB_RGB_COLORS, pBitmapInfo, pBits, clip.x, clip.y, clip.width, clip.height, NULL, 0, 0);
+
+
+ // First of all get it into a bitmap we can understand
+ wxBitmap Bitmap(BitmapWidth, BitmapHeight, 24);
+ wxMemoryDC MemDC;
+ MemDC.SelectObject(Bitmap);
+ GRenderRegion::StaticPlotBitmap(&MemDC, DIB_RGB_COLORS, pBitmapInfo, pBits, 0, 0, BitmapWidth, BitmapHeight, NULL, 0, 0);
+
+ //Bitmap.SaveFile(_T("/tmp/x.png"), wxBITMAP_TYPE_PNG);
+
+ // Now blit this to the printer, stretching as appropriate
+#if 0
+ RenderDC->Blit(clip.x, clip.y, clip.GetWidth(), clip.GetHeight(), &MemDC, 0, 0);
+#else
+ INT32 fwidth = clip.GetWidth();
+ INT32 fheight = clip.GetHeight();
+ wxBitmap bitmap( (int)fwidth, (int)fheight, 24 );
+ wxMemoryDC memDC;
+ memDC.SelectObject(bitmap);
+ memDC.Blit(0, 0, fwidth, fheight, &MemDC, 0, 0);
+
+ //bitmap.SaveFile(_T("/tmp/y.png"), wxBITMAP_TYPE_PNG);
+
+ RenderDC->DrawBitmap(bitmap, clip.x, clip.y);
#endif
+#endif
return TRUE;
}
Index: Trunk/XaraLX/wxOil/printprg.h
===================================================================
--- Trunk/XaraLX/wxOil/printprg.h (revision 1397)
+++ Trunk/XaraLX/wxOil/printprg.h (revision 1398)
@@ -177,6 +177,8 @@
BOOL IgnoreUpdates; // TRUE if the dlg is locked against showing any updated info
+ MonotonicTime UpdateTime;
+
public:
// The call back function for the print dialog.
static BOOL AbortProc();
Index: Trunk/XaraLX/wxOil/printprg.cpp
===================================================================
--- Trunk/XaraLX/wxOil/printprg.cpp (revision 1397)
+++ Trunk/XaraLX/wxOil/printprg.cpp (revision 1398)
@@ -163,6 +163,8 @@
Printing = FALSE;
IgnoreUpdates = FALSE;
Aborted = FALSE;
+
+ UpdateTime.Sample();
}
@@ -256,6 +258,7 @@
SetSliderMax(SLIDER_MAX);
SetSliderPos(0);
IgnoreUpdates = FALSE;
+ UpdateTime.Sample();
}
else if (Msg->DlgMsg == DIM_CANCEL)
{
@@ -470,15 +473,23 @@
// Ignore
return TRUE;
+ // Note this only paints the gadget if it is invalidated
pPrintProgressDlg->PaintGadgetNow(0);
- // Save current doc view etc. around yield as paint can destroy them.
- View * pCurrentView = View::GetCurrent();
- Document * pCurrentDocument = Document::GetCurrent();
- ::wxSafeYield(pPrintProgressDlg->WindowID, TRUE);
- pCurrentDocument->SetCurrent();
- pCurrentView->SetCurrent();
+ // Only sample if 750ms of printing has elapsed as the yield can take a while
+ if (pPrintProgressDlg->UpdateTime.Elapsed(750))
+ {
+ // Save current doc view etc. around yield as paint can destroy them.
+ View * pCurrentView = View::GetCurrent();
+ Document * pCurrentDocument = Document::GetCurrent();
+ ::wxSafeYield(pPrintProgressDlg->WindowID, TRUE);
+ pCurrentDocument->SetCurrent();
+ pCurrentView->SetCurrent();
+ // resample after the yield
+ pPrintProgressDlg->UpdateTime.Sample();
+ }
+
return Aborted;
}
Xara