From 8b9246b98aac039b8dbc4fb9e78efdb3bc3e9420 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Mon, 4 Nov 2013 17:33:20 +0200 Subject: 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 --- sw/qa/tiledrendering/tiledrendering.cxx | 22 +++++++++++++++++----- 1 file 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)); -- cgit