include/vcl/outdev.hxx | 9 ++++++++- include/vcl/print.hxx | 2 +- vcl/source/gdi/pdfwriter_impl.hxx | 2 +- vcl/source/gdi/pdfwriter_impl2.cxx | 5 ++++- vcl/source/gdi/print.cxx | 5 ++++- vcl/source/outdev/clipping.cxx | 10 ++++------ 6 files changed, 22 insertions(+), 11 deletions(-)
New commits: commit 58ef52cf3258030860d34f05bc19e2b42d9503c6 Author: Chris Sherlock <chris.sherloc...@gmail.com> AuthorDate: Tue Jul 2 04:57:36 2019 +1000 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Wed Jul 3 12:49:55 2019 +0200 tdf#74702: OutputDevice:InitClipRegion followup Followup to commit 3a99d7f621036, which did a good job of removing use of GetOutDevType() in OutputDevice initialization. Commit changes ClipRegionIntersectionRectangle() to ClipToDeviceBounds(). ClipRegionIntersectionRectangle() takes a region and clips it, however it breaks the contract in Printer and PDFWriterImpl where it does a noop - any caller on these classes will expect the region to be clipped to an intersecting rectangle. Instead, I have renamed it to ClipToDeviceBounds(), which is what the bClipBounds check shows it is doing in the original code. I have made it return the new clipped region as this seems more logical. I have also moved the comment to a doxygen comment on the function signature in OutputDevice. Change-Id: I64276920bb452839df04c16f0efc3d5581162673 Reviewed-on: https://gerrit.libreoffice.org/74967 Tested-by: Jenkins Reviewed-by: Adrien Ollier <adr.oll...@hotmail.fr> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 959a8ccdc036..cf1d5c09c685 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -666,7 +666,14 @@ public: protected: virtual void InitClipRegion(); - virtual void ClipRegionIntersectRectangle(vcl::Region&); + + /** Perform actual rect clip against outdev dimensions, to generate + empty clips whenever one of the values is completely off the device. + + @param aRegion region to be clipped to the device dimensions + @returns region clipped to the device bounds + **/ + virtual vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const; virtual void ClipToPaintRegion ( tools::Rectangle& rDstRect ); private: diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx index 6210acb5bac1..957d97b49a61 100644 --- a/include/vcl/print.hxx +++ b/include/vcl/print.hxx @@ -233,7 +233,7 @@ protected: const tools::PolyPolygon &rPolyPoly ) override; void ScaleBitmap ( Bitmap&, SalTwoRect& ) override { }; - void ClipRegionIntersectRectangle(vcl::Region&) override; + vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const override; public: void DrawGradientEx( OutputDevice* pOut, const tools::Rectangle& rRect, diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index c728b16c21f4..50bfa5863a6b 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -595,7 +595,7 @@ public: protected: void ImplClearFontData(bool bNewFontLists) override; - void ClipRegionIntersectRectangle(vcl::Region&) override; + vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const override; void DrawHatchLine_DrawLine(const Point& rStartPoint, const Point& rEndPoint) override; private: diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index bf24fd2978dc..63a369c177c9 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -2030,6 +2030,9 @@ void PDFWriterImpl::ImplClearFontData(bool bNewFontLists) } } -void PDFWriterImpl::ClipRegionIntersectRectangle(vcl::Region&) {} +vcl::Region PDFWriterImpl::ClipToDeviceBounds(vcl::Region aRegion) const +{ + return aRegion; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 8678dc1986b2..24253ca77609 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -1669,7 +1669,10 @@ void Printer::SetFontOrientation( LogicalFontInstance* const pFontEntry ) const pFontEntry->mnOrientation = pFontEntry->mxFontMetric->GetOrientation(); } -void Printer::ClipRegionIntersectRectangle(vcl::Region&) {} +vcl::Region Printer::ClipToDeviceBounds(vcl::Region aRegion) const +{ + return aRegion; +} Bitmap Printer::GetBitmap( const Point& rSrcPt, const Size& rSize ) const { diff --git a/vcl/source/outdev/clipping.cxx b/vcl/source/outdev/clipping.cxx index 6e3fa877bc4b..9dad2667bb66 100644 --- a/vcl/source/outdev/clipping.cxx +++ b/vcl/source/outdev/clipping.cxx @@ -153,8 +153,7 @@ void OutputDevice::InitClipRegion() mbOutputClipped = false; // #102532# Respect output offset also for clip region - vcl::Region aRegion( ImplPixelToDevicePixel( maRegion ) ); - ClipRegionIntersectRectangle(aRegion); + vcl::Region aRegion = ClipToDeviceBounds(ImplPixelToDevicePixel(maRegion)); if ( aRegion.IsEmpty() ) { @@ -183,15 +182,14 @@ void OutputDevice::InitClipRegion() mbInitClipRegion = false; } -void OutputDevice::ClipRegionIntersectRectangle(vcl::Region& rRegion) +vcl::Region OutputDevice::ClipToDeviceBounds(vcl::Region aRegion) const { - // Perform actual rect clip against outdev dimensions, - // to generate empty clips whenever one of the values is completely off the device. - rRegion.Intersect(tools::Rectangle{mnOutOffX, + aRegion.Intersect(tools::Rectangle{mnOutOffX, mnOutOffY, mnOutOffX + GetOutputWidthPixel() - 1, mnOutOffY + GetOutputHeightPixel() - 1 }); + return aRegion; } vcl::Region OutputDevice::GetActiveClipRegion() const _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits