summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-08-04 10:37:17 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-08-04 20:51:27 +0200
commit8c48d69f06ddb3cb6c807a1e7db62dddb9778ded (patch)
tree8b6bf137be41ebe93746c4958ab9106bbf5cc339 /vcl/source
parentc05fbde6c870b7e6bc2f9bf642dc7d76215a496f (diff)
Use more basegfx deg<->rad functions, instead of direct formulas
Also make the functions constexpr. Due to slight changes in floating-point arithmetics (90.0 instead of 180.0, M_PI2 instead of M_PI resp.), results might differ in last digits (usually 17th decimal digit). This has lead to need to tweak char2dump's PieChartTest unit test. Change-Id: I20323dd7dab27e4deb408ea4181e390cc05e7cd3 Reviewed-on: https://gerrit.libreoffice.org/58583 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/bitmap/BitmapEmbossGreyFilter.cxx4
-rw-r--r--vcl/source/outdev/line.cxx4
-rw-r--r--vcl/source/outdev/polygon.cxx6
-rw-r--r--vcl/source/outdev/polyline.cxx8
-rw-r--r--vcl/source/outdev/transparent.cxx4
-rw-r--r--vcl/source/window/scrwnd.cxx2
6 files changed, 15 insertions, 13 deletions
diff --git a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx
index f64126ac978a..3c12c5364168 100644
--- a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx
+++ b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx
@@ -40,8 +40,8 @@ BitmapEx BitmapEmbossGreyFilter::execute(BitmapEx const& rBitmapEx)
long nGrey11, nGrey12, nGrey13;
long nGrey21, nGrey22, nGrey23;
long nGrey31, nGrey32, nGrey33;
- double fAzim = mnAzimuthAngle100 * 0.01 * F_PI180;
- double fElev = mnElevationAngle100 * 0.01 * F_PI180;
+ double fAzim = basegfx::deg2rad(mnAzimuthAngle100 * 0.01);
+ double fElev = basegfx::deg2rad(mnElevationAngle100 * 0.01);
long* pHMap = new long[nWidth + 2];
long* pVMap = new long[nHeight + 2];
long nX, nY, nNx, nNy, nDotL;
diff --git a/vcl/source/outdev/line.cxx b/vcl/source/outdev/line.cxx
index eb126cc330da..8c856a83cd7c 100644
--- a/vcl/source/outdev/line.cxx
+++ b/vcl/source/outdev/line.cxx
@@ -143,7 +143,7 @@ void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt )
aB2DLineWidth,
basegfx::B2DLineJoin::NONE,
css::drawing::LineCap_BUTT,
- 15.0 * F_PI180, // not used with B2DLineJoin::NONE, but the correct default
+ basegfx::deg2rad(15.0), // not used with B2DLineJoin::NONE, but the correct default
this))
{
return;
@@ -252,7 +252,7 @@ void OutputDevice::drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const Lin
basegfx::B2DVector(1.0,1.0),
basegfx::B2DLineJoin::NONE,
css::drawing::LineCap_BUTT,
- 15.0 * F_PI180, // not used with B2DLineJoin::NONE, but the correct default
+ basegfx::deg2rad(15.0), // not used with B2DLineJoin::NONE, but the correct default
this);
}
diff --git a/vcl/source/outdev/polygon.cxx b/vcl/source/outdev/polygon.cxx
index d12fd102364f..bef902a2d273 100644
--- a/vcl/source/outdev/polygon.cxx
+++ b/vcl/source/outdev/polygon.cxx
@@ -99,7 +99,7 @@ void OutputDevice::DrawPolyPolygon( const tools::PolyPolygon& rPolyPoly )
aB2DLineWidth,
basegfx::B2DLineJoin::NONE,
css::drawing::LineCap_BUTT,
- 15.0 * F_PI180, // not used with B2DLineJoin::NONE, but the correct default
+ basegfx::deg2rad(15.0), // not used with B2DLineJoin::NONE, but the correct default
this);
}
}
@@ -210,7 +210,7 @@ void OutputDevice::DrawPolygon( const tools::Polygon& rPoly )
aB2DLineWidth,
basegfx::B2DLineJoin::NONE,
css::drawing::LineCap_BUTT,
- 15.0 * F_PI180, // not used with B2DLineJoin::NONE, but the correct default
+ basegfx::deg2rad(15.0), // not used with B2DLineJoin::NONE, but the correct default
this);
}
@@ -315,7 +315,7 @@ void OutputDevice::ImplDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyP
aB2DLineWidth,
basegfx::B2DLineJoin::NONE,
css::drawing::LineCap_BUTT,
- 15.0 * F_PI180, // not used with B2DLineJoin::NONE, but the correct default
+ basegfx::deg2rad(15.0), // not used with B2DLineJoin::NONE, but the correct default
this);
}
}
diff --git a/vcl/source/outdev/polyline.cxx b/vcl/source/outdev/polyline.cxx
index d13014426b68..bd5ca14b57f5 100644
--- a/vcl/source/outdev/polyline.cxx
+++ b/vcl/source/outdev/polyline.cxx
@@ -79,7 +79,7 @@ void OutputDevice::DrawPolyLine( const tools::Polygon& rPoly )
aB2DLineWidth,
basegfx::B2DLineJoin::NONE,
css::drawing::LineCap_BUTT,
- 15.0 * F_PI180 /*default fMiterMinimumAngle, not used*/,
+ basegfx::deg2rad(15.0) /*default fMiterMinimumAngle, not used*/,
this))
{
return;
@@ -129,7 +129,7 @@ void OutputDevice::DrawPolyLine( const tools::Polygon& rPoly, const LineInfo& rL
static_cast< double >(rLineInfo.GetWidth()),
rLineInfo.GetLineJoin(),
rLineInfo.GetLineCap(),
- 15.0 * F_PI180 /* default fMiterMinimumAngle, value not available in LineInfo */);
+ basegfx::deg2rad(15.0) /* default fMiterMinimumAngle, value not available in LineInfo */);
return;
}
@@ -222,7 +222,9 @@ void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon,
// to avoid optical gaps
for(sal_uInt32 a(0); a < aAreaPolyPolygon.count(); a++)
{
- (void)DrawPolyLineDirect( aAreaPolyPolygon.getB2DPolygon(a), 0.0, 0.0, basegfx::B2DLineJoin::NONE, css::drawing::LineCap_BUTT, 15.0 * F_PI180 /*default, not used*/, bTryAA);
+ (void)DrawPolyLineDirect(aAreaPolyPolygon.getB2DPolygon(a), 0.0, 0.0,
+ basegfx::B2DLineJoin::NONE, css::drawing::LineCap_BUTT,
+ basegfx::deg2rad(15.0) /*default, not used*/, bTryAA);
}
}
else
diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx
index cbe143a46da0..42874c7eba4e 100644
--- a/vcl/source/outdev/transparent.cxx
+++ b/vcl/source/outdev/transparent.cxx
@@ -265,7 +265,7 @@ void OutputDevice::DrawTransparent( const basegfx::B2DPolyPolygon& rB2DPolyPoly,
aHairlineWidth,
basegfx::B2DLineJoin::NONE,
css::drawing::LineCap_BUTT,
- 15.0 * F_PI180, // not used with B2DLineJoin::NONE, but the correct default
+ basegfx::deg2rad(15.0), // not used with B2DLineJoin::NONE, but the correct default
this );
}
}
@@ -368,7 +368,7 @@ bool OutputDevice::DrawTransparentNatively ( const tools::PolyPolygon& rPolyPoly
aLineWidths,
basegfx::B2DLineJoin::NONE,
css::drawing::LineCap_BUTT,
- 15.0 * F_PI180, // not used with B2DLineJoin::NONE, but the correct default
+ basegfx::deg2rad(15.0), // not used with B2DLineJoin::NONE, but the correct default
this );
}
// prepare to restore the fill color
diff --git a/vcl/source/window/scrwnd.cxx b/vcl/source/window/scrwnd.cxx
index 118ca5f77fca..ef882d36ea02 100644
--- a/vcl/source/window/scrwnd.cxx
+++ b/vcl/source/window/scrwnd.cxx
@@ -251,7 +251,7 @@ PointerStyle ImplWheelWindow::ImplGetMousePointer( long nDistX, long nDistY )
}
else
{
- double fAngle = atan2( static_cast<double>(-nDistY), nDistX ) / F_PI180;
+ double fAngle = basegfx::rad2deg(atan2(static_cast<double>(-nDistY), nDistX));
if( fAngle < 0.0 )
fAngle += 360.;