diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-14 12:50:42 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-15 06:34:33 +0200 |
commit | 690526f95e3ee4fd25bb2c987e093543e4bc435b (patch) | |
tree | 06b6bb7b6c907fb1876eac1e60b7dac952b21f7b /drawinglayer | |
parent | 1dc92b9e9951ef118d2d823d54f9a022c2e41a27 (diff) |
Generalize basegfx::fround for templated return type
And use it when assigning to tools::Long
Change-Id: I0814d7bac9cdd48191ba69c64e3b12a4973b3417
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166071
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'drawinglayer')
6 files changed, 40 insertions, 27 deletions
diff --git a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx index e2c76a79bbc6..22a20f095d24 100644 --- a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx +++ b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx @@ -154,7 +154,7 @@ namespace drawinglayer::unorenderer if(!aBitmapEx.IsEmpty()) { aBitmapEx.SetPrefMapMode(MapMode(MapUnit::Map100thMM)); - aBitmapEx.SetPrefSize(Size(basegfx::fround(fWidth), basegfx::fround(fHeight))); + aBitmapEx.SetPrefSize(Size(basegfx::fround<tools::Long>(fWidth), basegfx::fround<tools::Long>(fHeight))); XBitmap = vcl::unotools::xBitmapFromBitmapEx(aBitmapEx); } } diff --git a/drawinglayer/source/processor2d/SDPRProcessor2dTools.cxx b/drawinglayer/source/processor2d/SDPRProcessor2dTools.cxx index 3d738cd09c99..7d001cfd67fd 100644 --- a/drawinglayer/source/processor2d/SDPRProcessor2dTools.cxx +++ b/drawinglayer/source/processor2d/SDPRProcessor2dTools.cxx @@ -55,7 +55,8 @@ void takeCareOfOffsetXY( { const Size& rSize(rTarget.GetSizePixel()); const tools::Long w(rSize.Width()); - const tools::Long a(basegfx::fround(w * (1.0 - rFillGraphicAttribute.getOffsetX()))); + const tools::Long a( + basegfx::fround<tools::Long>(w * (1.0 - rFillGraphicAttribute.getOffsetX()))); if (0 != a && w != a) { @@ -98,7 +99,8 @@ void takeCareOfOffsetXY( { const Size& rSize(rTarget.GetSizePixel()); const tools::Long h(rSize.Height()); - const tools::Long a(basegfx::fround(h * (1.0 - rFillGraphicAttribute.getOffsetY()))); + const tools::Long a( + basegfx::fround<tools::Long>(h * (1.0 - rFillGraphicAttribute.getOffsetY()))); if (0 != a && h != a) { diff --git a/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx b/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx index 9f838a7e1b61..d4f14a13ce6c 100644 --- a/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx +++ b/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx @@ -50,8 +50,10 @@ bool renderWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D& rWron * basegfx::B2DPoint(rWrongSpellCandidate.getStart(), 0.0)); const basegfx::B2DPoint aStop(aLocalTransform * basegfx::B2DPoint(rWrongSpellCandidate.getStop(), 0.0)); - const Point aVclStart(basegfx::fround(aStart.getX()), basegfx::fround(aStart.getY())); - const Point aVclStop(basegfx::fround(aStop.getX()), basegfx::fround(aStop.getY())); + const Point aVclStart(basegfx::fround<tools::Long>(aStart.getX()), + basegfx::fround<tools::Long>(aStart.getY())); + const Point aVclStop(basegfx::fround<tools::Long>(aStop.getX()), + basegfx::fround<tools::Long>(aStop.getY())); // #i101075# draw it. Do not forget to use the evtl. offsetted origin of the target device, // e.g. when used with mask/transparence buffer device diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 0d4ee95470dc..7b3acd6a1e74 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -226,8 +226,10 @@ VclMetafileProcessor2D::impDumpToMetaFile(const primitive2d::Primitive2DContaine aPrimitiveRange.transform(maCurrentTransformation); const tools::Rectangle aPrimitiveRectangle( - basegfx::fround(aPrimitiveRange.getMinX()), basegfx::fround(aPrimitiveRange.getMinY()), - basegfx::fround(aPrimitiveRange.getMaxX()), basegfx::fround(aPrimitiveRange.getMaxY())); + basegfx::fround<tools::Long>(aPrimitiveRange.getMinX()), + basegfx::fround<tools::Long>(aPrimitiveRange.getMinY()), + basegfx::fround<tools::Long>(aPrimitiveRange.getMaxX()), + basegfx::fround<tools::Long>(aPrimitiveRange.getMaxY())); ScopedVclPtrInstance<VirtualDevice> aContentVDev; MapMode aNewMapMode(pLastOutputDevice->GetMapMode()); @@ -1183,9 +1185,10 @@ void VclMetafileProcessor2D::processControlPrimitive2D( mpPDFExtOutDevData->WrapBeginStructureElement(vcl::PDFWriter::NonStructElement); mpPDFExtOutDevData->SetStructureAttribute(vcl::PDFWriter::Placement, vcl::PDFWriter::Block); auto const range(rControlPrimitive.getB2DRange(getViewInformation2D())); - tools::Rectangle const aLogicRect( - basegfx::fround(range.getMinX()), basegfx::fround(range.getMinY()), - basegfx::fround(range.getMaxX()), basegfx::fround(range.getMaxY())); + tools::Rectangle const aLogicRect(basegfx::fround<tools::Long>(range.getMinX()), + basegfx::fround<tools::Long>(range.getMinY()), + basegfx::fround<tools::Long>(range.getMaxX()), + basegfx::fround<tools::Long>(range.getMaxY())); mpPDFExtOutDevData->SetStructureBoundingBox(aLogicRect); OUString const& rAltText(rControlPrimitive.GetAltText()); if (!rAltText.isEmpty() && !bDecorative) @@ -1641,7 +1644,7 @@ void VclMetafileProcessor2D::processPolygonStrokePrimitive2D( // use the transformed line width LineInfo aLineInfo(LineStyle::Solid, - basegfx::fround(getTransformedLineWidth(rLine.getWidth()))); + std::round(getTransformedLineWidth(rLine.getWidth()))); aLineInfo.SetLineJoin(rLine.getLineJoin()); aLineInfo.SetLineCap(rLine.getLineCap()); @@ -1971,7 +1974,7 @@ void VclMetafileProcessor2D::processPolyPolygonHatchPrimitive2D( aToolsPolyPolygon, Hatch(aHatchStyle, Color(maBColorModifierStack.getModifiedColor(rFillHatchAttribute.getColor())), - basegfx::fround(rFillHatchAttribute.getDistance()), + basegfx::fround<tools::Long>(rFillHatchAttribute.getDistance()), Degree10(basegfx::fround(basegfx::rad2deg<10>(rFillHatchAttribute.getAngle()))))); impEndSvtGraphicFill(pSvtGraphicFill.get()); @@ -2526,10 +2529,11 @@ void VclMetafileProcessor2D::processTransparencePrimitive2D( basegfx::fround(aDiscreteRange.getHeight()), nMaximumQuadraticPixels)); // add to target metafile (will create MetaFloatTransparentAction) - mpOutputDevice->DrawBitmapEx( - Point(basegfx::fround(aLogicRange.getMinX()), basegfx::fround(aLogicRange.getMinY())), - Size(basegfx::fround(aLogicRange.getWidth()), basegfx::fround(aLogicRange.getHeight())), - aBitmapEx); + mpOutputDevice->DrawBitmapEx(Point(basegfx::fround<tools::Long>(aLogicRange.getMinX()), + basegfx::fround<tools::Long>(aLogicRange.getMinY())), + Size(basegfx::fround<tools::Long>(aLogicRange.getWidth()), + basegfx::fround<tools::Long>(aLogicRange.getHeight())), + aBitmapEx); } void VclMetafileProcessor2D::processStructureTagPrimitive2D( @@ -2597,8 +2601,10 @@ void VclMetafileProcessor2D::processStructureTagPrimitive2D( { auto const range(rStructureTagCandidate.getB2DRange(getViewInformation2D())); tools::Rectangle const aLogicRect( - basegfx::fround(range.getMinX()), basegfx::fround(range.getMinY()), - basegfx::fround(range.getMaxX()), basegfx::fround(range.getMaxY())); + basegfx::fround<tools::Long>(range.getMinX()), + basegfx::fround<tools::Long>(range.getMinY()), + basegfx::fround<tools::Long>(range.getMaxX()), + basegfx::fround<tools::Long>(range.getMaxY())); mpPDFExtOutDevData->SetStructureBoundingBox(aLogicRect); break; } diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index d99893dbab98..8a960be8009d 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -372,8 +372,9 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D( fIgnoreShearX); const Point aOrigin( - basegfx::fround(aCurrentTranslate.getX() / aCurrentScaling.getX()), - basegfx::fround(aCurrentTranslate.getY() / aCurrentScaling.getY())); + basegfx::fround<tools::Long>(aCurrentTranslate.getX() / aCurrentScaling.getX()), + basegfx::fround<tools::Long>(aCurrentTranslate.getY() + / aCurrentScaling.getY())); Fraction aScaleX(aCurrentScaling.getX()); if (!aScaleX.IsValid()) @@ -394,7 +395,8 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D( if (fCurrentRotate) aTextTranslate *= basegfx::utils::createRotateB2DHomMatrix(fCurrentRotate); - aStartPoint = Point(aTextTranslate.getX(), aTextTranslate.getY()); + aStartPoint = Point(basegfx::fround<tools::Long>(aTextTranslate.getX()), + basegfx::fround<tools::Long>(aTextTranslate.getY())); bChangeMapMode = aMapMode != mpOutputDevice->GetMapMode(); if (bChangeMapMode) @@ -406,7 +408,8 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D( else { const basegfx::B2DPoint aPoint(aLocalTransform * basegfx::B2DPoint(0.0, 0.0)); - aStartPoint = Point(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY())); + aStartPoint = Point(basegfx::fround<tools::Long>(aPoint.getX()), + basegfx::fround<tools::Long>(aPoint.getY())); } // tdf#152990 set the font after the MapMode is (potentially) set so canvas uses the desired @@ -1060,8 +1063,8 @@ void VclProcessor2D::RenderMarkerArrayPrimitive2D( { const basegfx::B2DPoint aDiscreteTopLeft((maCurrentTransformation * pos) - aDiscreteHalfSize); - const Point aDiscretePoint(basegfx::fround(aDiscreteTopLeft.getX()), - basegfx::fround(aDiscreteTopLeft.getY())); + const Point aDiscretePoint(basegfx::fround<tools::Long>(aDiscreteTopLeft.getX()), + basegfx::fround<tools::Long>(aDiscreteTopLeft.getY())); mpOutputDevice->DrawBitmapEx(aDiscretePoint + aOrigin, rMarker); } @@ -1081,8 +1084,8 @@ void VclProcessor2D::RenderPointArrayPrimitive2D( for (auto const& pos : rPositions) { const basegfx::B2DPoint aViewPosition(maCurrentTransformation * pos); - const Point aPos(basegfx::fround(aViewPosition.getX()), - basegfx::fround(aViewPosition.getY())); + const Point aPos(basegfx::fround<tools::Long>(aViewPosition.getX()), + basegfx::fround<tools::Long>(aViewPosition.getY())); mpOutputDevice->DrawPixel(aPos, aVCLColor); } diff --git a/drawinglayer/source/tools/converters.cxx b/drawinglayer/source/tools/converters.cxx index 3e32af49c508..cf339f8aaa20 100644 --- a/drawinglayer/source/tools/converters.cxx +++ b/drawinglayer/source/tools/converters.cxx @@ -362,7 +362,7 @@ BitmapEx convertPrimitive2DContainerToBitmapEx(primitive2d::Primitive2DContainer if (aBitmapEx.IsEmpty()) return BitmapEx(); aBitmapEx.SetPrefMapMode(MapMode(MapUnit::Map100thMM)); - aBitmapEx.SetPrefSize(Size(basegfx::fround(fWidth), basegfx::fround(fHeight))); + aBitmapEx.SetPrefSize(Size(basegfx::fround<tools::Long>(fWidth), basegfx::fround<tools::Long>(fHeight))); return aBitmapEx; } |