diff options
Diffstat (limited to 'canvas/source/vcl/canvashelper_texturefill.cxx')
-rw-r--r-- | canvas/source/vcl/canvashelper_texturefill.cxx | 84 |
1 files changed, 41 insertions, 43 deletions
diff --git a/canvas/source/vcl/canvashelper_texturefill.cxx b/canvas/source/vcl/canvashelper_texturefill.cxx index 33f4f5c5318c..6972066b47a5 100644 --- a/canvas/source/vcl/canvashelper_texturefill.cxx +++ b/canvas/source/vcl/canvashelper_texturefill.cxx @@ -34,7 +34,7 @@ #include <basegfx/utils/tools.hxx> #include <com/sun/star/rendering/TexturingMode.hpp> #include <rtl/math.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <tools/poly.hxx> #include <vcl/bitmapex.hxx> #include <vcl/canvastools.hxx> @@ -154,18 +154,17 @@ namespace vclcanvas // 2 colors and 2 stops (at 0 and 1) is a linear gradient: if( rColors.size() == 2 && rValues.maStops.size() == 2 && rValues.maStops[0] == 0 && rValues.maStops[1] == 1) { - Gradient vclGradient( GradientStyle::Linear, rColors[ 0 ], rColors[ 1 ] ); - ::tools::Polygon aTempPoly( static_cast<sal_uInt16>(5) ); - aTempPoly[0] = ::Point( ::basegfx::fround( aLeftTop.getX() ), - ::basegfx::fround( aLeftTop.getY() ) ); - aTempPoly[1] = ::Point( ::basegfx::fround( aRightTop.getX() ), - ::basegfx::fround( aRightTop.getY() ) ); - aTempPoly[2] = ::Point( ::basegfx::fround( aRightBottom.getX() ), - ::basegfx::fround( aRightBottom.getY() ) ); - aTempPoly[3] = ::Point( ::basegfx::fround( aLeftBottom.getX() ), - ::basegfx::fround( aLeftBottom.getY() ) ); - aTempPoly[4] = aTempPoly[0]; - rOutDev.DrawGradient( aTempPoly, vclGradient ); + // tdf#144073 and tdf#147645: use bounds and angle for gradient + // Passing an expanded, rotated polygon noticeably modifies the + // drawing of the gradient in a slideshow due to moving of the + // starting and ending colors far off the edges of the drawing + // surface. So try another way and set the angle of the + // gradient and draw only the unadjusted bounds. + Gradient vclGradient( css::awt::GradientStyle_LINEAR, rColors[ 0 ], rColors[ 1 ] ); + double fRotate = atan2( aDirection.getY(), aDirection.getX() ); + const double nAngleInTenthOfDegrees = 3600.0 - basegfx::rad2deg<10>( fRotate ) + 900.0; + vclGradient.SetAngle( Degree10( ::basegfx::fround( nAngleInTenthOfDegrees ) ) ); + rOutDev.DrawGradient( rBounds, vclGradient ); return; } // 3 colors with first and last being equal and 3 stops (at 0, 0.5 and 1) is an axial gradient: @@ -173,18 +172,17 @@ namespace vclcanvas && rValues.maStops.size() == 3 && rValues.maStops[0] == 0 && rValues.maStops[1] == 0.5 && rValues.maStops[2] == 1) { - Gradient vclGradient( GradientStyle::Axial, rColors[ 1 ], rColors[ 0 ] ); - ::tools::Polygon aTempPoly( static_cast<sal_uInt16>(5) ); - aTempPoly[0] = ::Point( ::basegfx::fround( aLeftTop.getX() ), - ::basegfx::fround( aLeftTop.getY() ) ); - aTempPoly[1] = ::Point( ::basegfx::fround( aRightTop.getX() ), - ::basegfx::fround( aRightTop.getY() ) ); - aTempPoly[2] = ::Point( ::basegfx::fround( aRightBottom.getX() ), - ::basegfx::fround( aRightBottom.getY() ) ); - aTempPoly[3] = ::Point( ::basegfx::fround( aLeftBottom.getX() ), - ::basegfx::fround( aLeftBottom.getY() ) ); - aTempPoly[4] = aTempPoly[0]; - rOutDev.DrawGradient( aTempPoly, vclGradient ); + // tdf#144073 and tdf#147645: use bounds and angle for gradient + // Passing an expanded, rotated polygon noticeably modifies the + // drawing of the gradient in a slideshow due to moving of the + // starting and ending colors far off the edges of the drawing + // surface. So try another way and set the angle of the + // gradient and draw only the unadjusted bounds. + Gradient vclGradient( css::awt::GradientStyle_AXIAL, rColors[ 1 ], rColors[ 0 ] ); + double fRotate = atan2( aDirection.getY(), aDirection.getX() ); + const double nAngleInTenthOfDegrees = 3600.0 - basegfx::rad2deg<10>( fRotate ) + 900.0; + vclGradient.SetAngle( Degree10( ::basegfx::fround( nAngleInTenthOfDegrees ) ) ); + rOutDev.DrawGradient( rBounds, vclGradient ); return; } @@ -213,12 +211,12 @@ namespace vclcanvas // loop below, we set the _right_ edge here, which will be // readily copied into the left edge in the loop below const ::basegfx::B2DPoint& rPoint1( aLeftTop - 2.0*nDiagonalLength*aDirection ); - aTempPoly[1] = ::Point( ::basegfx::fround( rPoint1.getX() ), - ::basegfx::fround( rPoint1.getY() ) ); + aTempPoly[1] = ::Point( ::basegfx::fround<::tools::Long>( rPoint1.getX() ), + ::basegfx::fround<::tools::Long>( rPoint1.getY() ) ); const ::basegfx::B2DPoint& rPoint2( aLeftBottom - 2.0*nDiagonalLength*aDirection ); - aTempPoly[2] = ::Point( ::basegfx::fround( rPoint2.getX() ), - ::basegfx::fround( rPoint2.getY() ) ); + aTempPoly[2] = ::Point( ::basegfx::fround<::tools::Long>( rPoint2.getX() ), + ::basegfx::fround<::tools::Long>( rPoint2.getY() ) ); // iteratively render all other strips @@ -260,14 +258,14 @@ namespace vclcanvas const ::basegfx::B2DPoint& rPoint3( (nStepCount - i-1)/double(nStepCount)*aLeftTop + (i+1)/double(nStepCount)*aRightTop ); - aTempPoly[1] = ::Point( ::basegfx::fround( rPoint3.getX() ), - ::basegfx::fround( rPoint3.getY() ) ); + aTempPoly[1] = ::Point( ::basegfx::fround<::tools::Long>( rPoint3.getX() ), + ::basegfx::fround<::tools::Long>( rPoint3.getY() ) ); const ::basegfx::B2DPoint& rPoint4( (nStepCount - i-1)/double(nStepCount)*aLeftBottom + (i+1)/double(nStepCount)*aRightBottom ); - aTempPoly[2] = ::Point( ::basegfx::fround( rPoint4.getX() ), - ::basegfx::fround( rPoint4.getY() ) ); + aTempPoly[2] = ::Point( ::basegfx::fround<::tools::Long>( rPoint4.getX() ), + ::basegfx::fround<::tools::Long>( rPoint4.getY() ) ); rOutDev.DrawPolygon( aTempPoly ); } @@ -285,12 +283,12 @@ namespace vclcanvas // gradient rect two times the bound rect's diagonal to // the 'right'. const ::basegfx::B2DPoint& rPoint3( aRightTop + 2.0*nDiagonalLength*aDirection ); - aTempPoly[0] = aTempPoly[4] = ::Point( ::basegfx::fround( rPoint3.getX() ), - ::basegfx::fround( rPoint3.getY() ) ); + aTempPoly[0] = aTempPoly[4] = ::Point( ::basegfx::fround<::tools::Long>( rPoint3.getX() ), + ::basegfx::fround<::tools::Long>( rPoint3.getY() ) ); const ::basegfx::B2DPoint& rPoint4( aRightBottom + 2.0*nDiagonalLength*aDirection ); - aTempPoly[3] = ::Point( ::basegfx::fround( rPoint4.getX() ), - ::basegfx::fround( rPoint4.getY() ) ); + aTempPoly[3] = ::Point( ::basegfx::fround<::tools::Long>( rPoint4.getX() ), + ::basegfx::fround<::tools::Long>( rPoint4.getY() ) ); rOutDev.SetFillColor( rColors.back() ); @@ -420,8 +418,8 @@ namespace vclcanvas const ::basegfx::B2DPoint& rInnerPoint( aInnerPoly.getB2DPoint(p) ); aTempPoly[static_cast<sal_uInt16>(p)] = ::Point( - basegfx::fround( fT*rInnerPoint.getX() + (1-fT)*rOuterPoint.getX() ), - basegfx::fround( fT*rInnerPoint.getY() + (1-fT)*rOuterPoint.getY() ) ); + basegfx::fround<::tools::Long>( fT*rInnerPoint.getX() + (1-fT)*rOuterPoint.getX() ), + basegfx::fround<::tools::Long>( fT*rInnerPoint.getY() + (1-fT)*rOuterPoint.getY() ) ); } // close polygon explicitly @@ -900,15 +898,15 @@ namespace vclcanvas const ::Point aPtRepeat( vcl::unotools::pointFromB2DPoint( aSingleDeviceTextureRect.getMinimum() ) ); - const ::Size aSz( ::basegfx::fround( aScale.getX() * aBmpSize.Width ), - ::basegfx::fround( aScale.getY() * aBmpSize.Height ) ); + const ::Size aSz( ::basegfx::fround<::tools::Long>( aScale.getX() * aBmpSize.Width ), + ::basegfx::fround<::tools::Long>( aScale.getY() * aBmpSize.Height ) ); const ::Size aIntegerNextTileX( vcl::unotools::sizeFromB2DSize(aNextTileX) ); const ::Size aIntegerNextTileY( vcl::unotools::sizeFromB2DSize(aNextTileY) ); const ::Point aPt( textures[0].RepeatModeX == rendering::TexturingMode::NONE ? - ::basegfx::fround( aOutputPos.getX() ) : aPtRepeat.X(), + ::basegfx::fround<::tools::Long>( aOutputPos.getX() ) : aPtRepeat.X(), textures[0].RepeatModeY == rendering::TexturingMode::NONE ? - ::basegfx::fround( aOutputPos.getY() ) : aPtRepeat.Y() ); + ::basegfx::fround<::tools::Long>( aOutputPos.getY() ) : aPtRepeat.Y() ); const sal_Int32 nTilesX( textures[0].RepeatModeX == rendering::TexturingMode::NONE ? 1 : nX2 - nX1 ); const sal_Int32 nTilesY( textures[0].RepeatModeX == rendering::TexturingMode::NONE ? |