[Libreoffice-commits] core.git: Branch 'feature/tiledrendering' - sw/qa

Tor Lillqvist tml at collabora.com
Mon Nov 4 16:35:03 CET 2013


 sw/qa/tiledrendering/tiledrendering.cxx |   22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

New commits:
commit 49af35b26e1d8e2d40bbf990ebd51545d52b25f4
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Nov 4 17:33:20 2013 +0200

    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

diff --git a/sw/qa/tiledrendering/tiledrendering.cxx b/sw/qa/tiledrendering/tiledrendering.cxx
index 9d168d8..65f02db 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));


More information about the Libreoffice-commits mailing list