summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-05-12 21:42:09 +0200
committerLuboš Luňák <l.lunak@collabora.com>2019-05-22 13:07:19 +0200
commitd76c498d4871f663619f5af3ef90b8a3049e20f2 (patch)
tree2ad666cd4ae771a6b71073f7ac5b526e30aa6384 /canvas
parentf933d523903a58f512a0690ade481dee2185fa60 (diff)
fix complex transformation in CanvasHelper::fillTexturedPolyPolygon()
There's pretty much the same code in CanvasHelper::fillTexturedPolyPolygon() that has received various fixes over the time, but this code not, so fix it as well. Change-Id: I7293d4d67dff2d5276928bb3ab25adfb883ce3ca Reviewed-on: https://gerrit.libreoffice.org/72700 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/vcl/canvashelper_texturefill.cxx36
1 files changed, 29 insertions, 7 deletions
diff --git a/canvas/source/vcl/canvashelper_texturefill.cxx b/canvas/source/vcl/canvashelper_texturefill.cxx
index 32c125e09541..50a0976cc56b 100644
--- a/canvas/source/vcl/canvashelper_texturefill.cxx
+++ b/canvas/source/vcl/canvashelper_texturefill.cxx
@@ -636,7 +636,7 @@ namespace vclcanvas
}
else if( textures[0].Bitmap.is() )
{
- const geometry::IntegerSize2D aBmpSize( textures[0].Bitmap->getSize() );
+ geometry::IntegerSize2D aBmpSize( textures[0].Bitmap->getSize() );
ENSURE_ARG_OR_THROW( aBmpSize.Width != 0 &&
aBmpSize.Height != 0,
@@ -754,16 +754,35 @@ namespace vclcanvas
// GraphicObject only supports scaling, rotation
// and translation)
- // setup GraphicAttr
- aGrfAttr.SetMirrorFlags(
- ( aScale.getX() < 0.0 ? BmpMirrorFlags::Horizontal : BmpMirrorFlags::NONE ) |
- ( aScale.getY() < 0.0 ? BmpMirrorFlags::Vertical : BmpMirrorFlags::NONE ) );
- aGrfAttr.SetRotation( static_cast< sal_uInt16 >(::basegfx::fround( nRotate*10.0 )) );
+ // #i75339# don't apply mirror flags, having
+ // negative size values is enough to make
+ // GraphicObject flip the bitmap
+
+ // The angle has to be mapped from radian to tenths of
+ // degress with the orientation reversed: [0,2Pi) ->
+ // (3600,0]. Note that the original angle may have
+ // values outside the [0,2Pi) interval.
+ const double nAngleInTenthOfDegrees (3600.0 - nRotate * 3600.0 / (2*M_PI));
+ aGrfAttr.SetRotation( static_cast< sal_uInt16 >(::basegfx::fround(nAngleInTenthOfDegrees)) );
pGrfObj.reset( new GraphicObject( aBmpEx ) );
}
else
{
+ // modify output position, to account for the fact
+ // that transformBitmap() always normalizes its output
+ // bitmap into the smallest enclosing box.
+ ::basegfx::B2DRectangle aDestRect;
+ ::canvas::tools::calcTransformedRectBounds( aDestRect,
+ ::basegfx::B2DRectangle(0,
+ 0,
+ aBmpSize.Width,
+ aBmpSize.Height),
+ aMatrix );
+
+ aOutputPos.setX( aDestRect.getMinX() );
+ aOutputPos.setY( aDestRect.getMinY() );
+
// complex transformation, use generic affine bitmap
// transformation
aBmpEx = tools::transformBitmap( aBmpEx,
@@ -773,7 +792,10 @@ namespace vclcanvas
// clear scale values, generated bitmap already
// contains scaling
- aScale.setX( 0.0 ); aScale.setY( 0.0 );
+ aScale.setX( 1.0 ); aScale.setY( 1.0 );
+
+ // update bitmap size, bitmap has changed above.
+ aBmpSize = vcl::unotools::integerSize2DFromSize(aBmpEx.GetSizePixel());
}