summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2013-11-04 17:33:20 +0200
committerJan Holesovsky <kendy@collabora.com>2013-11-15 16:52:07 +0100
commit8b9246b98aac039b8dbc4fb9e78efdb3bc3e9420 (patch)
tree512a2a486d8678e7efc37c781c422ee490c14a50 /sw
parentfd530527fbe14a6e41c3c2d1c8788e98068ff1bb (diff)
Update the code snippet for tile rendering to be like in touch_lo_draw_tile()
Unfortunately the tiledrendering test program doesn't seem to work as expected any more, though. (Not before this commit, not after.) Obviously the common code needs to be factored out. Later. Change-Id: Ia33d065467eb5a287a06bf337e20b4a9a34ce561
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/tiledrendering/tiledrendering.cxx22
1 files changed, 17 insertions, 5 deletions
diff --git a/sw/qa/tiledrendering/tiledrendering.cxx b/sw/qa/tiledrendering/tiledrendering.cxx
index 9d168d892020..65f02dbc5407 100644
--- a/sw/qa/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/tiledrendering/tiledrendering.cxx
@@ -105,8 +105,8 @@ IMPL_LINK ( TiledRenderingDialog, RenderHdl, Button *, EMPTYARG )
int contextHeight = mpContextHeight->GetValue();
int tilePosX = mpTilePosX->GetValue();
int tilePosY = mpTilePosY->GetValue();
- int tileWidth = mpTileWidth->GetValue();
- int tileHeight = mpTileHeight->GetValue();
+ long tileWidth = mpTileWidth->GetValue();
+ long tileHeight = mpTileHeight->GetValue();
// do the same thing we are doing in touch_lo_draw_tile()
SwWrtShell *pViewShell = GetActiveWrtShell();
@@ -124,12 +124,24 @@ IMPL_LINK ( TiledRenderingDialog, RenderHdl, Button *, EMPTYARG )
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);
- aDevice.SetOutputSizePixel(aDevice.PixelToLogic(Size(contextWidth, contextHeight)));
+ // 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
- pViewShell->PaintTile(&aDevice, Rectangle(Point(tilePosX, tilePosY), Size(tileWidth, tileHeight)));
+ // draw - works in logic coordinates
+ pViewShell->PaintTile(&aDevice, Rectangle(Point(tilePosX, tilePosY), aDevice.PixelToLogic(Size(contextWidth, contextHeight))));
// debug
// aDevice.SetFillColor(Color(COL_RED));