summaryrefslogtreecommitdiff
path: root/vcl
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
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')
-rw-r--r--vcl/backendtest/VisualBackendTest.cxx4
-rw-r--r--vcl/headless/svpgdi.cxx2
-rw-r--r--vcl/opengl/gdiimpl.cxx2
-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
-rw-r--r--vcl/workben/svptest.cxx6
10 files changed, 22 insertions, 20 deletions
diff --git a/vcl/backendtest/VisualBackendTest.cxx b/vcl/backendtest/VisualBackendTest.cxx
index dc86727eae4c..c8a029474ae1 100644
--- a/vcl/backendtest/VisualBackendTest.cxx
+++ b/vcl/backendtest/VisualBackendTest.cxx
@@ -417,8 +417,8 @@ public:
basegfx::B2DPolygon polygon;
for (double a=0.0; a<360.0; a+=0.5)
{
- double x = std::sin(a*M_PI / 180.0) * (b+1) * 20;
- double y = std::cos(a*M_PI / 180.0) * (b+1) * 20;
+ double x = std::sin(basegfx::deg2rad(a)) * (b+1) * 20;
+ double y = std::cos(basegfx::deg2rad(a)) * (b+1) * 20;
polygon.append(basegfx::B2DPoint(x + 200 + 500 * fTime, y + 200 + 500 * fTime));
}
polygon.setClosed(true);
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 0b495e43eff2..f4a7dd71dcbb 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -721,7 +721,7 @@ void SvpSalGraphics::drawPolyLine(sal_uInt32 nPoints, const SalPoint* pPtAry)
aPoly.setClosed(false);
drawPolyLine(aPoly, 0.0, basegfx::B2DVector(1.0, 1.0), basegfx::B2DLineJoin::Miter,
- css::drawing::LineCap_BUTT, 15.0 * F_PI180 /*default*/);
+ css::drawing::LineCap_BUTT, basegfx::deg2rad(15.0) /*default*/);
}
void SvpSalGraphics::drawPolygon(sal_uInt32 nPoints, const SalPoint* pPtAry)
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 281153ceb376..5efecae3a34e 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1550,7 +1550,7 @@ void OpenGLSalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pP
aPoly.setClosed(false);
drawPolyLine(aPoly, 0.0, basegfx::B2DVector(1.0, 1.0), basegfx::B2DLineJoin::Miter,
- css::drawing::LineCap_BUTT, 15.0 * F_PI180 /*default*/);
+ css::drawing::LineCap_BUTT, basegfx::deg2rad(15.0) /*default*/);
}
void OpenGLSalGraphicsImpl::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry )
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.;
diff --git a/vcl/workben/svptest.cxx b/vcl/workben/svptest.cxx
index 00f99091e92d..09a99b4f003a 100644
--- a/vcl/workben/svptest.cxx
+++ b/vcl/workben/svptest.cxx
@@ -285,9 +285,9 @@ void MyWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rR
aGradient);
LineInfo aLineInfo(LineStyle::Solid, 200);
- double sind = sin(DELTA * M_PI / 180.0);
- double cosd = cos(DELTA * M_PI / 180.0);
- double factor = 1 + (DELTA / 1000.0);
+ const double sind = sin(basegfx::deg2rad(DELTA));
+ const double cosd = cos(basegfx::deg2rad(DELTA));
+ const double factor = 1 + (DELTA / 1000.0);
int n = 0;
Color aLineColor(0, 0, 0);
Color aApproachColor(0, 0, 200);