summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2013-11-15 16:47:20 +0100
committerJan Holesovsky <kendy@collabora.com>2013-11-15 16:52:08 +0100
commitb2a94ccdf91c9ea41fbde13ebfb5031ae76bc102 (patch)
tree6f0c5128d093d867c03c595f41682b7437356151 /sw
parentc9705f000086439b444e448d3c0e84b6dab1a522 (diff)
Tiled rendering: Move the common code to the right place - PaintTile().
Change-Id: Id0502c4e0dd48dce8d1a239b5d156ff290314954
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/viewsh.hxx2
-rw-r--r--sw/qa/tiledrendering/tiledrendering.cxx27
-rw-r--r--sw/source/core/view/viewsh.cxx52
3 files changed, 32 insertions, 49 deletions
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 57d3b1b37623..fd314eb2e7f5 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -252,7 +252,7 @@ public:
Sets the pOut so that the rRect is always painted over the entire
pOut, ie. starts in 0,0 and ends in width/height.
*/
- void PaintTile(OutputDevice *pOut, const Rectangle &rRect);
+ void PaintTile(VirtualDevice &rDevice, int contextWidth, int contextHeight, int tilePosX, int tilePosY, long tileWidth, long tileHeight);
sal_Bool IsPaintInProgress() const { return mbPaintInProgress; }
bool IsDrawingLayerPaintInProgress() const { return !mPrePostPaintRegions.empty(); }
diff --git a/sw/qa/tiledrendering/tiledrendering.cxx b/sw/qa/tiledrendering/tiledrendering.cxx
index 65f02dbc5407..57b512ca18e5 100644
--- a/sw/qa/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/tiledrendering/tiledrendering.cxx
@@ -121,31 +121,8 @@ IMPL_LINK ( TiledRenderingDialog, RenderHdl, Button *, EMPTYARG )
// VirtualDevice aDevice(&aData, [color depth]);
VirtualDevice aDevice;
- MapMode aMapMode(aDevice.GetMapMode());
- aMapMode.SetMapUnit(MAP_TWIP);
- aMapMode.SetOrigin(Point(-tilePosX, -tilePosY));
-
- // Scaling. Must convert from pixels to twips. We know
- // that VirtualDevises use a DPI of 96.
- Fraction scaleX = Fraction(contextWidth,96) * Fraction(1440L) / Fraction(tileWidth);
- Fraction scaleY = Fraction(contextHeight,96) * Fraction(1440L) / Fraction(tileHeight);
- aMapMode.SetScaleX(scaleX);
- aMapMode.SetScaleY(scaleY);
-
- aDevice.SetMapMode(aMapMode);
-
- // resizes the virtual device so to contain the entrie context
- aDevice.SetOutputSizePixel(Size(contextWidth, contextHeight));
-
- // scroll the requested area into view if necessary
- pViewShell->MakeVisible(SwRect(Point(tilePosX, tilePosY), aDevice.PixelToLogic(Size(contextWidth, contextHeight))));
-
- // draw - works in logic coordinates
- pViewShell->PaintTile(&aDevice, Rectangle(Point(tilePosX, tilePosY), aDevice.PixelToLogic(Size(contextWidth, contextHeight))));
-
- // debug
- // aDevice.SetFillColor(Color(COL_RED));
- // aDevice.DrawRect(Rectangle(1000, 1000, 2000, 2000));
+ // paint to it
+ pViewShell->PaintTile(aDevice, contextWidth, contextHeight, tilePosX, tilePosY, tileWidth, tileHeight);
// copy the aDevice content to mpImage
Bitmap aBitmap(aDevice.GetBitmap(aDevice.PixelToLogic(Point(0,0)), aDevice.PixelToLogic(Size(contextWidth, contextHeight))));
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 32db8806e137..eef028661d80 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1751,21 +1751,39 @@ void SwViewShell::Paint(const Rectangle &rRect)
}
}
-void SwViewShell::PaintTile(OutputDevice *pOut, const Rectangle &rRect)
+void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contextHeight, int tilePosX, int tilePosY, long tileWidth, long tileHeight)
{
- assert(pOut);
-
- // now we need to setup the SwViewShell's output device
+ // SwViewShell's output device setup
// TODO clean up SwViewShell's approach to output devices (the many of
// them - mpBufferedOut, mpOut, mpWin, ..., and get rid of
// mbTiledRendering)
OutputDevice *pSaveOut = mpOut;
-
mbTiledRendering = true;
- mpOut = pOut;
+ mpOut = &rDevice;
+
+ // setup the output device to draw the tile
+ MapMode aMapMode(rDevice.GetMapMode());
+ aMapMode.SetMapUnit(MAP_TWIP);
+ aMapMode.SetOrigin(Point(-tilePosX, -tilePosY));
+
+ // Scaling. Must convert from pixels to twips. We know
+ // that VirtualDevises use a DPI of 96.
+ Fraction scaleX = Fraction(contextWidth, 96) * Fraction(1440L) / Fraction(tileWidth);
+ Fraction scaleY = Fraction(contextHeight, 96) * Fraction(1440L) / Fraction(tileHeight);
+ aMapMode.SetScaleX(scaleX);
+ aMapMode.SetScaleY(scaleY);
+ rDevice.SetMapMode(aMapMode);
- Paint(rRect);
+ // resizes the virtual device so to contain the entrie context
+ rDevice.SetOutputSizePixel(Size(contextWidth, contextHeight));
+ // scroll the requested area into view if necessary
+ MakeVisible(SwRect(Point(tilePosX, tilePosY), rDevice.PixelToLogic(Size(contextWidth, contextHeight))));
+
+ // draw - works in logic coordinates
+ Paint(Rectangle(Point(tilePosX, tilePosY), rDevice.PixelToLogic(Size(contextWidth, contextHeight))));
+
+ // SwViewShell's output device tear down
mpOut = pSaveOut;
mbTiledRendering = false;
}
@@ -1803,22 +1821,10 @@ void touch_lo_draw_tile(void *context, int contextWidth, int contextHeight, MLOD
// that we get direct rendering; something like:
//
VirtualDevice aDevice;
- MapMode aMapMode(aDevice.GetMapMode());
- aMapMode.SetMapUnit(MAP_TWIP);
- aMapMode.SetOrigin(Point(-tilePosX, -tilePosY));
- // Scaling. Must convert from pixels to twips. We know
- // that VirtualDevises use a DPI of 96.
- Fraction scaleX = Fraction(contextWidth,96) * Fraction(1440L) / Fraction(tileWidth);
- Fraction scaleY = Fraction(contextHeight,96) * Fraction(1440L) / Fraction(tileHeight);
- aMapMode.SetScaleX(scaleX);
- aMapMode.SetScaleY(scaleY);
- aDevice.SetMapMode(aMapMode);
- // resizes the virtual device so to contain the entrie context
- aDevice.SetOutputSizePixel(Size(contextWidth, contextHeight));
- // scroll the requested area into view if necessary
- pViewShell->MakeVisible(SwRect(Point(tilePosX, tilePosY), aDevice.PixelToLogic(Size(contextWidth, contextHeight))));
- // draw - works in logic coordinates
- pViewShell->PaintTile(&aDevice, Rectangle(Point(tilePosX, tilePosY), aDevice.PixelToLogic(Size(contextWidth, contextHeight))));
+
+ // paint to it
+ pViewShell->PaintTile(aDevice, contextWidth, contextHeight, tilePosX, tilePosY, tileWidth, tileHeight);
+
// copy the aDevice content to mpImage
Bitmap aBitmap(aDevice.GetBitmap(aDevice.PixelToLogic(Point(0,0)), aDevice.PixelToLogic(Size(contextWidth, contextHeight))));
BitmapReadAccess * readAccess = aBitmap.AcquireReadAccess();